summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-08-11 06:58:44 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-08-11 06:58:44 -0700
commit9d09406d3204044675a765998f608f1b1b502c2e (patch)
tree31c0142e596adb917e10204fa6b687b26be583e1
parentc2b7f82686fd66b4440195363edf02b0c6b11a63 (diff)
downloadtxr-9d09406d3204044675a765998f608f1b1b502c2e.tar.gz
txr-9d09406d3204044675a765998f608f1b1b502c2e.tar.bz2
txr-9d09406d3204044675a765998f608f1b1b502c2e.zip
build: remove mkdir commands from build steps.
* Makefile (COMPILE_C_WITH_DEPS, WINDRES): Do not call mkdir. (win/%.res): Express dependency on existence of win subdirectory in the build directory. We use an order-only prerequisite, so that timestamps are not compared. We don't want to be rebuilding objects if the directory they are in has a newer timestamp, which is often the case. (OBJS): Extract the relative directory paths from $(OBJS), and make each directory the target of a rule which creates it. Then, make each target in $(OBJS) dependent (order-only) on the directory into which it will be placed, so before that object is built, the directory gets created with mkdir -p.
-rw-r--r--Makefile11
1 files changed, 8 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 350703ad..283b46cc 100644
--- a/Makefile
+++ b/Makefile
@@ -131,7 +131,6 @@ endef
define COMPILE_C_WITH_DEPS
$(call ABBREV,CC)
-$(call SH,mkdir -p $(dir $@))
$(call SH,$(TXR_CC) -MMD -MT $@ $(1) $(TXR_CFLAGS) -c -o $@ $<)
endef
@@ -142,7 +141,6 @@ endef
define WINDRES
$(call ABBREV,RES)
-$(call SH,mkdir -p $(dir $@))
$(call SH,windres -O coff -DTXR_VER=$(txr_ver) $< $@)
endef
@@ -187,7 +185,7 @@ dbg/%-win.o: $(top_srcdir)%.c
opt/%-win.o: $(top_srcdir)%.c
$(call COMPILE_C_WITH_DEPS, $(OPT_FLAGS))
-win/%.res: $(top_srcdir)win/%.rc $(top_srcdir)win/%.ico
+win/%.res: $(top_srcdir)win/%.rc $(top_srcdir)win/%.ico | win
$(call WINDRES)
%.tlo: %.tl | $(PROG)
@@ -249,6 +247,13 @@ dbg/lex.yy.o: lex.yy.c
opt/y.tab.o: y.tab.c
dbg/y.tab.o: y.tab.c
+# Turn each directory in the object file tree into target built by mkdir -p
+$(sort $(foreach name,$(OBJS),$(dir $(name)))) win:
+ $(call SH,mkdir -p $@)
+
+# Make each object file depend on its own directory, so that it's created.
+$(foreach obj,$(OBJS),$(eval $(obj): | $(dir $(obj))))
+
ifeq ($(maintainer),y)
lex.yy.c: $(top_srcdir)parser.l