summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-08-11 06:45:56 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-08-11 06:45:56 -0700
commitc2b7f82686fd66b4440195363edf02b0c6b11a63 (patch)
tree038e4ae9df7f29bfb1b671e637c41021adffda2b /Makefile
parentaf07e726a7573304b957a3712984f6ecf6167872 (diff)
downloadtxr-c2b7f82686fd66b4440195363edf02b0c6b11a63.tar.gz
txr-c2b7f82686fd66b4440195363edf02b0c6b11a63.tar.bz2
txr-c2b7f82686fd66b4440195363edf02b0c6b11a63.zip
build: remove cruft, simplifying dep generation.
We get rid of the sed-based processing which produces .v files from .d files. The only purpose of the variable assignments in the .v files ended up being a filter expression in the ABBREVN macro. I think the idea here was to show all the direct prerequisites of the target, suppressing the ones computed by generated dependency rules. * Makefile (ABBREVN): Just use $^ instead filtering out $^ using the $(DEP_$@) computed variable that holds all the dependencies. I don't see an issue. This is only used for linking and it correctly shows the .o files. (DEPGEN): Macro removed. (COMPILE_C_WITH_DEPS): Remove call to DEPGEN, removing an ugly sed step from the compilation of each file. (NL, CM, DEP): Macros removed. (OBJS, EXTRA_OBJS): Directly write rule which makes all objects depend on config.make. (opt/lex.yy.o, opt/txr.o, opt/match.o, opt/parser.o, opt/y.tab.o, dbg/lex.yy.o, dbg/txr.o, dbg/match.o, dbg/parser.o, dbg/y.tab.o): Explicitly write direct rules for these so the parser generation is correctly hooked into the dependency graph.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile46
1 files changed, 12 insertions, 34 deletions
diff --git a/Makefile b/Makefile
index d58b1309..350703ad 100644
--- a/Makefile
+++ b/Makefile
@@ -107,24 +107,13 @@ ABBREV = $(if $(VERBOSE),\
@:,\
@printf "%s %s -> %s\n" $(1) \
"$(patsubst $(top_srcdir)%,%,$<)" $@)
-# Filtering out $(DEP_$@) allows the abbreviated output to show just the direct
-# prerequisites without the long laundry list of additional dependencies.
ABBREVN = $(if $(VERBOSE),\
@:,\
@printf "%s %s -> %s\n" $(1) \
- "$(patsubst $(top_srcdir)%,%,$(filter-out $(DEP_$@),$^))" $@)
+ "$(patsubst $(top_srcdir)%,%,$^)" $@)
ABBREV3 = $(if $(VERBOSE),@:,@printf "%s %s -> %s\n" $(1) "$(3)" $(2))
ABBREV3SH = $(if $(VERBOSE),:,printf "%s %s -> %s\n" $(1) "$(3)" $(2))
-define DEPGEN
-$(V)sed -e ':x' \
- -e '/\\$$/ {' \
- -e 'N; s/\\\n//' \
- -e 'tx' \
- -e '}' < $(1) | \
- sed -e '1s/^/DEP_/' -e '1s/: [^ ]\+/ :=/' > $(1:.d=.v)
-endef
-
define SH
$(if $(VERBOSE), \
$(1), \
@@ -144,7 +133,6 @@ define COMPILE_C_WITH_DEPS
$(call ABBREV,CC)
$(call SH,mkdir -p $(dir $@))
$(call SH,$(TXR_CC) -MMD -MT $@ $(1) $(TXR_CFLAGS) -c -o $@ $<)
-$(call DEPGEN,${@:.o=.d})
endef
define LINK_PROG
@@ -245,31 +233,21 @@ $(PROG)-win: $(patsubst %/txr.o,%/txr-win.o,$(OPT_OBJS)) $(EXTRA_OBJS-y)
$(PROG)-win-dbg: $(patsubst %/txr.o,%/txr-win.o,$(DBG_OBJS)) $(EXTRA_OBJS-y)
$(call LINK_PROG,-mwindows)
-# Newline constant
-define NL
-
-
-endef
-
-CM := ,
-
-define DEP
-$(1): $(2)
-
-$(eval $(foreach item,$(1),DEP_$(item) += $(2)$(NL)))
-endef
-
# Pull in dependencies
--include $(OBJS:.o=.d) $(OBJS:.o=.v)
+-include $(OBJS:.o=.d)
+
+# Rebuild if config.make changes.
+$(OBJS) $(EXTRA_OBJS-y): config.make
-# Add dependencies
-$(call DEP,$(OBJS) $(EXTRA_OBJS-y),config.make config.h)
+# Parser dependencies
+opt/lex.yy.o opt/txr.o opt/match.o opt/parser.o: y.tab.h
+dbg/lex.yy.o dbg/txr.o dbg/match.o dbg/parser.o: y.tab.h
-$(eval $(foreach item,lex.yy.o txr.o match.o parser.o,\
- $(call DEP,opt/$(item) dbg/$(item),y.tab.h)))
+opt/lex.yy.o: lex.yy.c
+dbg/lex.yy.o: lex.yy.c
-$(eval $(foreach item,y.tab.c y.tab.h lex.yy.c,\
- $(call DEP,$(item),config.make config.h)))
+opt/y.tab.o: y.tab.c
+dbg/y.tab.o: y.tab.c
ifeq ($(maintainer),y)