-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
64 lines (46 loc) · 1018 Bytes
/
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
CC = clang++ --std=c++11
CFLAGS = -c -g -Wall -Werror
GTEST_INCL = -isystem $(GTEST_DIR)/include
GTEST_LD = -pthread -L$(GTEST_DIR) -lgtest
SRCDIRS = \
. \
goblb \
gobld \
gobll \
goblr \
gobls \
goblu \
INCL = $(SRCDIRS:%=-I%)
LIBS = \
FLAGS = \
$(INCL)
LDFLAGS = \
$(LIBS)
SRCS=$(shell find $(SRCDIRS) -maxdepth 1 -iname '*.cpp')
OBJS=$(SRCS:%.cpp=%.o)
NOTEST_OBJS=$(filter-out %.t.o,$(OBJS))
TEST_OBJS=$(filter-out %.m.o,$(OBJS))
all: lib
.PHONY: lib
lib: libgobl.a
.PHONY: gtest
gtest: gobl_gtest.tsk
.PHONY: main
main: gobl.tsk
.PHONY: clean
clean:
rm -f $(SRCDIRS:%=%/*.o)
libgobl.a: $(NOTEST_OBJS)
ar -rs $@ $^
mkdir -p include
for file in $$(find $(SRCDIRS) -maxdepth 1 -name '*.h'); do \
ln -sf $$file include/$$(basename $$file); \
done
gobl.tsk: $(NOTEST_OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
gobl_gtest.tsk: $(TEST_OBJS)
$(CC) -o $@ $^ $(LDFLAGS) $(GTEST_LD)
%.t.o: %.t.cpp
$(CC) $(CFLAGS) -o $*.t.o $^ $(FLAGS) $(GTEST_INCL)
%.o: %.cpp
$(CC) $(CFLAGS) -o $*.o $^ $(FLAGS)