From c1d56885ac2606f2cf7f265260e25d22b1530365 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Thu, 10 Aug 2023 11:28:49 -0600 Subject: [PATCH] Refactor Makefile config / Defaults.mk Makefile has included a Defaults.mk file to store variable configuration from one run for implicit inclusion in future runs, but the creation of this file has been automatic and opaque, and the state of it managed by a series of PHONY targets (e.g., config, genconfig, rm_config). This commit refactors config to name its files explicitly (so they can be more properly monitored by make) and makes the generation of Defaults.mk explicit so that its behavior is more obvious. Signed-off-by: Jonathon Anderson --- Dockerfile | 3 +-- Makefile | 25 ++++++++----------- Variables.mk | 3 +++ .../development-environment-vagrant.rst | 2 +- userdocs/quickstart/el8.rst | 2 +- userdocs/quickstart/el9.rst | 2 +- userdocs/quickstart/suse15.rst | 2 +- warewulf.spec.in | 5 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index dfffc58e..616c294d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,8 +7,7 @@ RUN zypper -n install --no-recommends git go1.18 libgpgme-devel &&\ COPY . /warewulf-src RUN cd /warewulf-src &&\ - make contclean &&\ - make genconfig \ + make contclean Defaults.mk \ PREFIX=/usr \ BINDIRa=/usr/bin \ SYSCONFDIR=/etc \ diff --git a/Makefile b/Makefile index 8a71dddc..667a522f 100644 --- a/Makefile +++ b/Makefile @@ -27,18 +27,16 @@ endif $(TOOLS_DIR): mkdir -p $@ -config: - printf " $(foreach V,$(VARLIST),$V := $(strip $($V))\n)" > Defaults.mk - find . -type f -name "*.in" -not -path "./vendor/*" \ - -exec sh -c 'sed -ne "$(foreach V,$(VARLIST),s,@$V@,$(strip $($V)),g;)p" $${0} > $${0%.in}' {} \; - touch config +.PHONY: config +config: etc/wwapic.conf \ + etc/wwapid.conf \ + etc/wwapird.conf \ + include/systemd/warewulfd.service \ + internal/pkg/config/buildconfig.go \ + warewulf.spec -.PHONY: rm_config -rm_config: - rm -f config - -.PHONY: genconfig -genconfig: rm_config config +%: %.in + sed -ne "$(foreach V,$(VARLIST),s,@$V@,$(strip $($V)),g;)p" $@.in >$@ .PHONY: lint lint: setup_tools @@ -183,11 +181,10 @@ wwapird: .PHONY: contclean contclean: + rm -f Defaults.mk rm -f $(WAREWULF)-$(VERSION).tar.gz rm -f bash_completion - rm -f config - rm -f config_defaults - rm -f Defaults.mk + rm -f config_defaults rm -f etc/wwapi{c,d,rd}.conf rm -f etc/wwapi{c,d,rd}.config rm -f include/systemd/warewulfd.service diff --git a/Variables.mk b/Variables.mk index 43e28ff6..aa22945a 100644 --- a/Variables.mk +++ b/Variables.mk @@ -97,3 +97,6 @@ export GOPROXY # built tags needed for wwbuild binary WW_GO_BUILD_TAGS := containers_image_openpgp containers_image_ostree + +Defaults.mk: + printf " $(foreach V,$(VARLIST),$V := $(strip $($V))\n)" >Defaults.mk diff --git a/userdocs/contributing/development-environment-vagrant.rst b/userdocs/contributing/development-environment-vagrant.rst index 8b3f0ba4..e437f080 100644 --- a/userdocs/contributing/development-environment-vagrant.rst +++ b/userdocs/contributing/development-environment-vagrant.rst @@ -158,7 +158,7 @@ Vagrantfile git clone https://github.com/hpcng/warewulf.git cd warewulf git checkout v4.4.0 - make genconfig \ + make clean Defaults.mk \ PREFIX=/usr \ BINDIR=/usr/bin \ SYSCONFDIR=/etc \ diff --git a/userdocs/quickstart/el8.rst b/userdocs/quickstart/el8.rst index b2ab3772..4e2e0510 100644 --- a/userdocs/quickstart/el8.rst +++ b/userdocs/quickstart/el8.rst @@ -13,7 +13,7 @@ Install Warewulf and dependencies git clone https://github.com/hpcng/warewulf.git cd warewulf - make genconfig \ + make clean Defaults.mk \ PREFIX=/usr \ BINDIR=/usr/bin \ SYSCONFDIR=/etc \ diff --git a/userdocs/quickstart/el9.rst b/userdocs/quickstart/el9.rst index 575dc2b3..0ad66d77 100644 --- a/userdocs/quickstart/el9.rst +++ b/userdocs/quickstart/el9.rst @@ -14,7 +14,7 @@ Install Warewulf and dependencies git clone https://github.com/hpcng/warewulf.git cd warewulf - make genconfig \ + make clean Defaults.mk \ PREFIX=/usr \ BINDIR=/usr/bin \ SYSCONFDIR=/etc \ diff --git a/userdocs/quickstart/suse15.rst b/userdocs/quickstart/suse15.rst index 7c0c58e2..ad6f8786 100644 --- a/userdocs/quickstart/suse15.rst +++ b/userdocs/quickstart/suse15.rst @@ -16,7 +16,7 @@ Install Warewulf and dependencies git clone https://github.com/hpcng/warewulf.git cd warewulf - PREFIX=/usr SYSCONFDIR=/etc TFTPDIR=/srv/tftproot LOCALSTATEDIR=/var/lib make genconfig + PREFIX=/usr SYSCONFDIR=/etc TFTPDIR=/srv/tftproot LOCALSTATEDIR=/var/lib make clean Defaults.mk make all sudo make install diff --git a/warewulf.spec.in b/warewulf.spec.in index f0208f83..8a6b15bc 100644 --- a/warewulf.spec.in +++ b/warewulf.spec.in @@ -71,7 +71,7 @@ system for large clusters of bare metal and/or virtual systems. %build %{?with_offline:OFFLINE_BUILD=1} # Install to sharedstatedir by redirecting LOCALSTATEDIR -make genconfig \ +make Defaults.mk \ PREFIX=%{_prefix} \ BINDIR=%{_bindir} \ SYSCONFDIR=%{_sysconfdir} \ @@ -92,7 +92,8 @@ make %install export NO_BRP_STALE_LINK_ERROR=yes -make install DESTDIR=%{buildroot} +make install \ + DESTDIR=%{buildroot} %pre