-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
86 lines (69 loc) · 2.35 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
#----------------------------------------------------------------------------
# MidoriDB root makefile
#----------------------------------------------------------------------------
DIR_ROOT := $(CURDIR)
include $(DIR_ROOT)/scripts/config.mk
DIR_SRC_SUBSYSTEMS := $(wildcard $(DIR_SRC)/*)
DIR_SRC_TESTS_SUBSYSTEMS := $(wildcard $(DIR_SRC_TESTS)/*)
#----------------------------------------------------------------------------
# Build targets
#----------------------------------------------------------------------------
default: build
all: clean compile link test
@# Help: clean, build and link the whole project
.PHONY: clean
clean:
@rm -rf $(DIR_BUILD)
@echo "[clean] generated files deleted"
@# Help: clean all generated files
.PHONY: compile
compile: $(DIR_SRC_SUBSYSTEMS)
.PHONY: $(DIR_SRC_SUBSYSTEMS)
$(DIR_SRC_SUBSYSTEMS):
@$(MAKE) $(MAKE_FLAGS) --directory=$@
.PHONY: build
build: clean compile link
@echo "[build] compiling sources"
@# Help: build the whole project
.PHONY: link
link:
@echo "[linker] linking all object files"
@$(CC) $(CFLAGS) \
-shared \
-o $(DIR_BUILD_LIB)/$(LIB_DYN_NAME) \
$(shell find $(DIR_BUILD_LIB)/ -type f -name "*.o") \
$(LDFLAGS)
.PHONY: $(DIR_SRC_TESTS_SUBSYSTEMS)
$(DIR_SRC_TESTS_SUBSYSTEMS):
@$(MAKE) $(MAKE_FLAGS) --directory=$@
.PHONY: test_compile
test_compile: $(DIR_SRC_TESTS_SUBSYSTEMS)
.PHONY: test
test: test_compile
@echo "[test/linker] linking all object files"
@for f in "$(DIR_BUILD_TESTS)/main/*.o"; \
do \
$(CC) $(CCFLAGS) \
-L$(DIR_BUILD_LIB) \
-lmidoridb \
-Wl,-rpath $(DIR_BUILD_LIB) \
-o $(DIR_BUILD_TESTS)/$$(basename $$f '.o') \
$$f \
$(shell find $(DIR_BUILD_TESTS) -name '*.o' \
-not -path '$(DIR_BUILD_TESTS)/main/*') \
$(TEST_LDFLAGS) ; \
done
.PHONY: cscope
cscope:
@rm -rf cscope*
@find . -name '\.pc' -prune -o -name '*\.[ch]' -print > cscope.files
@cscope -b -q -f cscope.out
MAKEOVERRIDES =
help:
@printf "%-20s %s\n" "Target" "Description"
@printf "%-20s %s\n" "------" "-----------"
@make -pqR : 2>/dev/null \
| awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \
| sort \
| egrep -v -e '^[^[:alnum:]]' -e '^$@$$' \
| xargs -I _ sh -c 'printf "%-20s " _; make _ -nB | (grep -i "^# Help:" || echo "") | tail -1 | sed "s/^# Help: //g"'