From 0ad4381a1185ed9ee964fbb8807eff66e8fe495d Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Wed, 15 Jun 2016 12:17:58 -0500 Subject: [PATCH] Make using Yacc optional, disabled by default A built-in GNU Make rule causes code/tools/lcc/lburg/gram.y to replace gram.c if gram.y has a newer modified time. This causes git diff to pick up changes to gram.c, which seems to have been manually modified to fix warnings and may vary by Yacc used to create it. It also requires installing a program to generate a file that already exists in a usable state in the code repository. So replace the built-in rule so it is only used if USE_YACC is 1 (defaults to 0). The Yacc executable name can be overriden using `make YACC=yacc` like before. I preferred to touch gram.c instead of installing Yacc because of the problems it causes. It doesn't really seem like a good idea to recommend others do that instead of disabling Yacc the Makefile though. --- Makefile | 20 ++++++++++++++++++++ README.md | 1 + 2 files changed, 21 insertions(+) diff --git a/Makefile b/Makefile index 12035172..fb7efd08 100644 --- a/Makefile +++ b/Makefile @@ -224,6 +224,10 @@ ifndef USE_RENDERER_DLOPEN USE_RENDERER_DLOPEN=1 endif +ifndef USE_YACC +USE_YACC=0 +endif + ifndef DEBUG_CFLAGS DEBUG_CFLAGS=-ggdb -O0 endif @@ -1351,6 +1355,10 @@ ifndef TOOLS_CC TOOLS_CC = gcc endif +ifndef YACC + YACC = yacc +endif + TOOLS_OPTIMIZE = -g -Wall -fno-strict-aliasing TOOLS_CFLAGS += $(TOOLS_OPTIMIZE) \ -DTEMPDIR=\"$(TEMPDIR)\" -DSYSTEM=\"\" \ @@ -1363,6 +1371,12 @@ ifeq ($(GENERATE_DEPENDENCIES),1) TOOLS_CFLAGS += -MMD endif +define DO_YACC +$(echo_cmd) "YACC $<" +$(Q)$(YACC) $< +$(Q)mv -f y.tab.c $@ +endef + define DO_TOOLS_CC $(echo_cmd) "TOOLS_CC $<" $(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) -o $@ -c $< @@ -1384,6 +1398,12 @@ LBURGOBJ= \ $(B)/tools/lburg/lburg.o \ $(B)/tools/lburg/gram.o +# override GNU Make built-in rule for converting gram.y to gram.c +%.c: %.y +ifeq ($(USE_YACC),1) + $(DO_YACC) +endif + $(B)/tools/lburg/%.o: $(LBURGDIR)/%.c $(DO_TOOLS_CC) diff --git a/README.md b/README.md index a5dacc9c..3e004ad8 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ Makefile.local: SERVERBIN - rename 'ioq3ded' server binary CLIENTBIN - rename 'ioquake3' client binary USE_RENDERER_DLOPEN - build and use the renderer in a library + USE_YACC - use yacc to update code/tools/lcc/lburg/gram.c BASEGAME - rename 'baseq3' BASEGAME_CFLAGS - custom CFLAGS for basegame MISSIONPACK - rename 'missionpack'