-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathMakefile
executable file
·95 lines (82 loc) · 2.23 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
PREFIX?=/usr/local
PREFIX_LOCAL=~
GLIBCFLAGS=-D_XOPEN_SOURCE=500
CPPFLAGS+=$(GLIBCFLAGS)
CFLAGS?=-pedantic -Wall -g -O2 -std=c11
OBJECTS=main.o \
server.o \
server_start.o \
client.o \
msgdump.o \
jobs.o \
execute.o \
msg.o \
mail.o \
error.o \
signals.o \
list.o \
print.o \
info.o \
env.o \
tail.o \
cjson/cJSON.o
TARGET=ts
INSTALL=install -c
GIT_REPO=$(shell git rev-parse --is-inside-work-tree)
all: OBJECTS+= gpu.o
all: LDFLAGS+=-L$(CUDA_HOME)/lib64 -L$(CUDA_HOME)/lib64/stubs -I$(CUDA_HOME)/include
all: LDLIBS+=-lnvidia-ml -lcudart -lcublas
all: gpu.o
$(TARGET): $(OBJECTS)
$(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(TARGET)
%.o : %.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
# Dependencies
main.o: main.c main.h
ifeq ($(GIT_REPO), true)
GIT_VERSION=$$(echo $$(git describe --dirty --always --tags) | tr - +); \
$(CC) $(CFLAGS) $(CPPFLAGS) -DTS_VERSION=$${GIT_VERSION} -c $< -o $@
endif
server_start.o: server_start.c main.h
server.o: server.c main.h
client.o: client.c main.h
msgdump.o: msgdump.c main.h
jobs.o: jobs.c main.h
execute.o: execute.c main.h
msg.o: msg.c main.h
mail.o: mail.c main.h
error.o: error.c main.h
signals.o: signals.c main.h
list.o: list.c main.h
tail.o: tail.c main.h
gpu.o: gpu.c main.h
$(CC) $(CFLAGS) $(CPPFLAGS) -L$(CUDA_HOME)/lib64 -I$(CUDA_HOME)/include -lpthread -c $< -o $@
cjson/cJSON.o: cjson/cJSON.c cjson/cJSON.h
cpu: CFLAGS+=-DCPU
all cpu: $(TARGET)
all cpu:
ifeq ($(GIT_REPO), true)
GIT_VERSION=$$(echo $$(git describe --dirty --always --tags) | tr - +); \
$(CC) $(CFLAGS) -DTS_VERSION=$${GIT_VERSION} man.c -o makeman
endif
clean:
rm -f *.o cjson/*.o $(TARGET) makeman ts.1
install: $(TARGET)
$(INSTALL) -d $(PREFIX)/bin
$(INSTALL) ts $(PREFIX)/bin
$(INSTALL) -d $(PREFIX)/share/man/man1
./makeman
$(INSTALL) -m 644 $(TARGET).1 $(PREFIX)/share/man/man1
install-local: $(TARGET)
$(INSTALL) -d $(PREFIX_LOCAL)/bin
$(INSTALL) ts $(PREFIX_LOCAL)/bin
$(INSTALL) -d $(PREFIX_LOCAL)/.local/share/man/man1
./makeman
$(INSTALL) -m 644 $(TARGET).1 $(PREFIX_LOCAL)/.local/share/man/man1
.PHONY: uninstall
uninstall:
rm -f $(PREFIX)/bin/$(TARGET)
rm -f $(PREFIX)/share/man/man1/$(TARGET).1
uninstall-local:
rm -f $(PREFIX_LOCAL)/bin/$(TARGET)
rm -f $(PREFIX_LOCAL)/.local/share/man/man1/$(TARGET).1