summaryrefslogtreecommitdiff
path: root/build-aux/Makefile.once.head/30-am.mk
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux/Makefile.once.head/30-am.mk')
-rw-r--r--build-aux/Makefile.once.head/30-am.mk64
1 files changed, 62 insertions, 2 deletions
diff --git a/build-aux/Makefile.once.head/30-am.mk b/build-aux/Makefile.once.head/30-am.mk
index 9049f2c88a..bea6e2aee9 100644
--- a/build-aux/Makefile.once.head/30-am.mk
+++ b/build-aux/Makefile.once.head/30-am.mk
@@ -13,11 +13,15 @@ am.INSTALL_SCRIPT ?= $(INSTALL) $< $@
am.INSTALL_LTLIBRARY ?= $(INSTALL) $< $@
am.INSTALL_DATA ?= $(INSTALL_DATA) $< $@
-################################################################################
+########################################################################
# this list of primaries is based on the Automake 1.15 manual
am.primaries ?= PROGRAMS LIBRARIES LTLIBRARIES LISP PYTHON JAVA SCRIPTS DATA HEADERS MANS TEXINFOS
-$(foreach p,$(am.primaries),$(eval am.inst2noinst_$p ?= $$(notdir $$1)))
+$(eval $(foreach p,$(am.primaries),am.inst2noinst_$p ?= $$(notdir $$1)$(at.nl)))
+
+am.primary2dirs = $(filter $(patsubst %dir,%,$(filter %dir,$(.VARIABLES))),\
+ $(patsubst %_$1,%,$(filter %_$1,$(.VARIABLES))))
+am.inst2dirs = $(sort $(dir $(foreach p,$(am.primaries),$(am.inst_$p))))
am.file2var = $(subst -,_,$(subst .,_,$1))
am.file2sources = $(addprefix $(srcdir)/,$(notdir $($(am.file2var)_SOURCES)))
@@ -26,3 +30,59 @@ am.file2.o = $(patsubst $(srcdir)/%,$(outdir)/%,$(patsubst %.c,%.o ,$(filter %.
am.file2.lo = $(patsubst %.o,%.lo,$(am.file2.o))
am.file2lib = $(foreach l, $($(am.file2var)_$2),$(if $(filter lib%.la,$l), $($(l:.la=).DEPENDS) , $l ))
am.file2cpp = $(foreach l,$1 $($(am.file2var)_$2),$(if $(filter lib%.la,$l), $($(l:.la=).CPPFLAGS) , ))
+
+define _am.per_primary
+noinst_$1 ?=
+check_$1 ?=
+
+am.inst_$1 := $$(foreach d,$$(call am.primary2dirs,$1),$$($$d_$1))
+am.noinst_$1 := $$(noinst_$1)
+am.check_$1 := $$(check_$1)
+$(foreach d,$(call am.primary2dirs,$1) noinst check,undefine $d_$1$(at.nl))
+ifneq ($$(am.inst_$1),)
+$$(am.inst_$1): private am.INSTALL = $$(am.INSTALL_$1)
+endif
+am.$1 = $$(am.check_$1) $$(am.noinst_$1) $$(call am.inst2noinst_$1,$$(am.inst_$1))
+endef
+########################################################################
+# TODO: I'm not in love with how _am.per_PROGRAM figures out at.subdirs
+# $1 = filename
+# $2 = varname
+define _am.per_PROGRAM
+$(foreach var,_am.depends $(call am.var_PROGRAMS,$2),$(var) ?=$(at.nl))
+_am.depends += $$(call at.path,$$(call am.file2.o,$1) $$(call am.file2lib,$1,LDADD))
+am.CPPFLAGS += $$($2_CPPFLAGS) $$(call am.file2cpp,$1,LDADD)
+am.CFLAGS += $$($2_CFLAGS)
+$$(outdir)/$1: private ALL_LDFLAGS += $$($2_LDFLAGS)
+$$(outdir)/$1: $$(_am.depends)
+am.subdirs := $$(sort $$(am.subdirs)\
+ $$(filter-out $$(abspath $$(srcdir)),\
+ $$(abspath $$(dir $$(filter-out -l% /%,$$(_am.depends))))))
+$(foreach var,_am.depends $(call am.var_LTLIBRARIES,$2),undefine $(var)$(at.nl))
+endef
+########################################################################
+# TODO: I'm not in love with how _am.per_LTLIBRARY figures out at.subdirs
+# $1 = filename
+# $2 = varname
+define _am.per_LTLIBRARY
+$(foreach var,_am.depends $(call am.var_LTLIBRARIES,$2),$(var) ?=$(at.nl))
+_am.depends += $$(call at.path,$$(call am.file2.lo,$1) $$(call am.file2lib,$1,LIBADD))
+am.CPPFLAGS += $$($2_CPPFLAGS) $$(call am.file2cpp,$1,LIBADD)
+am.CFLAGS += $$($2_CFLAGS)
+$$(outdir)/$1: private ALL_LDFLAGS += $$($2_LDFLAGS)
+$$(outdir)/$1: $$(_am.depends)
+am.subdirs := $$(sort $$(am.subdirs)\
+ $$(filter-out $$(abspath $$(srcdir)),\
+ $$(abspath $$(dir $$(filter-out -l% /%,$$(_am.depends))))))
+$(foreach var,_am.depends $(call am.var_LTLIBRARIES,$2),undefine $(var)$(at.nl))
+endef
+########################################################################
+define _am.per_directory
+$$(DESTDIR)$1/%: $$(outdir)/%
+ @$$(NORMAL_INSTALL)
+ $$(am.INSTALL)
+$$(DESTDIR)$1/%: $$(srcdir)/%
+ @$$(NORMAL_INSTALL)
+ $$(am.INSTALL)
+endef
+