summaryrefslogtreecommitdiff
path: root/build-aux/Makefile.head.mk
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux/Makefile.head.mk')
-rw-r--r--build-aux/Makefile.head.mk36
1 files changed, 17 insertions, 19 deletions
diff --git a/build-aux/Makefile.head.mk b/build-aux/Makefile.head.mk
index c2ce3075b2..6ac3d49f9f 100644
--- a/build-aux/Makefile.head.mk
+++ b/build-aux/Makefile.head.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2016 Luke Shumaker
+# Copyright (C) 2015-2017 Luke Shumaker
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@@ -13,8 +13,9 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+at.Makefile ?= Makefile
_at.MAKEFILE_LIST ?=
-_at.MAKEFILE_LIST := $(strip $(_at.MAKEFILE_LIST) $(abspath $(lastword $(filter-out %.mk,$(MAKEFILE_LIST)))))
+_at.MAKEFILE_LIST := $(strip $(_at.MAKEFILE_LIST) $(lastword $(filter %/$(at.Makefile),$(abspath $(MAKEFILE_LIST)))))
# This bit only gets evaluated once, at the very beginning
ifeq ($(origin _at.NO_ONCE),undefined)
@@ -24,24 +25,26 @@ ifeq ($(origin _at.NO_ONCE),undefined)
# 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 %/.,$(patsubst $(abspath $1)/%,%,$(abspath $2)/.)), \
+_at.relbase = $(strip \
+ $(if $(call _at.is_subdir,$1,$2), \
+ $(patsubst %/.,%,$(patsubst $(abspath $1)/%,%,$(abspath $2)/.)), \
$(abspath $2)))
_at.relto = $(strip \
$(if $(call _at.is_subdir,$1,$2), \
$(patsubst %/.,%,$(patsubst $(abspath $1)/%,%,$(abspath $2)/.)), \
- ../$(call _at.relto,$(dir $1),$2)))
+ ../$(call _at.relto,$(dir $(abspath $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.path = $(strip $(or \
+ $(if $(call _at.is_subdir, . ,$1), $(call _at.relto, . ,$1) ), \
+ $(if $(call _at.is_subdir,$(topoutdir),$1),$(patsubst %/.,%,$(topoutdir)/$(call _at.relto,$(topoutdir),$1))), \
+ $(if $(call _at.is_subdir,$(topsrcdir),$1),$(patsubst %/.,%,$(topsrcdir)/$(call _at.relto,$(topsrcdir),$1))), \
+ $(abspath $1)))
+_at.out2src = $(call _at.path,$(strip \
+ $(if $(call _at.is_subdir,$(topoutdir),$1), \
+ $(topsrcdir)/$(call _at.relto,$(topoutdir),$1), \
+ $1)))
_at.addprefix = $(call _at.path,$(if $(filter-out /%,$2),$1/$2,$2))
_at.rest = $(wordlist 2,$(words $1),$1)
@@ -86,9 +89,6 @@ define at.nl
endef
-# External configuration ###############################################
-at.Makefile ?= Makefile
-
# Include modules ######################################################
include $(sort $(wildcard $(topsrcdir)/build-aux/Makefile.once.head/*.mk))
_at.tmp_targets =
@@ -105,9 +105,7 @@ ifeq ($(call _at.is_subdir,$(topoutdir),$(outdir)),)
$(error Autothing: not a subdirectory of topoutdir=$(topoutdir): $(outdir))
endif
-# 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))
+srcdir := $(call _at.out2src,$(outdir))
ifeq ($(call _at.is_subdir,$(topsrcdir),$(srcdir)),)
$(error Autothing: not a subdirectory of topsrcdir=$(topsrcdir): $(srcdir))
endif