-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (43 loc) · 1.48 KB
/
Copy pathMakefile
File metadata and controls
53 lines (43 loc) · 1.48 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
41
42
43
44
45
46
47
48
49
50
51
52
53
SRC_DIRS := src
C_SRCS := $(foreach srcdir,$(SRC_DIRS),$(wildcard $(srcdir)/*.c))
CXX_SRCS := $(foreach srcdir,$(SRC_DIRS),$(wildcard $(srcdir)/*.cpp))
C_OBJS := ${C_SRCS:.c=.o}
CXX_OBJS := ${CXX_SRCS:.cpp=.o}
OBJS := $(C_OBJS) $(CXX_OBJS)
INCLUDE_DIRS := include
LIBRARY_DIRS :=
LIBRARIES :=
test_NAME := test
test_DIR := bin
test_FULL := $(test_DIR)/$(test_NAME)
test_SRC_DIRS := test
test_C_SRCS := $(foreach srcdir,$(test_SRC_DIRS),$(wildcard $(srcdir)/*.c))
test_CXX_SRCS := $(foreach srcdir,$(test_SRC_DIRS),$(wildcard $(srcdir)/*.cpp))
test_C_OBJS := ${test_C_SRCS:.c=.o}
test_CXX_OBJS := ${test_CXX_SRCS:.cpp=.o}
test_OBJS := $(test_C_OBJS) $(test_CXX_OBJS)
test_INCLUDE_DIRS := catch
test_LIBRARY_DIRS :=
test_LIBRARIES :=
all_OBJS := $(OBJS) $(test_OBJS)
DEP := $(all_OBJS:%.o=%.d)
CXXFLAGS += -std=c++11
CXXFLAGS += $(foreach includedir,$(INCLUDE_DIRS),-I$(includedir))
LDFLAGS += $(foreach librarydir,$(LIBRARY_DIRS),-L$(librarydir))
LDFLAGS += $(foreach library,$(LIBRARIES),-l$(library))
.PHONY: test experiment doc clean
test: CXXFLAGS += $(foreach includedir,$(test_INCLUDE_DIRS),-I$(includedir))
test: LDFLAGS += $(foreach librarydir,$(test_LIBRARY_DIRS),-L$(librarydir))
test: LDFLAGS += $(foreach library,$(test_LIBRARIES),-l$(library))
test: $(test_FULL)
./$(test_FULL)
$(test_FULL): $(test_OBJS) $(OBJS)
$(LINK.cc) $^ -o $@
-include $(DEP)
%.o: %.cpp
$(CXX) $(CXXFLAGS) -MMD -c $< -o $@
clean:
@- $(RM) $(test_FULL)
@- $(RM) $(test_OBJS)
@- $(RM) $(OBJS)
@- $(RM) $(DEP)