-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
40 lines (34 loc) · 1.42 KB
/
Makefile
File metadata and controls
40 lines (34 loc) · 1.42 KB
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
#####################################################################################
# Specify:
# (1) The folder containing the source files + name of the compiled program
# (2) Name of the program
#####################################################################################
SRC := src
BIN := program
OBJ := obj
MKDIR := mkdir -p
RM := rm -rf
SRCs := $(shell find $(SRC) -name "*.cpp")
OBJs := $(subst $(SRC), $(OBJ), $(SRCs:.cpp=.o))
CXX := g++ -std=c++17
CPPFLAGS := -Iinclude -Iinclude/ann -Iinclude/tensor -Iinclude/sformat -Idemo -Isrc
CFLAGS := -pthread #-Wall
LDLIBS := -lm -lpthread
#############################################################################################
# Note:
# (1) Use -Iinclude/tensor: because put xtensor and its headers inside of folder tensor
# (2) Use -Iinclude/sformat: because put sformat and its headers inside of folder sformat
# (3) Use -Iinclude/ann: because put header files of ann inside of folder ann
# (4) Use -Idemo: because put header files of demos inside of this folder
#############################################################################################
all: $(BIN)
$(BIN): $(OBJs)
$(CXX) $(CFLAGS) $(CPPFLAGS) $(OBJs) -o $@ $(LDLIBS)
$(OBJs): $(SRCs)
$(MKDIR) $(dir $@)
$(CXX) $(CFLAGS) $(CPPFLAGS) -c $(subst $(OBJ), $(SRC), $(@:.o=.cpp)) -o $@
# Here: repeat here for other other source codes
# Clean rule to remove generated files
clean:
$(RM) $(BIN)
$(RM) $(OBJ)