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 <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2023-08-10 11:28:49 -06:00
parent 64fd43bb86
commit c1d56885ac
8 changed files with 22 additions and 22 deletions

View File

@@ -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 \

View File

@@ -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

View File

@@ -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

View File

@@ -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 \

View File

@@ -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 \

View File

@@ -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 \

View File

@@ -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

View File

@@ -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