From 36f875645e36bf1ff015cc7d3441de2e1714b6fc Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 27 Mar 2018 20:25:30 -0400 Subject: Makefile: files,nested: Don't create pseudo-targets masking real files --- build-aux/Makefile.each.tail/09-nested.mk | 22 ++++++++++++++++++++++ build-aux/Makefile.each.tail/10-files.mk | 6 ++++-- build-aux/Makefile.each.tail/10-nested.mk | 21 --------------------- build-aux/Makefile.once.head/10-files.mk | 5 +++-- build-aux/Makefile.once.head/10-nested.mk | 5 +++-- 5 files changed, 32 insertions(+), 27 deletions(-) create mode 100644 build-aux/Makefile.each.tail/09-nested.mk delete mode 100644 build-aux/Makefile.each.tail/10-nested.mk diff --git a/build-aux/Makefile.each.tail/09-nested.mk b/build-aux/Makefile.each.tail/09-nested.mk new file mode 100644 index 0000000..ce36da3 --- /dev/null +++ b/build-aux/Makefile.each.tail/09-nested.mk @@ -0,0 +1,22 @@ +# Copyright (C) 2016-2018 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 . + +_nested.targets := $(notdir $(filter-out $(at.targets),$(addprefix $(outdir)/,$(nested.targets)))) +$(eval $(foreach _tmp.nested,$(_nested.targets),\ + $$(outdir)/$(_tmp.nested): $$(addsuffix /$(_tmp.nested),$$(call at.addprefix,$$(outdir),$$(nested.subdirs)))$(at.nl))) +.PHONY: $(addprefix $(outdir)/,$(_nested.targets)) + +at.subdirs += $(nested.subdirs) +at.targets += $(addprefix $(outdir)/,$(_nested.targets)) diff --git a/build-aux/Makefile.each.tail/10-files.mk b/build-aux/Makefile.each.tail/10-files.mk index 787a3bd..015a0ad 100644 --- a/build-aux/Makefile.each.tail/10-files.mk +++ b/build-aux/Makefile.each.tail/10-files.mk @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2017 Luke Shumaker +# Copyright (C) 2015-2018 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 @@ -26,12 +26,14 @@ _files.all = $(_files.src) $(_files.out) $(_files.sys) at.targets += $(subst *,%,$(_files.all)) +_files.groups := $(notdir $(filter-out $(at.targets),$(addprefix $(outdir)/,$(files.groups)))) + # Creative targets $(outdir)/$(files.generate): $(_files.src.gen) $(_files.src.cfg) $(outdir)/install: $(_files.sys.$(files.default)) $(outdir)/installdirs: $(sort $(dir $(_files.sys))) $(eval \ - $(foreach _files.g,$(files.groups),\ + $(foreach _files.g,$(_files.groups),\ $$(outdir)/$(_files.g): $$(_files.out.$(_files.g))$(at.nl))\ $(foreach _files.g,$(filter-out $(files.default),$(files.groups)),\ $$(outdir)/install-$(_files.g): $$(_files.sys.$(_files.g))$(at.nl))) diff --git a/build-aux/Makefile.each.tail/10-nested.mk b/build-aux/Makefile.each.tail/10-nested.mk deleted file mode 100644 index 667ec6f..0000000 --- a/build-aux/Makefile.each.tail/10-nested.mk +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (C) 2016-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 -# 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 . - -$(eval $(foreach _tmp.nested,$(nested.targets),\ - $$(outdir)/$(_tmp.nested): $$(addsuffix /$(_tmp.nested),$$(call at.addprefix,$$(outdir),$$(nested.subdirs)))$(at.nl))) -.PHONY: $(addprefix $(outdir)/,$(nested.targets)) - -at.subdirs += $(nested.subdirs) -at.targets += $(addprefix $(outdir)/,$(nested.targets)) diff --git a/build-aux/Makefile.once.head/10-files.mk b/build-aux/Makefile.once.head/10-files.mk index 564f9d6..9203d05 100644 --- a/build-aux/Makefile.once.head/10-files.mk +++ b/build-aux/Makefile.once.head/10-files.mk @@ -1,4 +1,4 @@ -# Copyright (C) 2015-2017 Luke Shumaker +# Copyright (C) 2015-2018 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 @@ -22,6 +22,7 @@ define mod.files.doc # - `RMDIR_P ?= rmdir -p --ignore-fail-on-non-empty` # - `TRUE ?= true` # Inputs: +# - Global variable : `at.targets` # - Global variable : `files.groups ?= all` # - Global variable : `files.default ?= all` # - Global variable : `files.vcsclean ?= files.vcsclean` @@ -44,7 +45,7 @@ define mod.files.doc # - Directory variable : `files.sys` # - Creative .PHONY targets: # - `$(outdir)/$(files.generate)` -# - `$(outdir)/$(group)` for `group` in `$(files.groups)` +# - `$(outdir)/$(group)` for `group` in `$(files.groups)`, unless $(outdir)/$(group) is already declared in $(at.targets) # - `$(outdir)/install` # - `$(outdir)/install-$(group)` for `group` in `$(filter-out $(files.default),$(files.groups))` # - `$(outdir)/installdirs` diff --git a/build-aux/Makefile.once.head/10-nested.mk b/build-aux/Makefile.once.head/10-nested.mk index d903d53..39c27e7 100644 --- a/build-aux/Makefile.once.head/10-nested.mk +++ b/build-aux/Makefile.once.head/10-nested.mk @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2017 Luke Shumaker +# Copyright (C) 2016-2018 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 @@ -16,10 +16,11 @@ mod.nested.description = Easy nested .PHONY targets define mod.nested.doc # Inputs: +# - Global variable : `at.targets` # - Global variable : `nested.targets` # - Directory variable : `nested.subdirs` # Outputs: -# - .PHONY Targets : `$(addprefix $(outdir)/,$(nested.targets))` +# - .PHONY Targets : `$(addprefix $(outdir)/,$(nested.targets))`, unless $(outdir)/$(target) is already declared in $(at.targets) # - Variable : `at.subdirs` # - Variable : `at.targets` # -- cgit v1.2.2