From 30e4649c2642351870914985be2b4f1e40bcd83f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 29 Jun 2015 00:43:52 -0600 Subject: (rvs) Start re-jiggering RVS. --- common.bottom.mk | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ common.top.mk | 47 +++++++++++++++++++++++++ config.mk | 46 ++++++++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100644 common.bottom.mk create mode 100644 common.top.mk create mode 100644 config.mk diff --git a/common.bottom.mk b/common.bottom.mk new file mode 100644 index 0000000..0e2c039 --- /dev/null +++ b/common.bottom.mk @@ -0,0 +1,105 @@ +# Copyright (C) 2015 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +include $(topsrcdir)/common.each.mk + + +# Aggregate variables + +# Add some more defaults to the *_files variables +clean_files += $(obj_files) +conf_files += Makefile $(topobjdir)/config.mk +# Now namespace the *_files variables +$(module)_src_files := $(addprefix $(srcdir)/,$(src_files)) +$(module)_obj_files := $(addprefix $(objdir)/,$(obj_files)) +$(module)_sys_files := $(addprefix $(DESTDIR)/,$(sys_files)) +$(module)_clean_files := $(addprefix $(objdir)/,$(clean_files)) +$(module)_slow_files := $(addprefix $(objdir)/,$(slow_files)) +$(module)_conf_files := $(addprefix $(objdir)/,$(conf_files)) +$(module)_dist_files := $(addprefix $(objdir)/,$(dist_files)) + +# And add them to the $(parent)_*_files variables (if applicable) +ifneq ($(parent),) +$(parent)_src_files := $($(parent)_src_files) $($(module)_src_files) +$(parent)_obj_files := $($(parent)_obj_files) $($(module)_obj_files) +$(parent)_sys_files := $($(parent)_sys_files) $($(module)_sys_files) +$(parent)_clean_files := $($(parent)_clean_files) $($(module)_clean_files) +$(parent)_slow_files := $($(parent)_slow_files) $($(module)_slow_files) +$(parent)_conf_files := $($(parent)_conf_files) $($(module)_conf_files) +$(parent)_dist_files := $($(parent)_dist_files) $($(module)_dist_files) +$(info added <$(module)> to <$(parent)>) +$(info $(parent)_clean_files => $($(parent)_clean_files)) +$(info $(parent)_obj_files => $($(parent)_obj_files)) +endif + +modules := $(modules) $(module) + + +# Include Makefiles from other directories + +define _nl + + +endef +$(eval \ + _COMMON_MK_NOONCE = n$(_nl)\ + $(foreach dir,$(subdirs),parent=$(module)$(_nl)include $(objdir)/$(dir)/Makefile$(_nl)) \ + $(foreach dir,$(depdirs),parent=dep $(_nl)include $(objdir)/$(dir)/Makefile$(_nl)) \ + _COMMON_MK_NOONCE = $(_COMMON_MK_NOONCE)) + + +# This only gets evaluated once, after all of the other Makefiles a read +ifeq ($(_COMMON_MK_NOONCE),) + +.phony = build install uninstall mostlyclean clean distclean maintainer-clean check + +# Declare phony targets +define module_rules +.PHONY: $(addsuffix -%(module),$(.phony)) +# Constructive phony targets +build-%(module): $(%(module)_obj_files) +install-%(module): $(%(module)_sys_files) +# Destructive phony targets +_%(module)_uninstall = $(%(module)_sys_files)) +_%(module)_mostlyclean = $(filter-out $(%(module)_slow_files) $(%(module)_conf_files) $(%(module)_dist_files),$(%(module)_clean_files)) +_%(module)_clean = $(filter-out $(%(module)_conf_files) $(%(module)_dist_files),$(%(module)_clean_files)) +_%(module)_distclean = $(filter-out $(%(module)_dist_files),$(%(module)_clean_files)) +_%(module)_maintainer-clean = $(%(module)_clean_files) +uninstall-%(module) mostlyclean-%(module) clean-%(module) distclean-%(module) maintainer-clean-%(module): %-%(module): + $(RM) -- $(sort $(_%(module)_$*)) + $(RMDIRS) $(sort $(dir $(_%(module)_$*))) 2>/dev/null || $(TRUE) +endef +$(foreach module,$(modules),$(eval $(subst %(module),$(module),$(value module_rules)))) + +# Alias each bare phony target to itself with the `-all` suffix +$(foreach t,$(.phony),$(eval $t: $t-all)) + +# Add the `dist` target +.PHONY: dist +dist: $(topobjdir)/$(PACKAGE)-$(VERSION).tar.gz +$(topobjdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topobjdir)/$(PACKAGE)-$(VERSION) + $(TAR) czf $@ -C $(. + +# Both of these have the argument order "parent,child" +_noslash = $(patsubst %/,%,$1) +_relto = $(call _noslash,$(patsubst $(abspath $1)/%,%,$(abspath $2)/)) +_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/) + +## Declare the standard targets +all: build +.PHONY: all + +## Set topobjdir, objdir, and srcdir (assumes that topsrcdir is already set) +ifeq ($(topobjdir),) +topobjdir := $(call _noslash,$(dir $(lastword $(filter %/config.mk config.mk,$(MAKEFILE_LIST))))) +endif + objdir := $(call _noslash,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) + srcdir := $(firstword $(call _relto,., $(topsrcdir)/$(call _relto,$(topobjdir),$(objdir)) ) .) + +## Set module name +module := $(firstword $(subst /,_,$(if $(call _is_subdir,.,$(objdir)),$(call _relto,.,$(objdir)),dep-$(call _relto,$(topobjdir),$(objdir)))) all) + +## Empty variables for use by the module +subdirs = +depdirs = + +src_files = +obj_files = +sys_files = + +clean_files = + +slow_files = +conf_files = +dist_files = diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..a64243b --- /dev/null +++ b/config.mk @@ -0,0 +1,46 @@ +ifeq ($(topsrcdir),) +topsrcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) +endif + +PACKAGE = rvs +VERSION = 0.10 +pkgtextdomain = $(PACKAGE) + +DESTDIR = +prefix = /usr/local +exec_prefix = $(prefix) + +bindir = $(exec_prefix)/bin +sbindir = $(exec_prefix)/sbin +libexecdir = $(exec_prefix)/libexec +datarootdir = $(prefix)/share +datadir = $(datarootdir) +sysconfdir = $(prefix)/etc +sharedstatedir = $(prefix)/com +localstatedir = $(prefix)/var +runstatedir = $(localstatedir)/run +localedir = $(datarootdir)/locale + +pkgdatadir = $(datadir)/$(PACKAGE) +pkglibexecdir = $(libexecdir)/$(PACKAGE) + +CFLAGS = -std=c99 -Werror -Wall -Wextra -pedantic -O2 +CPPFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE + +CC = cc +M4 = m4 +MKDIR = mkdir +MKDIRS = mkdir -p +RMDIRS = rmdir -p +INSTALL_DATA = install -m644 +INSTALL_PROGRAM = install -m755 +CP = cp +MV = mv +RM = rm -f +SED = sed +SORT = sort +TAR = tar +TRUE = true +PRINTF = printf + +AUTODEPS = t -- cgit v1.2.3-54-g00ecf From bd22a9cc04ad031bc3d472d7b9d61306f6247b4f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 29 Jun 2015 08:46:48 -0600 Subject: (rvs) `make dist` wasn't working --- common.bottom.mk | 36 +++++++++++++++++++++++++----------- common.top.mk | 4 +++- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/common.bottom.mk b/common.bottom.mk index 0e2c039..016e093 100644 --- a/common.bottom.mk +++ b/common.bottom.mk @@ -39,9 +39,6 @@ $(parent)_clean_files := $($(parent)_clean_files) $($(module)_clean_files) $(parent)_slow_files := $($(parent)_slow_files) $($(module)_slow_files) $(parent)_conf_files := $($(parent)_conf_files) $($(module)_conf_files) $(parent)_dist_files := $($(parent)_dist_files) $($(module)_dist_files) -$(info added <$(module)> to <$(parent)>) -$(info $(parent)_clean_files => $($(parent)_clean_files)) -$(info $(parent)_obj_files => $($(parent)_obj_files)) endif modules := $(modules) $(module) @@ -52,20 +49,37 @@ modules := $(modules) $(module) define _nl +endef +define _include_makefile +ifeq ($(filter $(abspath $1),$(included_makefiles)),) +include $(if $(call _is_subdir,.,$1),$(call _relto,.,$1),$(topobjdir)/$(call _relto,$(topobjdir),$1)) +endif endef $(eval \ _COMMON_MK_NOONCE = n$(_nl)\ - $(foreach dir,$(subdirs),parent=$(module)$(_nl)include $(objdir)/$(dir)/Makefile$(_nl)) \ - $(foreach dir,$(depdirs),parent=dep $(_nl)include $(objdir)/$(dir)/Makefile$(_nl)) \ + $(foreach dir,$(subdirs),parent=$(module)$(_nl)$(call _include_makefile,$(objdir)/$(dir)/Makefile)$(_nl))\ + parent=dep$(_nl)\ + $(call _include_makefile,$(topobjdir)/$(dir)/Makefile)$(_nl)\ _COMMON_MK_NOONCE = $(_COMMON_MK_NOONCE)) -# This only gets evaluated once, after all of the other Makefiles a read +# This only gets evaluated once, after all of the other Makefiles are read ifeq ($(_COMMON_MK_NOONCE),) - -.phony = build install uninstall mostlyclean clean distclean maintainer-clean check +# Empty module-level variables +objdir = /bogus +srcdir = /bogus +subdirs = +depdirs = +src_files = +obj_files = +sys_files = +clean_files = +slow_files = +conf_files = +dist_files = # Declare phony targets +.phony = build install uninstall mostlyclean clean distclean maintainer-clean check define module_rules .PHONY: $(addsuffix -%(module),$(.phony)) # Constructive phony targets @@ -93,11 +107,11 @@ $(topobjdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topobjdir)/$(PACKAGE)-$(VERSION) $(TAR) czf $@ -C $( Date: Mon, 29 Jun 2015 18:06:09 -0600 Subject: (rvs) Makefile: whoops, dist_files should go in srcdir, not objdir --- common.bottom.mk | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/common.bottom.mk b/common.bottom.mk index 016e093..2d56297 100644 --- a/common.bottom.mk +++ b/common.bottom.mk @@ -28,7 +28,7 @@ $(module)_sys_files := $(addprefix $(DESTDIR)/,$(sys_files)) $(module)_clean_files := $(addprefix $(objdir)/,$(clean_files)) $(module)_slow_files := $(addprefix $(objdir)/,$(slow_files)) $(module)_conf_files := $(addprefix $(objdir)/,$(conf_files)) -$(module)_dist_files := $(addprefix $(objdir)/,$(dist_files)) +$(module)_dist_files := $(addprefix $(srcdir)/,$(dist_files)) # And add them to the $(parent)_*_files variables (if applicable) ifneq ($(parent),) @@ -110,8 +110,7 @@ _addfile = $(call _copyfile,$3,$2/$(call _relto,$1,$3)) $(topobjdir)/$(PACKAGE)-$(VERSION): $(all_src_files) $(dep_src_files) $(all_dist_files) $(dep_dist_files) $(RM) -r $@ $(MKDIR) $(@D)/tmp.$(@F).$$$$ && \ - $(foreach f,$(all_src_files) $(dep_src_files) ,$(call _addfile,$(topsrcdir),$(@D)/tmp.$(@F).$$$$,$f) &&) \ - $(foreach f,$(all_dist_files) $(dep_dist_files),$(call _addfile,$(topobjdir),$(@D)/tmp.$(@F).$$$$,$f) &&) \ + $(foreach f,$^,$(call _addfile,$(topsrcdir),$(@D)/tmp.$(@F).$$$$,$f) &&) \ $(MV) $(@D)/tmp.$(@F).$$$$ $@ || $(RM) -r $(@D)/tmp.$(@F).$$$$ include $(topsrcdir)/common.once.mk -- cgit v1.2.3-54-g00ecf From d1470e3d20a2fe6edc0b90521f5b922681110827 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 1 Jul 2015 23:22:00 -0600 Subject: (rvs) A whole bunch of stuff --- common.bottom.mk | 116 ++++++++++++++++++++++++++++++++----------------------- common.top.mk | 22 +++++------ 2 files changed, 78 insertions(+), 60 deletions(-) diff --git a/common.bottom.mk b/common.bottom.mk index 2d56297..4a5833c 100644 --- a/common.bottom.mk +++ b/common.bottom.mk @@ -19,98 +19,116 @@ include $(topsrcdir)/common.each.mk # Aggregate variables # Add some more defaults to the *_files variables -clean_files += $(obj_files) -conf_files += Makefile $(topobjdir)/config.mk +clean_files += $(out_files) +conf_files += Makefile $(topoutdir)/config.mk # Now namespace the *_files variables -$(module)_src_files := $(addprefix $(srcdir)/,$(src_files)) -$(module)_obj_files := $(addprefix $(objdir)/,$(obj_files)) -$(module)_sys_files := $(addprefix $(DESTDIR)/,$(sys_files)) -$(module)_clean_files := $(addprefix $(objdir)/,$(clean_files)) -$(module)_slow_files := $(addprefix $(objdir)/,$(slow_files)) -$(module)_conf_files := $(addprefix $(objdir)/,$(conf_files)) -$(module)_dist_files := $(addprefix $(srcdir)/,$(dist_files)) +define _am_add_to_module +_am_$(module)_src_files = $(addprefix $(srcdir)/,$(src_files)) +_am_$(module)_out_files = $(addprefix $(outdir)/,$(out_files)) +_am_$(module)_sys_files = $(addprefix $(DESTDIR),$(sys_files)) +_am_$(module)_clean_files = $(addprefix $(outdir)/,$(clean_files)) +_am_$(module)_slow_files = $(addprefix $(outdir)/,$(slow_files)) +_am_$(module)_conf_files = $(addprefix $(outdir)/,$(conf_files)) +_am_$(module)_dist_files = $(addprefix $(srcdir)/,$(dist_files)) +endef +$(eval $(_am_add_to_module)) # And add them to the $(parent)_*_files variables (if applicable) +define _am_add_to_parent +_am_%(parent)_src_files += $(_am_%(module)_src_files) +_am_%(parent)_out_files += $(_am_%(module)_out_files) +_am_%(parent)_sys_files += $(_am_%(module)_sys_files) +_am_%(parent)_clean_files += $(_am_%(module)_clean_files) +_am_%(parent)_slow_files += $(_am_%(module)_slow_files) +_am_%(parent)_conf_files += $(_am_%(module)_conf_files) +_am_%(parent)_dist_files += $(_am_%(module)_dist_files) +endef ifneq ($(parent),) -$(parent)_src_files := $($(parent)_src_files) $($(module)_src_files) -$(parent)_obj_files := $($(parent)_obj_files) $($(module)_obj_files) -$(parent)_sys_files := $($(parent)_sys_files) $($(module)_sys_files) -$(parent)_clean_files := $($(parent)_clean_files) $($(module)_clean_files) -$(parent)_slow_files := $($(parent)_slow_files) $($(module)_slow_files) -$(parent)_conf_files := $($(parent)_conf_files) $($(module)_conf_files) -$(parent)_dist_files := $($(parent)_dist_files) $($(module)_dist_files) +$(eval $(subst %(parent),$(parent),$(subst %(module),$(module),$(value _am_add_to_parent)))) endif modules := $(modules) $(module) + +# Do some per-module magic + +_am_phony = build install uninstall mostlyclean clean distclean maintainer-clean check + +.PHONY: $(addsuffix -%(module),$(_am_phony)) + +$(addsuffix -$(module),uninstall mostlyclean clean distclean maintainer-clean) :: + $(RM) -- $(sort $(_am_$@)) + $(RMDIRS) $(sort $(dir $(_am_$@))) 2>/dev/null || $(TRUE) + # Include Makefiles from other directories -define _nl +define _am_nl endef -define _include_makefile +define _am_include_makefile ifeq ($(filter $(abspath $1),$(included_makefiles)),) -include $(if $(call _is_subdir,.,$1),$(call _relto,.,$1),$(topobjdir)/$(call _relto,$(topobjdir),$1)) +include $(if $(call _am_is_subdir,.,$1),$(call _am_relto,.,$1),$(topoutdir)/$(call _am_relto,$(topoutdir),$1)) endif endef $(eval \ - _COMMON_MK_NOONCE = n$(_nl)\ - $(foreach dir,$(subdirs),parent=$(module)$(_nl)$(call _include_makefile,$(objdir)/$(dir)/Makefile)$(_nl))\ - parent=dep$(_nl)\ - $(call _include_makefile,$(topobjdir)/$(dir)/Makefile)$(_nl)\ - _COMMON_MK_NOONCE = $(_COMMON_MK_NOONCE)) + _am_NO_ONCE = y$(_am_nl)\ + $(foreach dir,$(subdirs),parent=$(module)$(_am_nl)$(call _am_include_makefile,$(outdir)/$(dir)/Makefile)$(_am_nl))\ + parent=dep$(_am_nl)\ + $(call _am_include_makefile,$(topoutdir)/$(dir)/Makefile)$(_am_nl)\ + _am_NO_ONCE = $(_am_NO_ONCE)) # This only gets evaluated once, after all of the other Makefiles are read -ifeq ($(_COMMON_MK_NOONCE),) +ifeq ($(_am_NO_ONCE),) # Empty module-level variables -objdir = /bogus +outdir = /bogus srcdir = /bogus subdirs = depdirs = src_files = -obj_files = +out_files = sys_files = clean_files = slow_files = conf_files = dist_files = -# Declare phony targets -.phony = build install uninstall mostlyclean clean distclean maintainer-clean check -define module_rules -.PHONY: $(addsuffix -%(module),$(.phony)) +ifeq ($(abspath .),$(abspath $(topoutdir))) +_am_all_clean_files += $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz +$(addsuffix -all,mostlyclean clean distclean maintainer-clean) :: + $(RM) -r -- $(topoutdir)/$(PACKAGE)-$(VERSION) +endif + +define _am_module_rules # Constructive phony targets -build-%(module): $(%(module)_obj_files) -install-%(module): $(%(module)_sys_files) +build-%(module): $(_am_%(module)_out_files) +install-%(module): $(_am_%(module)_sys_files) # Destructive phony targets -_%(module)_uninstall = $(%(module)_sys_files)) -_%(module)_mostlyclean = $(filter-out $(%(module)_slow_files) $(%(module)_conf_files) $(%(module)_dist_files),$(%(module)_clean_files)) -_%(module)_clean = $(filter-out $(%(module)_conf_files) $(%(module)_dist_files),$(%(module)_clean_files)) -_%(module)_distclean = $(filter-out $(%(module)_dist_files),$(%(module)_clean_files)) -_%(module)_maintainer-clean = $(%(module)_clean_files) -uninstall-%(module) mostlyclean-%(module) clean-%(module) distclean-%(module) maintainer-clean-%(module): %-%(module): - $(RM) -- $(sort $(_%(module)_$*)) - $(RMDIRS) $(sort $(dir $(_%(module)_$*))) 2>/dev/null || $(TRUE) +_am_uninstall-%(module) = $(_am_%(module)_sys_files)) +_am_mostlyclean-%(module) = $(filter-out $(_am_%(module)_slow_files) $(_am_%(module)_conf_files) $(_am_%(module)_dist_files),$(_am_%(module)_clean_files)) +_am_clean-%(module) = $(filter-out $(_am_%(module)_conf_files) $(_am_%(module)_dist_files),$(_am_%(module)_clean_files)) +_am_distclean-%(module) = $(filter-out $(_am_%(module)_dist_files),$(_am_%(module)_clean_files)) +_am_maintainer-clean-%(module) = $(_am_%(module)_clean_files) endef -$(foreach module,$(modules),$(eval $(subst %(module),$(module),$(value module_rules)))) +$(foreach module,$(modules),$(eval $(subst %(module),$(module),$(value _am_module_rules)))) # Alias each bare phony target to itself with the `-all` suffix -$(foreach t,$(.phony),$(eval $t: $t-all)) +$(foreach t,$(_am_phony),$(eval $t: $t-all)) # Add the `dist` target .PHONY: dist -dist: $(topobjdir)/$(PACKAGE)-$(VERSION).tar.gz -$(topobjdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topobjdir)/$(PACKAGE)-$(VERSION) +dist: $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz +$(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topoutdir)/$(PACKAGE)-$(VERSION) $(TAR) czf $@ -C $(. # Both of these have the argument order "parent,child" -_noslash = $(patsubst %/,%,$1) -_relto = $(call _noslash,$(patsubst $(abspath $1)/%,%,$(abspath $2)/)) -_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/) +_am_noslash = $(patsubst %/,%,$1) +_am_relto = $(call _am_noslash,$(patsubst $(abspath $1)/%,%,$(abspath $2)/)) +_am_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/) ## Declare the standard targets all: build .PHONY: all -## Set topobjdir, objdir, and srcdir (assumes that topsrcdir is already set) -ifeq ($(topobjdir),) -topobjdir := $(call _noslash,$(dir $(lastword $(filter %/config.mk config.mk,$(MAKEFILE_LIST))))) +## Set topoutdir, outdir, and srcdir (assumes that topsrcdir is already set) +ifeq ($(topoutdir),) +topoutdir := $(call _am_noslash,$(dir $(lastword $(filter %/config.mk config.mk,$(MAKEFILE_LIST))))) endif - objdir := $(call _noslash,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) - srcdir := $(firstword $(call _relto,., $(topsrcdir)/$(call _relto,$(topobjdir),$(objdir)) ) .) + outdir := $(call _am_noslash,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) + srcdir := $(firstword $(call _am_relto,., $(topsrcdir)/$(call _am_relto,$(topoutdir),$(outdir)) ) .) -included_makefiles := $(included_makefiles) $(abspath $(objdir)/Makefile) +included_makefiles := $(included_makefiles) $(abspath $(outdir)/Makefile) ## Set module name -module := $(subst /,_,$(if $(call _is_subdir,.,$(objdir)),$(firstword $(call _relto,.,$(objdir)) all),dep-$(firstword $(call _relto,$(topobjdir),$(objdir)) top))) +module := $(subst /,_,$(if $(call _am_is_subdir,.,$(outdir)),$(firstword $(call _am_relto,.,$(outdir)) all),dep-$(firstword $(call _am_relto,$(topoutdir),$(outdir)) top))) ## Empty variables for use by the module subdirs = depdirs = src_files = -obj_files = +out_files = sys_files = clean_files = -- cgit v1.2.3-54-g00ecf From 1c22e513c969522a53aeec8e64004a72df06fab6 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 9 Jul 2015 18:53:23 -0600 Subject: (rvs) whitespace --- common.bottom.mk | 2 +- common.top.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common.bottom.mk b/common.bottom.mk index 4a5833c..e8b5493 100644 --- a/common.bottom.mk +++ b/common.bottom.mk @@ -1,5 +1,5 @@ # Copyright (C) 2015 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 # the Free Software Foundation, either version 3 of the License, or diff --git a/common.top.mk b/common.top.mk index 9a2fa0a..9e57088 100644 --- a/common.top.mk +++ b/common.top.mk @@ -1,5 +1,5 @@ # Copyright (C) 2015 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 # the Free Software Foundation, either version 3 of the License, or -- cgit v1.2.3-54-g00ecf From bce7ec06c4234cb5713bb20350b3aff9010e3703 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 8 Feb 2016 16:36:45 -0500 Subject: (libretools) Refactor the build system. Avoid recursive make. This looks like a lot, but more things should "just work". We have `make dist` now! --- automake.head.mk | 58 +++++++++++++++++++++++ automake.tail.mk | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ automake.txt | 88 ++++++++++++++++++++++++++++++++++ common.bottom.mk | 136 ----------------------------------------------------- common.top.mk | 49 ------------------- config.mk | 46 ------------------ 6 files changed, 286 insertions(+), 231 deletions(-) create mode 100644 automake.head.mk create mode 100644 automake.tail.mk create mode 100644 automake.txt delete mode 100644 common.bottom.mk delete mode 100644 common.top.mk delete mode 100644 config.mk diff --git a/automake.head.mk b/automake.head.mk new file mode 100644 index 0000000..a3c90fd --- /dev/null +++ b/automake.head.mk @@ -0,0 +1,58 @@ +# Copyright (C) 2015-2016 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +_am = am_ + +_am_noslash = $(patsubst %/.,%,$(patsubst %/,%,$1)) +# These are all $(call _am_func,parent,child) +#_am_relto = $(if $2,$(shell realpath -s --relative-to='$1' $2)) +_am_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/.) +_am_relto_helper = $(if $(call _am_is_subdir,$1,$2),$(patsubst $1/%,%,$(addsuffix /.,$2)),$(addprefix ../,$(call _am_relto_helper,$(patsubst %/,%,$(dir $1)),$2))) +_am_relto = $(call _am_noslash,$(call _am_relto_helper,$(call _am_noslash,$(abspath $1)),$(call _am_noslash,$(abspath $2)))) +# Note that _am_is_subdir says that a directory is a subdirectory of +# itself. +_am_path = $(call _am_relto,.,$1) + +## Declare the default target +all: build +.PHONY: all + +## Set topoutdir, outdir, and srcdir (assumes that topsrcdir is +## already set, and that $(topoutdir)/config.mk has been included) +ifeq ($(topoutdir),) +topoutdir := $(call _am_path,$(dir $(lastword $(filter %/config.mk config.mk,$(MAKEFILE_LIST))))) +endif + outdir := $(call _am_path,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) + srcdir := $(call _am_path,$(topsrcdir)/$(call _am_relto,$(topoutdir),$(outdir))) + +_am_included_makefiles := $(_am_included_makefiles) $(call _am_path,$(outdir)/Makefile) + +## Empty variables for use by the module +$(_am)subdirs = +$(_am)depdirs = + +$(_am)src_files = +$(_am)gen_files = +$(_am)cfg_files = +$(_am)out_files = +$(_am)sys_files = + +$(_am)clean_files = +$(_am)slow_files = + +ifeq ($(_am_NO_ONCE),) +include $(topsrcdir)/common.once.head.mk +endif +include $(topsrcdir)/common.each.head.mk diff --git a/automake.tail.mk b/automake.tail.mk new file mode 100644 index 0000000..5d6ad00 --- /dev/null +++ b/automake.tail.mk @@ -0,0 +1,140 @@ +# Copyright (C) 2015-2016 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +include $(topsrcdir)/common.each.tail.mk + + +# Aggregate variables + +# Add some more defaults to the *_files variables +$(_am)clean_files += $($(_am)gen_files) $($(_am)out_files) +$(_am)cfg_files += Makefile + +# Now namespace the *_files variables +define _am_save_variables +_am_src_files/$(outdir) = $(addprefix $(srcdir)/,$($(_am)src_files)) +_am_gen_files/$(outdir) = $(addprefix $(srcdir)/,$($(_am)gen_files)) +_am_cfg_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)cfg_files)) +_am_out_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)out_files)) +_am_sys_files/$(outdir) = $(addprefix $(DESTDIR),$($(_am)sys_files)) +_am_clean_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)clean_files)) +_am_slow_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)slow_files)) +_am_subdirs/$(outdir) = $($(_am)subdirs) +endef +$(eval $(_am_save_variables)) + +# And add them to the $(parent)_*_files variables (if applicable) +define _am_add_subdir +_am_src_files/%(outdir) += $(_am_src_files/%(subdir)) +_am_gen_files/%(outdir) += $(_am_gen_files/%(subdir)) +_am_cfg_files/%(outdir) += $(_am_cfg_files/%(subdir)) +_am_out_files/%(outdir) += $(_am_out_files/%(subdir)) +_am_sys_files/%(outdir) += $(_am_sys_files/%(subdir)) +_am_clean_files/%(outdir) += $(_am_clean_files/%(subdir)) +_am_slow_files/%(outdir) += $(_am_slow_files/%(subdir)) +endef +$(foreach subdir,$(call _am_path,$(addprefix $(outdir)/,$($(_am)subdirs))),$(eval $(subst %(outdir),$(outdir),$(subst %(subdir),$(subdir),$(value _am_add_subdir))))) + +_am_outdirs := $(_am_outdirs) $(outdir) + + +# Do some per-directory magic + +_am_phony = build install uninstall mostlyclean clean distclean maintainer-clean check + +.PHONY: $(addprefix $(outdir)/,$(_am_phony)) + +$(addprefix $(outdir)/,uninstall mostlyclean clean distclean maintainer-clean):: + $(RM) -- $(sort $(_am_$(@F)/$(@D))) + $(RMDIRS) $(sort $(dir $(_am_$(@F)/$(@D)))) 2>/dev/null || $(TRUE) + +# 'build' and 'install' must be defined later, because the +# am_*_files/* variables might not be complete yet. + + +# Include Makefiles from other directories + +define _am_nl + + +endef + +$(foreach _am_NO_ONCE,y,\ + $(foreach makefile,$(foreach dir,$($(_am)subdirs) $($(_am)depdirs),$(call _am_path,$(outdir)/$(dir)/Makefile)),\ + $(eval include $(filter-out $(_am_included_makefiles),$(makefile))))) + + +# This only gets evaluated once, after all of the other Makefiles are read +ifeq ($(_am_NO_ONCE),) +# Empty directory-level variables +outdir = /bogus +srcdir = /bogus + +$(_am)subdirs = +$(_am)depdirs = + +$(_am)src_files = +$(_am)gen_files = +$(_am)cfg_files = +$(_am)out_files = +$(_am)sys_files = +$(_am)clean_files = +$(_am)slow_files = + +_am_clean_files/$(topoutdir) += $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz +$(addprefix $(topoutdir)/,mostlyclean clean distclean maintainer-clean) :: + $(RM) -r -- $(topoutdir)/$(PACKAGE)-$(VERSION) + +define _am_directory_rules +# Constructive phony targets +$(outdir)/build : $(_am_out_files/%(outdir)) +$(outdir)/install: $(_am_sys_files/%(outdir)) +# Destructive phony targets +_am_uninstall/%(outdir) = $(_am_sys_files/%(outdir)) +_am_mostlyclean/%(outdir) = $(filter-out $(_am_slow_files/%(outdir)) $(_am_cfg_files/%(outdir)) $(_am_gen_files/%(outdir)),$(_am_clean_files/%(outdir))) +_am_clean/%(outdir) = $(filter-out $(_am_cfg_files/%(outdir)) $(_am_gen_files/%(outdir)),$(_am_clean_files/%(outdir))) +_am_distclean/%(outdir) = $(filter-out $(_am_gen_files/%(outdir)),$(_am_clean_files/%(outdir))) +_am_maintainer-clean/%(outdir) = $(_am_clean_files/%(outdir)) +endef +$(foreach outdir,$(_am_outdirs),$(eval $(subst %(outdir),$(outdir),$(value _am_directory_rules)))) + +# Add the `dist` target +.PHONY: dist +dist: $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz +$(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topoutdir)/$(PACKAGE)-$(VERSION) + $(TAR) czf $@ -C $(. - -include $(topsrcdir)/common.each.mk - - -# Aggregate variables - -# Add some more defaults to the *_files variables -clean_files += $(out_files) -conf_files += Makefile $(topoutdir)/config.mk -# Now namespace the *_files variables -define _am_add_to_module -_am_$(module)_src_files = $(addprefix $(srcdir)/,$(src_files)) -_am_$(module)_out_files = $(addprefix $(outdir)/,$(out_files)) -_am_$(module)_sys_files = $(addprefix $(DESTDIR),$(sys_files)) -_am_$(module)_clean_files = $(addprefix $(outdir)/,$(clean_files)) -_am_$(module)_slow_files = $(addprefix $(outdir)/,$(slow_files)) -_am_$(module)_conf_files = $(addprefix $(outdir)/,$(conf_files)) -_am_$(module)_dist_files = $(addprefix $(srcdir)/,$(dist_files)) -endef -$(eval $(_am_add_to_module)) - -# And add them to the $(parent)_*_files variables (if applicable) -define _am_add_to_parent -_am_%(parent)_src_files += $(_am_%(module)_src_files) -_am_%(parent)_out_files += $(_am_%(module)_out_files) -_am_%(parent)_sys_files += $(_am_%(module)_sys_files) -_am_%(parent)_clean_files += $(_am_%(module)_clean_files) -_am_%(parent)_slow_files += $(_am_%(module)_slow_files) -_am_%(parent)_conf_files += $(_am_%(module)_conf_files) -_am_%(parent)_dist_files += $(_am_%(module)_dist_files) -endef -ifneq ($(parent),) -$(eval $(subst %(parent),$(parent),$(subst %(module),$(module),$(value _am_add_to_parent)))) -endif - -modules := $(modules) $(module) - - -# Do some per-module magic - -_am_phony = build install uninstall mostlyclean clean distclean maintainer-clean check - -.PHONY: $(addsuffix -%(module),$(_am_phony)) - -$(addsuffix -$(module),uninstall mostlyclean clean distclean maintainer-clean) :: - $(RM) -- $(sort $(_am_$@)) - $(RMDIRS) $(sort $(dir $(_am_$@))) 2>/dev/null || $(TRUE) - - -# Include Makefiles from other directories - -define _am_nl - - -endef -define _am_include_makefile -ifeq ($(filter $(abspath $1),$(included_makefiles)),) -include $(if $(call _am_is_subdir,.,$1),$(call _am_relto,.,$1),$(topoutdir)/$(call _am_relto,$(topoutdir),$1)) -endif -endef -$(eval \ - _am_NO_ONCE = y$(_am_nl)\ - $(foreach dir,$(subdirs),parent=$(module)$(_am_nl)$(call _am_include_makefile,$(outdir)/$(dir)/Makefile)$(_am_nl))\ - parent=dep$(_am_nl)\ - $(call _am_include_makefile,$(topoutdir)/$(dir)/Makefile)$(_am_nl)\ - _am_NO_ONCE = $(_am_NO_ONCE)) - - -# This only gets evaluated once, after all of the other Makefiles are read -ifeq ($(_am_NO_ONCE),) -# Empty module-level variables -outdir = /bogus -srcdir = /bogus -subdirs = -depdirs = -src_files = -out_files = -sys_files = -clean_files = -slow_files = -conf_files = -dist_files = - -ifeq ($(abspath .),$(abspath $(topoutdir))) -_am_all_clean_files += $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz -$(addsuffix -all,mostlyclean clean distclean maintainer-clean) :: - $(RM) -r -- $(topoutdir)/$(PACKAGE)-$(VERSION) -endif - -define _am_module_rules -# Constructive phony targets -build-%(module): $(_am_%(module)_out_files) -install-%(module): $(_am_%(module)_sys_files) -# Destructive phony targets -_am_uninstall-%(module) = $(_am_%(module)_sys_files)) -_am_mostlyclean-%(module) = $(filter-out $(_am_%(module)_slow_files) $(_am_%(module)_conf_files) $(_am_%(module)_dist_files),$(_am_%(module)_clean_files)) -_am_clean-%(module) = $(filter-out $(_am_%(module)_conf_files) $(_am_%(module)_dist_files),$(_am_%(module)_clean_files)) -_am_distclean-%(module) = $(filter-out $(_am_%(module)_dist_files),$(_am_%(module)_clean_files)) -_am_maintainer-clean-%(module) = $(_am_%(module)_clean_files) -endef -$(foreach module,$(modules),$(eval $(subst %(module),$(module),$(value _am_module_rules)))) - -# Alias each bare phony target to itself with the `-all` suffix -$(foreach t,$(_am_phony),$(eval $t: $t-all)) - -# Add the `dist` target -.PHONY: dist -dist: $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz -$(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topoutdir)/$(PACKAGE)-$(VERSION) - $(TAR) czf $@ -C $(. - -# Both of these have the argument order "parent,child" -_am_noslash = $(patsubst %/,%,$1) -_am_relto = $(call _am_noslash,$(patsubst $(abspath $1)/%,%,$(abspath $2)/)) -_am_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/) - -## Declare the standard targets -all: build -.PHONY: all - -## Set topoutdir, outdir, and srcdir (assumes that topsrcdir is already set) -ifeq ($(topoutdir),) -topoutdir := $(call _am_noslash,$(dir $(lastword $(filter %/config.mk config.mk,$(MAKEFILE_LIST))))) -endif - outdir := $(call _am_noslash,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) - srcdir := $(firstword $(call _am_relto,., $(topsrcdir)/$(call _am_relto,$(topoutdir),$(outdir)) ) .) - -included_makefiles := $(included_makefiles) $(abspath $(outdir)/Makefile) - -## Set module name -module := $(subst /,_,$(if $(call _am_is_subdir,.,$(outdir)),$(firstword $(call _am_relto,.,$(outdir)) all),dep-$(firstword $(call _am_relto,$(topoutdir),$(outdir)) top))) - -## Empty variables for use by the module -subdirs = -depdirs = - -src_files = -out_files = -sys_files = - -clean_files = - -slow_files = -conf_files = -dist_files = diff --git a/config.mk b/config.mk deleted file mode 100644 index a64243b..0000000 --- a/config.mk +++ /dev/null @@ -1,46 +0,0 @@ -ifeq ($(topsrcdir),) -topsrcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -endif - -PACKAGE = rvs -VERSION = 0.10 -pkgtextdomain = $(PACKAGE) - -DESTDIR = -prefix = /usr/local -exec_prefix = $(prefix) - -bindir = $(exec_prefix)/bin -sbindir = $(exec_prefix)/sbin -libexecdir = $(exec_prefix)/libexec -datarootdir = $(prefix)/share -datadir = $(datarootdir) -sysconfdir = $(prefix)/etc -sharedstatedir = $(prefix)/com -localstatedir = $(prefix)/var -runstatedir = $(localstatedir)/run -localedir = $(datarootdir)/locale - -pkgdatadir = $(datadir)/$(PACKAGE) -pkglibexecdir = $(libexecdir)/$(PACKAGE) - -CFLAGS = -std=c99 -Werror -Wall -Wextra -pedantic -O2 -CPPFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE - -CC = cc -M4 = m4 -MKDIR = mkdir -MKDIRS = mkdir -p -RMDIRS = rmdir -p -INSTALL_DATA = install -m644 -INSTALL_PROGRAM = install -m755 -CP = cp -MV = mv -RM = rm -f -SED = sed -SORT = sort -TAR = tar -TRUE = true -PRINTF = printf - -AUTODEPS = t -- cgit v1.2.3-54-g00ecf From a2718bfbd5dee3b5a69fcdb4361748ef84cbd06c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 1 Mar 2016 19:15:29 -0500 Subject: (libretools) improve HACKING documentation --- automake.head.mk | 2 +- automake.txt | 131 +++++++++++++++++++++++++++++++------------------------ 2 files changed, 75 insertions(+), 58 deletions(-) diff --git a/automake.head.mk b/automake.head.mk index a3c90fd..ad7154c 100644 --- a/automake.head.mk +++ b/automake.head.mk @@ -39,7 +39,7 @@ endif _am_included_makefiles := $(_am_included_makefiles) $(call _am_path,$(outdir)/Makefile) -## Empty variables for use by the module +## Empty variables for use by each Makefile $(_am)subdirs = $(_am)depdirs = diff --git a/automake.txt b/automake.txt index 307b321..22a0b84 100644 --- a/automake.txt +++ b/automake.txt @@ -7,14 +7,13 @@ automake.{head,tail}.mk Makefiles and how to use them, kinda. I wrote a "clone" of automake. I say clone, because it works differently. Yeah, I need a new name for it. -Anyway, how to use it: +High-level overview +------------------- In each source directory, you write a `Makefile`, very similarly to if you were writing for plain GNU Make, with -_am_phony = build install uninstall mostlyclean clean distclean maintainer-clean check - - + # adjust the number of `../` segments as appropriate include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk include $(topsrcdir)/automake.head.mk @@ -22,63 +21,81 @@ _am_phony = build install uninstall mostlyclean clean distclean maintainer-clean include $(topsrcdir)/automake.tail.mk -Write your own `common.each.mk` that gets included after the body of -your Makefile for each Makefile. - -Write your own `common.once.mk` that gets included once after -everything else has been parsed. - -There are several commands that generate files; simply record what -they the list of files in their output to the following variables: - -| Variable | Command | Description | Relative to | -|-----------+--------------+-----------------------------------+-------------| -| src_files | emacs | Files that the developer writes | srcdir | -| gen_files | ??? | Files the developer compiles | srcdir | -| cfg_files | ./configure | Users' compile-time configuration | outdir | -| out_files | make all | Files the user compiles | outdir | -| sys_files | make install | Files the user installs | DESTDIR | - -In addition, there are - - subdirs : A list of other directories containing Makefiles that - contain or generate files that are dependencies of - targets in this directory. They are not necesarily - actually subdirectories of this directory in the - filesystem. - - clean_files : A list of things to `rm` in addition to - `$(out_files)` when you run `make clean`. (Example: - `*.o`). - - slow_files : A list of things in `$(out_files)` that (as an - exception) should _not_ be deleted when you run `make - mostlyclean`. - -Each directory containing a Makefile is a "module". The module name -is one of 4 things (with / replaced with _ in all cases): - - `all` - - $(realpath --relative-to=. $dir_name) - - dep-top - - dep-$(realpath --relative-to=$(topoutdir) $dir_name) - -The dep-* options are only used if that directory is not a child of -the current directory. +Write your own `common.{each,once}.{head,tail}.mk` files that get +included: + - `common.once.head.mk`: before parsing any of your Makefiles + - `common.each.head.mk`: before parsing each of your Makefiles + - `common.each.tail.mk`: after parsing each of your Makefiles + - `common.each.tail.mk`: after parsing all of your Makefiles Here is a table of all of the .PHONY targets that automake takes care of for you: -| this | and this | are aliases for this | which is just a case of this | -|------+------------------+----------------------+------------------------------| -| all | build | build-all | build-$(module) | -| | install | install-all | install-$(module) | -| | uninstall | uninstall-all | uninstall-$(module) | -| | mostlyclean | mostlyclean-all | mostlyclean-$(module) | -| | clean | clean-all | clean-$(module) | -| | distclean | distclean-all | distclean-$(module) | -| | maintainer-clean | maintainer-clean-all | maintainer-clean-$(module) | -| | check | check-all | check-$(module) | -| | | | dist | +| this | and this | are aliases for this | +|------+------------------+--------------------------------------------------------| +| all | build | $(outdir)/build | +| | install | $(outdir)/install | +| | uninstall | $(outdir)/uninstall | +| | mostlyclean | $(outdir)/mostlyclean | +| | clean | $(outdir)/clean | +| | distclean | $(outdir)/distclean | +| | maintainer-clean | $(outdir)/maintainer-clean | +| | check | $(outdir)/check (not implemented for you) | +| | dist | $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz (not .PHONY) | + +You are responsible for implementing the `$(outdir)/check` target in +each of your Makefiles. + +Telling automake about your program +----------------------------------- + +You tell automake what to do for you by setting some variables. They +are all prefixed with `am_`; this prefix may be changed by editing the +`_am` variable at the top of `automake.head.mk`. + +There are several commands that generate files; simply record the list +of files that each command generates as the following variable +variables: + +| Variable | Create Command | Delete Command | Description | Relative to | +|--------------+----------------+-----------------------------+-----------------------------------+-------------| +| am_src_files | emacs | rm -rf . | Files that the developer writes | srcdir | +| am_gen_files | ??? | make maintainer-clean | Files the developer compiles | srcdir | +| am_cfg_files | ./configure | make distclean | Users' compile-time configuration | outdir | +| am_out_files | make all | make mostlyclean/make clean | Files the user compiles | outdir | +| am_sys_files | make install | make uninstall | Files the user installs | DESTDIR | + +In addition, there are two more variables that control not how files +are created, but how they are deleted: + +| Variable | Affected command | Description | Relative to | +|----------------+------------------+------------------------------------------------+-------------| +| am_clean_files | make clean | A list of things to `rm` in addition to the | outdir | +| | | files in `$(am_out_files)`. (Example: `*.o`) | | +|----------------+------------------+------------------------------------------------+-------------| +| am_slow_files | make mostlyclean | A list of things that (as an exception) should | outdir | +| | | _not_ be deleted. (otherwise, `mostlyclean` | | +| | | is the same as `clean`) | | + +Finally, there are two variables that express the relationships +between directories: + +| Variable | Description | +|------------+---------------------------------------------------------| +| am_subdirs | A list of other directories (containing Makefiles) that | +| | may be considered "children" of this | +| | directory/Makefile; building a phony target in this | +| | directory should also build it in the subdirectory. | +| | They are not necesarily actually subdirectories of this | +| | directory in the filesystem. | +|------------+---------------------------------------------------------| +| am_depdirs | A list of other directories (containing Makefiles) that | +| | contain or generate files that are dependencies of | +| | targets in this directory. They are not necesarily | +| | actually subdirectories of this directory in the | +| | filesystem. Except for files that are dependencies of | +| | files in this directory, things in the dependency | +| | directory will not be built. | ---- Copyright (C) 2016 Luke Shumaker -- cgit v1.2.3-54-g00ecf From 592eded56c45cdecb9ec9b6fc269d6c3e60f4c4c Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 3 Mar 2016 00:36:34 -0500 Subject: (rvs) buildsystem --- automake.tail.mk | 11 +++++------ config.mk.in | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 config.mk.in diff --git a/automake.tail.mk b/automake.tail.mk index 5d6ad00..a24820b 100644 --- a/automake.tail.mk +++ b/automake.tail.mk @@ -19,8 +19,7 @@ include $(topsrcdir)/common.each.tail.mk # Aggregate variables # Add some more defaults to the *_files variables -$(_am)clean_files += $($(_am)gen_files) $($(_am)out_files) -$(_am)cfg_files += Makefile +$(_am)clean_files += $($(_am)gen_files) $($(_am)cfg_files) $($(_am)out_files) # Now namespace the *_files variables define _am_save_variables @@ -103,10 +102,10 @@ $(outdir)/build : $(_am_out_files/%(outdir)) $(outdir)/install: $(_am_sys_files/%(outdir)) # Destructive phony targets _am_uninstall/%(outdir) = $(_am_sys_files/%(outdir)) -_am_mostlyclean/%(outdir) = $(filter-out $(_am_slow_files/%(outdir)) $(_am_cfg_files/%(outdir)) $(_am_gen_files/%(outdir)),$(_am_clean_files/%(outdir))) -_am_clean/%(outdir) = $(filter-out $(_am_cfg_files/%(outdir)) $(_am_gen_files/%(outdir)),$(_am_clean_files/%(outdir))) -_am_distclean/%(outdir) = $(filter-out $(_am_gen_files/%(outdir)),$(_am_clean_files/%(outdir))) -_am_maintainer-clean/%(outdir) = $(_am_clean_files/%(outdir)) +_am_mostlyclean/%(outdir) = $(filter-out $(_am_slow_files/%(outdir)) $(_am_cfg_files/%(outdir)) $(_am_gen_files/%(outdir)) $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir))) +_am_clean/%(outdir) = $(filter-out $(_am_cfg_files/%(outdir)) $(_am_gen_files/%(outdir)) $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir))) +_am_distclean/%(outdir) = $(filter-out $(_am_gen_files/%(outdir)) $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir))) +_am_maintainer-clean/%(outdir) = $(filter-out $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir))) endef $(foreach outdir,$(_am_outdirs),$(eval $(subst %(outdir),$(outdir),$(value _am_directory_rules)))) diff --git a/config.mk.in b/config.mk.in new file mode 100644 index 0000000..ca8fa7f --- /dev/null +++ b/config.mk.in @@ -0,0 +1,47 @@ +ifeq ($(topsrcdir),) +topsrcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) + +PACKAGE = rvs +VERSION = 0.10 +pkgtextdomain = $(PACKAGE) + +DESTDIR = +prefix = /usr/local +exec_prefix = $(prefix) + +bindir = $(exec_prefix)/bin +sbindir = $(exec_prefix)/sbin +libexecdir = $(exec_prefix)/libexec +datarootdir = $(prefix)/share +datadir = $(datarootdir) +sysconfdir = $(prefix)/etc +sharedstatedir = $(prefix)/com +localstatedir = $(prefix)/var +runstatedir = $(localstatedir)/run +localedir = $(datarootdir)/locale + +pkgdatadir = $(datadir)/$(PACKAGE) +pkglibexecdir = $(libexecdir)/$(PACKAGE) + +CFLAGS = -std=c99 -Werror -Wall -Wextra -pedantic -O2 +CPPFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE + +CC = cc +M4 = m4 +MKDIR = mkdir +MKDIRS = mkdir -p +RMDIRS = rmdir -p +INSTALL_DATA = install -m644 +INSTALL_PROGRAM = install -m755 +CP = cp +MV = mv +RM = rm -f +SED = sed +SORT = sort +TAR = tar +TRUE = true +PRINTF = printf + +AUTODEPS = t + +endif -- cgit v1.2.3-54-g00ecf From 8b4ed19938c1314ea15eb0b507dcc5aadeb3d9e6 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 3 Mar 2016 17:55:39 -0500 Subject: make a public `am_path`, more docs --- automake.head.mk | 3 +- automake.txt | 96 +++++++++++++++++++++++++++++++++++++++++++++----------- config.mk.in | 47 --------------------------- 3 files changed, 80 insertions(+), 66 deletions(-) delete mode 100644 config.mk.in diff --git a/automake.head.mk b/automake.head.mk index ad7154c..c79da83 100644 --- a/automake.head.mk +++ b/automake.head.mk @@ -17,13 +17,14 @@ _am = am_ _am_noslash = $(patsubst %/.,%,$(patsubst %/,%,$1)) # These are all $(call _am_func,parent,child) -#_am_relto = $(if $2,$(shell realpath -s --relative-to='$1' $2)) +#_am_relto = $(if $2,$(shell realpath -sm --relative-to='$1' $2)) _am_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/.) _am_relto_helper = $(if $(call _am_is_subdir,$1,$2),$(patsubst $1/%,%,$(addsuffix /.,$2)),$(addprefix ../,$(call _am_relto_helper,$(patsubst %/,%,$(dir $1)),$2))) _am_relto = $(call _am_noslash,$(call _am_relto_helper,$(call _am_noslash,$(abspath $1)),$(call _am_noslash,$(abspath $2)))) # Note that _am_is_subdir says that a directory is a subdirectory of # itself. _am_path = $(call _am_relto,.,$1) +am_path = $(foreach p,$1,$(call _am_relto,$p)) ## Declare the default target all: build diff --git a/automake.txt b/automake.txt index 22a0b84..b6b9184 100644 --- a/automake.txt +++ b/automake.txt @@ -10,6 +10,34 @@ differently. Yeah, I need a new name for it. High-level overview ------------------- +Now, what this does for you is: + +It makes it _easy_ to write non-recursive Makefiles--and ones that are +similar to plain recursive Makefiles, at that! (search for the paper +"Recursive Make Considered Harmful") As harmful as recursive make is, +it's historically been difficult to to write non-recursive Makefiles. +This makes it easy. + +It also makes it easy to follow the GNU standards for your makefiles: +it takes care of this entire table of .PHONY targets for you: + +| this | and this | are aliases for this | +|------+------------------+--------------------------------------------------------| +| all | build | $(outdir)/build | +| | install | $(outdir)/install | +| | uninstall | $(outdir)/uninstall | +| | mostlyclean | $(outdir)/mostlyclean | +| | clean | $(outdir)/clean | +| | distclean | $(outdir)/distclean | +| | maintainer-clean | $(outdir)/maintainer-clean | +| | check | $(outdir)/check (not implemented for you) | +| | dist | $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz (not .PHONY) | + +(You are still responsible for implementing the `$(outdir)/check` +target in each of your Makefiles.) + +What you have to do is: + In each source directory, you write a `Makefile`, very similarly to if you were writing for plain GNU Make, with @@ -21,30 +49,40 @@ you were writing for plain GNU Make, with include $(topsrcdir)/automake.tail.mk -Write your own `common.{each,once}.{head,tail}.mk` files that get -included: +And in the top-level output directory, you write a `config.mk` with: + + ifeq ($(topsrcdir),) + # have your ./configure script adjust topsrcdir if doing an + # out-of-tree build + topsrcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) + + # your configuration + + endif + +And in the top-level source directory, Write your own helper makefiles +that get included: - `common.once.head.mk`: before parsing any of your Makefiles - `common.each.head.mk`: before parsing each of your Makefiles - `common.each.tail.mk`: after parsing each of your Makefiles - `common.each.tail.mk`: after parsing all of your Makefiles -Here is a table of all of the .PHONY targets that automake takes care -of for you: +The `common.*.mk` makefiles are nice for including generic pattern +rules and variables that aren't specific to a directory. -| this | and this | are aliases for this | -|------+------------------+--------------------------------------------------------| -| all | build | $(outdir)/build | -| | install | $(outdir)/install | -| | uninstall | $(outdir)/uninstall | -| | mostlyclean | $(outdir)/mostlyclean | -| | clean | $(outdir)/clean | -| | distclean | $(outdir)/distclean | -| | maintainer-clean | $(outdir)/maintainer-clean | -| | check | $(outdir)/check (not implemented for you) | -| | dist | $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz (not .PHONY) | +You're probably thinking that this sounds too good to be true! +Unfortunately, there are two major deviations from writing a plain +recursive Makefile: -You are responsible for implementing the `$(outdir)/check` target in -each of your Makefiles. + 1. all targets and prerequisites (including .PHONY targets!) need to + be prefixed with + `$(srcdir)`/`$(outdir)`/`$(topsrcdir)`/`$(topoutdir)`. + * sub-gotcha: this means that if a pattern rule has a + prerequisite that may be in srcdir or outdir, then it must be + specified twice, once for each case. + 2. if a prerequisite is in a directory "owned" by another Makefile, + you must filter the pathname through `am_path`: + `$(call am_path,YOUR_PATH)`. Telling automake about your program ----------------------------------- @@ -53,6 +91,11 @@ You tell automake what to do for you by setting some variables. They are all prefixed with `am_`; this prefix may be changed by editing the `_am` variable at the top of `automake.head.mk`. +The exception to this is the `am_path` variable, which is a macro that +is used to make a list of filenames relative to the appropriate +directory, because unlike normal GNU (Auto)Make, $(outdir) isn't +nescessarily equal to '.'. See above. + There are several commands that generate files; simply record the list of files that each command generates as the following variable variables: @@ -97,9 +140,26 @@ between directories: | | files in this directory, things in the dependency | | | directory will not be built. | +Tips, notes +----------- + +If you have a `./configure` script, don't have it modify the +`Makefile`s; have everything you need modified be in +`$(topoutdir)/config.mk` and have it generate that; then have it copy +(or (sym?)link?) every `$(srcdir)/Makefile` into `$(outdir)/Makefile`. + +If you're wondering, `am_path` is defined equivalently to: + + am_path = $(if $1,$(shell realpath -sm -- $1))` + +though it is implemented purely in Make, instead of calling out to +another program. Besides that older versions of coreutils don't have +`realpath`, calling to an external program like that can have a +_substantial_ slowdown on the parse time. + ---- Copyright (C) 2016 Luke Shumaker This documentation file is placed into the public domain. If that is not possible in your legal system, I grant you permission to use it in -absolutely every way that I can legally do so. +absolutely every way that I can legally grant to you. diff --git a/config.mk.in b/config.mk.in deleted file mode 100644 index ca8fa7f..0000000 --- a/config.mk.in +++ /dev/null @@ -1,47 +0,0 @@ -ifeq ($(topsrcdir),) -topsrcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) - -PACKAGE = rvs -VERSION = 0.10 -pkgtextdomain = $(PACKAGE) - -DESTDIR = -prefix = /usr/local -exec_prefix = $(prefix) - -bindir = $(exec_prefix)/bin -sbindir = $(exec_prefix)/sbin -libexecdir = $(exec_prefix)/libexec -datarootdir = $(prefix)/share -datadir = $(datarootdir) -sysconfdir = $(prefix)/etc -sharedstatedir = $(prefix)/com -localstatedir = $(prefix)/var -runstatedir = $(localstatedir)/run -localedir = $(datarootdir)/locale - -pkgdatadir = $(datadir)/$(PACKAGE) -pkglibexecdir = $(libexecdir)/$(PACKAGE) - -CFLAGS = -std=c99 -Werror -Wall -Wextra -pedantic -O2 -CPPFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE - -CC = cc -M4 = m4 -MKDIR = mkdir -MKDIRS = mkdir -p -RMDIRS = rmdir -p -INSTALL_DATA = install -m644 -INSTALL_PROGRAM = install -m755 -CP = cp -MV = mv -RM = rm -f -SED = sed -SORT = sort -TAR = tar -TRUE = true -PRINTF = printf - -AUTODEPS = t - -endif -- cgit v1.2.3-54-g00ecf From 45d77264cab813a4465116a3ac33a0a44a1389e7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 3 Mar 2016 18:51:55 -0500 Subject: I lied about am_path being equivalent to `realpath -sm` --- automake.txt | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/automake.txt b/automake.txt index b6b9184..c9834d3 100644 --- a/automake.txt +++ b/automake.txt @@ -82,7 +82,9 @@ recursive Makefile: specified twice, once for each case. 2. if a prerequisite is in a directory "owned" by another Makefile, you must filter the pathname through `am_path`: - `$(call am_path,YOUR_PATH)`. + `$(call am_path,YOUR_PATH)`. Further, that path must NOT contain + a `..` segment; if you need to refer to a sibling directory, do it + relative to `$(topoutdir)` or `$(topsrcdir)`. Telling automake about your program ----------------------------------- @@ -93,8 +95,8 @@ are all prefixed with `am_`; this prefix may be changed by editing the The exception to this is the `am_path` variable, which is a macro that is used to make a list of filenames relative to the appropriate -directory, because unlike normal GNU (Auto)Make, $(outdir) isn't -nescessarily equal to '.'. See above. +directory, because unlike normal GNU (Auto)Make, `$(outdir)` isn't +nescessarily equal to `.`. See above. There are several commands that generate files; simply record the list of files that each command generates as the following variable @@ -148,15 +150,6 @@ If you have a `./configure` script, don't have it modify the `$(topoutdir)/config.mk` and have it generate that; then have it copy (or (sym?)link?) every `$(srcdir)/Makefile` into `$(outdir)/Makefile`. -If you're wondering, `am_path` is defined equivalently to: - - am_path = $(if $1,$(shell realpath -sm -- $1))` - -though it is implemented purely in Make, instead of calling out to -another program. Besides that older versions of coreutils don't have -`realpath`, calling to an external program like that can have a -_substantial_ slowdown on the parse time. - ---- Copyright (C) 2016 Luke Shumaker -- cgit v1.2.3-54-g00ecf From 37ef1295bf8885876df8de989569a2233f97583f Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 4 Mar 2016 13:20:55 -0500 Subject: Have the caller be responsible for setting topoutdir --- automake.head.mk | 11 ++++------- automake.txt | 40 +++++++++++++++++++++++----------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/automake.head.mk b/automake.head.mk index c79da83..37d3b07 100644 --- a/automake.head.mk +++ b/automake.head.mk @@ -30,13 +30,10 @@ am_path = $(foreach p,$1,$(call _am_relto,$p)) all: build .PHONY: all -## Set topoutdir, outdir, and srcdir (assumes that topsrcdir is -## already set, and that $(topoutdir)/config.mk has been included) -ifeq ($(topoutdir),) -topoutdir := $(call _am_path,$(dir $(lastword $(filter %/config.mk config.mk,$(MAKEFILE_LIST))))) -endif - outdir := $(call _am_path,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) - srcdir := $(call _am_path,$(topsrcdir)/$(call _am_relto,$(topoutdir),$(outdir))) +## Set outdir and srcdir (assumes that topoutdir and topsrcdir are +## already set) +outdir := $(call _am_path,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) +srcdir := $(call _am_path,$(topsrcdir)/$(call _am_relto,$(topoutdir),$(outdir))) _am_included_makefiles := $(_am_included_makefiles) $(call _am_path,$(outdir)/Makefile) diff --git a/automake.txt b/automake.txt index c9834d3..935af5f 100644 --- a/automake.txt +++ b/automake.txt @@ -41,25 +41,14 @@ What you have to do is: In each source directory, you write a `Makefile`, very similarly to if you were writing for plain GNU Make, with - # adjust the number of `../` segments as appropriate - include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk + topoutdir ?= ... + topsrcdir ?= ... include $(topsrcdir)/automake.head.mk # your makefile include $(topsrcdir)/automake.tail.mk -And in the top-level output directory, you write a `config.mk` with: - - ifeq ($(topsrcdir),) - # have your ./configure script adjust topsrcdir if doing an - # out-of-tree build - topsrcdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) - - # your configuration - - endif - And in the top-level source directory, Write your own helper makefiles that get included: - `common.once.head.mk`: before parsing any of your Makefiles @@ -145,10 +134,27 @@ between directories: Tips, notes ----------- -If you have a `./configure` script, don't have it modify the -`Makefile`s; have everything you need modified be in -`$(topoutdir)/config.mk` and have it generate that; then have it copy -(or (sym?)link?) every `$(srcdir)/Makefile` into `$(outdir)/Makefile`. +I like to have the first (non-comment) line in a Makefile be: + + include $(dir $(lastword $(MAKEFILE_LIST)))/../../config.mk + +(adjusting the number of `../` sequences as nescessary). Then, my +(user-editable) `config.mk` is of the form: + + ifeq ($(topsrcdir),) + topoutdir := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) + topsrcdir := $(topoutdir) + + # your configuration + + endif + +If the package has a `./configure` script, then I have it modifiy +topsrcdir as necessary, as well as modifying whatever other parts of +the configuration. All of the configuration lives in `config.mk`; +`./configure` doesn't modify any `Makefile`s, it just generates +`config.mk`, and copies (or (sym?)link?) every `$(srcdir)/Makefile` to +`$(outdir)/Makefile`. ---- Copyright (C) 2016 Luke Shumaker -- cgit v1.2.3-54-g00ecf From 7da2f4c04a4ef39d1eee541b71cbc4f9c10dfa3b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 27 May 2016 19:10:45 -0400 Subject: fix mistake in am_path --- automake.head.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automake.head.mk b/automake.head.mk index 37d3b07..431f14d 100644 --- a/automake.head.mk +++ b/automake.head.mk @@ -24,7 +24,7 @@ _am_relto = $(call _am_noslash,$(call _am_relto_helper,$(call _am_noslash,$(absp # Note that _am_is_subdir says that a directory is a subdirectory of # itself. _am_path = $(call _am_relto,.,$1) -am_path = $(foreach p,$1,$(call _am_relto,$p)) +am_path = $(foreach p,$1,$(call _am_relto,.,$p)) ## Declare the default target all: build -- cgit v1.2.3-54-g00ecf From 42f72fea1078ddb379dd4e6df80a98e1072ba726 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 27 May 2016 21:09:58 -0400 Subject: move everything into build-aux --- automake.head.mk | 56 --------------- automake.tail.mk | 139 ----------------------------------- automake.txt | 164 ------------------------------------------ build-aux/Makefile.README.txt | 164 ++++++++++++++++++++++++++++++++++++++++++ build-aux/Makefile.head.mk | 49 +++++++++++++ build-aux/Makefile.tail.mk | 52 ++++++++++++++ 6 files changed, 265 insertions(+), 359 deletions(-) delete mode 100644 automake.head.mk delete mode 100644 automake.tail.mk delete mode 100644 automake.txt create mode 100644 build-aux/Makefile.README.txt create mode 100644 build-aux/Makefile.head.mk create mode 100644 build-aux/Makefile.tail.mk diff --git a/automake.head.mk b/automake.head.mk deleted file mode 100644 index 431f14d..0000000 --- a/automake.head.mk +++ /dev/null @@ -1,56 +0,0 @@ -# Copyright (C) 2015-2016 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 -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -_am = am_ - -_am_noslash = $(patsubst %/.,%,$(patsubst %/,%,$1)) -# These are all $(call _am_func,parent,child) -#_am_relto = $(if $2,$(shell realpath -sm --relative-to='$1' $2)) -_am_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/.) -_am_relto_helper = $(if $(call _am_is_subdir,$1,$2),$(patsubst $1/%,%,$(addsuffix /.,$2)),$(addprefix ../,$(call _am_relto_helper,$(patsubst %/,%,$(dir $1)),$2))) -_am_relto = $(call _am_noslash,$(call _am_relto_helper,$(call _am_noslash,$(abspath $1)),$(call _am_noslash,$(abspath $2)))) -# Note that _am_is_subdir says that a directory is a subdirectory of -# itself. -_am_path = $(call _am_relto,.,$1) -am_path = $(foreach p,$1,$(call _am_relto,.,$p)) - -## Declare the default target -all: build -.PHONY: all - -## Set outdir and srcdir (assumes that topoutdir and topsrcdir are -## already set) -outdir := $(call _am_path,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) -srcdir := $(call _am_path,$(topsrcdir)/$(call _am_relto,$(topoutdir),$(outdir))) - -_am_included_makefiles := $(_am_included_makefiles) $(call _am_path,$(outdir)/Makefile) - -## Empty variables for use by each Makefile -$(_am)subdirs = -$(_am)depdirs = - -$(_am)src_files = -$(_am)gen_files = -$(_am)cfg_files = -$(_am)out_files = -$(_am)sys_files = - -$(_am)clean_files = -$(_am)slow_files = - -ifeq ($(_am_NO_ONCE),) -include $(topsrcdir)/common.once.head.mk -endif -include $(topsrcdir)/common.each.head.mk diff --git a/automake.tail.mk b/automake.tail.mk deleted file mode 100644 index a24820b..0000000 --- a/automake.tail.mk +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright (C) 2015-2016 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 -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -include $(topsrcdir)/common.each.tail.mk - - -# Aggregate variables - -# Add some more defaults to the *_files variables -$(_am)clean_files += $($(_am)gen_files) $($(_am)cfg_files) $($(_am)out_files) - -# Now namespace the *_files variables -define _am_save_variables -_am_src_files/$(outdir) = $(addprefix $(srcdir)/,$($(_am)src_files)) -_am_gen_files/$(outdir) = $(addprefix $(srcdir)/,$($(_am)gen_files)) -_am_cfg_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)cfg_files)) -_am_out_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)out_files)) -_am_sys_files/$(outdir) = $(addprefix $(DESTDIR),$($(_am)sys_files)) -_am_clean_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)clean_files)) -_am_slow_files/$(outdir) = $(addprefix $(outdir)/,$($(_am)slow_files)) -_am_subdirs/$(outdir) = $($(_am)subdirs) -endef -$(eval $(_am_save_variables)) - -# And add them to the $(parent)_*_files variables (if applicable) -define _am_add_subdir -_am_src_files/%(outdir) += $(_am_src_files/%(subdir)) -_am_gen_files/%(outdir) += $(_am_gen_files/%(subdir)) -_am_cfg_files/%(outdir) += $(_am_cfg_files/%(subdir)) -_am_out_files/%(outdir) += $(_am_out_files/%(subdir)) -_am_sys_files/%(outdir) += $(_am_sys_files/%(subdir)) -_am_clean_files/%(outdir) += $(_am_clean_files/%(subdir)) -_am_slow_files/%(outdir) += $(_am_slow_files/%(subdir)) -endef -$(foreach subdir,$(call _am_path,$(addprefix $(outdir)/,$($(_am)subdirs))),$(eval $(subst %(outdir),$(outdir),$(subst %(subdir),$(subdir),$(value _am_add_subdir))))) - -_am_outdirs := $(_am_outdirs) $(outdir) - - -# Do some per-directory magic - -_am_phony = build install uninstall mostlyclean clean distclean maintainer-clean check - -.PHONY: $(addprefix $(outdir)/,$(_am_phony)) - -$(addprefix $(outdir)/,uninstall mostlyclean clean distclean maintainer-clean):: - $(RM) -- $(sort $(_am_$(@F)/$(@D))) - $(RMDIRS) $(sort $(dir $(_am_$(@F)/$(@D)))) 2>/dev/null || $(TRUE) - -# 'build' and 'install' must be defined later, because the -# am_*_files/* variables might not be complete yet. - - -# Include Makefiles from other directories - -define _am_nl - - -endef - -$(foreach _am_NO_ONCE,y,\ - $(foreach makefile,$(foreach dir,$($(_am)subdirs) $($(_am)depdirs),$(call _am_path,$(outdir)/$(dir)/Makefile)),\ - $(eval include $(filter-out $(_am_included_makefiles),$(makefile))))) - - -# This only gets evaluated once, after all of the other Makefiles are read -ifeq ($(_am_NO_ONCE),) -# Empty directory-level variables -outdir = /bogus -srcdir = /bogus - -$(_am)subdirs = -$(_am)depdirs = - -$(_am)src_files = -$(_am)gen_files = -$(_am)cfg_files = -$(_am)out_files = -$(_am)sys_files = -$(_am)clean_files = -$(_am)slow_files = - -_am_clean_files/$(topoutdir) += $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz -$(addprefix $(topoutdir)/,mostlyclean clean distclean maintainer-clean) :: - $(RM) -r -- $(topoutdir)/$(PACKAGE)-$(VERSION) - -define _am_directory_rules -# Constructive phony targets -$(outdir)/build : $(_am_out_files/%(outdir)) -$(outdir)/install: $(_am_sys_files/%(outdir)) -# Destructive phony targets -_am_uninstall/%(outdir) = $(_am_sys_files/%(outdir)) -_am_mostlyclean/%(outdir) = $(filter-out $(_am_slow_files/%(outdir)) $(_am_cfg_files/%(outdir)) $(_am_gen_files/%(outdir)) $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir))) -_am_clean/%(outdir) = $(filter-out $(_am_cfg_files/%(outdir)) $(_am_gen_files/%(outdir)) $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir))) -_am_distclean/%(outdir) = $(filter-out $(_am_gen_files/%(outdir)) $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir))) -_am_maintainer-clean/%(outdir) = $(filter-out $(_am_src_files/%(outdir)),$(_am_clean_files/%(outdir))) -endef -$(foreach outdir,$(_am_outdirs),$(eval $(subst %(outdir),$(outdir),$(value _am_directory_rules)))) - -# Add the `dist` target -.PHONY: dist -dist: $(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz -$(topoutdir)/$(PACKAGE)-$(VERSION).tar.gz: $(topoutdir)/$(PACKAGE)-$(VERSION) - $(TAR) czf $@ -C $(. + +# This bit only gets evaluated once, at the very beginning +ifeq ($(_am_NO_ONCE),) + +_am = am_ + +_am_noslash = $(patsubst %/.,%,$(patsubst %/,%,$1)) +# These are all $(call _am_func,parent,child) +#_am_relto = $(if $2,$(shell realpath -sm --relative-to='$1' $2)) +_am_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/.) +_am_relto_helper = $(if $(call _am_is_subdir,$1,$2),$(patsubst $1/%,%,$(addsuffix /.,$2)),$(addprefix ../,$(call _am_relto_helper,$(patsubst %/,%,$(dir $1)),$2))) +_am_relto = $(call _am_noslash,$(call _am_relto_helper,$(call _am_noslash,$(abspath $1)),$(call _am_noslash,$(abspath $2)))) +# Note that _am_is_subdir says that a directory is a subdirectory of +# itself. +am_path = $(foreach p,$1,$(call _am_relto,.,$p)) + +$(_am)dirlocal += $(_am)subdirs +$(_am)dirlocal += $(_am)depdirs + +include $(topsrcdir)/common.once.head.mk + +endif # _am_NO_ONCE + +# This bit gets evaluated for each Makefile + +## Set outdir and srcdir (assumes that topoutdir and topsrcdir are +## already set) +outdir := $(call am_path,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) +srcdir := $(call am_path,$(topsrcdir)/$(call _am_relto,$(topoutdir),$(outdir))) + +_am_included_makefiles := $(_am_included_makefiles) $(call am_path,$(outdir)/Makefile) + +$(foreach v,$($(_am)dirlocal),$(eval $v=)) + +include $(topsrcdir)/common.each.head.mk diff --git a/build-aux/Makefile.tail.mk b/build-aux/Makefile.tail.mk new file mode 100644 index 0000000..472d2db --- /dev/null +++ b/build-aux/Makefile.tail.mk @@ -0,0 +1,52 @@ +# Copyright (C) 2015-2016 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +# This bit gets evaluated for each Makefile processed + +include $(wildcard $(topsrcdir)/build-aux/Makefile.each.tail/*.mk) + +# Make the namespaced versions of all of the dirlocal variables +$(foreach v,$($(_am)dirlocal),$(eval $v/$(outdir) = $($v))) + +# Remember that this is a directory that we've visited +_am_outdirs := $(_am_outdirs) $(outdir) + +# Generic phony target declarations: +# mark them phony +.PHONY: $(addprefix $(outdir)/,$($(_am)phony)) +# have them depend on subdirs +$(foreach t,$($(_am)phony),$(eval $(outdir)/$t: $(addsuffix /$t,$(subdirs)))) + +# Include Makefiles from other directories + +define _am_nl + + +endef +$(foreach _am_NO_ONCE,y,\ + $(foreach makefile,$(call am_path,$(addsuffix /Makefile,$($(_am)subdirs) $($(_am)depdirs))),\ + $(eval include $(filter-out $(_am_included_makefiles),$(makefile))))) + +# This bit only gets evaluated once, after all of the other Makefiles are read +ifeq ($(_am_NO_ONCE),) + +outdir = /bogus +srcdir = /bogus + +$(foreach v,$($(_am)dirlocal),$(eval $v=)) + +include $(wildcard $(topsrcdir)/build-aux/Makefile.once.tail/*.mk) + +endif # _am_NO_ONCE -- cgit v1.2.3-54-g00ecf From feadb8948e04996a4d024896dc50c82e62ceac56 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 29 May 2016 16:05:16 -0400 Subject: work on things --- build-aux/Makefile.head.mk | 39 +++++++++++++++++++++------------------ build-aux/Makefile.tail.mk | 25 ++++++++++--------------- 2 files changed, 31 insertions(+), 33 deletions(-) diff --git a/build-aux/Makefile.head.mk b/build-aux/Makefile.head.mk index e4ae329..e5ef379 100644 --- a/build-aux/Makefile.head.mk +++ b/build-aux/Makefile.head.mk @@ -14,36 +14,39 @@ # along with this program. If not, see . # This bit only gets evaluated once, at the very beginning -ifeq ($(_am_NO_ONCE),) +ifeq ($(_at.NO_ONCE),) + +_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)))) +# Note that _at.is_subdir says that a directory is a subdirectory of +# itself. +at.path = $(foreach p,$1,$(call _at.relto,.,$p)) -_am = am_ +define at.nl -_am_noslash = $(patsubst %/.,%,$(patsubst %/,%,$1)) -# These are all $(call _am_func,parent,child) -#_am_relto = $(if $2,$(shell realpath -sm --relative-to='$1' $2)) -_am_is_subdir = $(filter $(abspath $1)/%,$(abspath $2)/.) -_am_relto_helper = $(if $(call _am_is_subdir,$1,$2),$(patsubst $1/%,%,$(addsuffix /.,$2)),$(addprefix ../,$(call _am_relto_helper,$(patsubst %/,%,$(dir $1)),$2))) -_am_relto = $(call _am_noslash,$(call _am_relto_helper,$(call _am_noslash,$(abspath $1)),$(call _am_noslash,$(abspath $2)))) -# Note that _am_is_subdir says that a directory is a subdirectory of -# itself. -am_path = $(foreach p,$1,$(call _am_relto,.,$p)) -$(_am)dirlocal += $(_am)subdirs -$(_am)dirlocal += $(_am)depdirs +endef + +at.dirlocal += at.subdirs +at.dirlocal += at.depdirs include $(topsrcdir)/common.once.head.mk -endif # _am_NO_ONCE +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 am_path,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) -srcdir := $(call am_path,$(topsrcdir)/$(call _am_relto,$(topoutdir),$(outdir))) +outdir := $(call at.path,$(dir $(lastword $(filter-out %.mk,$(MAKEFILE_LIST))))) +srcdir := $(call at.path,$(topsrcdir)/$(call _at.relto,$(topoutdir),$(outdir))) -_am_included_makefiles := $(_am_included_makefiles) $(call am_path,$(outdir)/Makefile) +_at.included_makefiles := $(_at.included_makefiles) $(call at.path,$(outdir)/Makefile) -$(foreach v,$($(_am)dirlocal),$(eval $v=)) +$(foreach v,$(at.dirlocal),$(eval $v=)) include $(topsrcdir)/common.each.head.mk diff --git a/build-aux/Makefile.tail.mk b/build-aux/Makefile.tail.mk index 472d2db..bb197dc 100644 --- a/build-aux/Makefile.tail.mk +++ b/build-aux/Makefile.tail.mk @@ -18,35 +18,30 @@ include $(wildcard $(topsrcdir)/build-aux/Makefile.each.tail/*.mk) # Make the namespaced versions of all of the dirlocal variables -$(foreach v,$($(_am)dirlocal),$(eval $v/$(outdir) = $($v))) +$(foreach v,$(at.dirlocal),$(eval $v/$(outdir) = $($v))) # Remember that this is a directory that we've visited -_am_outdirs := $(_am_outdirs) $(outdir) +_at.outdirs := $(_at.outdirs) $(outdir) # Generic phony target declarations: # mark them phony -.PHONY: $(addprefix $(outdir)/,$($(_am)phony)) +.PHONY: $(addprefix $(outdir)/,$(at.phony)) # have them depend on subdirs -$(foreach t,$($(_am)phony),$(eval $(outdir)/$t: $(addsuffix /$t,$(subdirs)))) +$(foreach t,$(at.phony),$(eval $(outdir)/$t: $(addsuffix /$t,$(subdirs)))) # Include Makefiles from other directories - -define _am_nl - - -endef -$(foreach _am_NO_ONCE,y,\ - $(foreach makefile,$(call am_path,$(addsuffix /Makefile,$($(_am)subdirs) $($(_am)depdirs))),\ - $(eval include $(filter-out $(_am_included_makefiles),$(makefile))))) +$(foreach _at.NO_ONCE,y,\ + $(foreach makefile,$(call am_path,$(addsuffix /Makefile,$(at.subdirs) $(at.depdirs))),\ + $(eval include $(filter-out $(_at.included_makefiles),$(makefile))))) # This bit only gets evaluated once, after all of the other Makefiles are read -ifeq ($(_am_NO_ONCE),) +ifeq ($(_at.NO_ONCE),) outdir = /bogus srcdir = /bogus -$(foreach v,$($(_am)dirlocal),$(eval $v=)) +$(foreach v,$(at.dirlocal),$(eval $v=)) include $(wildcard $(topsrcdir)/build-aux/Makefile.once.tail/*.mk) -endif # _am_NO_ONCE +endif # _at.NO_ONCE -- cgit v1.2.3-54-g00ecf From 8441649be887b54222d52fb9e69247c9012acff2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 29 May 2016 16:09:27 -0400 Subject: Remove everything but the core --- build-aux/Makefile.each.head/.gitignore | 0 build-aux/Makefile.each.tail/.gitignore | 0 build-aux/Makefile.once.head/.gitignore | 0 build-aux/Makefile.once.tail/.gitignore | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 build-aux/Makefile.each.head/.gitignore create mode 100644 build-aux/Makefile.each.tail/.gitignore create mode 100644 build-aux/Makefile.once.head/.gitignore create mode 100644 build-aux/Makefile.once.tail/.gitignore diff --git a/build-aux/Makefile.each.head/.gitignore b/build-aux/Makefile.each.head/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/build-aux/Makefile.each.tail/.gitignore b/build-aux/Makefile.each.tail/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/build-aux/Makefile.once.head/.gitignore b/build-aux/Makefile.once.head/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/build-aux/Makefile.once.tail/.gitignore b/build-aux/Makefile.once.tail/.gitignore new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3-54-g00ecf From 0b3959406003cb61c9d10e2f1d45c755ec700392 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 29 May 2016 18:39:41 -0400 Subject: add checks that top{src,out}dir are set --- build-aux/Makefile.head.mk | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build-aux/Makefile.head.mk b/build-aux/Makefile.head.mk index e5ef379..c680f41 100644 --- a/build-aux/Makefile.head.mk +++ b/build-aux/Makefile.head.mk @@ -16,6 +16,13 @@ # This bit only gets evaluated once, at the very beginning ifeq ($(_at.NO_ONCE),) +ifeq ($(topsrcdir),) +$(error topsrcdir must be set before including Makefile.head.mk) +endif +ifeq ($(topoutdir),) +$(error topoutdir must be set before including Makefile.head.mk) +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)) -- cgit v1.2.3-54-g00ecf From b910b85b2d7d732ccfeaf69ab7ec79140a4a7802 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 30 May 2016 23:58:38 -0400 Subject: 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 --- build-aux/Makefile.head.mk | 12 ++++++++---- build-aux/Makefile.tail.mk | 16 ++++++++++------ 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 -- cgit v1.2.3-54-g00ecf From 395ed7ee8b871d7cd6c8e14a67a73ee03efa18f2 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 30 May 2016 23:58:57 -0400 Subject: the README is still outdated, but fix some paths in it --- build-aux/Makefile.README.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-aux/Makefile.README.txt b/build-aux/Makefile.README.txt index 935af5f..e06ba52 100644 --- a/build-aux/Makefile.README.txt +++ b/build-aux/Makefile.README.txt @@ -43,11 +43,11 @@ you were writing for plain GNU Make, with topoutdir ?= ... topsrcdir ?= ... - include $(topsrcdir)/automake.head.mk + include $(topsrcdir)/build-aux/Makefile.head.mk # your makefile - include $(topsrcdir)/automake.tail.mk + include $(topsrcdir)/build-aux/Makefile.tail.mk And in the top-level source directory, Write your own helper makefiles that get included: -- cgit v1.2.3-54-g00ecf From 00eedbd6178cd92409be08d62b395f92680858ef Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 31 May 2016 00:54:10 -0400 Subject: avoid prefixing things with ./ --- build-aux/Makefile.tail.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build-aux/Makefile.tail.mk b/build-aux/Makefile.tail.mk index f7d42b9..dfbad5a 100644 --- a/build-aux/Makefile.tail.mk +++ b/build-aux/Makefile.tail.mk @@ -17,8 +17,8 @@ include $(call _at.reverse,$(sort $(wildcard $(topsrcdir)/build-aux/Makefile.each.tail/*.mk))) -at.subdirs := $(addprefix $(outdir)/,$(at.subdirs)) -at.depdirs := $(addprefix $(outdir)/,$(at.depdirs)) +at.subdirs := $(patsubst ./%,%,$(addprefix $(outdir)/,$(at.subdirs))) +at.depdirs := $(patsubst ./%,%,$(addprefix $(outdir)/,$(at.depdirs))) # Move all of the dirlocal variables to their namespaced version $(foreach v,$(at.dirlocal),$(eval $v/$(outdir) := $$($v))) -- cgit v1.2.3-54-g00ecf