-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
65 lines (50 loc) · 1.67 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
DIR_BUILD = build
DIR_SRC = src
C_OBJECTS = $(addprefix $(DIR_BUILD)/,$(notdir $(shell \
find src/main/c | grep "\\.\(c\)$$" | \
sed -e 's/\(.\+\)\.\(.\+\)/\1-\2.o/')))
C_TARGETS = $(addprefix $(DIR_BUILD)/,$(notdir $(shell \
find src/test/c | grep "\\.[a-zA-Z0-9]\+$$" | \
sed -e 's/\(.\+\)\.\(.\+\)/\1-\2/')))
CC_HEADERS = $(shell find src/main/cc -regex ".+\.h")
CC_OBJECTS = $(addprefix $(DIR_BUILD)/,$(notdir $(shell \
find src/main/cc | grep "\\.\(cc\)$$" | \
sed -e 's/\(.\+\)\.\(.\+\)/\1-\2.o/')))
CC_TARGETS = $(addprefix $(DIR_BUILD)/,$(notdir $(shell \
find src/test/cc | grep "\\.[a-zA-Z0-9]\+$$" | \
sed -e 's/\(.\+\)\.\(.\+\)/\1-\2/')))
# C options
GCC = gcc
C_FLAGS = -g -O2 -Wall -Werror
# C++ options
CC_LINT = cpplint
GPP = g++
CC_FLAGS = -std=c++11 -g -O2 -Wall -Werror
# C++ compiler and options
G++ = g++
vpath %.c $(DIR_SRC)/main/c
vpath %.c $(DIR_SRC)/test/c
vpath %.cc $(DIR_SRC)/main/cc
vpath %.cc $(DIR_SRC)/test/cc
.PHONY: all clean test
all: $(C_TARGETS) $(CC_TARGETS)
$(DIR_BUILD)/%-c.o: %.c
$(GCC) $(C_FLAGS) -I $(DIR_SRC)/main/c $< -c -o $@
$(DIR_BUILD)/%-c: %.c $(C_OBJECTS)
$(GCC) $(C_FLAGS) -I $(DIR_SRC)/main/c $< $(C_OBJECTS) -o $@
$(DIR_BUILD)/%-cc.o: %.cc $(CC_HEADERS)
# cat $< | grep ^#include | awk '{print $$2}' | xargs $(CC_LINT)
# $(CC_LINT) $<
$(GPP) $(CC_FLAGS) -I . $< -c -o $@
$(DIR_BUILD)/%-cc: %.cc $(CC_OBJECTS) $(CC_HEADERS)
# cat $< | grep ^#include | awk '{print $$2}' | xargs $(CC_LINT)
# $(CC_LINT) $<
$(GPP) $(CC_FLAGS) -I . $< $(CC_OBJECTS) -o $@
echo $(CC_HEADERS)
test:
$(DIR_BUILD)/sort-insertion-c
$(DIR_BUILD)/sort-merge-c
$(DIR_BUILD)/sort-heap-c
$(DIR_BUILD)/sort-quick-c
clean:
rm -rf $(DIR_BUILD)/*