-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathMakefile
47 lines (39 loc) · 1.5 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
CC = gcc
CFLAGS =
# just set TARGET_VER to a valid ver eg. one of: 390.48 325.08 325.15 319.32 319.23
TARGET_VER = 470.161.03
TARGET_MAJOR := $(shell echo ${TARGET_VER} | cut -d . -f 1)
TARGET_MINOR := $(shell echo ${TARGET_VER} | cut -d . -f 2)
TARGET = libnvidia-ml.so.1
# change libdir below based on where libnvidia-ml.so.1 resides.
# some common values are: /usr/lib, /usr/lib64, /usr/lib/i386-linux-gnu, /usr/lib/x86_64-linux-gnu
libdir = /usr/lib/x86_64-linux-gnu
INSTALL = /usr/bin/install -D
.PHONY: check_supported clean install all
all: check_supported $(TARGET)
check_supported:
ifeq ($(TARGET_MAJOR),319)
else ifeq ($(TARGET_MAJOR),325)
else ifeq ($(TARGET_MAJOR),331)
else ifeq ($(TARGET_MAJOR),390)
else ifeq ($(TARGET_MAJOR),396)
else ifeq ($(TARGET_MAJOR),410)
else ifeq ($(TARGET_MAJOR),415)
else ifeq ($(TARGET_MAJOR),418)
else ifeq ($(TARGET_MAJOR),430)
else ifeq ($(TARGET_MAJOR),440)
else ifeq ($(TARGET_MAJOR),450)
else ifeq ($(TARGET_MAJOR),460)
else ifeq ($(TARGET_MAJOR),470)
else
$(error Driver major version $(TARGET_MAJOR) is not supported!)
endif
${TARGET:1=${TARGET_VER}}: empty.c
${CC} ${CFLAGS} -shared -fPIC -s $(<) -o $(@)
$(TARGET): ${TARGET:1=${TARGET_VER}}
${CC} ${CFLAGS} -Wl,--no-as-needed -shared -fPIC -s -o $(@) -DNVML_PATCH_${TARGET_MAJOR} -DNVML_PATCH_MINOR=${TARGET_MINOR} -DNVML_VERSION=\"$(TARGET_VER)\" $< nvml_fix.c
clean:
rm -f $(TARGET)
rm -f ${TARGET:1=${TARGET_VER}}
install: $(TARGET)
$(INSTALL) -Dm755 $(^) $(libdir)/$(^)