and support the _HEADERS variables as well
[apps/madtty.git] / am / footer.mk
index 49a1afd..0acffb8 100644 (file)
@@ -61,14 +61,16 @@ install-LIBRARIES/%::
        $(if $($*dir),$(INSTALL_DATA) $($*_LIBRARIES:=.so*) $(DESTDIR)$($*dir))
 
 define CLASS_LIBRARIES_tpl
-  all:: $1.so$$(if $$($1_VERSION),.$$($1_VERSION))
-  install-LIBRARIES/$2:: $1.so$$(if $$($1_VERSION),.$$($1_VERSION))
+  all:: $1.so$3
+  install-LIBRARIES/$2:: $1.so$3
 
   install:: install-LIBRARIES/$2
 
-  $1.so$$(if $$($1_VERSION),.$$($1_VERSION)): $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
+  $1.so$3: $$(call deps_create,$$($1_SOURCES),$(_cobjs)/$1)
        $(CC) $$(CFLAGS) $$($1_CPPFLAGS) -fPIC -shared -o $$@ $$(filter %.o,$$^) \
                $$(LDFLAGS) $$($1_LDFLAGS) $$($1_LIBADD)
+       $$(if $$(word 2,$$(subst ., ,$3)),ln -sf $$@ $1.so.$$(word 1,$$(subst ., ,$3)))
+       $$(if $$($1_VERSION), ln -sf $$@ $1.so)
 
   $$(eval $$(call RULE_C_tpl,$1,-fPIC))
 
@@ -76,7 +78,8 @@ define CLASS_LIBRARIES_tpl
            $(RM) $1.so*
 endef
 $(foreach v,$(filter %_LIBRARIES,$(.VARIABLES)), \
-            $(foreach x,$($v),$(eval $(call CLASS_LIBRARIES_tpl,$x,$(v:_LIBRARIES=)))))
+            $(foreach x,$($v),$(eval $(call CLASS_LIBRARIES_tpl,$x,$(v:_LIBRARIES=),$(...\
+           ...)$(if $($x_VERSION),.$($x_VERSION))))))
 
 
 ##
@@ -99,6 +102,16 @@ install-SCRIPTS/%::
 
 install:: $(foreach v,$(filter %_SCRIPTS,$(.VARIABLES)),$(patsubst %_SCRIPTS,install-SCRIPTS/%,$v))
 
+##
+##  rules for *_HEADERS
+##
+
+install-HEADERS/%::
+       $(if $($*dir), $(INSTALL_DIR) $(DESTDIR)$($*dir))
+       $(if $($*dir), $(INSTALL_DATA) $($*_HEADERS) $(DESTDIR)$($*dir))
+
+install:: $(foreach v,$(filter %_HEADERS,$(.VARIABLES)),$(patsubst %_HEADERS,install-HEADERS/%,$v))
+
 
 ########################################################################}}}#
 #[ Candy ]##############################################################{{{#
@@ -124,7 +137,7 @@ endif
 
 ########################################################################}}}#
 
-all check clobber distclean::
+all check clobber distclean install::
        @set -e $(patsubst %,; $(MAKE) -rC % $@,$(SUBDIRS))
 
 CLEAN_RECURSE=1