From 9d09406d3204044675a765998f608f1b1b502c2e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 11 Aug 2023 06:58:44 -0700 Subject: 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. --- Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'Makefile') 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 -- cgit v1.2.3