forked from Sissuire/Grokking-Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (46 loc) · 1.17 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
MY_PROG=demo
CC=cc
CFLAGS = -Wall -g -std=c17
CXX=c++
CPPFLAGS = -Wall -g -std=c++17
OBJ_DIR = obj
BIN_DIR = bin
OUT_DIRS = $(OBJ_DIR) $(BIN_DIR)
ECHO = @echo
MD = mkdir -p
# Search for dependencies and targets from "src" and "include" directories
# The directories are separated by space
#VPATH = obj src include
# Search for .c files in "src" directory; .h files in "include" directory
# The pattern matching character '%' matches filename without the extension
#vpath %.cpp src
#vpath %.c src
#vpath %.h include
VPATH = $(BIN_DIR)
#vpath $(MY_PROG) $(BIN_DIR)
vpath %.o $(OBJ_DIR)
#vpath %.d $(DEPDIR)
default: $(MY_PROG)
all: clean $(MY_PROG)
$(MY_PROG): demo.o GrokkingAlgorithms.o # UtilsGrokkingAlgo.o
@$(MD) $(BIN_DIR)
$(CXX) -o $(BIN_DIR)/$@ $(OBJ_DIR)/*.o
#%.o: %.c %.h ${OUT_DIRS}
# $(CC) $(CFLAGS) -c $< -o $@
%.o: %.cpp %.h
@$(MD) $(OBJ_DIR)
$(CXX) $(CPPFLAGS) -c $< -o $(OBJ_DIR)/$@
.PHONY: clean run acho dirs
clean:
$(ECHO) "Cleaning..."
$(RM) $(MY_PROG) *.o
$(RM) -r ${OUT_DIRS}
run: $(MY_PROG)
$(ECHO) "Running $(MY_PROG)"
@$(BIN_DIR)/$(MY_PROG)
echo:
$(ECHO) $(MKDIR)
dirs: ${OUT_DIRS}
${OUT_DIRS}:
$(ECHO) "Creating directories..."
$(MD) ${OUT_DIRS}