summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-05-30 23:58:38 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-05-30 23:58:38 -0400
commitb910b85b2d7d732ccfeaf69ab7ec79140a4a7802 (patch)
tree66b2d392b6bac7df5f8695e36df50b6e7ad8dfae
parent0b3959406003cb61c9d10e2f1d45c755ec700392 (diff)
fix
- Make at.relto public, as mod-dist needs it - Include the correct files in .head.mk - Sort the head includes forwards - Sort the tail includes backwards - Correctly prefix at.{sub,dep}dirs with $(outdir) - Undefine variables after they have been namespaced. - Don't try to access at.{sub,dep}dirs after they have been undefined
-rw-r--r--build-aux/Makefile.head.mk12
-rw-r--r--build-aux/Makefile.tail.mk16
2 files changed, 18 insertions, 10 deletions
diff --git a/build-aux/Makefile.head.mk b/build-aux/Makefile.head.mk
index c680f41..63a3462 100644
--- a/build-aux/Makefile.head.mk
+++ b/build-aux/Makefile.head.mk
@@ -25,23 +25,27 @@ endif
_at.noslash = $(patsubst %/.,%,$(patsubst %/,%,$1))
# These are all $(call _at.func,parent,child)
-#_at.relto = $(if $2,$(shell realpath -sm --relative-to='$1' $2))
+#at.relto = $(if $2,$(shell realpath -sm --relative-to='$1' $2))
_at.is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/.)
_at.relto_helper = $(if $(call _at.is_subdir,$1,$2),$(patsubst $1/%,%,$(addsuffix /.,$2)),$(addprefix ../,$(call _at.relto_helper,$(patsubst %/,%,$(dir $1)),$2)))
_at.relto = $(call _at.noslash,$(call _at.relto_helper,$(call _at.noslash,$(abspath $1)),$(call _at.noslash,$(abspath $2))))
+at.relto = $(foreach p,$2,$(call _at.relto,$1,$p))
# Note that _at.is_subdir says that a directory is a subdirectory of
# itself.
-at.path = $(foreach p,$1,$(call _at.relto,.,$p))
+at.path = $(call at.relto,.,$1)
define at.nl
endef
+_at.rest = $(wordlist 2,$(words $1),$1)
+_at.reverse = $(if $1,$(call _at.reverse,$(_at.rest))) $(firstword $1)
+
at.dirlocal += at.subdirs
at.dirlocal += at.depdirs
-include $(topsrcdir)/common.once.head.mk
+include $(sort $(wildcard $(topsrcdir)/build-aux/Makefile.once.head/*.mk))
endif # _at.NO_ONCE
@@ -56,4 +60,4 @@ _at.included_makefiles := $(_at.included_makefiles) $(call at.path,$(outdir)/Mak
$(foreach v,$(at.dirlocal),$(eval $v=))
-include $(topsrcdir)/common.each.head.mk
+include $(sort $(wildcard $(topsrcdir)/build-aux/Makefile.each.head/*.mk))
diff --git a/build-aux/Makefile.tail.mk b/build-aux/Makefile.tail.mk
index bb197dc..f7d42b9 100644
--- a/build-aux/Makefile.tail.mk
+++ b/build-aux/Makefile.tail.mk
@@ -15,10 +15,14 @@
# This bit gets evaluated for each Makefile processed
-include $(wildcard $(topsrcdir)/build-aux/Makefile.each.tail/*.mk)
+include $(call _at.reverse,$(sort $(wildcard $(topsrcdir)/build-aux/Makefile.each.tail/*.mk)))
-# Make the namespaced versions of all of the dirlocal variables
-$(foreach v,$(at.dirlocal),$(eval $v/$(outdir) = $($v)))
+at.subdirs := $(addprefix $(outdir)/,$(at.subdirs))
+at.depdirs := $(addprefix $(outdir)/,$(at.depdirs))
+
+# Move all of the dirlocal variables to their namespaced version
+$(foreach v,$(at.dirlocal),$(eval $v/$(outdir) := $$($v)))
+$(foreach v,$(at.dirlocal),$(eval undefine $v))
# Remember that this is a directory that we've visited
_at.outdirs := $(_at.outdirs) $(outdir)
@@ -27,11 +31,11 @@ _at.outdirs := $(_at.outdirs) $(outdir)
# mark them phony
.PHONY: $(addprefix $(outdir)/,$(at.phony))
# have them depend on subdirs
-$(foreach t,$(at.phony),$(eval $(outdir)/$t: $(addsuffix /$t,$(subdirs))))
+$(foreach t,$(at.phony),$(eval $(outdir)/$t: $(addsuffix /$t,$(at.subdirs/$(outdir)))))
# Include Makefiles from other directories
$(foreach _at.NO_ONCE,y,\
- $(foreach makefile,$(call am_path,$(addsuffix /Makefile,$(at.subdirs) $(at.depdirs))),\
+ $(foreach makefile,$(call at.path,$(addsuffix /Makefile,$(at.subdirs/$(outdir)) $(at.depdirs/$(outdir)))),\
$(eval include $(filter-out $(_at.included_makefiles),$(makefile)))))
# This bit only gets evaluated once, after all of the other Makefiles are read
@@ -42,6 +46,6 @@ srcdir = /bogus
$(foreach v,$(at.dirlocal),$(eval $v=))
-include $(wildcard $(topsrcdir)/build-aux/Makefile.once.tail/*.mk)
+include $(call _at.reverse,$(sort $(wildcard $(topsrcdir)/build-aux/Makefile.once.tail/*.mk)))
endif # _at.NO_ONCE