-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbin.mk
34 lines (25 loc) · 1.02 KB
/
bin.mk
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
# generates target to build binaries and .so
define bin_target_tpl
# add extra LDFLAGS specific for this target (don't add duplicates)
$$(addprefix $1/,$2): LDFLAGS=$(filter-out $$(LDFLAGS-$2),$(LDFLAGS)) $$(LDFLAGS-$2)
ifneq ($$(CC-$2),)
$$(addprefix $1/,$2): CC=$$(CC-$2)
endif
ifneq ($$(INCFLAGS-$2),)
$$(addprefix $1/,$$(IN-$2)): CFLAGS+=$$(INCFLAGS-$2)
endif
# rule to generate target from IN-files for this target. NOTE: manually add -shared ad LDFLAG for .so
$$(addprefix $1/,$2): $$(addprefix $1/,$$(IN-$2)) $$(DEPS-$2)
@$$(PRE-$2)
$$(CC) $$(filter %.o,$$^) $$(LDFLAGS) -o $$@
$$(POST-$2)
# include extra dependencies generated during compilation of this target
-include $$(addprefix $1/,$$(IN-$2:.o=.d))
endef
bin_target = $(eval $(call bin_target_tpl,$1,$2))
# generates target to build binaries and .so
define bin_target_clean_tpl
# add .a, its .o and generated dep files to cleanup rule
clean: RMFLAGS+=$$(addprefix $1/,$2 $$(IN-$2) $$(IN-$2:.o=.d))
endef
bin_target_clean = $(eval $(call bin_target_clean_tpl,$1,$2))