From 8a5ecbb4fcaf0d9864074666a45d9263b73f31b8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 7 Aug 2016 21:03:44 -0400 Subject: (systemd) stuff --- build-aux/Makefile.head.mk | 101 ++++++++++++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 29 deletions(-) (limited to 'build-aux/Makefile.head.mk') diff --git a/build-aux/Makefile.head.mk b/build-aux/Makefile.head.mk index 36c2c0a..8213043 100644 --- a/build-aux/Makefile.head.mk +++ b/build-aux/Makefile.head.mk @@ -12,60 +12,103 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . + +_at.MAKEFILE_LIST ?= +_at.MAKEFILE_LIST := $(strip $(_at.MAKEFILE_LIST) $(abspath $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) # This bit only gets evaluated once, at the very beginning ifeq ($(origin _at.NO_ONCE),undefined) +# Internal functions ################################################### + +# These 4 functions are all $(call _at.func,parent,child) +_at.is_strict_subdir = $(filter $(abspath $1)/%,$(abspath $2)) +_at.is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/.) +_at.relbase = $(strip \ + $(if $(call _at.is_subdir,$1,$2), \ + $(patsubst $(abspath $1)/%,%,$(abspath $2)/.), \ + $(abspath $2))) +_at.relto = $(strip \ + $(if $(call _at.is_subdir,$1,$2), \ + $(patsubst $(abspath $1)/%,%,$(abspath $2)/.), \ + ../$(call _at.relto,$(dir $1),$2))) + +# These 3 functions only take one operand; we define public multi-operand +# versions below. +_at.path = $(strip \ + $(if $(call _at.is_subdir,$(topoutdir),$1), \ + $(patsubst %/.,%,$(topoutdir)/$(call _at.relto,.,$1)), \ + $(if $(call _at.is_subdir,$(topsrcdir),$1), \ + $(patsubst %/.,%,$(topsrcdir)/$(call _at.relto,$(topsrcdir),$1)), \ + $(abspath $1)))) +_at.out2src = $(call _at.path,$(if $(call _at.is_subdir,$(topoutdir),$1),$(topsrcdir)/$(call _at.path,$1),$1)) +_at.addprefix = $(call _at.path,$(if $(filter-out /%,$2),$1/$2,$2)) + +_at.rest = $(wordlist 2,$(words $1),$1) +_at.reverse = $(if $1,$(call _at.reverse,$(_at.rest))) $(firstword $1) + +# Sanity checking ###################################################### +ifeq ($(filter undefine,$(.FEATURES)),) +$(error Autothing: We need a version of Make that supports 'undefine') +endif ifeq ($(topsrcdir),) -$(error topsrcdir must be set before including Makefile.head.mk) +$(error Autothing: topsrcdir must be set (and non-empty) before including Makefile.head.mk) endif ifeq ($(topoutdir),) -$(error topoutdir must be set before including Makefile.head.mk) +$(error Autothing: topoutdir must be set (and non-empty) before including Makefile.head.mk) endif +ifneq ($(call _at.is_strict_subdir,$(topoutdir),$(topsrcdir)),) +$(error Autothing: topsrcdir=$(topsrcdir) must not be a subdirectory of topoutdir=$(topoutdir)) +endif + +# Internal setup ####################################################### -_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.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 = $(call at.relto,.,$1) +# External provisions ################################################## -_at.addprefix = $(if $(filter /%,$2),$2,$1/$2) -at.addprefix = $(foreach f,$2, $(addsuffix $(if $(filter %/,$f),/),$(call at.path,$(call _at.addprefix,$1,$f)) )) +# These 4 functions are all $(call _at.func,parent,child) +at.is_subdir = $(_at.is_subdir) +at.is_strict_subdir = $(_at.is_strict_subdir) +#at.relbase = $(if $2,$(shell realpath -sm --relative-base=$1 -- $2)) +at.relbase = $(foreach _at.tmp,$2,$(call _at.relbase,$1,$(_at.tmp))) +#at.relto = $(if $2,$(shell realpath -sm --relative-to=$1 -- $2)) +at.relto = $(foreach _at.tmp,$2,$(call _at.relto,$1,$(_at.tmp))) + +at.path = $(foreach _at.tmp,$1,$(call _at.path,$(_at.tmp))) +at.out2src = $(foreach _at.tmp,$1,$(call _at.out2src,$(_at.tmp))) +at.addprefix = $(foreach _at.tmp,$2,$(call _at.addprefix,$1,$(_at.tmp))) define at.nl endef +# External configuration ############################################### at.Makefile ?= Makefile -_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 - -_at.outdirs ?= -_at.included_makefiles ?= - +# Include modules ###################################################### include $(sort $(wildcard $(topsrcdir)/build-aux/Makefile.once.head/*.mk)) +_at.tmp_targets = +_at.tmp_subdirs = +_at.VARIABLES = +_at.VARIABLES := $(.VARIABLES) endif # _at.NO_ONCE # This bit gets evaluated for each Makefile -## Set outdir and srcdir (assumes that topoutdir and topsrcdir are -## already set) -outdir := $(call at.path,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) -srcdir := $(call at.path,$(topsrcdir)/$(call _at.relto,$(topoutdir),$(outdir))) +outdir := $(call _at.path,$(dir $(lastword $(_at.MAKEFILE_LIST)))) +ifeq ($(call _at.is_subdir,$(topoutdir),$(outdir)),) +$(error Autothing: not a subdirectory of topoutdir=$(topoutdir): $(outdir)) +endif -_at.included_makefiles := $(_at.included_makefiles) $(call at.path,$(outdir)/$(at.Makefile)) +# Don't use at.out2src because we *know* that $(outdir) is inside $(topoutdir), +# and has already had $(_at.path) called on it. +srcdir := $(call _at.path,$(topsrcdir)/$(outdir)) +ifeq ($(call _at.is_subdir,$(topsrcdir),$(srcdir)),) +$(error Autothing: not a subdirectory of topsrcdir=$(topsrcdir): $(srcdir)) +endif -$(foreach v,$(at.dirlocal),$(eval $v=)) +at.subdirs = +at.targets = include $(sort $(wildcard $(topsrcdir)/build-aux/Makefile.each.head/*.mk)) -- cgit v1.2.3