From bf0449388c87d377bec1b365b5bf81807cb288d2 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 1 Jan 2025 17:19:47 +0100 Subject: [PATCH] build: Get rid of directory order-only dependencies. They only clutter the Makefile for no good reason. Just create all build directories beforehand. One order-only dependency remains: We want to invoke the compiler only after all generated .h files have been created. Otherwise the .d files may be created incorrectly. --- Makefile.real | 18 ++++++++---------- m4/lls/makefile | 6 +++--- yy/makefile | 4 ++-- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/Makefile.real b/Makefile.real index a6aee13c..6f914293 100644 --- a/Makefile.real +++ b/Makefile.real @@ -48,7 +48,9 @@ lls_m4_dir := m4/lls test_dir := t yy_src_dir := yy yy_build_dir := $(build_dir)/yy -GIT_VERSION := $(shell $(SHELL_DEFINES) ./version-gen.sh $(PACKAGE) $(version_dir)/version.c) +GIT_VERSION := $(shell $(MKDIR_P) $(object_dir) $(dep_dir) $(man_dir) \ + $(m4depdir) $(lls_suite_dir) $(yy_build_dir) && \ + $(SHELL_DEFINES) ./version-gen.sh $(PACKAGE) $(version_dir)/version.c) executables := recv filter audioc write afh ifneq ($(CRYPTOLIB),) @@ -366,10 +368,6 @@ ifeq ($(findstring clean, $(MAKECMDGOALS)),) -include $(m4_lls_deps) endif -$(object_dir) $(man_dir) $(dep_dir) $(m4depdir) $(lls_suite_dir) \ - $(yy_build_dir): - @$(MKDIR_P) $@ - CPPFLAGS += -DLOGLEVELS='$(LOGLEVELS)' CPPFLAGS += -DSEVERITIES=$(SEVERITIES) CPPFLAGS += -I$(lls_suite_dir) @@ -443,12 +441,12 @@ $(man_dir)/para_server.1: all_commands := $(server_commands) $(man_dir)/para_write.1: all_commands := $(write_commands) $(man_dir)/para_%.1: $(lls_suite_dir)/%.lsg.man \ - $(lls_m4_dir)/copyright.m4 | $(man_dir) + $(lls_m4_dir)/copyright.m4 $(call SAY, LLSMAN $<) cat $< $(all_commands) > $@ $(M4) $(lls_m4_dir)/copyright.m4 >> $@ -$(object_dir)/%.o: %.c | $(object_dir) +$(object_dir)/%.o: %.c OD = $(addsuffix .d, $(addprefix $(dep_dir)/, $(1))) \ $(addsuffix .o, $(addprefix $(object_dir)/, $(1))) @@ -481,16 +479,16 @@ $(call OD, afs aft attribute blob mood playlist score server vss command \ $(call OD, compress_filter): CFLAGS += -O3 -$(object_dir)/%.o: %.c | $(object_dir) $(dep_dir) $(lsg_h) $(yy_h) +$(object_dir)/%.o: %.c define CC_CMD $(call SAY, CC $<) $(CC) -c -o $(object_dir)/$(*F).o -MMD -MF \ $(dep_dir)/$(*F).d -MT $(object_dir)/$(*F).o \ $(CPPFLAGS) $(STRICT_CFLAGS) $(CFLAGS) $< endef -CC_PREREQUISITES := %.c | $(object_dir) $(dep_dir) $(lsg_h) $(yy_h) +CC_PREREQUISITES := %.c | $(lsg_h) $(yy_h) # There should be a # better way to write these. -$(object_dir)/%.o: $(version_dir)/%.c | $(object_dir) +$(object_dir)/%.o: $(version_dir)/%.c $(CC_CMD) $(object_dir)/%.o: $(CC_PREREQUISITES) $(CC_CMD) diff --git a/m4/lls/makefile b/m4/lls/makefile index a13f079e..0aa4744a 100644 --- a/m4/lls/makefile +++ b/m4/lls/makefile @@ -1,13 +1,13 @@ .PRECIOUS: $(lls_suite_dir)/%.suite $(lsg_h) lls_m4_include_dir := $(lls_m4_dir)/include -$(lls_suite_dir)/%.m4d: $(lls_m4_dir)/%.suite.m4 | $(lls_suite_dir) +$(lls_suite_dir)/%.m4d: $(lls_m4_dir)/%.suite.m4 $(call SAY, M4D $<) $(M4) -Pg -I $(lls_m4_include_dir) -s $< \ | awk '{if ($$1 ~ /#line/) {gsub(/"/, "", $$3); if ($$3 != "$<") \ print "$(lls_suite_dir)/$(*F).suite: " $$3}}' | sort | uniq > $@ -$(lls_suite_dir)/%.suite: $(lls_m4_dir)/%.suite.m4 | $(lls_suite_dir) +$(lls_suite_dir)/%.suite: $(lls_m4_dir)/%.suite.m4 $(call SAY, M4 $<) $(M4) -Pg -I $(lls_m4_include_dir) -D GIT_VERSION=$(GIT_VERSION) \ -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) -D LOGLEVELS=$(LOGLEVELS) \ @@ -26,6 +26,6 @@ $(lls_suite_dir)/%.lsg.man: $(lls_suite_dir)/%.suite $(call SAY, LSGM $<) $(LOPSUBGEN) --gen-man --output-dir $(lls_suite_dir) < $< -$(object_dir)/%.o: $(lls_suite_dir)/%.c | $(object_dir) +$(object_dir)/%.o: $(lls_suite_dir)/%.c $(call SAY, CC $<) $(CC) -c -o $@ $(CPPFLAGS) $(STRICT_CFLAGS) $< diff --git a/yy/makefile b/yy/makefile index ed70d655..e8492563 100644 --- a/yy/makefile +++ b/yy/makefile @@ -1,7 +1,7 @@ .PRECIOUS: $(yy_build_dir)/%.flex.c $(yy_build_dir)/%.bison.c \ $(yy_build_dir)/%.bison.h -$(yy_build_dir)/%.flex.c: $(yy_src_dir)/%.lex | $(yy_build_dir) +$(yy_build_dir)/%.flex.c: $(yy_src_dir)/%.lex @[ -z "$(Q)" ] || echo 'FLEX $<' @$(FLEX) -o $@ $< @@ -11,7 +11,7 @@ $(yy_build_dir)/%.bison.c $(yy_build_dir)/%.bison.h: $(yy_src_dir)/%.y \ @$(BISON) --defines=$(yy_build_dir)/$(notdir $(<:.y=.bison.h)) \ --output=$(yy_build_dir)/$(notdir $(<:.y=.bison.c)) $< -$(object_dir)/%.o: $(yy_build_dir)/%.c | $(object_dir) +$(object_dir)/%.o: $(yy_build_dir)/%.c @[ -z "$(Q)" ] || echo 'CC $<' @$(Q) $(CC) -g -c -o $@ $(CPPFLAGS) -MMD -MF $(dep_dir)/$(*F).d \ -MT $@ -iquote . -Wno-unused-macros $< -- 2.39.5