-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
115 lines (85 loc) · 2.75 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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
CC = clang++
AR = ar
PREFIX = /usr/local
INCLUDES = .
BUILD_STD = c++20
M_ARCH = native
CFLAGS = -g -std=$(BUILD_STD) -O3 -Wall \
-fmessage-length=0 -Wno-unused-local-typedef \
# -fsanitize=address -fno-omit-frame-pointer
NATIVE_CFLAGS = -march=$(M_ARCH) $(CFLAGS)
LDFLAGS = -g -lgeomc -lboost_unit_test_framework \
# -fsanitize=address -fno-omit-frame-pointer
IFLAGS = $(addprefix -I, $(INCLUDES))
LIB_SRC = $(wildcard geomc/*.cpp) $(wildcard geomc/*/*.cpp) $(wildcard geomc/*/*/*.cpp)
TEST_SRC = $(wildcard regression/*cpp)
ALL_SRC = $(LIB_SRC) $(TEST_SRC) test/Profile.cpp
H_FILES = $(shell find geomc -name "*.h")
TEST_BINS = $(addprefix bin/, $(basename $(TEST_SRC)))
LIB_OBJS = $(addprefix build/, $(LIB_SRC:.cpp=.o))
EMLIB_OBJS = $(addprefix build/em/, $(LIB_SRC:.cpp=.o))
LIBNAME = libgeomc.a
LIB = lib/$(LIBNAME)
LITELIB = lib/libgeomc_lite.a
EMLIB = lib/libgeomc_em.a
INSTALL_INC_DIR = $(PREFIX)/include
INSTALL_LIB_DIR = $(PREFIX)/lib
WASM_INC_DIR = /usr/local/wasm/include
WASM_LIB_DIR = /usr/local/wasm/lib
all: lib litelib test
docs:
mkdir -p doc/gen
doxygen
clean:
rm -rf ./build/*
rm -f ./lib/*.a
rm -rf ./doc/gen/html
install: $(LIB) $(LITELIB)
install -d $(foreach f, $(H_FILES), $(INSTALL_INC_DIR)/$(dir $(f)))
install -d $(INSTALL_LIB_DIR)
install -m 644 $(LIB) $(INSTALL_LIB_DIR)
install -m 644 $(LITELIB) $(INSTALL_LIB_DIR)
for f in $(H_FILES); do install -m 644 $$f $(INSTALL_INC_DIR)/$$f; done
install-wasm:
mkdir -p $(WASM_INC_DIR)
cp -rf ./geomc $(WASM_INC_DIR)
cp -rf $(EMLIB) $(WASM_LIB_DIR)/$(LIBNAME)
uninstall:
rm -rf $(INSTALL_INC_DIR)/geomc
rm -f $(INSTALL_LIB_DIR)/$(LIBNAME)
rm -f $(INSTALL_LIB_DIR)/$(notdir $(LITELIB))
test: $(TEST_BINS)
$(foreach x, $(TEST_BINS), $(x);)
test-%: bin/regression/%
$<
# basic library
lib: $(LIB)
# minimal library
litelib: $(LITELIB)
# emscripten-compatible library
emlib: $(EMLIB)
# auto-dependencies:
DEP = $(patsubst %.cpp, build/%.d, $(ALL_SRC))
-include $(DEP)
# build rules:
build/%.o: %.cpp build/%.d
$(CC) -c $(NATIVE_CFLAGS) $(IFLAGS) -o $@ $<
build/em/%.o: %.cpp build/%.d
@mkdir -p build/em/$(dir $<)
emcc -c $(CFLAGS) $(IFLAGS) -o $@ $<
build/%.d: %.cpp
@mkdir -p build/$(dir $<)
$(CC) $(CFLAGS) $(IFLAGS) $< -MM -MT $(@:.d=.o) > $@
$(LIB): $(LIB_OBJS)
@mkdir -p lib
$(AR) rs $(LIB) $(LIB_OBJS)
$(LITELIB) : build/geomc/GeomException.o build/geomc/function/functiondetail/SipHash.o
$(AR) rs $(LITELIB) build/geomc/GeomException.o build/geomc/function/functiondetail/SipHash.o
$(EMLIB) : $(EMLIB_OBJS)
emar rs $(EMLIB) $(EMLIB_OBJS)
bin/regression/%: build/regression/%.o lib
@mkdir -p $(dir $@)
$(CC) $(LDFLAGS) $< -o $@
bin/%: build/%.o lib
@mkdir -p $(dir $(patsubst build/%, bin/%, $<))
$(CC) -g $< $(LIB) -o $@