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.
This commit is contained in:
Zack Middleton 2016-06-15 12:17:58 -05:00
parent 4474297af8
commit 0ad4381a11
2 changed files with 21 additions and 0 deletions

View File

@ -224,6 +224,10 @@ ifndef USE_RENDERER_DLOPEN
USE_RENDERER_DLOPEN=1 USE_RENDERER_DLOPEN=1
endif endif
ifndef USE_YACC
USE_YACC=0
endif
ifndef DEBUG_CFLAGS ifndef DEBUG_CFLAGS
DEBUG_CFLAGS=-ggdb -O0 DEBUG_CFLAGS=-ggdb -O0
endif endif
@ -1351,6 +1355,10 @@ ifndef TOOLS_CC
TOOLS_CC = gcc TOOLS_CC = gcc
endif endif
ifndef YACC
YACC = yacc
endif
TOOLS_OPTIMIZE = -g -Wall -fno-strict-aliasing TOOLS_OPTIMIZE = -g -Wall -fno-strict-aliasing
TOOLS_CFLAGS += $(TOOLS_OPTIMIZE) \ TOOLS_CFLAGS += $(TOOLS_OPTIMIZE) \
-DTEMPDIR=\"$(TEMPDIR)\" -DSYSTEM=\"\" \ -DTEMPDIR=\"$(TEMPDIR)\" -DSYSTEM=\"\" \
@ -1363,6 +1371,12 @@ ifeq ($(GENERATE_DEPENDENCIES),1)
TOOLS_CFLAGS += -MMD TOOLS_CFLAGS += -MMD
endif endif
define DO_YACC
$(echo_cmd) "YACC $<"
$(Q)$(YACC) $<
$(Q)mv -f y.tab.c $@
endef
define DO_TOOLS_CC define DO_TOOLS_CC
$(echo_cmd) "TOOLS_CC $<" $(echo_cmd) "TOOLS_CC $<"
$(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) -o $@ -c $< $(Q)$(TOOLS_CC) $(TOOLS_CFLAGS) -o $@ -c $<
@ -1384,6 +1398,12 @@ LBURGOBJ= \
$(B)/tools/lburg/lburg.o \ $(B)/tools/lburg/lburg.o \
$(B)/tools/lburg/gram.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 $(B)/tools/lburg/%.o: $(LBURGDIR)/%.c
$(DO_TOOLS_CC) $(DO_TOOLS_CC)

View File

@ -89,6 +89,7 @@ Makefile.local:
SERVERBIN - rename 'ioq3ded' server binary SERVERBIN - rename 'ioq3ded' server binary
CLIENTBIN - rename 'ioquake3' client binary CLIENTBIN - rename 'ioquake3' client binary
USE_RENDERER_DLOPEN - build and use the renderer in a library 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 - rename 'baseq3'
BASEGAME_CFLAGS - custom CFLAGS for basegame BASEGAME_CFLAGS - custom CFLAGS for basegame
MISSIONPACK - rename 'missionpack' MISSIONPACK - rename 'missionpack'