1 #[ Rules and Depends ]##################################################{{{#
3 AUTO_DEPENDS += filter_c
4 filter_c = $(addprefix $2/,$(patsubst %.c,%.o,$(filter %.c,$1)))
6 # this is some ad-hoc last resort dependency method
8 @$(MAKE) -q -rC $(dir $(@D)) $(_cobjs)/$(@F) || $(MAKE) -rC $(dir $(@D)) $(_cobjs)/$(@F)
10 # this implicit rule is used to force directory existence, without depending
11 # on the directory itself, since its mtime changes too often.
12 %/.exists: Makefile $(CONFDIR)/$(wildcard *.mk)
16 # We don't want make to remove these files because of default rules.
20 $(_cobjs)/$1/%.o: %.c $(_cobjs)/$1/.exists
21 $(CC) $$(CFLAGS) $$($1_CPPFLAGS) $2 -MMD -MT "$$(@D)/$$*.d $$(@D)/$$*.o" -MF $$(@D)/$$*.d -g -c -o $$@ $$<
23 $(_cobjs)/$1/%.d: %.c $(_cobjs)/$1/.exists
24 @$(CPP) $$(CFLAGS) $$($1_CPPFLAGS) $2 -MM -MT "$$(@D)/$$*.d $$(@D)/$$*.o" -MF $$(@D)/$$*.d $$<
26 -include $$(wildcard $(_cobjs)/$1/*.d) /dev/null
29 ########################################################################}}}#
30 #[ Classes ]############################################################{{{#
32 deps_create = $(foreach f,$(AUTO_DEPENDS),$(call $f,$1,$2))
34 define CLASS_LIBRARIES_tpl
37 $1.so: $(_cobjs)/$1/.exists $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
38 $(CC) $$(CFLAGS) $$($1_CPPFLAGS) -fPIC -shared -o $$@ \
39 $$(filter %.o,$$^) $$(LDFLAGS) $$($1_LDFLAGS) $$($1_LIBADD)
41 $$(eval $$(call RULE_C_tpl,$1,-fPIC $2))
47 $(foreach l,$(filter %_LIBRARIES,$(.VARIABLES)),$($l)), \
48 $(eval $(call CLASS_LIBRARIES_tpl,$l,)))
52 #$1: $(_cobjs)/$1/.exists $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
53 # $(CC) -o $$@ $$(CFLAGS) $$($1_CPPFLAGS) $$(filter %.o,$$^) \
54 # $$(LDFLAGS) $$($1_LDFLAGS) $$(filter %.a,$$^)
56 #$$(eval $$(call RULE_C_tpl,$1,$2))
61 #$(foreach x,$(__EXE__),$(eval $(call CLASS_EXE_tpl,$x,)))
63 ########################################################################}}}#
64 #[ Candy ]##############################################################{{{#
74 ctags -o .$@ --recurse=yes --exclude=.svn --exclude=\*.mk --totals=yes;
80 $(MAKE) -C $(DEPTH) $@
85 ########################################################################}}}#
87 all check clobber distclean::
88 @set -e $(patsubst %,; $(MAKE) -rC % $@,$(SUBDIRS))
93 @$(if $(CLEAN_RECURSE),$(patsubst %,$(MAKE) -rC % $@;,$(SUBDIRS)))
95 clobber distclean:: CLEAN_RECURSE=
96 clobber distclean:: clean
99 .PHONY: all check clean clobber distclean FORCE