Makefile: use a "by-the-book" way to detect build environment change

"Move if changed" is a widely use approach for this.  And we also need
to detect if BASEDIR has changed.
This commit is contained in:
Xi Ruoyao 2023-01-23 19:10:21 +08:00
parent 51bec49736
commit 41275f9aac
No known key found for this signature in database
GPG Key ID: ACAAD20E19E710E3
2 changed files with 11 additions and 12 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ version.ent
blfs-bootscripts*
xxx
*.swp
build-env

View File

@ -34,12 +34,6 @@ ifneq ($(REV), sysv)
endif
endif
# Let's get the previous REV: it'll be used to see if we should
# rebuild version.ent
PREVREV != if [ -f conditional.ent ]; then \
gawk '/INCLUDE/{ print $$3 }' conditional.ent; \
fi
ifeq ($(REV), sysv)
BASEDIR ?= $(HOME)/public_html/blfs-book
NOCHUNKS_OUTPUT ?= blfs-book.html
@ -279,12 +273,7 @@ $(DUMPDIR): $(RENDERTMP)/$(BLFSFULL)
validate profile-html blfs-patch-list wget-list \
test-links dump-commands bootscripts systemd-units
# make version.ent unconditionally if we have changed REV
ifneq ($(REV), $(PREVREV))
.PHONY: version.ent
endif
version.ent: general.ent packages.ent gnome.ent $(ALLXML) $(ALLXSL)
version.ent: general.ent packages.ent gnome.ent $(ALLXML) $(ALLXSL) build-env
$(Q)./git-version.sh $(REV)
#ALL_PYTHON_DEPS := $(filter-out $(PYHOSTED), \
@ -309,3 +298,12 @@ version.ent: general.ent packages.ent gnome.ent $(ALLXML) $(ALLXSL)
# stylesheets/pythonhosted.xsl \
# general/prog/python-modules.xml
# $(Q)mv temp.xml $@
.PHONY: update-build-env
update-build-env:
$(Q)echo REV=$(REV) > $@.new
$(Q)echo BASEDIR=$(BASEDIR) >> $@.new
$(Q)diff $@.new $@ 2>/dev/null >/dev/null || mv $@.new $@
$(Q)rm -f $@.new
build-env: update-build-env