AUTO_DEPENDS += filter_c
filter_c = $(addprefix $2/,$(patsubst %.c,%.o,$(filter %.c,$1)))
-# this is some ad-hoc last resort dependency method
-%.a: FORCE
- @$(MAKE) -q -rC $(dir $(@D)) $(_cobjs)/$(@F) || $(MAKE) -rC $(dir $(@D)) $(_cobjs)/$(@F)
-
# this implicit rule is used to force directory existence, without depending
# on the directory itself, since its mtime changes too often.
%/.exists: Makefile $(CONFDIR)/$(wildcard *.mk)
deps_create = $(foreach f,$(AUTO_DEPENDS),$(call $f,$1,$2))
-install-LIBRARIES/%::
- mkdir -p $($*dir)
- cp $($*_LIBRARIES:=.so) $($*dir)
+##
+## rules for *_PROGRAMS
+##
+
+install-PROGRAMS/%::
+ $(if $($*dir),$(INSTALL_DIR) $(DESTDIR)$($*dir))
+ $(if $($*dir),$(INSTALL_PROGRAMS) $($*_PROGRAMS:=.so*) $(DESTDIR)$($*dir))
+
+define CLASS_PROGRAMS_tpl
+ all:: $1
+ install-PROGRAMS/$2:: $1
+ install:: install-PROGRAMS/$2
+
+ $1: $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
+ $(CC) $$(CFLAGS) $$($1_CPPFLAGS) -o $$@ $$(filter %.o,$$^) \
+ $$(LDFLAGS) $$($1_LDFLAGS) $$($1_LIBADD)
+
+ $$(eval $$(call RULE_C_tpl,$1,))
+
+ clean::
+ $(RM) $1
+endef
+$(foreach v,$(filter %_PROGRAMS,$(.VARIABLES)), \
+ $(foreach x,$($v),$(eval $(call CLASS_PROGRAMS_tpl,$x,$(v:_PROGRAMS=)))))
-uninstall-LIBRARIES/%::
- rm -f $(patsubst %,$($*dir)/%.so,$($*_LIBRARIES))
- rmdir -p $($*dir) || true 2> /dev/null
+##
+## rules for *_LIBRARIES
+##
+
+install-LIBRARIES/%::
+ $(if $($*dir),$(INSTALL_DIR) $(DESTDIR)$($*dir))
+ $(if $($*dir),$(INSTALL_DATA) $($*_LIBRARIES:=.so*) $(DESTDIR)$($*dir))
define CLASS_LIBRARIES_tpl
-all:: $1.so
-install-LIBRARIES/$2:: $1.so
+ all:: $1.so$$(if $$($1_VERSION),.$$($1_VERSION))
+ install-LIBRARIES/$2:: $1.so$$(if $$($1_VERSION),.$$($1_VERSION))
-install:: install-LIBRARIES/$2
-uninstall:: uninstall-LIBRARIES/$2
+ install:: install-LIBRARIES/$2
-$1.so: $(_cobjs)/$1/.exists $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
- $(CC) $$(CFLAGS) $$($1_CPPFLAGS) -fPIC -shared -o $$@ \
- $$(filter %.o,$$^) $$(LDFLAGS) $$($1_LDFLAGS) $$($1_LIBADD)
+ $1.so$$(if $$($1_VERSION),.$$($1_VERSION)): $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
+ $(CC) $$(CFLAGS) $$($1_CPPFLAGS) -fPIC -shared -o $$@ $$(filter %.o,$$^) \
+ $$(LDFLAGS) $$($1_LDFLAGS) $$($1_LIBADD)
-$$(eval $$(call RULE_C_tpl,$1,-fPIC))
+ $$(eval $$(call RULE_C_tpl,$1,-fPIC))
-clean::
- $(RM) $1.so
+ clean::
+ $(RM) $1.so*
endef
$(foreach v,$(filter %_LIBRARIES,$(.VARIABLES)), \
$(foreach x,$($v),$(eval $(call CLASS_LIBRARIES_tpl,$x,$(v:_LIBRARIES=)))))
+##
+## rules for *_DATA
+##
+
install-DATA/%::
- mkdir -p $($*dir)
- cp $($*_DATA) $($*dir)
+ $(if $($*dir), $(INSTALL_DIR) $(DESTDIR)$($*dir))
+ $(if $($*dir), $(INSTALL_DATA) $($*_DATA) $(DESTDIR)$($*dir))
-uninstall-DATA/%::
- rm -f $(patsubst %,$($*dir)/%,$($*_DATA))
- rmdir -p $($*dir) || true 2> /dev/null
+install:: $(foreach v,$(filter %_DATA,$(.VARIABLES)),$(patsubst %_DATA,install-DATA/%,$v))
+
+##
+## rules for *_SCRIPTS
+##
+
+install-SCRIPTS/%::
+ $(if $($*dir), $(INSTALL_DIR) $(DESTDIR)$($*dir))
+ $(if $($*dir), $(INSTALL_PROGRAMS) $($*_SCRIPTS) $(DESTDIR)$($*dir))
+
+install:: $(foreach v,$(filter %_SCRIPTS,$(.VARIABLES)),$(patsubst %_SCRIPTS,install-SCRIPTS/%,$v))
-define CLASS_DATA_tpl
-install:: install-DATA/$2
-uninstall:: uninstall-DATA/$2
-endef
-$(foreach v,$(filter %_DATA,$(.VARIABLES)), \
- $(foreach x,$($v),$(eval $(call CLASS_DATA_tpl,$x,$(v:_DATA=)))))
-
-#define CLASS_EXE_tpl
-#all:: $1
-#$1: $(_cobjs)/$1/.exists $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
-# $(CC) -o $$@ $$(CFLAGS) $$($1_CPPFLAGS) $$(filter %.o,$$^) \
-# $$(LDFLAGS) $$($1_LDFLAGS) $$(filter %.a,$$^)
-#
-#$$(eval $$(call RULE_C_tpl,$1,$2))
-#
-#clean::
-# $(RM) $1
-#endef
-#$(foreach x,$(__EXE__),$(eval $(call CLASS_EXE_tpl,$x,)))
########################################################################}}}#
#[ Candy ]##############################################################{{{#