-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathMakefile
67 lines (55 loc) · 1.32 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
#
# 1. General Compiler Settings
#
COMPILER = gcc
CFLAGS = -std=c++11 -Wextra -fpermissive -fmessage-length=0 -mbmi2 -mavx2 -MMD -MP -Wno-deprecated-declarations
LDFLAGS = -lstdc++ -lm
INCLUDES =
#
# 2. Traget Specific Settings
#
# 2.1 Linux / Windows
ifeq ($(shell uname),Linux)
# TensorRT
LDFLAGS += -L/usr/local/cuda/targets/x86_64-linux/lib/ -lpthread -lcudart -lnvinfer -lnvonnxparser -lnvparsers
INCLUDES += -I/usr/local/cuda/include -I/usr/local/cuda/targets/x86_64-linux/include
OUTFILE = AQ
else
echo 'TensorRT7 on Windows deos not support MinGW. Use MSVC instead.'
endif
# 2.2 Set FLAGS
ifeq ($(TARGET),)
CFLAGS += -Ofast -fno-fast-math
endif
ifeq ($(TARGET),debug)
CFLAGS += -g -Og
endif
#
# 3. Default Settings
#
OUTFILE = AQ
OBJDIR = ./obj
SRCDIR = ./src
SOURCES = $(wildcard $(SRCDIR)/*.cc)
OBJECTS = $(addprefix $(OBJDIR)/, $(SOURCES:.cc=.o))
DEPENDS = $(OBJECTS:.o=.d)
#
# 4. Public Targets
#
.PHONY: all debug clean
all:
$(MAKE) executable
debug:
$(MAKE) TARGET=$@ executable
clean:
rm -f $(OBJECTS) $(DEPENDS) $(OUTFILE) ${OBJECTS:.o=.gcda}
#
# 5. Private Targets
#
.PHONY: executable
executable: $(OBJECTS)
$(COMPILER) -o $(OUTFILE) $^ $(LDFLAGS) $(CFLAGS)
$(OBJDIR)/%.o: %.cc Makefile
@[ -d $(dir $@) ] || mkdir -p $(dir $@)
$(COMPILER) $(CFLAGS) $(INCLUDES) -o $@ -c $<
-include $(DEPENDS)