-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathMakefile.in
91 lines (71 loc) · 2.43 KB
/
Makefile.in
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# TODO: Switch to cmake
# Sources
OUT_DIR = bin/
SOURCES = \
test/src/map/main.cpp \
test/src/array/main.cpp \
test/src/value/main.cpp \
test/src/parser/main.cpp \
test/src/odr/main.cpp
OBJECTS = ${SOURCES:.cpp=.cpp.o}
TEST_OBJECTS = $(SOURCES:.cpp=.test)
TESTS = $(foreach test,${SOURCES}, $(addprefix ${OUT_DIR}, $(notdir $(test))))
# Generation/Installation
PREFIX = %PREFIX%
INCLUDEDIR = %INCLUDEDIR%
THREADS = %THREADS%
# Compiler flags
CXX ?= c++
CXX_WARN_FLAGS = -Wall -Wextra -Werror -pedantic
CXX_DEBUG_FLAGS =
CXX_OPTIM_FLAGS = -O3
CXX_INCLUDE_FLAGS = -Iinclude -Itest/include -Ilib/jest/include
CXX_PLATFORM_FLAGS = %CXX_PLATFORM_FLAGS%
CXX_FLAGS += -std=c++1y \
${CXX_PLATFORM_FLAGS} \
${CXX_INCLUDE_FLAGS} \
${CXX_WARN_FLAGS} \
${CXX_DEBUG_FLAGS} \
${CXX_OPTIM_FLAGS}
LD_PLATFORM_LIBS = %LD_PLATFORM_LIBS%
LD_LIBS += ${LD_PLATFORM_LIBS}
PROJECT = %PROJECT%
.PHONY: all threaded setup clean ${PROJECT} ${PROJECT}_setup install uninstall test test_setup
.SILENT:
all:
${MAKE} -j ${THREADS} threaded
exit $$?
threaded: ${PROJECT}
echo "Success"
setup: clean
echo "Preparing"
mkdir -p ${OUT_DIR}
clean:
rm -rf ${OUT_DIR}
echo "Cleaned"
${PROJECT}: ${PROJECT}_setup ${OBJECTS}
echo "Done building ${PROJECT} tests"
${PROJECT}_setup: setup
echo "Building ${PROJECT} tests"
%.cpp.o: %.cpp ${PROJECT}_setup
echo " Compiling $<"
mkdir -p ${OUT_DIR}$(dir $(shell echo $< | sed 's_test/src/__')) > /dev/null
${CXX} ${CXX_FLAGS} $< ${LD_LIBS} -o ${OUT_DIR}$(shell echo "$(shell echo $< | sed 's/\.cpp//')" | sed 's_test/src/__') > /dev/null
test/src/odr/main.cpp.o: ${PROJECT}_setup
echo " Validating ODR"
mkdir -p ${OUT_DIR}$(dir $(shell echo test/src/odr/main.cpp | sed 's_test/src/__')) > /dev/null
${CXX} ${CXX_FLAGS} test/src/odr/main1.cpp test/src/odr/main2.cpp ${LD_LIBS} -o ${OUT_DIR}$(shell echo "$(shell echo test/src/odr/main.cpp | sed 's/\.cpp//')" | sed 's_test/src/__') > /dev/null
install:
export installdir=${DESTDIR}${INCLUDEDIR} && \
export project=${PROJECT} && \
./do_install safe
uninstall:
export installdir=${DESTDIR}${INCLUDEDIR} && \
export project=${PROJECT} && \
./do_install undo
test: test_setup ${TEST_OBJECTS}
test_setup:
%.test: test_setup
echo "******** ${OUT_DIR}$(shell echo "$(shell echo $@ | sed 's/\.test//')" | sed 's_test/src/__') ********"
${OUT_DIR}$(shell echo "$(shell echo $@ | sed 's/\.test//')" | sed 's_test/src/__') > /dev/null
echo