summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-07-14 06:39:20 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-07-14 06:39:20 -0700
commit2830565f6c00ea423c7496cfb3539bdb5625248b (patch)
tree1f7e28c770690b14b0f95b109f9d223d1e915e72 /Makefile
parent0b830828cbace15b524b28b04aa6716cb57ed589 (diff)
downloadtxr-2830565f6c00ea423c7496cfb3539bdb5625248b.tar.gz
txr-2830565f6c00ea423c7496cfb3539bdb5625248b.tar.bz2
txr-2830565f6c00ea423c7496cfb3539bdb5625248b.zip
build: recompile txr.c if build_id changes.
With this change, it is possible to make build_id=abcd to rebuild TXR with the given build ID. Any changes in the value of a dynamic, git-generated build_id will likewise trigger a rebuild. * Makefile (old_build_id): New variable. We read the old build ID from a file called .build_id in the build directory. If it differs from the current expanded ID, build_id_exp, we remove the object files affected by build_id. In all cases, we then write the current build ID into the .build_id file. (clean, distclean): Remove .build_id.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile11
1 files changed, 9 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index c59bcee0..0094985f 100644
--- a/Makefile
+++ b/Makefile
@@ -329,6 +329,13 @@ opt/txr-win.o: TXR_CFLAGS += -DPROG_NAME=\"$(PROG)-win\" \
-DTXR_REL_PATH=\"$(bindir_rel)/$(PROG)-win$(EXE)\"
dbg/txr-win.o: TXR_CFLAGS += -DPROG_NAME=\"$(PROG)-win-dbg\" \
-DTXR_REL_PATH=\"$(bindir_rel)/$(PROG)-win-dbg$(EXE)\"
+
+old_build_id=$(shell cat .build_id 2> /dev/null)
+ifneq ($(build_id_exp),$(old_build_id))
+$(shell rm -f $(call EACH_CONF,txr.o txr-win.o))
+endif
+$(shell printf "%s" "$(build_id_exp)" > .build_id)
+
ifneq ($(build_id_exp),)
$(call EACH_CONF,txr.o txr-win.o): TXR_CFLAGS += -DTXR_BUILD_ID=\"$(build_id_exp)\"
endif
@@ -343,7 +350,7 @@ rebuild clean: notconfigured
distclean:
$(V)echo "executing generic cleanup for non-configured directory"
- rm -f txr txr.exe txr-dbg txr-dbg.exe txr-win.exe txr-win-dbg.exe
+ rm -f txr txr.exe txr-dbg txr-dbg.exe txr-win.exe txr-win-dbg.exe .build_id
rm -f y.tab.c lex.yy.c y.tab.h y.output
rm -rf opt dbg tst
rm -f stdlib/*.tlo run.sh
@@ -358,7 +365,7 @@ rebuild: clean $(PROG)
clean: conftest.clean clean-tlo
rm -f $(PROG)$(EXE) $(PROG)-dbg$(EXE) y.tab.c lex.yy.c y.tab.h y.output
rm -f y.tab.h.old
- rm -f $(PROG)-win$(EXE) $(PROG)-win-dbg$(EXE)
+ rm -f $(PROG)-win$(EXE) $(PROG)-win-dbg$(EXE) .build_id
rm -rf opt dbg tst
rm -f $(EXTRA_OBJS-y) run.sh