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))
36 cp $($*_LIBRARIES:=.so) $($*dir)
38 uninstall-LIBRARIES/%::
39 rm -f $(patsubst %,$($*dir)/%.so,$($*_LIBRARIES))
40 rmdir -p $($*dir) || true 2> /dev/null
42 define CLASS_LIBRARIES_tpl
44 install-LIBRARIES/$2:: $1.so
46 install:: install-LIBRARIES/$2
47 uninstall:: uninstall-LIBRARIES/$2
49 $1.so: $(_cobjs)/$1/.exists $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
50 $(CC) $$(CFLAGS) $$($1_CPPFLAGS) -fPIC -shared -o $$@ \
51 $$(filter %.o,$$^) $$(LDFLAGS) $$($1_LDFLAGS) $$($1_LIBADD)
53 $$(eval $$(call RULE_C_tpl,$1,-fPIC))
58 $(foreach v,$(filter %_LIBRARIES,$(.VARIABLES)), \
59 $(foreach x,$($v),$(eval $(call CLASS_LIBRARIES_tpl,$x,$(v:_LIBRARIES=)))))
64 cp $($*_DATA) $($*dir)
67 rm -f $(patsubst %,$($*dir)/%,$($*_DATA))
68 rmdir -p $($*dir) || true 2> /dev/null
71 install:: install-DATA/$2
72 uninstall:: uninstall-DATA/$2
74 $(foreach v,$(filter %_DATA,$(.VARIABLES)), \
75 $(foreach x,$($v),$(eval $(call CLASS_DATA_tpl,$x,$(v:_DATA=)))))
79 #$1: $(_cobjs)/$1/.exists $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
80 # $(CC) -o $$@ $$(CFLAGS) $$($1_CPPFLAGS) $$(filter %.o,$$^) \
81 # $$(LDFLAGS) $$($1_LDFLAGS) $$(filter %.a,$$^)
83 #$$(eval $$(call RULE_C_tpl,$1,$2))
88 #$(foreach x,$(__EXE__),$(eval $(call CLASS_EXE_tpl,$x,)))
90 ########################################################################}}}#
91 #[ Candy ]##############################################################{{{#
101 ctags -o .$@ --recurse=yes --exclude=.svn --exclude=\*.mk --totals=yes;
107 $(MAKE) -C $(DEPTH) $@
112 ########################################################################}}}#
114 all check clobber distclean::
115 @set -e $(patsubst %,; $(MAKE) -rC % $@,$(SUBDIRS))
119 $(RM) -r $(_cobjs) $(CLEANFILES)
120 @$(if $(CLEAN_RECURSE),$(patsubst %,$(MAKE) -rC % $@;,$(SUBDIRS)))
122 clobber distclean:: CLEAN_RECURSE=
123 clobber distclean:: clean
124 $(RM) -r .objs* $(DISTCLEANFILES)
126 ifeq (".","$(DEPTH)")
128 $(RM) $(patsubst %.in,%,$(wildcard $(CONFDIR)/*.in))
131 .PHONY: all check clean clobber distclean install FORCE