From e8a6db783059327f154446387bd85f4718adc1ef Mon Sep 17 00:00:00 2001 From: Izuru Yakumo Date: Tue, 15 Jul 2025 15:09:05 -0300 Subject: [PATCH] Use the QVM build toolchain from ioq3 --- Makefile | 1520 +++-------------------- code/tools/asm/cmdlib.c | 28 +- code/tools/asm/cmdlib.h | 3 +- code/tools/asm/notes.txt | 2 +- code/tools/asm/q3asm.c | 44 +- code/tools/lcc/cpp/cpp.c | 16 +- code/tools/lcc/cpp/cpp.h | 2 +- code/tools/lcc/cpp/include.c | 7 +- code/tools/lcc/cpp/lex.c | 20 + code/tools/lcc/cpp/macro.c | 11 +- code/tools/lcc/cpp/tokens.c | 4 +- code/tools/lcc/cpp/unix.c | 21 +- code/tools/lcc/doc/4.html | 8 +- code/tools/lcc/doc/install.html | 4 +- code/tools/lcc/etc/bytecode.c | 13 +- code/tools/lcc/etc/lcc.c | 80 +- code/tools/lcc/lburg/gram.c | 2068 +++++++++++++++++++++++-------- code/tools/lcc/lburg/gram.y | 23 + code/tools/lcc/lburg/lburg.c | 4 +- code/tools/lcc/src/bytecode.c | 3 +- code/tools/lcc/src/c.h | 3 +- code/tools/lcc/src/dag.c | 3 +- code/tools/lcc/src/enode.c | 5 +- code/tools/lcc/src/error.c | 2 +- code/tools/lcc/src/expr.c | 20 +- code/tools/lcc/src/gen.c | 2 +- code/tools/lcc/src/init.c | 4 +- code/tools/lcc/src/list.c | 2 +- code/tools/lcc/src/output.c | 2 +- code/tools/lcc/src/simp.c | 4 +- code/tools/lcc/src/stmt.c | 7 +- code/tools/lcc/src/tree.c | 2 +- 32 files changed, 1982 insertions(+), 1955 deletions(-) diff --git a/Makefile b/Makefile index 4006765..766f6f9 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # # ioq3 Makefile -# +# Modified for Illusion Arena # GNU Make required # @@ -23,20 +23,6 @@ ifeq ($(COMPILE_PLATFORM),mingw32) endif endif - BUILD_STANDALONE = 1 - BUILD_CLIENT = 0 - BUILD_CLIENT_SMP = 0 - BUILD_SERVER = 0 - BUILD_GAME_SO = 1 - BUILD_GAME_QVM = 1 -ifndef BUILD_MISSIONPACK - BUILD_MISSIONPACK= -endif - -ifneq ($(PLATFORM),darwin) - BUILD_CLIENT_SMP = 0 -endif - ############################################################################# # # If you require a different configuration from the defaults below, create a @@ -58,6 +44,9 @@ endif ifeq ($(COMPILE_ARCH),powerpc64) COMPILE_ARCH=ppc64 endif +ifeq ($(COMPILE_ARCH),amd64) + COMPILE_ARCH=x86_64 +endif ifndef ARCH ARCH=$(COMPILE_ARCH) @@ -76,7 +65,7 @@ endif export CROSS_COMPILING ifndef COPYDIR -COPYDIR="/usr/local/games/quake3" +COPYDIR="/usr/local/games/illusion" endif ifndef MOUNT_DIR @@ -91,117 +80,40 @@ ifndef GENERATE_DEPENDENCIES GENERATE_DEPENDENCIES=1 endif -ifndef USE_OPENAL -USE_OPENAL=1 +ifneq ($(MOD_OA),1) + ifneq ($(MOD_Q3),0) + MOD_Q3=1 + CFLAGS+=-DMOD_Q3A + endif endif -ifndef USE_OPENAL_DLOPEN - ifeq ($(PLATFORM),mingw32) - USE_OPENAL_DLOPEN=1 - else - USE_OPENAL_DLOPEN=0 +ifneq ($(MOD_Q3),1) + ifneq ($(MOD_OA),0) + MOD_OA=1 + CFLAGS+=-DMOD_OA endif endif -ifndef USE_CURL -USE_CURL=1 -endif - -ifndef USE_CURL_DLOPEN - ifeq ($(PLATFORM),mingw32) - USE_CURL_DLOPEN=0 - else - USE_CURL_DLOPEN=1 - endif -endif - -ifndef USE_CODEC_VORBIS -USE_CODEC_VORBIS=0 -endif - -ifndef USE_MUMBLE -USE_MUMBLE=1 -endif - -ifndef USE_VOIP -USE_VOIP=1 -endif - -ifndef USE_INTERNAL_SPEEX -USE_INTERNAL_SPEEX=1 -endif - -ifndef USE_LOCAL_HEADERS -USE_LOCAL_HEADERS=1 -endif - ############################################################################# BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH) BR=$(BUILD_DIR)/release-$(PLATFORM)-$(ARCH) -CDIR=$(MOUNT_DIR)/client -SDIR=$(MOUNT_DIR)/server RDIR=$(MOUNT_DIR)/renderer CMDIR=$(MOUNT_DIR)/qcommon -SDLDIR=$(MOUNT_DIR)/sdl -ASMDIR=$(MOUNT_DIR)/asm -SYSDIR=$(MOUNT_DIR)/sys GDIR=$(MOUNT_DIR)/game CGDIR=$(MOUNT_DIR)/cgame BLIBDIR=$(MOUNT_DIR)/botlib -NDIR=$(MOUNT_DIR)/null UIDIR=$(MOUNT_DIR)/ui Q3UIDIR=$(MOUNT_DIR)/q3_ui -JPDIR=$(MOUNT_DIR)/jpeg-6b -SPEEXDIR=$(MOUNT_DIR)/libspeex Q3ASMDIR=$(MOUNT_DIR)/tools/asm LBURGDIR=$(MOUNT_DIR)/tools/lcc/lburg Q3CPPDIR=$(MOUNT_DIR)/tools/lcc/cpp Q3LCCETCDIR=$(MOUNT_DIR)/tools/lcc/etc Q3LCCSRCDIR=$(MOUNT_DIR)/tools/lcc/src -LOKISETUPDIR=misc/setup -NSISDIR=misc/nsis -SDLHDIR=$(MOUNT_DIR)/SDL12 -LIBSDIR=$(MOUNT_DIR)/libs TEMPDIR=/tmp -# set PKG_CONFIG_PATH to influence this, e.g. -# PKG_CONFIG_PATH=/opt/cross/i386-mingw32msvc/lib/pkgconfig -ifeq ($(shell which pkg-config > /dev/null; echo $$?),0) - CURL_CFLAGS=$(shell pkg-config --cflags libcurl) - CURL_LIBS=$(shell pkg-config --libs libcurl) - OPENAL_CFLAGS=$(shell pkg-config --cflags openal) - OPENAL_LIBS=$(shell pkg-config --libs openal) - # FIXME: introduce CLIENT_CFLAGS - SDL_CFLAGS=$(shell pkg-config --cflags sdl|sed 's/-Dmain=SDL_main//') - SDL_LIBS=$(shell pkg-config --libs sdl) -endif -# Use sdl-config if all else fails -ifeq ($(SDL_CFLAGS),) - ifeq ($(shell which sdl-config > /dev/null; echo $$?),0) - SDL_CFLAGS=$(shell sdl-config --cflags) - SDL_LIBS=$(shell sdl-config --libs) - endif -endif - # version info -VERSION=1.36 - -USE_SVN= -ifeq ($(wildcard .svn),.svn) - SVN_REV=$(shell LANG=C svnversion .) - ifneq ($(SVN_REV),) - VERSION:=$(VERSION)_SVN$(SVN_REV) - USE_SVN=1 - endif -else -ifeq ($(wildcard .git/svn/.metadata),.git/svn/.metadata) - SVN_REV=$(shell LANG=C git svn info | awk '$$1 == "Revision:" {print $$2; exit 0}') - ifneq ($(SVN_REV),) - VERSION:=$(VERSION)_SVN$(SVN_REV) - endif -endif -endif +VERSION=$(shell git rev-list --all | wc -l) ############################################################################# @@ -232,26 +144,7 @@ ifeq ($(PLATFORM),linux) endif endif - BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ - -pipe -DUSE_ICON $(SDL_CFLAGS) - - ifeq ($(USE_OPENAL),1) - BASE_CFLAGS += -DUSE_OPENAL - ifeq ($(USE_OPENAL_DLOPEN),1) - BASE_CFLAGS += -DUSE_OPENAL_DLOPEN - endif - endif - - ifeq ($(USE_CURL),1) - BASE_CFLAGS += -DUSE_CURL - ifeq ($(USE_CURL_DLOPEN),1) - BASE_CFLAGS += -DUSE_CURL_DLOPEN - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - BASE_CFLAGS += -DUSE_CODEC_VORBIS - endif + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes -pipe -DUSE_ICON OPTIMIZE = -O3 -ffast-math -funroll-loops -fomit-frame-pointer @@ -294,32 +187,6 @@ ifeq ($(PLATFORM),linux) THREAD_LIBS=-lpthread LIBS=-ldl -lm - CLIENT_LIBS=$(SDL_LIBS) -lGL - - ifeq ($(USE_OPENAL),1) - ifneq ($(USE_OPENAL_DLOPEN),1) - CLIENT_LIBS += -lopenal - endif - endif - - ifeq ($(USE_CURL),1) - ifneq ($(USE_CURL_DLOPEN),1) - CLIENT_LIBS += -lcurl - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_LIBS += -lvorbisfile -lvorbis -logg - endif - - ifeq ($(USE_MUMBLE),1) - CLIENT_LIBS += -lrt - endif - -ifeq ($(USE_LOCAL_HEADERS),1) - BASE_CFLAGS += -I$(SDLHDIR)/include - endif - ifeq ($(ARCH),i386) # linux32 make ... BASE_CFLAGS += -m32 @@ -360,43 +227,8 @@ ifeq ($(PLATFORM),darwin) endif BASE_CFLAGS += -fno-strict-aliasing -DMACOS_X -fno-common -pipe - - ifeq ($(USE_OPENAL),1) - BASE_CFLAGS += -DUSE_OPENAL - ifneq ($(USE_OPENAL_DLOPEN),1) - CLIENT_LIBS += -framework OpenAL - else - BASE_CFLAGS += -DUSE_OPENAL_DLOPEN - endif - endif - - ifeq ($(USE_CURL),1) - BASE_CFLAGS += -DUSE_CURL - ifneq ($(USE_CURL_DLOPEN),1) - CLIENT_LIBS += -lcurl - else - BASE_CFLAGS += -DUSE_CURL_DLOPEN - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - BASE_CFLAGS += -DUSE_CODEC_VORBIS - CLIENT_LIBS += -lvorbisfile -lvorbis -logg - endif - BASE_CFLAGS += -D_THREAD_SAFE=1 - ifeq ($(USE_LOCAL_HEADERS),1) - BASE_CFLAGS += -I$(SDLHDIR)/include - endif - - # We copy sdlmain before ranlib'ing it so that subversion doesn't think - # the file has been modified by each build. - LIBSDLMAIN=$(B)/libSDLmain.a - LIBSDLMAINSRC=$(LIBSDIR)/macosx/libSDLmain.a - CLIENT_LIBS += -framework Cocoa -framework IOKit -framework OpenGL \ - $(LIBSDIR)/macosx/libSDL-1.2.0.dylib - OPTIMIZE += -ffast-math -falign-loops=16 ifneq ($(HAVE_VM_COMPILED),true) @@ -404,7 +236,6 @@ ifeq ($(PLATFORM),darwin) endif DEBUG_CFLAGS = $(BASE_CFLAGS) -g -O0 - RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) SHLIBEXT=dylib @@ -430,28 +261,13 @@ ifeq ($(PLATFORM),mingw32) ARCH=x86 - BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ - -DUSE_ICON + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes -DUSE_ICON # In the absence of wspiapi.h, require Windows XP or later ifeq ($(shell test -e $(CMDIR)/wspiapi.h; echo $$?),1) BASE_CFLAGS += -DWINVER=0x501 endif - ifeq ($(USE_OPENAL),1) - BASE_CFLAGS += -DUSE_OPENAL - BASE_CFLAGS += $(OPENAL_CFLAGS) - ifeq ($(USE_OPENAL_DLOPEN),1) - BASE_CFLAGS += -DUSE_OPENAL_DLOPEN - else - CLIENT_LDFLAGS += $(OPENAL_LDFLAGS) - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - BASE_CFLAGS += -DUSE_CODEC_VORBIS - endif - OPTIMIZE = -O3 -march=i586 -fno-omit-frame-pointer -ffast-math \ -falign-loops=2 -funroll-loops -falign-jumps=2 -falign-functions=2 \ -fstrength-reduce @@ -462,29 +278,10 @@ ifeq ($(PLATFORM),mingw32) SHLIBCFLAGS= SHLIBLDFLAGS=-shared $(LDFLAGS) - BINEXT=.exe - LIBS= -lws2_32 -lwinmm CLIENT_LDFLAGS = -mwindows CLIENT_LIBS = -lgdi32 -lole32 -lopengl32 - ifeq ($(USE_CURL),1) - BASE_CFLAGS += -DUSE_CURL - BASE_CFLAGS += $(CURL_CFLAGS) - ifneq ($(USE_CURL_DLOPEN),1) - ifeq ($(USE_LOCAL_HEADERS),1) - BASE_CFLAGS += -DCURL_STATICLIB - CLIENT_LIBS += $(LIBSDIR)/win32/libcurl.a - else - CLIENT_LIBS += $(CURL_LIBS) - endif - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_LIBS += -lvorbisfile -lvorbis -logg - endif - ifeq ($(ARCH),x86) # build 32bit BASE_CFLAGS += -m32 @@ -493,21 +290,6 @@ ifeq ($(PLATFORM),mingw32) DEBUG_CFLAGS=$(BASE_CFLAGS) -g -O0 RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE) - # libmingw32 must be linked before libSDLmain - CLIENT_LIBS += -lmingw32 - ifeq ($(USE_LOCAL_HEADERS),1) - BASE_CFLAGS += -I$(SDLHDIR)/include - CLIENT_LIBS += $(LIBSDIR)/win32/libSDLmain.a \ - $(LIBSDIR)/win32/libSDL.dll.a - else - BASE_CFLAGS += $(SDL_CFLAGS) - CLIENT_LIBS += $(SDL_LIBS) - endif - - - - BUILD_CLIENT_SMP = 0 - else # ifeq mingw32 ############################################################################# @@ -526,17 +308,6 @@ ifeq ($(PLATFORM),freebsd) BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ -DUSE_ICON $(SDL_CFLAGS) - ifeq ($(USE_OPENAL),1) - BASE_CFLAGS += -DUSE_OPENAL - ifeq ($(USE_OPENAL_DLOPEN),1) - BASE_CFLAGS += -DUSE_OPENAL_DLOPEN - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - BASE_CFLAGS += -DUSE_CODEC_VORBIS - endif - ifeq ($(ARCH),axp) BASE_CFLAGS += -DNO_VM_COMPILED RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -ffast-math -funroll-loops \ @@ -563,20 +334,6 @@ ifeq ($(PLATFORM),freebsd) # don't need -ldl (FreeBSD) LIBS=-lm - CLIENT_LIBS = - - CLIENT_LIBS += $(SDL_LIBS) -lGL - - ifeq ($(USE_OPENAL),1) - ifneq ($(USE_OPENAL_DLOPEN),1) - CLIENT_LIBS += $(THREAD_LIBS) -lopenal - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_LIBS += -lvorbisfile -lvorbis -logg - endif - else # ifeq freebsd ############################################################################# @@ -588,20 +345,7 @@ ifeq ($(PLATFORM),openbsd) #default to i386, no tests done on anything else ARCH=i386 - - BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ - -DUSE_ICON $(SDL_CFLAGS) - - ifeq ($(USE_OPENAL),1) - BASE_CFLAGS += -DUSE_OPENAL - ifeq ($(USE_OPENAL_DLOPEN),1) - BASE_CFLAGS += -DUSE_OPENAL_DLOPEN - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - BASE_CFLAGS += -DUSE_CODEC_VORBIS - endif + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes -DUSE_ICON $(SDL_CFLAGS) BASE_CFLAGS += -DNO_VM_COMPILED -I/usr/X11R6/include -I/usr/local/include RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 \ @@ -619,20 +363,6 @@ ifeq ($(PLATFORM),openbsd) THREAD_LIBS=-lpthread LIBS=-lm - CLIENT_LIBS = - - CLIENT_LIBS += $(SDL_LIBS) -lGL - - ifeq ($(USE_OPENAL),1) - ifneq ($(USE_OPENAL_DLOPEN),1) - CLIENT_LIBS += $(THREAD_LIBS) -lossaudio -lopenal - endif - endif - - ifeq ($(USE_CODEC_VORBIS),1) - CLIENT_LIBS += -lvorbisfile -lvorbis -logg - endif - else # ifeq openbsd ############################################################################# @@ -644,7 +374,10 @@ ifeq ($(PLATFORM),netbsd) ifeq ($(shell uname -m),i386) ARCH=i386 endif - + ifeq ($(shell uname -m),amd64) + ARCH=x86_64 + endif + LIBS=-lm SHLIBEXT=so SHLIBCFLAGS=-fPIC @@ -653,15 +386,8 @@ ifeq ($(PLATFORM),netbsd) BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes - ifneq ($(ARCH),i386) - BASE_CFLAGS += -DNO_VM_COMPILED - endif - DEBUG_CFLAGS=$(BASE_CFLAGS) -g - BUILD_CLIENT = 0 - BUILD_GAME_QVM = 0 - else # ifeq netbsd ############################################################################# @@ -676,7 +402,7 @@ ifeq ($(PLATFORM),irix64) MKDIR = mkdir -p BASE_CFLAGS=-Dstricmp=strcasecmp -Xcpluscomm -woff 1185 \ - -I. $(SDL_CFLAGS) -I$(ROOT)/usr/include -DNO_VM_COMPILED + -I. -I$(ROOT)/usr/include -DNO_VM_COMPILED RELEASE_CFLAGS=$(BASE_CFLAGS) -O3 DEBUG_CFLAGS=$(BASE_CFLAGS) -g @@ -700,7 +426,7 @@ ifeq ($(PLATFORM),sunos) CC=gcc INSTALL=ginstall MKDIR=gmkdir - COPYDIR="/usr/local/share/games/quake3" + COPYDIR="/usr/local/share/games/illusion" ifneq (,$(findstring i86pc,$(shell uname -m))) ARCH=i386 @@ -714,8 +440,7 @@ ifeq ($(PLATFORM),sunos) endif endif - BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \ - -pipe -DUSE_ICON $(SDL_CFLAGS) + BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes -pipe -DUSE_ICON OPTIMIZE = -O3 -ffast-math -funroll-loops @@ -754,8 +479,6 @@ ifeq ($(PLATFORM),sunos) BOTCFLAGS=-O0 - CLIENT_LIBS +=$(SDL_LIBS) -lGL -lX11 -lXext -liconv -lm - else # ifeq sunos ############################################################################# @@ -780,55 +503,19 @@ endif #SunOS TARGETS = -ifneq ($(BUILD_SERVER),0) - TARGETS += $(B)/ioq3ded.$(ARCH)$(BINEXT) -endif - -ifneq ($(BUILD_CLIENT),0) - TARGETS += $(B)/ioquake3.$(ARCH)$(BINEXT) - ifneq ($(BUILD_CLIENT_SMP),0) - TARGETS += $(B)/ioquake3-smp.$(ARCH)$(BINEXT) - endif -endif - ifneq ($(BUILD_GAME_SO),0) TARGETS += \ - $(B)/baseq3/cgame$(ARCH).$(SHLIBEXT) \ - $(B)/baseq3/qagame$(ARCH).$(SHLIBEXT) \ - $(B)/baseq3/ui$(ARCH).$(SHLIBEXT) - ifneq ($(BUILD_MISSIONPACK),0) - TARGETS += \ - $(B)/missionpack/cgame$(ARCH).$(SHLIBEXT) \ - $(B)/missionpack/qagame$(ARCH).$(SHLIBEXT) \ - $(B)/missionpack/ui$(ARCH).$(SHLIBEXT) - endif + $(B)/baseia/cgame$(ARCH).$(SHLIBEXT) \ + $(B)/baseia/qagame$(ARCH).$(SHLIBEXT) \ + $(B)/baseia/ui$(ARCH).$(SHLIBEXT) endif ifneq ($(BUILD_GAME_QVM),0) ifneq ($(CROSS_COMPILING),1) TARGETS += \ - $(B)/baseq3/vm/cgame.qvm \ - $(B)/baseq3/vm/qagame.qvm \ - $(B)/baseq3/vm/ui.qvm - ifneq ($(BUILD_MISSIONPACK),0) - TARGETS += \ - $(B)/missionpack/vm/qagame.qvm \ - $(B)/missionpack/vm/cgame.qvm \ - $(B)/missionpack/vm/ui.qvm - endif - endif -endif - -ifeq ($(USE_MUMBLE),1) - BASE_CFLAGS += -DUSE_MUMBLE -endif - -ifeq ($(USE_VOIP),1) - BASE_CFLAGS += -DUSE_VOIP - ifeq ($(USE_INTERNAL_SPEEX),1) - BASE_CFLAGS += -DFLOATING_POINT -DUSE_ALLOCA -I$(SPEEXDIR)/include - else - CLIENT_LIBS += -lspeex + $(B)/baseia/vm/cgame.qvm \ + $(B)/baseia/vm/qagame.qvm \ + $(B)/baseia/vm/ui.qvm endif endif @@ -836,14 +523,6 @@ ifdef DEFAULT_BASEDIR BASE_CFLAGS += -DDEFAULT_BASEDIR=\\\"$(DEFAULT_BASEDIR)\\\" endif -ifeq ($(USE_LOCAL_HEADERS),1) - BASE_CFLAGS += -DUSE_LOCAL_HEADERS -endif - -ifeq ($(BUILD_STANDALONE),1) - BASE_CFLAGS += -DSTANDALONE -endif - ifeq ($(GENERATE_DEPENDENCIES),1) DEPEND_CFLAGS = -MMD else @@ -860,21 +539,6 @@ echo_cmd=@echo Q=@ endif -define DO_CC -$(echo_cmd) "CC $<" -$(Q)$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -o $@ -c $< -endef - -define DO_SMP_CC -$(echo_cmd) "SMP_CC $<" -$(Q)$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) -DSMP -o $@ -c $< -endef - -define DO_BOT_CC -$(echo_cmd) "BOT_CC $<" -$(Q)$(CC) $(NOTSHLIBCFLAGS) $(CFLAGS) $(BOTCFLAGS) -DBOTLIB -o $@ -c $< -endef - ifeq ($(GENERATE_DEPENDENCIES),1) DO_QVM_DEP=cat $(@:%.o=%.d) | sed -e 's/\.o/\.asm/g' >> $(@:%.o=%.d) endif @@ -903,46 +567,11 @@ $(Q)$(CC) -DUI $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $< $(Q)$(DO_QVM_DEP) endef -define DO_SHLIB_CC_MISSIONPACK -$(echo_cmd) "SHLIB_CC_MISSIONPACK $<" -$(Q)$(CC) -DMISSIONPACK $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $< -$(Q)$(DO_QVM_DEP) -endef - -define DO_GAME_CC_MISSIONPACK -$(echo_cmd) "GAME_CC_MISSIONPACK $<" -$(Q)$(CC) -DMISSIONPACK -DQAGAME $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $< -$(Q)$(DO_QVM_DEP) -endef - -define DO_CGAME_CC_MISSIONPACK -$(echo_cmd) "CGAME_CC_MISSIONPACK $<" -$(Q)$(CC) -DMISSIONPACK -DCGAME $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $< -$(Q)$(DO_QVM_DEP) -endef - -define DO_UI_CC_MISSIONPACK -$(echo_cmd) "UI_CC_MISSIONPACK $<" -$(Q)$(CC) -DMISSIONPACK -DUI $(CFLAGS) $(SHLIBCFLAGS) -o $@ -c $< -$(Q)$(DO_QVM_DEP) -endef - define DO_AS $(echo_cmd) "AS $<" $(Q)$(CC) $(CFLAGS) -x assembler-with-cpp -o $@ -c $< endef -define DO_DED_CC -$(echo_cmd) "DED_CC $<" -$(Q)$(CC) $(NOTSHLIBCFLAGS) -DDEDICATED $(CFLAGS) -o $@ -c $< -endef - -define DO_WINDRES -$(echo_cmd) "WINDRES $<" -$(Q)$(WINDRES) -i $< -o $@ -endef - - ############################################################################# # MAIN TARGETS ############################################################################# @@ -962,7 +591,7 @@ release: # an informational message, then start building targets: makedirs @echo "" - @echo "Building ioquake3 in $(B):" + @echo "Building Illusion Arena in $(B):" @echo " PLATFORM: $(PLATFORM)" @echo " ARCH: $(ARCH)" @echo " VERSION: $(VERSION)" @@ -970,36 +599,6 @@ targets: makedirs @echo " COMPILE_ARCH: $(COMPILE_ARCH)" @echo " CC: $(CC)" @echo "" - @echo " CFLAGS:" - -@for i in $(CFLAGS); \ - do \ - echo " $$i"; \ - done - @echo "" - @echo " LDFLAGS:" - -@for i in $(LDFLAGS); \ - do \ - echo " $$i"; \ - done - @echo "" - @echo " LIBS:" - -@for i in $(LIBS); \ - do \ - echo " $$i"; \ - done - @echo "" - @echo " CLIENT_LIBS:" - -@for i in $(CLIENT_LIBS); \ - do \ - echo " $$i"; \ - done - @echo "" - @echo " Output:" - -@for i in $(TARGETS); \ - do \ - echo " $$i"; \ - done - @echo "" ifneq ($(TARGETS),) @$(MAKE) $(TARGETS) V=$(V) endif @@ -1007,21 +606,12 @@ endif makedirs: @if [ ! -d $(BUILD_DIR) ];then $(MKDIR) $(BUILD_DIR);fi @if [ ! -d $(B) ];then $(MKDIR) $(B);fi - @if [ ! -d $(B)/client ];then $(MKDIR) $(B)/client;fi - @if [ ! -d $(B)/clientsmp ];then $(MKDIR) $(B)/clientsmp;fi - @if [ ! -d $(B)/ded ];then $(MKDIR) $(B)/ded;fi - @if [ ! -d $(B)/baseq3 ];then $(MKDIR) $(B)/baseq3;fi - @if [ ! -d $(B)/baseq3/cgame ];then $(MKDIR) $(B)/baseq3/cgame;fi - @if [ ! -d $(B)/baseq3/game ];then $(MKDIR) $(B)/baseq3/game;fi - @if [ ! -d $(B)/baseq3/ui ];then $(MKDIR) $(B)/baseq3/ui;fi - @if [ ! -d $(B)/baseq3/qcommon ];then $(MKDIR) $(B)/baseq3/qcommon;fi - @if [ ! -d $(B)/baseq3/vm ];then $(MKDIR) $(B)/baseq3/vm;fi - @if [ ! -d $(B)/missionpack ];then $(MKDIR) $(B)/missionpack;fi - @if [ ! -d $(B)/missionpack/cgame ];then $(MKDIR) $(B)/missionpack/cgame;fi - @if [ ! -d $(B)/missionpack/game ];then $(MKDIR) $(B)/missionpack/game;fi - @if [ ! -d $(B)/missionpack/ui ];then $(MKDIR) $(B)/missionpack/ui;fi - @if [ ! -d $(B)/missionpack/qcommon ];then $(MKDIR) $(B)/missionpack/qcommon;fi - @if [ ! -d $(B)/missionpack/vm ];then $(MKDIR) $(B)/missionpack/vm;fi + @if [ ! -d $(B)/baseia ];then $(MKDIR) $(B)/baseia;fi + @if [ ! -d $(B)/baseia/cgame ];then $(MKDIR) $(B)/baseia/cgame;fi + @if [ ! -d $(B)/baseia/game ];then $(MKDIR) $(B)/baseia/game;fi + @if [ ! -d $(B)/baseia/ui ];then $(MKDIR) $(B)/baseia/ui;fi + @if [ ! -d $(B)/baseia/qcommon ];then $(MKDIR) $(B)/baseia/qcommon;fi + @if [ ! -d $(B)/baseia/vm ];then $(MKDIR) $(B)/baseia/vm;fi @if [ ! -d $(B)/tools ];then $(MKDIR) $(B)/tools;fi @if [ ! -d $(B)/tools/asm ];then $(MKDIR) $(B)/tools/asm;fi @if [ ! -d $(B)/tools/etc ];then $(MKDIR) $(B)/tools/etc;fi @@ -1168,27 +758,6 @@ $(echo_cmd) "UI_Q3LCC $<" $(Q)$(Q3LCC) -DUI -o $@ $< endef -define DO_Q3LCC_MISSIONPACK -$(echo_cmd) "Q3LCC_MISSIONPACK $<" -$(Q)$(Q3LCC) -DMISSIONPACK -o $@ $< -endef - -define DO_CGAME_Q3LCC_MISSIONPACK -$(echo_cmd) "CGAME_Q3LCC_MISSIONPACK $<" -$(Q)$(Q3LCC) -DMISSIONPACK -DCGAME -o $@ $< -endef - -define DO_GAME_Q3LCC_MISSIONPACK -$(echo_cmd) "GAME_Q3LCC_MISSIONPACK $<" -$(Q)$(Q3LCC) -DMISSIONPACK -DQAGAME -o $@ $< -endef - -define DO_UI_Q3LCC_MISSIONPACK -$(echo_cmd) "UI_Q3LCC_MISSIONPACK $<" -$(Q)$(Q3LCC) -DMISSIONPACK -DUI -o $@ $< -endef - - Q3ASMOBJ = \ $(B)/tools/asm/q3asm.o \ $(B)/tools/asm/cmdlib.o @@ -1200,889 +769,219 @@ $(Q3ASM): $(Q3ASMOBJ) $(echo_cmd) "LD $@" $(Q)$(CC) $(TOOLS_CFLAGS) $(TOOLS_LDFLAGS) -o $@ $^ $(TOOLS_LIBS) - -############################################################################# -# CLIENT/SERVER -############################################################################# - -Q3OBJ = \ - $(B)/client/cl_cgame.o \ - $(B)/client/cl_cin.o \ - $(B)/client/cl_console.o \ - $(B)/client/cl_input.o \ - $(B)/client/cl_keys.o \ - $(B)/client/cl_main.o \ - $(B)/client/cl_net_chan.o \ - $(B)/client/cl_parse.o \ - $(B)/client/cl_scrn.o \ - $(B)/client/cl_ui.o \ - $(B)/client/cl_avi.o \ - \ - $(B)/client/cm_load.o \ - $(B)/client/cm_patch.o \ - $(B)/client/cm_polylib.o \ - $(B)/client/cm_test.o \ - $(B)/client/cm_trace.o \ - \ - $(B)/client/cmd.o \ - $(B)/client/common.o \ - $(B)/client/cvar.o \ - $(B)/client/files.o \ - $(B)/client/md4.o \ - $(B)/client/md5.o \ - $(B)/client/msg.o \ - $(B)/client/net_chan.o \ - $(B)/client/net_ip.o \ - $(B)/client/huffman.o \ - \ - $(B)/client/snd_adpcm.o \ - $(B)/client/snd_dma.o \ - $(B)/client/snd_mem.o \ - $(B)/client/snd_mix.o \ - $(B)/client/snd_wavelet.o \ - \ - $(B)/client/snd_main.o \ - $(B)/client/snd_codec.o \ - $(B)/client/snd_codec_wav.o \ - $(B)/client/snd_codec_ogg.o \ - \ - $(B)/client/qal.o \ - $(B)/client/snd_openal.o \ - \ - $(B)/client/cl_curl.o \ - \ - $(B)/client/sv_bot.o \ - $(B)/client/sv_ccmds.o \ - $(B)/client/sv_client.o \ - $(B)/client/sv_game.o \ - $(B)/client/sv_init.o \ - $(B)/client/sv_main.o \ - $(B)/client/sv_net_chan.o \ - $(B)/client/sv_snapshot.o \ - $(B)/client/sv_world.o \ - \ - $(B)/client/q_math.o \ - $(B)/client/q_shared.o \ - \ - $(B)/client/unzip.o \ - $(B)/client/puff.o \ - $(B)/client/vm.o \ - $(B)/client/vm_interpreted.o \ - \ - $(B)/client/be_aas_bspq3.o \ - $(B)/client/be_aas_cluster.o \ - $(B)/client/be_aas_debug.o \ - $(B)/client/be_aas_entity.o \ - $(B)/client/be_aas_file.o \ - $(B)/client/be_aas_main.o \ - $(B)/client/be_aas_move.o \ - $(B)/client/be_aas_optimize.o \ - $(B)/client/be_aas_reach.o \ - $(B)/client/be_aas_route.o \ - $(B)/client/be_aas_routealt.o \ - $(B)/client/be_aas_sample.o \ - $(B)/client/be_ai_char.o \ - $(B)/client/be_ai_chat.o \ - $(B)/client/be_ai_gen.o \ - $(B)/client/be_ai_goal.o \ - $(B)/client/be_ai_move.o \ - $(B)/client/be_ai_weap.o \ - $(B)/client/be_ai_weight.o \ - $(B)/client/be_ea.o \ - $(B)/client/be_interface.o \ - $(B)/client/l_crc.o \ - $(B)/client/l_libvar.o \ - $(B)/client/l_log.o \ - $(B)/client/l_memory.o \ - $(B)/client/l_precomp.o \ - $(B)/client/l_script.o \ - $(B)/client/l_struct.o \ - \ - $(B)/client/jcapimin.o \ - $(B)/client/jcapistd.o \ - $(B)/client/jccoefct.o \ - $(B)/client/jccolor.o \ - $(B)/client/jcdctmgr.o \ - $(B)/client/jchuff.o \ - $(B)/client/jcinit.o \ - $(B)/client/jcmainct.o \ - $(B)/client/jcmarker.o \ - $(B)/client/jcmaster.o \ - $(B)/client/jcomapi.o \ - $(B)/client/jcparam.o \ - $(B)/client/jcphuff.o \ - $(B)/client/jcprepct.o \ - $(B)/client/jcsample.o \ - $(B)/client/jdapimin.o \ - $(B)/client/jdapistd.o \ - $(B)/client/jdatasrc.o \ - $(B)/client/jdcoefct.o \ - $(B)/client/jdcolor.o \ - $(B)/client/jddctmgr.o \ - $(B)/client/jdhuff.o \ - $(B)/client/jdinput.o \ - $(B)/client/jdmainct.o \ - $(B)/client/jdmarker.o \ - $(B)/client/jdmaster.o \ - $(B)/client/jdpostct.o \ - $(B)/client/jdsample.o \ - $(B)/client/jdtrans.o \ - $(B)/client/jerror.o \ - $(B)/client/jfdctflt.o \ - $(B)/client/jidctflt.o \ - $(B)/client/jmemmgr.o \ - $(B)/client/jmemnobs.o \ - $(B)/client/jutils.o \ - \ - $(B)/client/tr_animation.o \ - $(B)/client/tr_backend.o \ - $(B)/client/tr_bsp.o \ - $(B)/client/tr_cmds.o \ - $(B)/client/tr_curve.o \ - $(B)/client/tr_flares.o \ - $(B)/client/tr_font.o \ - $(B)/client/tr_image.o \ - $(B)/client/tr_image_png.o \ - $(B)/client/tr_image_jpg.o \ - $(B)/client/tr_image_bmp.o \ - $(B)/client/tr_image_tga.o \ - $(B)/client/tr_image_pcx.o \ - $(B)/client/tr_init.o \ - $(B)/client/tr_light.o \ - $(B)/client/tr_main.o \ - $(B)/client/tr_marks.o \ - $(B)/client/tr_mesh.o \ - $(B)/client/tr_model.o \ - $(B)/client/tr_noise.o \ - $(B)/client/tr_scene.o \ - $(B)/client/tr_shade.o \ - $(B)/client/tr_shade_calc.o \ - $(B)/client/tr_shader.o \ - $(B)/client/tr_shadows.o \ - $(B)/client/tr_sky.o \ - $(B)/client/tr_surface.o \ - $(B)/client/tr_world.o \ - \ - $(B)/client/sdl_gamma.o \ - $(B)/client/sdl_input.o \ - $(B)/client/sdl_snd.o \ - \ - $(B)/client/con_passive.o \ - $(B)/client/con_log.o \ - $(B)/client/sys_main.o - -ifeq ($(ARCH),i386) - Q3OBJ += \ - $(B)/client/snd_mixa.o \ - $(B)/client/matha.o \ - $(B)/client/ftola.o \ - $(B)/client/snapvectora.o -endif -ifeq ($(ARCH),x86) - Q3OBJ += \ - $(B)/client/snd_mixa.o \ - $(B)/client/matha.o \ - $(B)/client/ftola.o \ - $(B)/client/snapvectora.o -endif - -ifeq ($(USE_VOIP),1) -ifeq ($(USE_INTERNAL_SPEEX),1) -Q3OBJ += \ - $(B)/client/bits.o \ - $(B)/client/buffer.o \ - $(B)/client/cb_search.o \ - $(B)/client/exc_10_16_table.o \ - $(B)/client/exc_10_32_table.o \ - $(B)/client/exc_20_32_table.o \ - $(B)/client/exc_5_256_table.o \ - $(B)/client/exc_5_64_table.o \ - $(B)/client/exc_8_128_table.o \ - $(B)/client/fftwrap.o \ - $(B)/client/filterbank.o \ - $(B)/client/filters.o \ - $(B)/client/gain_table.o \ - $(B)/client/gain_table_lbr.o \ - $(B)/client/hexc_10_32_table.o \ - $(B)/client/hexc_table.o \ - $(B)/client/high_lsp_tables.o \ - $(B)/client/jitter.o \ - $(B)/client/kiss_fft.o \ - $(B)/client/kiss_fftr.o \ - $(B)/client/lpc.o \ - $(B)/client/lsp.o \ - $(B)/client/lsp_tables_nb.o \ - $(B)/client/ltp.o \ - $(B)/client/mdf.o \ - $(B)/client/modes.o \ - $(B)/client/modes_wb.o \ - $(B)/client/nb_celp.o \ - $(B)/client/preprocess.o \ - $(B)/client/quant_lsp.o \ - $(B)/client/resample.o \ - $(B)/client/sb_celp.o \ - $(B)/client/smallft.o \ - $(B)/client/speex.o \ - $(B)/client/speex_callbacks.o \ - $(B)/client/speex_header.o \ - $(B)/client/stereo.o \ - $(B)/client/vbr.o \ - $(B)/client/vq.o \ - $(B)/client/window.o -endif -endif - - -ifeq ($(HAVE_VM_COMPILED),true) - ifeq ($(ARCH),i386) - Q3OBJ += $(B)/client/vm_x86.o - endif - ifeq ($(ARCH),x86) - Q3OBJ += $(B)/client/vm_x86.o - endif - ifeq ($(ARCH),x86_64) - Q3OBJ += $(B)/client/vm_x86_64.o $(B)/client/vm_x86_64_assembler.o - endif - ifeq ($(ARCH),ppc) - Q3OBJ += $(B)/client/vm_powerpc.o $(B)/client/vm_powerpc_asm.o - endif - ifeq ($(ARCH),ppc64) - Q3OBJ += $(B)/client/vm_powerpc.o $(B)/client/vm_powerpc_asm.o - endif - ifeq ($(ARCH),sparc) - Q3OBJ += $(B)/client/vm_sparc.o - endif -endif - -ifeq ($(PLATFORM),mingw32) - Q3OBJ += \ - $(B)/client/win_resource.o \ - $(B)/client/sys_win32.o -else - Q3OBJ += \ - $(B)/client/sys_unix.o -endif - -ifeq ($(USE_MUMBLE),1) - Q3OBJ += \ - $(B)/client/libmumblelink.o -endif - -Q3POBJ += \ - $(B)/client/sdl_glimp.o - -Q3POBJ_SMP += \ - $(B)/clientsmp/sdl_glimp.o - -$(B)/ioquake3.$(ARCH)$(BINEXT): $(Q3OBJ) $(Q3POBJ) $(LIBSDLMAIN) - $(echo_cmd) "LD $@" - $(Q)$(CC) $(CLIENT_CFLAGS) $(CFLAGS) $(CLIENT_LDFLAGS) $(LDFLAGS) \ - -o $@ $(Q3OBJ) $(Q3POBJ) \ - $(LIBSDLMAIN) $(CLIENT_LIBS) $(LIBS) - -$(B)/ioquake3-smp.$(ARCH)$(BINEXT): $(Q3OBJ) $(Q3POBJ_SMP) $(LIBSDLMAIN) - $(echo_cmd) "LD $@" - $(Q)$(CC) $(CLIENT_CFLAGS) $(CFLAGS) $(CLIENT_LDFLAGS) $(LDFLAGS) $(THREAD_LDFLAGS) \ - -o $@ $(Q3OBJ) $(Q3POBJ_SMP) \ - $(THREAD_LIBS) $(LIBSDLMAIN) $(CLIENT_LIBS) $(LIBS) - -ifneq ($(strip $(LIBSDLMAIN)),) -ifneq ($(strip $(LIBSDLMAINSRC)),) -$(LIBSDLMAIN) : $(LIBSDLMAINSRC) - cp $< $@ - ranlib $@ -endif -endif - - - -############################################################################# -# DEDICATED SERVER -############################################################################# - -Q3DOBJ = \ - $(B)/ded/sv_bot.o \ - $(B)/ded/sv_client.o \ - $(B)/ded/sv_ccmds.o \ - $(B)/ded/sv_game.o \ - $(B)/ded/sv_init.o \ - $(B)/ded/sv_main.o \ - $(B)/ded/sv_net_chan.o \ - $(B)/ded/sv_snapshot.o \ - $(B)/ded/sv_world.o \ - \ - $(B)/ded/cm_load.o \ - $(B)/ded/cm_patch.o \ - $(B)/ded/cm_polylib.o \ - $(B)/ded/cm_test.o \ - $(B)/ded/cm_trace.o \ - $(B)/ded/cmd.o \ - $(B)/ded/common.o \ - $(B)/ded/cvar.o \ - $(B)/ded/files.o \ - $(B)/ded/md4.o \ - $(B)/ded/msg.o \ - $(B)/ded/net_chan.o \ - $(B)/ded/net_ip.o \ - $(B)/ded/huffman.o \ - \ - $(B)/ded/q_math.o \ - $(B)/ded/q_shared.o \ - \ - $(B)/ded/unzip.o \ - $(B)/ded/vm.o \ - $(B)/ded/vm_interpreted.o \ - \ - $(B)/ded/be_aas_bspq3.o \ - $(B)/ded/be_aas_cluster.o \ - $(B)/ded/be_aas_debug.o \ - $(B)/ded/be_aas_entity.o \ - $(B)/ded/be_aas_file.o \ - $(B)/ded/be_aas_main.o \ - $(B)/ded/be_aas_move.o \ - $(B)/ded/be_aas_optimize.o \ - $(B)/ded/be_aas_reach.o \ - $(B)/ded/be_aas_route.o \ - $(B)/ded/be_aas_routealt.o \ - $(B)/ded/be_aas_sample.o \ - $(B)/ded/be_ai_char.o \ - $(B)/ded/be_ai_chat.o \ - $(B)/ded/be_ai_gen.o \ - $(B)/ded/be_ai_goal.o \ - $(B)/ded/be_ai_move.o \ - $(B)/ded/be_ai_weap.o \ - $(B)/ded/be_ai_weight.o \ - $(B)/ded/be_ea.o \ - $(B)/ded/be_interface.o \ - $(B)/ded/l_crc.o \ - $(B)/ded/l_libvar.o \ - $(B)/ded/l_log.o \ - $(B)/ded/l_memory.o \ - $(B)/ded/l_precomp.o \ - $(B)/ded/l_script.o \ - $(B)/ded/l_struct.o \ - \ - $(B)/ded/null_client.o \ - $(B)/ded/null_input.o \ - $(B)/ded/null_snddma.o \ - \ - $(B)/ded/con_log.o \ - $(B)/ded/sys_main.o - -ifeq ($(ARCH),i386) - Q3DOBJ += \ - $(B)/ded/ftola.o \ - $(B)/ded/snapvectora.o \ - $(B)/ded/matha.o -endif -ifeq ($(ARCH),x86) - Q3DOBJ += \ - $(B)/ded/ftola.o \ - $(B)/ded/snapvectora.o \ - $(B)/ded/matha.o -endif - -ifeq ($(HAVE_VM_COMPILED),true) - ifeq ($(ARCH),i386) - Q3DOBJ += $(B)/ded/vm_x86.o - endif - ifeq ($(ARCH),x86) - Q3DOBJ += $(B)/ded/vm_x86.o - endif - ifeq ($(ARCH),x86_64) - Q3DOBJ += $(B)/ded/vm_x86_64.o $(B)/ded/vm_x86_64_assembler.o - endif - ifeq ($(ARCH),ppc) - Q3DOBJ += $(B)/ded/vm_powerpc.o $(B)/ded/vm_powerpc_asm.o - endif - ifeq ($(ARCH),ppc64) - Q3DOBJ += $(B)/ded/vm_powerpc.o $(B)/ded/vm_powerpc_asm.o - endif - ifeq ($(ARCH),sparc) - Q3DOBJ += $(B)/ded/vm_sparc.o - endif -endif - -ifeq ($(PLATFORM),mingw32) - Q3DOBJ += \ - $(B)/ded/win_resource.o \ - $(B)/ded/sys_win32.o \ - $(B)/ded/con_win32.o -else - Q3DOBJ += \ - $(B)/ded/sys_unix.o \ - $(B)/ded/con_tty.o -endif - -$(B)/ioq3ded.$(ARCH)$(BINEXT): $(Q3DOBJ) - $(echo_cmd) "LD $@" - $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(Q3DOBJ) $(LIBS) - - - ############################################################################# ## BASEQ3 CGAME ############################################################################# Q3CGOBJ_ = \ - $(B)/baseq3/cgame/cg_main.o \ - $(B)/baseq3/game/bg_misc.o \ - $(B)/baseq3/game/bg_lib.o \ - $(B)/baseq3/game/bg_pmove.o \ - $(B)/baseq3/game/bg_slidemove.o \ - $(B)/baseq3/cgame/cg_challenges.o \ - $(B)/baseq3/cgame/cg_consolecmds.o \ - $(B)/baseq3/cgame/cg_draw.o \ - $(B)/baseq3/cgame/cg_drawtools.o \ - $(B)/baseq3/cgame/cg_effects.o \ - $(B)/baseq3/cgame/cg_ents.o \ - $(B)/baseq3/cgame/cg_event.o \ - $(B)/baseq3/cgame/cg_info.o \ - $(B)/baseq3/cgame/cg_localents.o \ - $(B)/baseq3/cgame/cg_marks.o \ - $(B)/baseq3/cgame/cg_players.o \ - $(B)/baseq3/cgame/cg_playerstate.o \ - $(B)/baseq3/cgame/cg_predict.o \ - $(B)/baseq3/cgame/cg_scoreboard.o \ - $(B)/baseq3/cgame/cg_servercmds.o \ - $(B)/baseq3/cgame/cg_snapshot.o \ - $(B)/baseq3/cgame/cg_unlagged.o \ - $(B)/baseq3/cgame/cg_view.o \ - $(B)/baseq3/cgame/cg_weapons.o \ + $(B)/baseia/cgame/cg_main.o \ + $(B)/baseia/game/bg_misc.o \ + $(B)/baseia/game/bg_lib.o \ + $(B)/baseia/game/bg_pmove.o \ + $(B)/baseia/game/bg_slidemove.o \ + $(B)/baseia/cgame/cg_challenges.o \ + $(B)/baseia/cgame/cg_consolecmds.o \ + $(B)/baseia/cgame/cg_draw.o \ + $(B)/baseia/cgame/cg_drawtools.o \ + $(B)/baseia/cgame/cg_effects.o \ + $(B)/baseia/cgame/cg_ents.o \ + $(B)/baseia/cgame/cg_event.o \ + $(B)/baseia/cgame/cg_info.o \ + $(B)/baseia/cgame/cg_localents.o \ + $(B)/baseia/cgame/cg_marks.o \ + $(B)/baseia/cgame/cg_players.o \ + $(B)/baseia/cgame/cg_playerstate.o \ + $(B)/baseia/cgame/cg_predict.o \ + $(B)/baseia/cgame/cg_scoreboard.o \ + $(B)/baseia/cgame/cg_servercmds.o \ + $(B)/baseia/cgame/cg_snapshot.o \ + $(B)/baseia/cgame/cg_unlagged.o \ + $(B)/baseia/cgame/cg_view.o \ + $(B)/baseia/cgame/cg_weapons.o \ \ - $(B)/baseq3/qcommon/q_math.o \ - $(B)/baseq3/qcommon/q_shared.o + $(B)/baseia/qcommon/q_math.o \ + $(B)/baseia/qcommon/q_shared.o -Q3CGOBJ = $(Q3CGOBJ_) $(B)/baseq3/cgame/cg_syscalls.o +Q3CGOBJ = $(Q3CGOBJ_) $(B)/baseia/cgame/cg_syscalls.o Q3CGVMOBJ = $(Q3CGOBJ_:%.o=%.asm) -$(B)/baseq3/cgame$(ARCH).$(SHLIBEXT): $(Q3CGOBJ) +$(B)/baseia/cgame$(ARCH).$(SHLIBEXT): $(Q3CGOBJ) $(echo_cmd) "LD $@" $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3CGOBJ) -$(B)/baseq3/vm/cgame.qvm: $(Q3CGVMOBJ) $(CGDIR)/cg_syscalls.asm $(Q3ASM) +$(B)/baseia/vm/cgame.qvm: $(Q3CGVMOBJ) $(CGDIR)/cg_syscalls.asm $(Q3ASM) $(echo_cmd) "Q3ASM $@" $(Q)$(Q3ASM) -o $@ $(Q3CGVMOBJ) $(CGDIR)/cg_syscalls.asm -############################################################################# -## MISSIONPACK CGAME -############################################################################# - -MPCGOBJ_ = \ - $(B)/missionpack/cgame/cg_main.o \ - $(B)/missionpack/game/bg_misc.o \ - $(B)/missionpack/game/bg_lib.o \ - $(B)/missionpack/game/bg_pmove.o \ - $(B)/missionpack/game/bg_slidemove.o \ - $(B)/missionpack/cgame/cg_challenges.o \ - $(B)/missionpack/cgame/cg_consolecmds.o \ - $(B)/missionpack/cgame/cg_newdraw.o \ - $(B)/missionpack/cgame/cg_draw.o \ - $(B)/missionpack/cgame/cg_drawtools.o \ - $(B)/missionpack/cgame/cg_effects.o \ - $(B)/missionpack/cgame/cg_ents.o \ - $(B)/missionpack/cgame/cg_event.o \ - $(B)/missionpack/cgame/cg_info.o \ - $(B)/missionpack/cgame/cg_localents.o \ - $(B)/missionpack/cgame/cg_marks.o \ - $(B)/missionpack/cgame/cg_players.o \ - $(B)/missionpack/cgame/cg_playerstate.o \ - $(B)/missionpack/cgame/cg_predict.o \ - $(B)/missionpack/cgame/cg_scoreboard.o \ - $(B)/missionpack/cgame/cg_servercmds.o \ - $(B)/missionpack/cgame/cg_snapshot.o \ - $(B)/missionpack/cgame/cg_unlagged.o \ - $(B)/missionpack/cgame/cg_view.o \ - $(B)/missionpack/cgame/cg_weapons.o \ - $(B)/missionpack/ui/ui_shared.o \ - \ - $(B)/missionpack/qcommon/q_math.o \ - $(B)/missionpack/qcommon/q_shared.o - -MPCGOBJ = $(MPCGOBJ_) $(B)/missionpack/cgame/cg_syscalls.o -MPCGVMOBJ = $(MPCGOBJ_:%.o=%.asm) - -$(B)/missionpack/cgame$(ARCH).$(SHLIBEXT): $(MPCGOBJ) - $(echo_cmd) "LD $@" - $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(MPCGOBJ) - -$(B)/missionpack/vm/cgame.qvm: $(MPCGVMOBJ) $(CGDIR)/cg_syscalls.asm $(Q3ASM) - $(echo_cmd) "Q3ASM $@" - $(Q)$(Q3ASM) -o $@ $(MPCGVMOBJ) $(CGDIR)/cg_syscalls.asm - - - ############################################################################# ## BASEQ3 GAME ############################################################################# Q3GOBJ_ = \ - $(B)/baseq3/game/g_main.o \ - $(B)/baseq3/game/ai_chat.o \ - $(B)/baseq3/game/ai_cmd.o \ - $(B)/baseq3/game/ai_dmnet.o \ - $(B)/baseq3/game/ai_dmq3.o \ - $(B)/baseq3/game/ai_main.o \ - $(B)/baseq3/game/ai_team.o \ - $(B)/baseq3/game/ai_vcmd.o \ - $(B)/baseq3/game/bg_misc.o \ - $(B)/baseq3/game/bg_lib.o \ - $(B)/baseq3/game/bg_pmove.o \ - $(B)/baseq3/game/bg_slidemove.o \ - $(B)/baseq3/game/g_active.o \ - $(B)/baseq3/game/g_arenas.o \ - $(B)/baseq3/game/g_admin.o \ - $(B)/baseq3/game/g_bot.o \ - $(B)/baseq3/game/g_client.o \ - $(B)/baseq3/game/g_cmds.o \ - $(B)/baseq3/game/g_cmds_ext.o \ - $(B)/baseq3/game/g_combat.o \ - $(B)/baseq3/game/g_items.o \ - $(B)/baseq3/game/bg_alloc.o \ - $(B)/baseq3/game/g_fileops.o \ - $(B)/baseq3/game/g_killspree.o \ - $(B)/baseq3/game/g_misc.o \ - $(B)/baseq3/game/g_missile.o \ - $(B)/baseq3/game/g_mover.o \ - $(B)/baseq3/game/g_playerstore.o \ - $(B)/baseq3/game/g_session.o \ - $(B)/baseq3/game/g_spawn.o \ - $(B)/baseq3/game/g_svcmds.o \ - $(B)/baseq3/game/g_svcmds_ext.o \ - $(B)/baseq3/game/g_target.o \ - $(B)/baseq3/game/g_team.o \ - $(B)/baseq3/game/g_trigger.o \ - $(B)/baseq3/game/g_unlagged.o \ - $(B)/baseq3/game/g_utils.o \ - $(B)/baseq3/game/g_vote.o \ - $(B)/baseq3/game/g_weapon.o \ + $(B)/baseia/game/g_main.o \ + $(B)/baseia/game/ai_chat.o \ + $(B)/baseia/game/ai_cmd.o \ + $(B)/baseia/game/ai_dmnet.o \ + $(B)/baseia/game/ai_dmq3.o \ + $(B)/baseia/game/ai_main.o \ + $(B)/baseia/game/ai_team.o \ + $(B)/baseia/game/bg_misc.o \ + $(B)/baseia/game/bg_lib.o \ + $(B)/baseia/game/bg_pmove.o \ + $(B)/baseia/game/bg_slidemove.o \ + $(B)/baseia/game/g_active.o \ + $(B)/baseia/game/g_arenas.o \ + $(B)/baseia/game/g_admin.o \ + $(B)/baseia/game/g_bot.o \ + $(B)/baseia/game/g_client.o \ + $(B)/baseia/game/g_cmds.o \ + $(B)/baseia/game/g_cmds_ext.o \ + $(B)/baseia/game/g_combat.o \ + $(B)/baseia/game/g_items.o \ + $(B)/baseia/game/bg_alloc.o \ + $(B)/baseia/game/g_fileops.o \ + $(B)/baseia/game/g_killspree.o \ + $(B)/baseia/game/g_misc.o \ + $(B)/baseia/game/g_missile.o \ + $(B)/baseia/game/g_mover.o \ + $(B)/baseia/game/g_playerstore.o \ + $(B)/baseia/game/g_session.o \ + $(B)/baseia/game/g_spawn.o \ + $(B)/baseia/game/g_svcmds.o \ + $(B)/baseia/game/g_svcmds_ext.o \ + $(B)/baseia/game/g_target.o \ + $(B)/baseia/game/g_team.o \ + $(B)/baseia/game/g_trigger.o \ + $(B)/baseia/game/g_unlagged.o \ + $(B)/baseia/game/g_utils.o \ + $(B)/baseia/game/g_vote.o \ + $(B)/baseia/game/g_weapon.o \ \ - $(B)/baseq3/qcommon/q_math.o \ - $(B)/baseq3/qcommon/q_shared.o + $(B)/baseia/qcommon/q_math.o \ + $(B)/baseia/qcommon/q_shared.o -Q3GOBJ = $(Q3GOBJ_) $(B)/baseq3/game/g_syscalls.o +Q3GOBJ = $(Q3GOBJ_) $(B)/baseia/game/g_syscalls.o Q3GVMOBJ = $(Q3GOBJ_:%.o=%.asm) -$(B)/baseq3/qagame$(ARCH).$(SHLIBEXT): $(Q3GOBJ) +$(B)/baseia/qagame$(ARCH).$(SHLIBEXT): $(Q3GOBJ) $(echo_cmd) "LD $@" $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3GOBJ) -$(B)/baseq3/vm/qagame.qvm: $(Q3GVMOBJ) $(GDIR)/g_syscalls.asm $(Q3ASM) +$(B)/baseia/vm/qagame.qvm: $(Q3GVMOBJ) $(GDIR)/g_syscalls.asm $(Q3ASM) $(echo_cmd) "Q3ASM $@" $(Q)$(Q3ASM) -o $@ $(Q3GVMOBJ) $(GDIR)/g_syscalls.asm -############################################################################# -## MISSIONPACK GAME -############################################################################# - -MPGOBJ_ = \ - $(B)/missionpack/game/g_main.o \ - $(B)/missionpack/game/ai_chat.o \ - $(B)/missionpack/game/ai_cmd.o \ - $(B)/missionpack/game/ai_dmnet.o \ - $(B)/missionpack/game/ai_dmq3.o \ - $(B)/missionpack/game/ai_main.o \ - $(B)/missionpack/game/ai_team.o \ - $(B)/missionpack/game/ai_vcmd.o \ - $(B)/missionpack/game/bg_misc.o \ - $(B)/missionpack/game/bg_lib.o \ - $(B)/missionpack/game/bg_pmove.o \ - $(B)/missionpack/game/bg_slidemove.o \ - $(B)/missionpack/game/g_active.o \ - $(B)/missionpack/game/g_admin.o \ - $(B)/missionpack/game/g_arenas.o \ - $(B)/missionpack/game/g_bot.o \ - $(B)/missionpack/game/g_client.o \ - $(B)/missionpack/game/g_cmds.o \ - $(B)/missionpack/game/g_cmds_ext.o \ - $(B)/missionpack/game/g_combat.o \ - $(B)/missionpack/game/g_items.o \ - $(B)/missionpack/game/bg_alloc.o \ - $(B)/missionpack/game/g_fileops.o \ - $(B)/missionpack/game/g_killspree.o \ - $(B)/missionpack/game/g_misc.o \ - $(B)/missionpack/game/g_missile.o \ - $(B)/missionpack/game/g_mover.o \ - $(B)/missionpack/game/g_playerstore.o \ - $(B)/missionpack/game/g_session.o \ - $(B)/missionpack/game/g_spawn.o \ - $(B)/missionpack/game/g_svcmds.o \ - $(B)/missionpack/game/g_svcmds_ext.o \ - $(B)/missionpack/game/g_target.o \ - $(B)/missionpack/game/g_team.o \ - $(B)/missionpack/game/g_trigger.o \ - $(B)/missionpack/game/g_unlagged.o \ - $(B)/missionpack/game/g_utils.o \ - $(B)/missionpack/game/g_vote.o \ - $(B)/missionpack/game/g_weapon.o \ - \ - $(B)/missionpack/qcommon/q_math.o \ - $(B)/missionpack/qcommon/q_shared.o - -MPGOBJ = $(MPGOBJ_) $(B)/missionpack/game/g_syscalls.o -MPGVMOBJ = $(MPGOBJ_:%.o=%.asm) - -$(B)/missionpack/qagame$(ARCH).$(SHLIBEXT): $(MPGOBJ) - $(echo_cmd) "LD $@" - $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(MPGOBJ) - -$(B)/missionpack/vm/qagame.qvm: $(MPGVMOBJ) $(GDIR)/g_syscalls.asm $(Q3ASM) - $(echo_cmd) "Q3ASM $@" - $(Q)$(Q3ASM) -o $@ $(MPGVMOBJ) $(GDIR)/g_syscalls.asm - - - ############################################################################# ## BASEQ3 UI ############################################################################# Q3UIOBJ_ = \ - $(B)/baseq3/ui/ui_main.o \ - $(B)/baseq3/game/bg_misc.o \ - $(B)/baseq3/game/bg_lib.o \ - $(B)/baseq3/ui/ui_addbots.o \ - $(B)/baseq3/ui/ui_atoms.o \ - $(B)/baseq3/ui/ui_cdkey.o \ - $(B)/baseq3/ui/ui_challenges.o \ - $(B)/baseq3/ui/ui_cinematics.o \ - $(B)/baseq3/ui/ui_confirm.o \ - $(B)/baseq3/ui/ui_connect.o \ - $(B)/baseq3/ui/ui_controls2.o \ - $(B)/baseq3/ui/ui_credits.o \ - $(B)/baseq3/ui/ui_demo2.o \ - $(B)/baseq3/ui/ui_display.o \ - $(B)/baseq3/ui/ui_firstconnect.o \ - $(B)/baseq3/ui/ui_gameinfo.o \ - $(B)/baseq3/ui/ui_ingame.o \ - $(B)/baseq3/ui/ui_loadconfig.o \ - $(B)/baseq3/ui/ui_menu.o \ - $(B)/baseq3/ui/ui_mfield.o \ - $(B)/baseq3/ui/ui_mods.o \ - $(B)/baseq3/ui/ui_network.o \ - $(B)/baseq3/ui/ui_options.o \ - $(B)/baseq3/ui/ui_password.o \ - $(B)/baseq3/ui/ui_playermodel.o \ - $(B)/baseq3/ui/ui_players.o \ - $(B)/baseq3/ui/ui_playersettings.o \ - $(B)/baseq3/ui/ui_preferences.o \ - $(B)/baseq3/ui/ui_qmenu.o \ - $(B)/baseq3/ui/ui_removebots.o \ - $(B)/baseq3/ui/ui_saveconfig.o \ - $(B)/baseq3/ui/ui_serverinfo.o \ - $(B)/baseq3/ui/ui_servers2.o \ - $(B)/baseq3/ui/ui_setup.o \ - $(B)/baseq3/ui/ui_sound.o \ - $(B)/baseq3/ui/ui_sparena.o \ - $(B)/baseq3/ui/ui_specifyserver.o \ - $(B)/baseq3/ui/ui_splevel.o \ - $(B)/baseq3/ui/ui_sppostgame.o \ - $(B)/baseq3/ui/ui_spskill.o \ - $(B)/baseq3/ui/ui_startserver.o \ - $(B)/baseq3/ui/ui_team.o \ - $(B)/baseq3/ui/ui_teamorders.o \ - $(B)/baseq3/ui/ui_video.o \ - $(B)/baseq3/ui/ui_votemenu.o \ - $(B)/baseq3/ui/ui_votemenu_fraglimit.o \ - $(B)/baseq3/ui/ui_votemenu_timelimit.o \ - $(B)/baseq3/ui/ui_votemenu_gametype.o \ - $(B)/baseq3/ui/ui_votemenu_kick.o \ - $(B)/baseq3/ui/ui_votemenu_map.o \ - $(B)/baseq3/ui/ui_votemenu_custom.o \ + $(B)/baseia/ui/ui_main.o \ + $(B)/baseia/game/bg_misc.o \ + $(B)/baseia/game/bg_lib.o \ + $(B)/baseia/ui/ui_addbots.o \ + $(B)/baseia/ui/ui_atoms.o \ + $(B)/baseia/ui/ui_cdkey.o \ + $(B)/baseia/ui/ui_challenges.o \ + $(B)/baseia/ui/ui_cinematics.o \ + $(B)/baseia/ui/ui_confirm.o \ + $(B)/baseia/ui/ui_connect.o \ + $(B)/baseia/ui/ui_controls2.o \ + $(B)/baseia/ui/ui_credits.o \ + $(B)/baseia/ui/ui_demo2.o \ + $(B)/baseia/ui/ui_display.o \ + $(B)/baseia/ui/ui_firstconnect.o \ + $(B)/baseia/ui/ui_gameinfo.o \ + $(B)/baseia/ui/ui_ingame.o \ + $(B)/baseia/ui/ui_loadconfig.o \ + $(B)/baseia/ui/ui_menu.o \ + $(B)/baseia/ui/ui_mfield.o \ + $(B)/baseia/ui/ui_mods.o \ + $(B)/baseia/ui/ui_network.o \ + $(B)/baseia/ui/ui_options.o \ + $(B)/baseia/ui/ui_password.o \ + $(B)/baseia/ui/ui_playermodel.o \ + $(B)/baseia/ui/ui_players.o \ + $(B)/baseia/ui/ui_playersettings.o \ + $(B)/baseia/ui/ui_preferences.o \ + $(B)/baseia/ui/ui_qmenu.o \ + $(B)/baseia/ui/ui_removebots.o \ + $(B)/baseia/ui/ui_saveconfig.o \ + $(B)/baseia/ui/ui_serverinfo.o \ + $(B)/baseia/ui/ui_servers2.o \ + $(B)/baseia/ui/ui_setup.o \ + $(B)/baseia/ui/ui_sound.o \ + $(B)/baseia/ui/ui_sparena.o \ + $(B)/baseia/ui/ui_specifyserver.o \ + $(B)/baseia/ui/ui_splevel.o \ + $(B)/baseia/ui/ui_sppostgame.o \ + $(B)/baseia/ui/ui_spskill.o \ + $(B)/baseia/ui/ui_startserver.o \ + $(B)/baseia/ui/ui_team.o \ + $(B)/baseia/ui/ui_teamorders.o \ + $(B)/baseia/ui/ui_video.o \ + $(B)/baseia/ui/ui_votemenu.o \ + $(B)/baseia/ui/ui_votemenu_fraglimit.o \ + $(B)/baseia/ui/ui_votemenu_timelimit.o \ + $(B)/baseia/ui/ui_votemenu_gametype.o \ + $(B)/baseia/ui/ui_votemenu_kick.o \ + $(B)/baseia/ui/ui_votemenu_map.o \ + $(B)/baseia/ui/ui_votemenu_custom.o \ \ - $(B)/baseq3/qcommon/q_math.o \ - $(B)/baseq3/qcommon/q_shared.o + $(B)/baseia/qcommon/q_math.o \ + $(B)/baseia/qcommon/q_shared.o -Q3UIOBJ = $(Q3UIOBJ_) $(B)/missionpack/ui/ui_syscalls.o +Q3UIOBJ = $(Q3UIOBJ_) Q3UIVMOBJ = $(Q3UIOBJ_:%.o=%.asm) -$(B)/baseq3/ui$(ARCH).$(SHLIBEXT): $(Q3UIOBJ) +$(B)/baseia/ui$(ARCH).$(SHLIBEXT): $(Q3UIOBJ) $(echo_cmd) "LD $@" $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(Q3UIOBJ) -$(B)/baseq3/vm/ui.qvm: $(Q3UIVMOBJ) $(UIDIR)/ui_syscalls.asm $(Q3ASM) +$(B)/baseia/vm/ui.qvm: $(Q3UIVMOBJ) $(UIDIR)/ui_syscalls.asm $(Q3ASM) $(echo_cmd) "Q3ASM $@" $(Q)$(Q3ASM) -o $@ $(Q3UIVMOBJ) $(UIDIR)/ui_syscalls.asm -############################################################################# -## MISSIONPACK UI -############################################################################# - -MPUIOBJ_ = \ - $(B)/missionpack/ui/ui_main.o \ - $(B)/missionpack/ui/ui_atoms.o \ - $(B)/missionpack/ui/ui_gameinfo.o \ - $(B)/missionpack/ui/ui_players.o \ - $(B)/missionpack/ui/ui_shared.o \ - \ - $(B)/missionpack/ui/bg_misc.o \ - $(B)/missionpack/ui/bg_lib.o \ - \ - $(B)/missionpack/qcommon/q_math.o \ - $(B)/missionpack/qcommon/q_shared.o - -MPUIOBJ = $(MPUIOBJ_) $(B)/missionpack/ui/ui_syscalls.o -MPUIVMOBJ = $(MPUIOBJ_:%.o=%.asm) - -$(B)/missionpack/ui$(ARCH).$(SHLIBEXT): $(MPUIOBJ) - $(echo_cmd) "LD $@" - $(Q)$(CC) $(CFLAGS) $(SHLIBLDFLAGS) -o $@ $(MPUIOBJ) - -$(B)/missionpack/vm/ui.qvm: $(MPUIVMOBJ) $(UIDIR)/ui_syscalls.asm $(Q3ASM) - $(echo_cmd) "Q3ASM $@" - $(Q)$(Q3ASM) -o $@ $(MPUIVMOBJ) $(UIDIR)/ui_syscalls.asm - - - -############################################################################# -## CLIENT/SERVER RULES -############################################################################# - -$(B)/client/%.o: $(ASMDIR)/%.s - $(DO_AS) - -$(B)/client/%.o: $(CDIR)/%.c - $(DO_CC) - -$(B)/client/%.o: $(SDIR)/%.c - $(DO_CC) - -$(B)/client/%.o: $(CMDIR)/%.c - $(DO_CC) - -$(B)/client/%.o: $(BLIBDIR)/%.c - $(DO_BOT_CC) - -$(B)/client/%.o: $(JPDIR)/%.c - $(DO_CC) - -$(B)/client/%.o: $(SPEEXDIR)/%.c - $(DO_CC) - -$(B)/client/%.o: $(RDIR)/%.c - $(DO_CC) - -$(B)/client/%.o: $(SDLDIR)/%.c - $(DO_CC) - -$(B)/clientsmp/%.o: $(SDLDIR)/%.c - $(DO_SMP_CC) - -$(B)/client/%.o: $(SYSDIR)/%.c - $(DO_CC) - -$(B)/client/%.o: $(SYSDIR)/%.rc - $(DO_WINDRES) - - -$(B)/ded/%.o: $(ASMDIR)/%.s - $(DO_AS) - -$(B)/ded/%.o: $(SDIR)/%.c - $(DO_DED_CC) - -$(B)/ded/%.o: $(CMDIR)/%.c - $(DO_DED_CC) - -$(B)/ded/%.o: $(BLIBDIR)/%.c - $(DO_BOT_CC) - -$(B)/ded/%.o: $(SYSDIR)/%.c - $(DO_DED_CC) - -$(B)/ded/%.o: $(SYSDIR)/%.rc - $(DO_WINDRES) - -$(B)/ded/%.o: $(NDIR)/%.c - $(DO_DED_CC) - -# Extra dependencies to ensure the SVN version is incorporated -ifeq ($(USE_SVN),1) - $(B)/client/cl_console.o : .svn/entries - $(B)/client/common.o : .svn/entries - $(B)/ded/common.o : .svn/entries -endif - - ############################################################################# ## GAME MODULE RULES ############################################################################# -$(B)/baseq3/cgame/bg_%.o: $(GDIR)/bg_%.c +$(B)/baseia/cgame/bg_%.o: $(GDIR)/bg_%.c $(DO_CGAME_CC) -$(B)/baseq3/cgame/%.o: $(CGDIR)/%.c +$(B)/baseia/cgame/%.o: $(CGDIR)/%.c $(DO_CGAME_CC) -$(B)/baseq3/cgame/bg_%.asm: $(GDIR)/bg_%.c $(Q3LCC) +$(B)/baseia/cgame/bg_%.asm: $(GDIR)/bg_%.c $(Q3LCC) $(DO_CGAME_Q3LCC) -$(B)/baseq3/cgame/%.asm: $(CGDIR)/%.c $(Q3LCC) +$(B)/baseia/cgame/%.asm: $(CGDIR)/%.c $(Q3LCC) $(DO_CGAME_Q3LCC) -$(B)/missionpack/cgame/bg_%.o: $(GDIR)/bg_%.c - $(DO_CGAME_CC_MISSIONPACK) - -$(B)/missionpack/cgame/%.o: $(CGDIR)/%.c - $(DO_CGAME_CC_MISSIONPACK) - -$(B)/missionpack/cgame/bg_%.asm: $(GDIR)/bg_%.c $(Q3LCC) - $(DO_CGAME_Q3LCC_MISSIONPACK) - -$(B)/missionpack/cgame/%.asm: $(CGDIR)/%.c $(Q3LCC) - $(DO_CGAME_Q3LCC_MISSIONPACK) - - -$(B)/baseq3/game/%.o: $(GDIR)/%.c +$(B)/baseia/game/%.o: $(GDIR)/%.c $(DO_GAME_CC) -$(B)/baseq3/game/%.asm: $(GDIR)/%.c $(Q3LCC) +$(B)/baseia/game/%.asm: $(GDIR)/%.c $(Q3LCC) $(DO_GAME_Q3LCC) -$(B)/missionpack/game/%.o: $(GDIR)/%.c - $(DO_GAME_CC_MISSIONPACK) - -$(B)/missionpack/game/%.asm: $(GDIR)/%.c $(Q3LCC) - $(DO_GAME_Q3LCC_MISSIONPACK) - - -$(B)/baseq3/ui/bg_%.o: $(GDIR)/bg_%.c +$(B)/baseia/ui/bg_%.o: $(GDIR)/bg_%.c $(DO_UI_CC) -$(B)/baseq3/ui/%.o: $(Q3UIDIR)/%.c +$(B)/baseia/ui/%.o: $(Q3UIDIR)/%.c $(DO_UI_CC) -$(B)/baseq3/ui/bg_%.asm: $(GDIR)/bg_%.c $(Q3LCC) +$(B)/baseia/ui/bg_%.asm: $(GDIR)/bg_%.c $(Q3LCC) $(DO_UI_Q3LCC) -$(B)/baseq3/ui/%.asm: $(Q3UIDIR)/%.c $(Q3LCC) +$(B)/baseia/ui/%.asm: $(Q3UIDIR)/%.c $(Q3LCC) $(DO_UI_Q3LCC) -$(B)/missionpack/ui/bg_%.o: $(GDIR)/bg_%.c - $(DO_UI_CC_MISSIONPACK) - -$(B)/missionpack/ui/%.o: $(UIDIR)/%.c - $(DO_UI_CC_MISSIONPACK) - -$(B)/missionpack/ui/bg_%.asm: $(GDIR)/bg_%.c $(Q3LCC) - $(DO_UI_Q3LCC_MISSIONPACK) - -$(B)/missionpack/ui/%.asm: $(UIDIR)/%.c $(Q3LCC) - $(DO_UI_Q3LCC_MISSIONPACK) - - -$(B)/baseq3/qcommon/%.o: $(CMDIR)/%.c +$(B)/baseia/qcommon/%.o: $(CMDIR)/%.c $(DO_SHLIB_CC) -$(B)/baseq3/qcommon/%.asm: $(CMDIR)/%.c $(Q3LCC) +$(B)/baseia/qcommon/%.asm: $(CMDIR)/%.c $(Q3LCC) $(DO_Q3LCC) -$(B)/missionpack/qcommon/%.o: $(CMDIR)/%.c - $(DO_SHLIB_CC_MISSIONPACK) - -$(B)/missionpack/qcommon/%.asm: $(CMDIR)/%.c $(Q3LCC) - $(DO_Q3LCC_MISSIONPACK) - - ############################################################################# # MISC ############################################################################# @@ -2094,52 +993,20 @@ TOOLSOBJ = $(LBURGOBJ) $(Q3CPPOBJ) $(Q3RCCOBJ) $(Q3LCCOBJ) $(Q3ASMOBJ) copyfiles: release - @if [ ! -d $(COPYDIR)/baseq3 ]; then echo "You need to set COPYDIR to where your Quake3 data is!"; fi - -$(MKDIR) -p -m 0755 $(COPYDIR)/baseq3 - -$(MKDIR) -p -m 0755 $(COPYDIR)/missionpack - -ifneq ($(BUILD_CLIENT),0) - $(INSTALL) -s -m 0755 $(BR)/ioquake3.$(ARCH)$(BINEXT) $(COPYDIR)/ioquake3.$(ARCH)$(BINEXT) -endif - -# Don't copy the SMP until it's working together with SDL. -#ifneq ($(BUILD_CLIENT_SMP),0) -# $(INSTALL) -s -m 0755 $(BR)/ioquake3-smp.$(ARCH)$(BINEXT) $(COPYDIR)/ioquake3-smp.$(ARCH)$(BINEXT) -#endif - -ifneq ($(BUILD_SERVER),0) - @if [ -f $(BR)/ioq3ded.$(ARCH)$(BINEXT) ]; then \ - $(INSTALL) -s -m 0755 $(BR)/ioq3ded.$(ARCH)$(BINEXT) $(COPYDIR)/ioq3ded.$(ARCH)$(BINEXT); \ - fi -endif + @if [ ! -d $(COPYDIR)/code ]; then echo "You need to set COPYDIR to where your I::A data is!"; fi + -$(MKDIR) -p -m 0755 $(COPYDIR)/code ifneq ($(BUILD_GAME_SO),0) - $(INSTALL) -s -m 0755 $(BR)/baseq3/cgame$(ARCH).$(SHLIBEXT) \ - $(COPYDIR)/baseq3/. - $(INSTALL) -s -m 0755 $(BR)/baseq3/qagame$(ARCH).$(SHLIBEXT) \ - $(COPYDIR)/baseq3/. - $(INSTALL) -s -m 0755 $(BR)/baseq3/ui$(ARCH).$(SHLIBEXT) \ - $(COPYDIR)/baseq3/. - ifneq ($(BUILD_MISSIONPACK),0) - -$(MKDIR) -p -m 0755 $(COPYDIR)/missionpack - $(INSTALL) -s -m 0755 $(BR)/missionpack/cgame$(ARCH).$(SHLIBEXT) \ - $(COPYDIR)/missionpack/. - $(INSTALL) -s -m 0755 $(BR)/missionpack/qagame$(ARCH).$(SHLIBEXT) \ - $(COPYDIR)/missionpack/. - $(INSTALL) -s -m 0755 $(BR)/missionpack/ui$(ARCH).$(SHLIBEXT) \ - $(COPYDIR)/missionpack/. - endif + $(INSTALL) -s -m 0755 $(BR)/baseia/cgame$(ARCH).$(SHLIBEXT) \ + $(COPYDIR)/baseia/. + $(INSTALL) -s -m 0755 $(BR)/baseia/qagame$(ARCH).$(SHLIBEXT) \ + $(COPYDIR)/baseia/. + $(INSTALL) -s -m 0755 $(BR)/baseia/ui$(ARCH).$(SHLIBEXT) \ + $(COPYDIR)/baseia/. endif clean: clean-debug clean-release -#We do not make installers -#ifeq ($(PLATFORM),mingw32) -# @$(MAKE) -C $(NSISDIR) clean -#else -# @$(MAKE) -C $(LOKISETUPDIR) clean -#endif - clean-debug: @$(MAKE) clean2 B=$(BD) @@ -2169,18 +1036,11 @@ toolsclean2: distclean: clean toolsclean @rm -rf $(BUILD_DIR) -installer: release -ifeq ($(PLATFORM),mingw32) - @$(MAKE) VERSION=$(VERSION) -C $(NSISDIR) V=$(V) -else - @$(MAKE) VERSION=$(VERSION) -C $(LOKISETUPDIR) V=$(V) -endif - dist: - rm -rf ioquake3-$(VERSION) - svn export . ioquake3-$(VERSION) - tar --owner=root --group=root --force-local -cjf ioquake3-$(VERSION).tar.bz2 ioquake3-$(VERSION) - rm -rf ioquake3-$(VERSION) + rm -rf ia-$(VERSION) + svn export . ia-$(VERSION) + tar --owner=root --group=root --force-local -cjf ia-$(VERSION).tar.bz2 ia-$(VERSION) + rm -rf ia-$(VERSION) ############################################################################# # DEPENDENCIES diff --git a/code/tools/asm/cmdlib.c b/code/tools/asm/cmdlib.c index de2610d..f927461 100644 --- a/code/tools/asm/cmdlib.c +++ b/code/tools/asm/cmdlib.c @@ -63,9 +63,9 @@ char *ex_argv[MAX_EX_ARGC]; void ExpandWildcards( int *argc, char ***argv ) { struct _finddata_t fileinfo; - int handle; + intptr_t handle; int i; - char filename[1024]; + char filename[2048]; char filebase[1024]; char *path; @@ -88,7 +88,7 @@ void ExpandWildcards( int *argc, char ***argv ) do { - sprintf (filename, "%s%s", filebase, fileinfo.name); + snprintf (filename, sizeof(filename), "%s%s", filebase, fileinfo.name); ex_argv[ex_argc++] = copystring (filename); } while (_findnext( handle, &fileinfo ) != -1); @@ -126,7 +126,7 @@ void Error( const char *error, ... ) vsprintf (text, error,argptr); va_end (argptr); - sprintf (text2, "%s\nGetLastError() = %i", text, err); + snprintf (text2, sizeof(text2), "%s\nGetLastError() = %i", text, err); MessageBox(NULL, text2, "Error", 0 /* MB_OK */ ); exit (1); @@ -185,7 +185,7 @@ void _printf( const char *format, ... ) { vsprintf (text, format, argptr); va_end (argptr); - printf(text); + printf("%s", text); #ifdef WIN32 if (!lookedForServer) { @@ -318,7 +318,7 @@ char *ExpandPath (const char *path) strcpy( full, path ); return full; } - sprintf (full, "%s%s", qdir, path); + snprintf (full, sizeof(full), "%s%s", qdir, path); return full; } @@ -331,20 +331,20 @@ char *ExpandGamePath (const char *path) strcpy( full, path ); return full; } - sprintf (full, "%s%s", gamedir, path); + snprintf (full, sizeof(full), "%s%s", gamedir, path); return full; } char *ExpandPathAndArchive (const char *path) { char *expanded; - char archivename[1024]; + char archivename[2048]; expanded = ExpandPath (path); if (archive) { - sprintf (archivename, "%s/%s", archivedir, path); + snprintf (archivename, sizeof(archivename), "%s/%s", archivedir, path); QCopyFile (expanded, archivename); } return expanded; @@ -396,10 +396,12 @@ void Q_getwd (char *out) int i = 0; #ifdef WIN32 - _getcwd (out, 256); + if (_getcwd (out, 256) == NULL) + strcpy(out, "."); /* shrug */ strcat (out, "\\"); #else - getcwd (out, 256); + if (getcwd (out, 256) == NULL) + strcpy(out, "."); /* shrug */ strcat (out, "/"); #endif @@ -732,7 +734,7 @@ int LoadFile( const char *filename, void **bufferptr ) ============== LoadFileBlock - -rounds up memory allocation to 4K boundry +rounds up memory allocation to 4K boundary - ============== */ @@ -808,7 +810,7 @@ void DefaultExtension (char *path, const char *extension) { char *src; // -// if path doesnt have a .EXT, append extension +// if path doesn't have a .EXT, append extension // (extension should include the .) // src = path + strlen(path) - 1; diff --git a/code/tools/asm/cmdlib.h b/code/tools/asm/cmdlib.h index c8ee460..3233abd 100644 --- a/code/tools/asm/cmdlib.h +++ b/code/tools/asm/cmdlib.h @@ -59,7 +59,7 @@ typedef unsigned char byte; #define MAX_OS_PATH 1024 #define MEM_BLOCKSIZE 4096 -// the dec offsetof macro doesnt work very well... +// the dec offsetof macro doesn't work very well... #define myoffsetof(type,identifier) ((size_t)&((type *)0)->identifier) @@ -71,7 +71,6 @@ char *strupr (char *in); char *strlower (char *in); int Q_strncasecmp( const char *s1, const char *s2, int n ); int Q_stricmp( const char *s1, const char *s2 ); -#define Q_strequal(s1,s2) (Q_stricmp(s1,s2)==0) void Q_getwd( char *out ); int Q_filelength (FILE *f); diff --git a/code/tools/asm/notes.txt b/code/tools/asm/notes.txt index 63297f3..571f8ca 100644 --- a/code/tools/asm/notes.txt +++ b/code/tools/asm/notes.txt @@ -1,5 +1,5 @@ -don't do any paramter conversion (double to float, etc) +don't do any parameter conversion (double to float, etc) diff --git a/code/tools/asm/q3asm.c b/code/tools/asm/q3asm.c index 8b2e183..bf6efd6 100644 --- a/code/tools/asm/q3asm.c +++ b/code/tools/asm/q3asm.c @@ -250,7 +250,6 @@ static void hashtable_init (hashtable_t *H, int buckets) { H->buckets = buckets; H->table = calloc(H->buckets, sizeof(*(H->table))); - return; } static hashtable_t *hashtable_new (int buckets) @@ -285,7 +284,6 @@ static void hashtable_add (hashtable_t *H, int hashvalue, void *datum) } hc->data = datum; hc->next = 0; - return; } static hashchain_t *hashtable_get (hashtable_t *H, int hashvalue) @@ -386,8 +384,12 @@ static void sort_symbols () symbol_t *s; symbol_t **symlist; + if(!symbols) + return; + //crumb("sort_symbols: Constructing symlist array\n"); for (elems = 0, s = symbols; s; s = s->next, elems++) /* nop */ ; + symlist = malloc(elems * sizeof(symbol_t*)); for (i = 0, s = symbols; s; s = s->next, i++) { @@ -475,7 +477,7 @@ static unsigned int HashString (const char *key) acc = (acc << 2) | (acc >> 30); acc &= 0xffffffffU; } - return abs(acc); + return acc; } @@ -489,10 +491,10 @@ static void CodeError( char *fmt, ... ) { errorCount++; - report( "%s:%i ", currentFileName, currentFileLine ); + fprintf( stderr, "%s:%i ", currentFileName, currentFileLine ); va_start( argptr,fmt ); - vprintf( fmt,argptr ); + vfprintf( stderr, fmt, argptr ); va_end( argptr ); } @@ -544,7 +546,7 @@ static void DefineSymbol( char *sym, int value ) { // add the file prefix to local symbols to guarantee unique if ( sym[0] == '$' ) { - sprintf( expanded, "%s_%i", sym, currentFileIndex ); + snprintf( expanded, sizeof(expanded), "%s_%i", sym, currentFileIndex ); sym = expanded; } @@ -600,7 +602,7 @@ static int LookupSymbol( char *sym ) { // add the file prefix to local symbols to guarantee unique if ( sym[0] == '$' ) { - sprintf( expanded, "%s_%i", sym, currentFileIndex ); + snprintf( expanded, sizeof(expanded), "%s_%i", sym, currentFileIndex ); sym = expanded; } @@ -786,7 +788,7 @@ HackToSegment BIG HACK: I want to put all 32 bit values in the data segment so they can be byte swapped, and all char data in the lit -segment, but switch jump tables are emited in the lit segment and +segment, but switch jump tables are emitted in the lit segment and initialized strng variables are put in the data segment. I can change segments here, but I also need to fixup the @@ -946,12 +948,11 @@ STAT("PROC"); ASM(ENDPROC) { - int v, v2; if ( !strcmp( token, "endproc" ) ) { STAT("ENDPROC"); Parse(); // skip the function name - v = ParseValue(); // locals - v2 = ParseValue(); // arg marshalling + ParseValue(); // locals + ParseValue(); // arg marshalling // all functions must leave something on the opstack instructionCount++; @@ -1128,7 +1129,7 @@ STAT("BYTE"); return 0; } - // code labels are emited as instruction counts, not byte offsets, + // code labels are emitted as instruction counts, not byte offsets, // because the physical size of the code will change with // different run time compilers and we want to minimize the // size of the required translation table @@ -1520,12 +1521,13 @@ static void ShowHelp( char *argv0 ) { Error("Usage: %s [OPTION]... [FILES]...\n\ Assemble LCC bytecode assembly to Q3VM bytecode.\n\ \n\ - -o OUTPUT Write assembled output to file OUTPUT.qvm\n\ - -f LISTFILE Read options and list of files to assemble from LISTFILE.q3asm\n\ - -b BUCKETS Set symbol hash table to BUCKETS buckets\n\ - -v Verbose compilation report\n\ - -vq3 Produce a qvm file compatible with Q3 1.32b\n\ - -h --help -? Show this help\n\ + -o OUTPUT Write assembled output to file OUTPUT.qvm\n\ + -f LISTFILE Read options and list of files to assemble from LISTFILE.q3asm\n\ + -b BUCKETS Set symbol hash table to BUCKETS buckets\n\ + -m Generate a mapfile for each OUTPUT.qvm\n\ + -v Verbose compilation report\n\ + -vq3 Produce a qvm file compatible with Q3 1.32b\n\ + -h --help -? Show this help\n\ ", argv0); } @@ -1562,7 +1564,7 @@ int main( int argc, char **argv ) { if ( !strcmp( argv[i], "-o" ) ) { if ( i == argc - 1 ) { - Error( "-o must preceed a filename" ); + Error( "-o must precede a filename" ); } /* Timbo of Tremulous pointed out -o not working; stock ID q3asm folded in the change. Yay. */ strcpy( outputFilename, argv[ i+1 ] ); @@ -1572,7 +1574,7 @@ int main( int argc, char **argv ) { if ( !strcmp( argv[i], "-f" ) ) { if ( i == argc - 1 ) { - Error( "-f must preceed a filename" ); + Error( "-f must precede a filename" ); } ParseOptionFile( argv[ i+1 ] ); i++; @@ -1618,7 +1620,7 @@ Motivation: not wanting to scrollback for pages to find asm error. } // In some case it Segfault without this check if ( numAsmFiles == 0 ) { - Error( "No file to assemble\n" ); + Error( "No file to assemble" ); } InitTables(); diff --git a/code/tools/lcc/cpp/cpp.c b/code/tools/lcc/cpp/cpp.c index 1fcffbc..13e0485 100644 --- a/code/tools/lcc/cpp/cpp.c +++ b/code/tools/lcc/cpp/cpp.c @@ -9,7 +9,7 @@ char rcsid[] = "cpp.c - faked rcsid"; #define OUTS 16384 char outbuf[OUTS]; -char *outp = outbuf; +char *outbufp = outbuf; Source *cursource; int nerrs; struct token nltoken = { NL, 0, 0, 0, 1, (uchar*)"\n" }; @@ -19,6 +19,15 @@ int ifdepth; int ifsatisfied[NIF]; int skipping; +time_t reproducible_time() +{ + char *source_date_epoch; + time_t t; + if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL || + (t = (time_t)strtol(source_date_epoch, NULL, 10)) <= 0) + return time(NULL); + return t; +} int main(int argc, char **argv) @@ -28,7 +37,7 @@ main(int argc, char **argv) char ebuf[BUFSIZ]; setbuf(stderr, ebuf); - t = time(NULL); + t = reproducible_time(); curtime = ctime(&t); maketokenrow(3, &tr); expandlex(); @@ -51,7 +60,7 @@ process(Tokenrow *trp) for (;;) { if (trp->tp >= trp->lp) { trp->tp = trp->lp = trp->bp; - outp = outbuf; + outbufp = outbuf; anymacros |= gettokens(trp, 1); trp->tp = trp->bp; } @@ -250,7 +259,6 @@ control(Tokenrow *trp) break; } setempty(trp); - return; } void * diff --git a/code/tools/lcc/cpp/cpp.h b/code/tools/lcc/cpp/cpp.h index 87871d9..ddd7502 100644 --- a/code/tools/lcc/cpp/cpp.h +++ b/code/tools/lcc/cpp/cpp.h @@ -143,7 +143,7 @@ void setobjname(char *); char *basepath( char *fname ); -extern char *outp; +extern char *outbufp; extern Token nltoken; extern Source *cursource; extern char *curtime; diff --git a/code/tools/lcc/cpp/include.c b/code/tools/lcc/cpp/include.c index 1bb8847..5ecd8b3 100644 --- a/code/tools/lcc/cpp/include.c +++ b/code/tools/lcc/cpp/include.c @@ -108,7 +108,6 @@ doinclude(Tokenrow *trp) return; syntax: error(ERROR, "Syntax error in #include"); - return; } /* @@ -121,7 +120,7 @@ genline(void) static Tokenrow tr = { &ta, &ta, &ta+1, 1 }; uchar *p; - ta.t = p = (uchar*)outp; + ta.t = p = (uchar*)outbufp; strcpy((char*)p, "#line "); p += sizeof("#line ")-1; p = (uchar*)outnum((char*)p, cursource->line); @@ -134,8 +133,8 @@ genline(void) strcpy((char*)p, cursource->filename); p += strlen((char*)p); *p++ = '"'; *p++ = '\n'; - ta.len = (char*)p-outp; - outp = (char*)p; + ta.len = (char*)p-outbufp; + outbufp = (char*)p; tr.tp = tr.bp; puttokens(&tr); } diff --git a/code/tools/lcc/cpp/lex.c b/code/tools/lcc/cpp/lex.c index 8030354..66092e1 100644 --- a/code/tools/lcc/cpp/lex.c +++ b/code/tools/lcc/cpp/lex.c @@ -511,6 +511,25 @@ foldline(Source *s) return 0; } +// This doesn't have proper tracking across read() to only remove \r from \r\n sequence. +// The lexer doesn't correctly handle standalone \r anyway though. +int +crlf_to_lf(unsigned char *buf, int n) { + int i, count; + + count = 0; + + for (i = 0; i < n; i++) { + if (buf[i] == '\r') { + continue; + } + + buf[count++] = buf[i]; + } + + return count; +} + int fillbuf(Source *s) { @@ -521,6 +540,7 @@ fillbuf(Source *s) error(FATAL, "Input buffer overflow"); if (s->fd<0 || (n=read(s->fd, (char *)s->inl, INS/8)) <= 0) n = 0; + n = crlf_to_lf(s->inl, n); if ((*s->inp&0xff) == EOB) /* sentinel character appears in input */ *s->inp = EOFC; s->inl += n; diff --git a/code/tools/lcc/cpp/macro.c b/code/tools/lcc/cpp/macro.c index 49d1129..2972083 100644 --- a/code/tools/lcc/cpp/macro.c +++ b/code/tools/lcc/cpp/macro.c @@ -218,7 +218,6 @@ expand(Tokenrow *trp, Nlist *np) insertrow(trp, ntokc, &ntr); trp->tp -= rowlen(&ntr); dofree(ntr.bp); - return; } /* @@ -471,10 +470,10 @@ builtin(Tokenrow *trp, int biname) /* most are strings */ tp->type = STRING; if (tp->wslen) { - *outp++ = ' '; + *outbufp++ = ' '; tp->wslen = 1; } - op = outp; + op = outbufp; *op++ = '"'; switch (biname) { @@ -509,7 +508,7 @@ builtin(Tokenrow *trp, int biname) } if (tp->type==STRING) *op++ = '"'; - tp->t = (uchar*)outp; - tp->len = op - outp; - outp = op; + tp->t = (uchar*)outbufp; + tp->len = op - outbufp; + outbufp = op; } diff --git a/code/tools/lcc/cpp/tokens.c b/code/tools/lcc/cpp/tokens.c index 147569b..964453c 100644 --- a/code/tools/lcc/cpp/tokens.c +++ b/code/tools/lcc/cpp/tokens.c @@ -267,7 +267,7 @@ peektokens(Tokenrow *trp, char *str) if (str) fprintf(stderr, "%s ", str); if (tpbp || tp>trp->lp) - fprintf(stderr, "(tp offset %d) ", tp-trp->bp); + fprintf(stderr, "(tp offset %ld) ", (long int) (tp - trp->bp)); for (tp=trp->bp; tplp && tpbp+32; tp++) { if (tp->type!=NL) { int c = tp->t[tp->len]; @@ -315,7 +315,7 @@ puttokens(Tokenrow *trp) if (wbp >= &wbuf[OBS]) { write(1, wbuf, OBS); if (wbp > &wbuf[OBS]) - memcpy(wbuf, wbuf+OBS, wbp - &wbuf[OBS]); + memmove(wbuf, wbuf+OBS, wbp - &wbuf[OBS]); wbp -= OBS; } } diff --git a/code/tools/lcc/cpp/unix.c b/code/tools/lcc/cpp/unix.c index 17986d8..56f1fff 100644 --- a/code/tools/lcc/cpp/unix.c +++ b/code/tools/lcc/cpp/unix.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "cpp.h" extern int lcc_getopt(int, char *const *, const char *); @@ -64,11 +65,22 @@ setup(int argc, char **argv) fp = (char*)newstring((uchar*)argv[optind], strlen(argv[optind]), 0); if ((fd = open(fp, 0)) <= 0) error(FATAL, "Can't open input file %s", fp); +#ifdef WIN32 + _setmode(fd, _O_BINARY); +#endif } if (optind+1A Ret C Compiler). These assumptions simplified the compiler, and were suitable for 32-bit architectures. But on 64-bit architectures, such as the DEC ALPHA, it's natural to have four sizes of integers and perhaps three sizes of floats, and on 16-bit -architectures, 32-bit pointers don't fit in unsigned integers. Also, the 3.x constaints +architectures, 32-bit pointers don't fit in unsigned integers. Also, the 3.x constraints limited the use of lcc's back ends for other languages, such as Java.

Version 4.x removes all of these restrictions: It supports any number of sizes for @@ -99,7 +99,7 @@ the symbol's type field.

5.5 Dag Operators

-

The op field a of node structure holds a dag operator, which +

The op field of a node structure holds a dag operator, which consists of a generic operator, a type suffix, and a size indicator. The type suffixes are:

@@ -516,14 +516,14 @@ e.g.,

The type suffix for a conversion operator denotes the type of the result and the size indicator gives the size of the result. For example, CVUI4 converts an unsigned (U) to a 4-byte signed integer (I4). The syms[0] -field points to a symbol-table entry for a integer constant that gives the size of the +field points to a symbol-table entry for an integer constant that gives the size of the source operand. For example, if syms[0] in a CVUI4 points to a symbol-table entry for 2, the conversion widens a 2-byte unsigned integer to a 4-byte signed integer. Conversions that widen unsigned integers zero-extend; those that widen signed integers sign-extend.

The front end composes conversions between types T1 and T2 -by widening T1 to it's "supertype", if necessary, converting +by widening T1 to its "supertype", if necessary, converting that result to T2's supertype, then narrowing the result to T2, if necessary. The following table lists the supertypes; omitted entries are their own supertypes.

diff --git a/code/tools/lcc/doc/install.html b/code/tools/lcc/doc/install.html index 3cc59a8..3410e8f 100644 --- a/code/tools/lcc/doc/install.html +++ b/code/tools/lcc/doc/install.html @@ -722,7 +722,7 @@ C:\dist\lcc\4.1>copy %BUILDDIR%\bprint.exe \bin

Reporting Bugs

lcc is a large, complex program. We find and repair errors routinely. If you think that -you've found a error, follow the steps below, which are adapted from the instructions in +you've found an error, follow the steps below, which are adapted from the instructions in Chapter 1 of A Retargetable C Compiler: Design and Implementation.

    @@ -751,7 +751,7 @@ Chapter 1 of A Retargetable C Compiler: Design and Implementation. HREF="ftp://ftp.cs.princeton.edu/pub/lcc">pub/lcc. A README file there gives acquistion details, and the LOG file reports what errors - were fixed and when they were fixed. If you report a error that's been fixed, you might + were fixed and when they were fixed. If you report an error that's been fixed, you might get a canned reply.
  1. Send your program by electronic mail to lcc-bugs@cs.princeton.edu. Please send only valid C programs; put all remarks in C comments so that we can process reports diff --git a/code/tools/lcc/etc/bytecode.c b/code/tools/lcc/etc/bytecode.c index fe4178f..4a2fe44 100644 --- a/code/tools/lcc/etc/bytecode.c +++ b/code/tools/lcc/etc/bytecode.c @@ -34,9 +34,14 @@ void UpdatePaths( const char *lccBinary ) { char basepath[ 1024 ]; char *p; + size_t basepathsz = sizeof( basepath ) - 1; - strncpy( basepath, lccBinary, 1024 ); - p = strrchr( basepath, PATH_SEP ); + strncpy( basepath, lccBinary, basepathsz ); + basepath[basepathsz] = 0; + p = strrchr( basepath, '/' ); + + if( !p ) + p = strrchr( basepath, '\\' ); if( p ) { @@ -52,6 +57,10 @@ int option(char *arg) { cpp[0] = concat(&arg[8], "/q3cpp" BINEXT); include[0] = concat("-I", concat(&arg[8], "/include")); com[0] = concat(&arg[8], "/q3rcc" BINEXT); + } else if (strncmp(arg, "-lcppdir=", 9) == 0) { + cpp[0] = concat(&arg[9], "/q3cpp" BINEXT); + } else if (strncmp(arg, "-lrccdir=", 9) == 0) { + com[0] = concat(&arg[9], "/q3rcc" BINEXT); } else if (strcmp(arg, "-p") == 0 || strcmp(arg, "-pg") == 0) { fprintf( stderr, "no profiling supported, %s ignored.\n", arg); } else if (strcmp(arg, "-b") == 0) diff --git a/code/tools/lcc/etc/lcc.c b/code/tools/lcc/etc/lcc.c index 13ed690..1ff51c5 100644 --- a/code/tools/lcc/etc/lcc.c +++ b/code/tools/lcc/etc/lcc.c @@ -11,7 +11,12 @@ static char rcsid[] = "Id: dummy rcsid"; #include #include #include +#ifdef WIN32 +#include /* getpid() */ +#include /* access() */ +#else #include +#endif #ifndef TEMPDIR #define TEMPDIR "/tmp" @@ -217,14 +222,74 @@ char *basename(char *name) { #ifdef WIN32 #include + +static char *escapeDoubleQuotes(const char *string) { + int stringLength = strlen(string); + int bufferSize = stringLength + 1; + int i, j; + char *newString; + + if (string == NULL) + return NULL; + + for (i = 0; i < stringLength; i++) { + if (string[i] == '"') + bufferSize++; + } + + newString = (char*)malloc(bufferSize); + + if (newString == NULL) + return NULL; + + for (i = 0, j = 0; i < stringLength; i++) { + if (string[i] == '"') + newString[j++] = '\\'; + + newString[j++] = string[i]; + } + + newString[j] = '\0'; + + return newString; +} + +static int spawn(const char *cmdname, char **argv) { + int argc = 0; + char **newArgv = argv; + int i; + intptr_t exitStatus; + + // _spawnvp removes double quotes from arguments, so we + // have to escape them manually + while (*newArgv++ != NULL) + argc++; + + newArgv = (char **)malloc(sizeof(char*) * (argc + 1)); + + for (i = 0; i < argc; i++) + newArgv[i] = escapeDoubleQuotes(argv[i]); + + newArgv[argc] = NULL; + + exitStatus = _spawnvp(_P_WAIT, cmdname, (const char *const *)newArgv); + + for (i = 0; i < argc; i++) + free(newArgv[i]); + + free(newArgv); + return exitStatus; +} + #else + #define _P_WAIT 0 #ifndef __sun extern int fork(void); #endif extern int wait(int *); -static int _spawnvp(int mode, const char *cmdname, char *argv[]) { +static int spawn(const char *cmdname, char **argv) { int pid, n, status; switch (pid = fork()) { @@ -292,11 +357,7 @@ static int callsys(char **av) { fprintf(stderr, "\n"); } if (verbose < 2) -#ifndef WIN32 - status = _spawnvp(_P_WAIT, executable, argv); -#else - status = _spawnvp(_P_WAIT, executable, (const char* const*)argv); -#endif + status = spawn(executable, argv); if (status == -1) { fprintf(stderr, "%s: ", progname); perror(argv[0]); @@ -376,7 +437,7 @@ static char *exists(char *name) { b = b->link; if (b->str[0]) { char buf[1024]; - sprintf(buf, "%s/%s", b->str, name); + snprintf(buf, sizeof(buf), "%s/%s", b->str, name); if (access(buf, 4) == 0) return strsave(buf); } else if (access(name, 4) == 0) @@ -575,7 +636,7 @@ static void opt(char *arg) { clist = append(&arg[3], clist); return; } - break; /* and fall thru */ + break; /* and fall through */ case 'a': alist = append(&arg[3], alist); return; @@ -757,10 +818,9 @@ char *strsave(const char *str) { char *stringf(const char *fmt, ...) { char buf[1024]; va_list ap; - int n; va_start(ap, fmt); - n = vsprintf(buf, fmt, ap); + vsprintf(buf, fmt, ap); va_end(ap); return strsave(buf); } diff --git a/code/tools/lcc/lburg/gram.c b/code/tools/lcc/lburg/gram.c index a1cc890..463581e 100644 --- a/code/tools/lcc/lburg/gram.c +++ b/code/tools/lcc/lburg/gram.c @@ -1,262 +1,1545 @@ -#if defined(__STDC__) || defined(__cplusplus) -#define YYCONST const -#define YYPARAMS(x) x -#define YYDEFUN(name, arglist, args) name(args) -#define YYAND , -#define YYPTR void * -#else -#define YYCONST -#define YYPARAMS(x) () -#define YYDEFUN(name, arglist, args) name arglist args; -#define YYAND ; -#define YYPTR char * -#endif -#ifndef lint -YYCONST static char yysccsid[] = "@(#)yaccpar 1.8 (Berkeley +Cygnus.28) 01/20/91"; -#endif -#define YYBYACC 1 -#ifndef YYDONT_INCLUDE_STDIO -#include -#endif -//#ifdef __cplusplus TA stdlib.h applies to C too -#include /* for malloc/realloc/free */ -//#endif -#line 2 "lburg/gram.y" +/* A Bison parser, made by GNU Bison 3.0.2. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "3.0.2" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 0 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + + + + +/* Copy the first part of user declarations. */ +#line 1 "code/tools/lcc/lburg/gram.y" /* yacc.c:339 */ + #include #include "lburg.h" +//static char rcsid[] = "$Id: gram.y 145 2001-10-17 21:53:10Z timo $"; /*lint -e616 -e527 -e652 -esym(552,yynerrs) -esym(563,yynewstate,yyerrlab) */ static int yylineno = 0; -#line 8 "lburg/gram.y" -typedef union { + +#line 74 "y.tab.c" /* yacc.c:339 */ + +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + + +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int yydebug; +#endif + +/* Token type. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + enum yytokentype + { + TERMINAL = 258, + START = 259, + PPERCENT = 260, + ID = 261, + TEMPLATE = 262, + CODE = 263, + INT = 264 + }; +#endif +/* Tokens. */ +#define TERMINAL 258 +#define START 259 +#define PPERCENT 260 +#define ID 261 +#define TEMPLATE 262 +#define CODE 263 +#define INT 264 + +/* Value type. */ +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE YYSTYPE; +union YYSTYPE +{ +#line 8 "code/tools/lcc/lburg/gram.y" /* yacc.c:355 */ + int n; char *string; Tree tree; -} YYSTYPE; -#line 37 "y.tab.c" -#define TERMINAL 257 -#define START 258 -#define PPERCENT 259 -#define ID 260 -#define TEMPLATE 261 -#define CODE 262 -#define INT 263 -#define YYERRCODE 256 -static YYCONST short yylhs[] = { -1, - 0, 0, 4, 4, 6, 6, 6, 6, 7, 7, - 5, 5, 5, 5, 1, 3, 3, 3, 2, -}; -static YYCONST short yylen[] = { 2, - 3, 1, 0, 2, 3, 3, 1, 2, 0, 4, - 0, 7, 2, 3, 1, 1, 4, 6, 1, -}; -static YYCONST short yydefred[] = { 3, - 0, 0, 0, 9, 0, 11, 7, 4, 8, 0, - 15, 0, 0, 0, 5, 6, 0, 13, 0, 0, - 14, 0, 10, 0, 0, 0, 0, 0, 19, 0, - 17, 0, 12, 0, 18, -}; -static YYCONST short yydgoto[] = { 1, - 12, 30, 25, 2, 13, 8, 10, -}; -static YYCONST short yysindex[] = { 0, - 0, -4, -2, 0, -250, 0, 0, 0, 0, -9, - 0, 1, -10, -49, 0, 0, 3, 0, -44, -248, - 0, -244, 0, -22, -242, -244, -245, -37, 0, 10, - 0, -244, 0, -20, 0, -}; -static YYCONST short yyrindex[] = { 0, - 0, 22, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 23, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, -39, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, -}; -static YYCONST short yygindex[] = { 0, - 11, 0, -23, 0, 0, 0, 0, -}; -#define YYTABLESIZE 255 -static YYCONST short yytable[] = { 18, - 15, 16, 28, 31, 16, 7, 32, 9, 34, 11, - 16, 20, 21, 22, 23, 24, 29, 26, 27, 33, - 35, 2, 1, 19, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 16, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 17, 0, 0, 0, 11, - 14, 3, 4, 5, 6, -}; -static YYCONST short yycheck[] = { 10, - 10, 41, 26, 41, 44, 10, 44, 10, 32, 260, - 10, 61, 10, 58, 263, 260, 262, 40, 261, 10, - 41, 0, 0, 13, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 261, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 256, -1, -1, -1, 260, - 260, 256, 257, 258, 259, -}; -#define YYFINAL 1 -#ifndef YYDEBUG -#define YYDEBUG 0 -#endif -#define YYMAXTOKEN 263 -#if YYDEBUG -static YYCONST char *YYCONST yyname[] = { -"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,"':'",0,0, -"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -"TERMINAL","START","PPERCENT","ID","TEMPLATE","CODE","INT", -}; -static YYCONST char *YYCONST yyrule[] = { -"$accept : spec", -"spec : decls PPERCENT rules", -"spec : decls", -"decls :", -"decls : decls decl", -"decl : TERMINAL blist '\\n'", -"decl : START nonterm '\\n'", -"decl : '\\n'", -"decl : error '\\n'", -"blist :", -"blist : blist ID '=' INT", -"rules :", -"rules : rules nonterm ':' tree TEMPLATE cost '\\n'", -"rules : rules '\\n'", -"rules : rules error '\\n'", -"nonterm : ID", -"tree : ID", -"tree : ID '(' tree ')'", -"tree : ID '(' tree ',' tree ')'", -"cost : CODE", -}; -#endif -#define YYLEX yylex() -#define YYEMPTY -1 -#define yyclearin (yychar=(YYEMPTY)) -#define yyerrok (yyerrflag=0) -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif -#ifdef YYSTACKSIZE -#ifndef YYMAXDEPTH -#define YYMAXDEPTH YYSTACKSIZE -#endif -#else -#ifdef YYMAXDEPTH -#define YYSTACKSIZE YYMAXDEPTH -#else -#define YYSTACKSIZE 500 -#define YYMAXDEPTH 500 -#endif -#endif -#ifndef YYMAXSTACKSIZE -#define YYMAXSTACKSIZE 10000 -#endif -int yydebug; -int yynerrs; -int yyerrflag; -int yychar; -YYSTYPE yyval; -YYSTYPE yylval; -static short *yyss; -static YYSTYPE *yyvs; -static int yystacksize; -#define yyfree(x) free(x) -extern int yylex(); -static YYPTR -YYDEFUN (yymalloc, (bytes), unsigned bytes) +#line 135 "y.tab.c" /* yacc.c:355 */ +}; +# define YYSTYPE_IS_TRIVIAL 1 +# define YYSTYPE_IS_DECLARED 1 +#endif + + +extern YYSTYPE yylval; + +int yyparse (void); +int yylex(void); + + + +/* Copy the second part of user declarations. */ + +#line 150 "y.tab.c" /* yacc.c:358 */ + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#else +typedef signed char yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if defined YYENABLE_NLS && YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) +# endif +# endif +# ifndef YY_ +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(E) ((void) (E)) +#else +# define YYUSE(E) /* empty */ +#endif + +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") +#else +# define YY_INITIAL_VALUE(Value) Value +#endif +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END +#endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS +# include /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined EXIT_SUCCESS +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined EXIT_SUCCESS +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc { - YYPTR ptr = (YYPTR) malloc (bytes); - if (ptr != 0) return (ptr); - yyerror ("yyparse: memory exhausted"); - return (0); + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +# define YYCOPY_NEEDED 1 + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) + +#endif + +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 3 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 35 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 16 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 9 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 20 +/* YYNSTATES -- Number of states. */ +#define YYNSTATES 37 + +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 264 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 10, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 13, 14, 2, 2, 15, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 12, 2, + 2, 11, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9 +}; + +#if YYDEBUG + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ +static const yytype_uint8 yyrline[] = +{ + 0, 22, 22, 23, 26, 27, 30, 31, 35, 36, + 39, 40, 43, 44, 45, 46, 49, 52, 53, 54, + 57 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || 0 +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "TERMINAL", "START", "PPERCENT", "ID", + "TEMPLATE", "CODE", "INT", "'\\n'", "'='", "':'", "'('", "')'", "','", + "$accept", "spec", "decls", "decl", "blist", "rules", "nonterm", "tree", + "cost", YY_NULLPTR +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 10, 61, 58, 40, 41, 44 +}; +# endif + +#define YYPACT_NINF -26 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-26))) + +#define YYTABLE_NINF -4 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int8 yypact[] = +{ + -26, 11, 0, -26, 5, -26, 8, -26, -26, -26, + -26, 3, -26, 7, 6, 9, -26, -26, 12, -26, + 13, 14, -26, 15, -26, 16, 17, 15, 18, 4, + -26, 20, -26, 15, -26, 19, -26 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 4, 0, 0, 1, 0, 10, 0, 12, 8, 5, + 9, 0, 16, 0, 0, 0, 6, 7, 0, 14, + 0, 0, 15, 0, 11, 17, 0, 0, 0, 0, + 20, 0, 18, 0, 13, 0, 19 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -26, -26, -26, -26, -26, -26, 21, -25, -26 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 1, 2, 9, 11, 14, 13, 26, 31 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int8 yytable[] = +{ + -3, 4, 29, 5, 6, 7, -2, 18, 35, 15, + 8, 3, 12, 16, 12, 10, 19, 17, 32, 33, + 21, 25, 22, 24, 28, 23, 30, 0, 0, 27, + 34, 0, 0, 36, 0, 20 +}; + +static const yytype_int8 yycheck[] = +{ + 0, 1, 27, 3, 4, 5, 0, 1, 33, 6, + 10, 0, 6, 10, 6, 10, 10, 10, 14, 15, + 11, 6, 10, 9, 7, 12, 8, -1, -1, 13, + 10, -1, -1, 14, -1, 14 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 17, 18, 0, 1, 3, 4, 5, 10, 19, + 10, 20, 6, 22, 21, 6, 10, 10, 1, 10, + 22, 11, 10, 12, 9, 6, 23, 13, 7, 23, + 8, 24, 14, 15, 10, 23, 14 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 16, 17, 17, 18, 18, 19, 19, 19, 19, + 20, 20, 21, 21, 21, 21, 22, 23, 23, 23, + 24 +}; + + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 3, 1, 0, 2, 3, 3, 1, 2, + 0, 4, 0, 7, 2, 3, 1, 1, 4, 6, + 1 +}; + + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 + + + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) + +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif + + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ + +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +{ + FILE *yyo = yyoutput; + YYUSE (yyo); + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# endif + YYUSE (yytype); } -static YYPTR -YYDEFUN (yyrealloc, (old, bytes), YYPTR old YYAND unsigned bytes) + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { - YYPTR ptr = (YYPTR) realloc (old, bytes); - if (ptr != 0) return (ptr); - yyerror ("yyparse: memory exhausted"); - return (0); + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); } -static int -#ifdef __GNUC__ -inline -#endif -yygrow () -{ -#if YYDEBUG - int old_stacksize = yystacksize; -#endif - short *new_yyss; - YYSTYPE *new_yyvs; +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ - if (yystacksize == YYMAXSTACKSIZE) - return (1); - yystacksize += (yystacksize + 1 ) / 2; - if (yystacksize > YYMAXSTACKSIZE) - yystacksize = YYMAXSTACKSIZE; -#if YYDEBUG - if (yydebug) - printf("yydebug: growing stack size from %d to %d\n", - old_stacksize, yystacksize); -#endif - new_yyss = (short *) yyrealloc ((char *)yyss, yystacksize * sizeof (short)); - if (new_yyss == 0) - return (1); - new_yyvs = (YYSTYPE *) yyrealloc ((char *)yyvs, yystacksize * sizeof (YYSTYPE)); - if (new_yyvs == 0) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) { - yyfree (new_yyss); - return (1); + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); } - yyss = new_yyss; - yyvs = new_yyvs; - return (0); + YYFPRINTF (stderr, "\n"); } -#line 60 "lburg/gram.y" + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +static void +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) +{ + unsigned long int yylno = yyrline[yyrule]; + int yynrhs = yyr2[yyrule]; + int yyi; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +static YYSIZE_T +yystrlen (const char *yystr) +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +static char * +yystpcpy (char *yydest, const char *yysrc) +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) + { + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } + } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; +} +#endif /* YYERROR_VERBOSE */ + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) +{ + YYUSE (yyvaluep); + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END +} + + + + +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; +/* Number of syntax errors so far. */ +int yynerrs; + + +/*----------. +| yyparse. | +`----------*/ + +int +yyparse (void) +{ + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + 'yyss': related to states. + 'yyvs': related to semantic values. + + Refer to the stacks through separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken = 0; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yypact_value_is_default (yyn)) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = yylex (); + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yytable_value_is_error (yyn)) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + '$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 2: +#line 22 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { yylineno = 0; } +#line 1240 "y.tab.c" /* yacc.c:1646 */ + break; + + case 3: +#line 23 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { yylineno = 0; } +#line 1246 "y.tab.c" /* yacc.c:1646 */ + break; + + case 7: +#line 31 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { + if (nonterm((yyvsp[-1].string))->number != 1) + yyerror("redeclaration of the start symbol\n"); + } +#line 1255 "y.tab.c" /* yacc.c:1646 */ + break; + + case 9: +#line 36 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { yyerrok; } +#line 1261 "y.tab.c" /* yacc.c:1646 */ + break; + + case 11: +#line 40 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { term((yyvsp[-2].string), (yyvsp[0].n)); } +#line 1267 "y.tab.c" /* yacc.c:1646 */ + break; + + case 13: +#line 44 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { rule((yyvsp[-5].string), (yyvsp[-3].tree), (yyvsp[-2].string), (yyvsp[-1].string)); } +#line 1273 "y.tab.c" /* yacc.c:1646 */ + break; + + case 15: +#line 46 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { yyerrok; } +#line 1279 "y.tab.c" /* yacc.c:1646 */ + break; + + case 16: +#line 49 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { nonterm((yyval.string) = (yyvsp[0].string)); } +#line 1285 "y.tab.c" /* yacc.c:1646 */ + break; + + case 17: +#line 52 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { (yyval.tree) = tree((yyvsp[0].string), 0, 0); } +#line 1291 "y.tab.c" /* yacc.c:1646 */ + break; + + case 18: +#line 53 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { (yyval.tree) = tree((yyvsp[-3].string), (yyvsp[-1].tree), 0); } +#line 1297 "y.tab.c" /* yacc.c:1646 */ + break; + + case 19: +#line 54 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { (yyval.tree) = tree((yyvsp[-5].string), (yyvsp[-3].tree), (yyvsp[-1].tree)); } +#line 1303 "y.tab.c" /* yacc.c:1646 */ + break; + + case 20: +#line 57 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646 */ + { if (*(yyvsp[0].string) == 0) (yyval.string) = "0"; } +#line 1309 "y.tab.c" /* yacc.c:1646 */ + break; + + +#line 1313 "y.tab.c" /* yacc.c:1646 */ + default: break; + } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now 'shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ +yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) + { + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; + } +# undef YYSYNTAX_ERROR +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule whose action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined yyoverflow || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + return yyresult; +} +#line 59 "code/tools/lcc/lburg/gram.y" /* yacc.c:1906 */ + #include #include #include @@ -270,12 +1553,32 @@ static char buf[BUFSIZ], *bp = buf; static int ppercent = 0; static int code = 0; +static void crlf_to_lf(char *buf, int bufmax) { + int i, count; + + count = 0; + + for (i = 0; i < bufmax; i++) { + if (buf[i] == '\r' && buf[i+1] == '\n') { + // skip '\r' + continue; + } + + buf[count++] = buf[i]; + + if (buf[i] == '\0') { + break; + } + } +} + static int get(void) { if (*bp == 0) { bp = buf; *bp = 0; if (fgets(buf, sizeof buf, infp) == NULL) return EOF; + crlf_to_lf(buf, sizeof buf); yylineno++; while (buf[0] == '%' && buf[1] == '{' && buf[2] == '\n') { for (;;) { @@ -283,6 +1586,7 @@ static int get(void) { yywarn("unterminated %{...%}\n"); return EOF; } + crlf_to_lf(buf, sizeof buf); yylineno++; if (strcmp(buf, "%}\n") == 0) break; @@ -290,6 +1594,7 @@ static int get(void) { } if (fgets(buf, sizeof buf, infp) == NULL) return EOF; + crlf_to_lf(buf, sizeof buf); yylineno++; } } @@ -399,284 +1704,5 @@ void yywarn(char *fmt, ...) { fprintf(stderr, "line %d: ", yylineno); fprintf(stderr, "warning: "); vfprintf(stderr, fmt, ap); -} -#line 403 "y.tab.c" -#define YYABORT goto yyabort -#define YYACCEPT goto yyaccept -#define YYERROR goto yyerrlab - -#if YYDEBUG -#ifdef __cplusplus -extern "C" char *getenv(); -#else -extern char *getenv(); -#endif -#endif - -int -yyparse() -{ - register int yym, yyn, yystate; - register YYSTYPE *yyvsp; - register short *yyssp; - short *yysse; -#if YYDEBUG - register YYCONST char *yys; - - if (yys = getenv("YYDEBUG")) - { - yyn = *yys; - if (yyn >= '0' && yyn <= '9') - yydebug = yyn - '0'; - } -#endif - - yynerrs = 0; - yyerrflag = 0; - yychar = (-1); - - if (yyss == 0) - { - yyss = (short *) yymalloc (YYSTACKSIZE * sizeof (short)); - if (yyss == 0) - goto yyabort; - yyvs = (YYSTYPE *) yymalloc (YYSTACKSIZE * sizeof (YYSTYPE)); - if (yyvs == 0) - { - yyfree (yyss); - goto yyabort; - } - yystacksize = YYSTACKSIZE; - } - yysse = yyss + yystacksize - 1; - yyssp = yyss; - yyvsp = yyvs; - *yyssp = yystate = 0; - goto yyloop; - -yypush_lex: - yyval = yylval; - yystate = yytable[yyn]; -yypush: - if (yyssp >= yysse) - { - int depth = yyssp - yyss; - if (yygrow() != 0) - goto yyoverflow; - yysse = yyss + yystacksize -1; - yyssp = depth + yyss; - yyvsp = depth + yyvs; - } - *++yyssp = yystate; - *++yyvsp = yyval; - -yyloop: - if ((yyn = yydefred[yystate])) goto yyreduce; - yyn = yysindex[yystate]; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, reading %d (%s)\n", yystate, - yychar, yys); - } -#endif - } - if (yyn != 0 - && ((yyn += yychar), ((unsigned)yyn <= (unsigned)YYTABLESIZE)) - && yycheck[yyn] == yychar) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, shifting to state %d\n", - yystate, yytable[yyn]); -#endif - if (yyerrflag > 0) --yyerrflag; - yychar = (-1); - goto yypush_lex; - } - yyn = yyrindex[yystate]; - if (yyn != 0 - && ((yyn += yychar), ((unsigned)yyn <= (unsigned)YYTABLESIZE)) - && yycheck[yyn] == yychar) - { - yyn = yytable[yyn]; - goto yyreduce; - } - if (yyerrflag) goto yyinrecovery; -#ifdef lint - goto yynewerror; -yynewerror: -#endif - yyerror("syntax error"); -#ifdef lint - goto yyerrlab; -yyerrlab: -#endif - ++yynerrs; -yyinrecovery: - if (yyerrflag < 3) - { - yyerrflag = 3; - for (;;) - { - yyn = yysindex[*yyssp]; - if (yyn != 0 - && ((yyn += YYERRCODE), ((unsigned)yyn <= (unsigned)YYTABLESIZE)) - && yycheck[yyn] == YYERRCODE) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, error recovery shifting\ - to state %d\n", *yyssp, yytable[yyn]); -#endif - goto yypush_lex; - } - else - { -#if YYDEBUG - if (yydebug) - printf("yydebug: error recovery discarding state %d\n", - *yyssp); -#endif - if (yyssp <= yyss) goto yyabort; - --yyssp; - --yyvsp; - } - } - } - else - { - if (yychar == 0) goto yyabort; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, error recovery discards token %d (%s)\n", - yystate, yychar, yys); - } -#endif - yychar = (-1); - goto yyloop; - } -yyreduce: -#if YYDEBUG - if (yydebug) - printf("yydebug: state %d, reducing by rule %d (%s)\n", - yystate, yyn, yyrule[yyn]); -#endif - yym = yylen[yyn]; - yyval = yyvsp[1-yym]; - switch (yyn) - { -case 1: -#line 22 "lburg/gram.y" -{ yylineno = 0; } -break; -case 2: -#line 23 "lburg/gram.y" -{ yylineno = 0; } -break; -case 6: -#line 31 "lburg/gram.y" -{ - if (nonterm(yyvsp[-1].string)->number != 1) - yyerror("redeclaration of the start symbol\n"); - } -break; -case 8: -#line 36 "lburg/gram.y" -{ yyerrok; } -break; -case 10: -#line 40 "lburg/gram.y" -{ term(yyvsp[-2].string, yyvsp[0].n); } -break; -case 12: -#line 44 "lburg/gram.y" -{ rule(yyvsp[-5].string, yyvsp[-3].tree, yyvsp[-2].string, yyvsp[-1].string); } -break; -case 14: -#line 46 "lburg/gram.y" -{ yyerrok; } -break; -case 15: -#line 49 "lburg/gram.y" -{ nonterm(yyval.string = yyvsp[0].string); } -break; -case 16: -#line 52 "lburg/gram.y" -{ yyval.tree = tree(yyvsp[0].string, 0, 0); } -break; -case 17: -#line 53 "lburg/gram.y" -{ yyval.tree = tree(yyvsp[-3].string, yyvsp[-1].tree, 0); } -break; -case 18: -#line 54 "lburg/gram.y" -{ yyval.tree = tree(yyvsp[-5].string, yyvsp[-3].tree, yyvsp[-1].tree); } -break; -case 19: -#line 57 "lburg/gram.y" -{ if (*yyvsp[0].string == 0) yyval.string = "0"; } -break; -#line 630 "y.tab.c" - } - yyssp -= yym; - yyvsp -= yym; - yym = yylhs[yyn]; - yystate = *yyssp; - if (yystate == 0 && yym == 0) - { -#if YYDEBUG - if (yydebug) - printf("yydebug: after reduction, shifting from state 0 to\ - state %d\n", YYFINAL); -#endif - yystate = YYFINAL; - *++yyssp = YYFINAL; - *++yyvsp = yyval; - if (yychar < 0) - { - if ((yychar = yylex()) < 0) yychar = 0; -#if YYDEBUG - if (yydebug) - { - yys = 0; - if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; - if (!yys) yys = "illegal-symbol"; - printf("yydebug: state %d, reading %d (%s)\n", - YYFINAL, yychar, yys); - } -#endif - } - if (yychar == 0) goto yyaccept; - goto yyloop; - } - yyn = yygindex[yym]; - if (yyn != 0 - && ((yyn += yystate), ((unsigned)yyn <= (unsigned)YYTABLESIZE)) - && yycheck[yyn] == yystate) - yystate = yytable[yyn]; - else - yystate = yydgoto[yym]; -#if YYDEBUG - if (yydebug) - printf("yydebug: after reduction, shifting from state %d \ -to state %d\n", *yyssp, yystate); -#endif - goto yypush; -yyoverflow: - yyerror("yacc stack overflow"); -yyabort: - return (1); -yyaccept: - return (0); + va_end(ap); } diff --git a/code/tools/lcc/lburg/gram.y b/code/tools/lcc/lburg/gram.y index 1ecd8a9..2dae09b 100644 --- a/code/tools/lcc/lburg/gram.y +++ b/code/tools/lcc/lburg/gram.y @@ -70,12 +70,32 @@ static char buf[BUFSIZ], *bp = buf; static int ppercent = 0; static int code = 0; +static void crlf_to_lf(char *buf, int bufmax) { + int i, count; + + count = 0; + + for (i = 0; i < bufmax; i++) { + if (buf[i] == '\r' && buf[i+1] == '\n') { + // skip '\r' + continue; + } + + buf[count++] = buf[i]; + + if (buf[i] == '\0') { + break; + } + } +} + static int get(void) { if (*bp == 0) { bp = buf; *bp = 0; if (fgets(buf, sizeof buf, infp) == NULL) return EOF; + crlf_to_lf(buf, sizeof buf); yylineno++; while (buf[0] == '%' && buf[1] == '{' && buf[2] == '\n') { for (;;) { @@ -83,6 +103,7 @@ static int get(void) { yywarn("unterminated %{...%}\n"); return EOF; } + crlf_to_lf(buf, sizeof buf); yylineno++; if (strcmp(buf, "%}\n") == 0) break; @@ -90,6 +111,7 @@ static int get(void) { } if (fgets(buf, sizeof buf, infp) == NULL) return EOF; + crlf_to_lf(buf, sizeof buf); yylineno++; } } @@ -199,4 +221,5 @@ void yywarn(char *fmt, ...) { fprintf(stderr, "line %d: ", yylineno); fprintf(stderr, "warning: "); vfprintf(stderr, fmt, ap); + va_end(ap); } diff --git a/code/tools/lcc/lburg/lburg.c b/code/tools/lcc/lburg/lburg.c index c43c96a..7cf859f 100644 --- a/code/tools/lcc/lburg/lburg.c +++ b/code/tools/lcc/lburg/lburg.c @@ -56,14 +56,14 @@ int main(int argc, char *argv[]) { } else if (infp == NULL) { if (strcmp(argv[i], "-") == 0) infp = stdin; - else if ((infp = fopen(argv[i], "r")) == NULL) { + else if ((infp = fopen(argv[i], "rb")) == NULL) { yyerror("%s: can't read `%s'\n", argv[0], argv[i]); exit(1); } } else if (outfp == NULL) { if (strcmp(argv[i], "-") == 0) outfp = stdout; - if ((outfp = fopen(argv[i], "w")) == NULL) { + if ((outfp = fopen(argv[i], "wb")) == NULL) { yyerror("%s: can't write `%s'\n", argv[0], argv[i]); exit(1); } diff --git a/code/tools/lcc/src/bytecode.c b/code/tools/lcc/src/bytecode.c index e83429f..871056a 100644 --- a/code/tools/lcc/src/bytecode.c +++ b/code/tools/lcc/src/bytecode.c @@ -261,8 +261,7 @@ static void LoadSourceFile( const char *filename ) { length = filelength( f ); sourceFile = malloc( length + 1 ); if ( sourceFile ) { - size_t size; - size = fread( sourceFile, length, 1, f ); + fread( sourceFile, length, 1, f ); sourceFile[length] = 0; } diff --git a/code/tools/lcc/src/c.h b/code/tools/lcc/src/c.h index 68c8f62..a7044d3 100644 --- a/code/tools/lcc/src/c.h +++ b/code/tools/lcc/src/c.h @@ -577,6 +577,7 @@ extern Tree cnsttree(Type, ...); extern Tree consttree(unsigned int, Type); extern Tree eqtree(int, Tree, Tree); extern int iscallb(Tree); +extern int isnullptr(Tree); extern Tree shtree(int, Tree, Tree); extern void typeerror(int, Tree, Tree); @@ -644,7 +645,7 @@ extern int process(char *); extern int findfunc(char *, char *); extern int findcount(char *, int, int); -extern Tree constexpr(int); +extern Tree constantexpr(int); extern int intexpr(int, int); extern Tree simplify(int, Type, Tree, Tree); extern int ispow2(unsigned long u); diff --git a/code/tools/lcc/src/dag.c b/code/tools/lcc/src/dag.c index 420cbe7..459f569 100644 --- a/code/tools/lcc/src/dag.c +++ b/code/tools/lcc/src/dag.c @@ -519,7 +519,8 @@ void emitcode(void) { (*IR->stabline)(&cp->u.point.src); swtoseg(CODE); } break; case Gen: case Jump: case Label: if (cp->u.forest) - (*IR->emit)(cp->u.forest); break; + (*IR->emit)(cp->u.forest); + break; case Local: if (glevel && IR->stabsym) { (*IR->stabsym)(cp->u.var); swtoseg(CODE); diff --git a/code/tools/lcc/src/enode.c b/code/tools/lcc/src/enode.c index 760096d..d59c31b 100644 --- a/code/tools/lcc/src/enode.c +++ b/code/tools/lcc/src/enode.c @@ -5,7 +5,6 @@ static Tree addtree(int, Tree, Tree); static Tree andtree(int, Tree, Tree); static Tree cmptree(int, Tree, Tree); static int compatible(Type, Type); -static int isnullptr(Tree e); static Tree multree(int, Tree, Tree); static Tree subtree(int, Tree, Tree); #define isvoidptr(ty) \ @@ -220,7 +219,7 @@ static int compatible(Type ty1, Type ty2) { && isptr(ty2) && !isfunc(ty2->type) && eqtype(unqual(ty1->type), unqual(ty2->type), 0); } -static int isnullptr(Tree e) { +int isnullptr(Tree e) { Type ty = unqual(e->type); return generic(e->op) == CNST @@ -402,7 +401,7 @@ Tree addrof(Tree p) { Symbol t1 = q->u.sym; q->u.sym = 0; q = idtree(t1); - /* fall thru */ + /* fall through */ } case INDIR: if (p == q) diff --git a/code/tools/lcc/src/error.c b/code/tools/lcc/src/error.c index 2187c10..52ca11f 100644 --- a/code/tools/lcc/src/error.c +++ b/code/tools/lcc/src/error.c @@ -80,7 +80,7 @@ int fatal(const char *name, const char *fmt, int n) { return 0; } -/* printtoken - print current token preceeded by a space */ +/* printtoken - print current token preceded by a space */ static void printtoken(void) { switch (t) { case ID: fprint(stderr, " `%s'", token); break; diff --git a/code/tools/lcc/src/expr.c b/code/tools/lcc/src/expr.c index b8cb08b..bcf2558 100644 --- a/code/tools/lcc/src/expr.c +++ b/code/tools/lcc/src/expr.c @@ -159,7 +159,8 @@ static Tree unary(void) { if (isarith(p->type)) p = cast(p, promote(p->type)); else - typeerror(ADD, p, NULL); break; + typeerror(ADD, p, NULL); + break; case '-': t = gettok(); p = unary(); p = pointer(p); if (isarith(p->type)) { Type ty = promote(p->type); @@ -170,18 +171,21 @@ static Tree unary(void) { } else p = simplify(NEG, ty, p, NULL); } else - typeerror(SUB, p, NULL); break; + typeerror(SUB, p, NULL); + break; case '~': t = gettok(); p = unary(); p = pointer(p); if (isint(p->type)) { Type ty = promote(p->type); p = simplify(BCOM, ty, cast(p, ty), NULL); } else - typeerror(BCOM, p, NULL); break; + typeerror(BCOM, p, NULL); + break; case '!': t = gettok(); p = unary(); p = pointer(p); if (isscalar(p->type)) p = simplify(NOT, inttype, cond(p), NULL); else - typeerror(NOT, p, NULL); break; + typeerror(NOT, p, NULL); + break; case INCR: t = gettok(); p = unary(); p = incr(INCR, pointer(p), consttree(1, inttype)); break; case DECR: t = gettok(); p = unary(); p = incr(DECR, pointer(p), consttree(1, inttype)); break; case TYPECODE: case SIZEOF: { int op = t; @@ -318,7 +322,8 @@ static Tree postfix(Tree p) { p->type); t = gettok(); } else - error("field name expected\n"); break; + error("field name expected\n"); + break; case DEREF: t = gettok(); p = pointer(p); if (t == ID) { @@ -331,7 +336,8 @@ static Tree postfix(Tree p) { t = gettok(); } else - error("field name expected\n"); break; + error("field name expected\n"); + break; default: return p; } @@ -621,7 +627,7 @@ Tree cast(Tree p, Type type) { p = simplify(CVP, dst, p, NULL); else { if ((isfunc(src->type) && !isfunc(dst->type)) - || (!isfunc(src->type) && isfunc(dst->type))) + || (!isnullptr(p) && !isfunc(src->type) && isfunc(dst->type))) warning("conversion from `%t' to `%t' is compiler dependent\n", p->type, type); if (src->size != dst->size) diff --git a/code/tools/lcc/src/gen.c b/code/tools/lcc/src/gen.c index 4ee170d..1413a78 100644 --- a/code/tools/lcc/src/gen.c +++ b/code/tools/lcc/src/gen.c @@ -292,7 +292,7 @@ static void dumptree(Node p) { dumptree(p->kids[0]); break; } - /* else fall thru */ + /* else fall through */ case EQ: case NE: case GT: case GE: case LE: case LT: case ASGN: case BOR: case BAND: case BXOR: case RSH: case LSH: case ADD: case SUB: case DIV: case MUL: case MOD: diff --git a/code/tools/lcc/src/init.c b/code/tools/lcc/src/init.c index 172d7c0..af1936f 100644 --- a/code/tools/lcc/src/init.c +++ b/code/tools/lcc/src/init.c @@ -40,7 +40,7 @@ static int genconst(Tree e, int def) { if (isarith(e->type)) error("cast from `%t' to `%t' is illegal in constant expressions\n", e->kids[0]->type, e->type); - /* fall thru */ + /* fall through */ case CVI: case CVU: case CVF: e = e->kids[0]; continue; @@ -192,7 +192,7 @@ static int initstruct(int len, Type ty, int lev) { return n; } -/* initializer - constexpr | { constexpr ( , constexpr )* [ , ] } */ +/* initializer - constantexpr | { constantexpr ( , constantexpr )* [ , ] } */ Type initializer(Type ty, int lev) { int n = 0; Tree e; diff --git a/code/tools/lcc/src/list.c b/code/tools/lcc/src/list.c index 29e660a..9c3ec9f 100644 --- a/code/tools/lcc/src/list.c +++ b/code/tools/lcc/src/list.c @@ -33,7 +33,7 @@ int length(List list) { return n; } -/* ltov - convert list to an NULL-terminated vector allocated in arena */ +/* ltov - convert list to a NULL-terminated vector allocated in arena */ void *ltov(List *list, unsigned arena) { int i = 0; void **array = newarray(length(*list) + 1, sizeof array[0], arena); diff --git a/code/tools/lcc/src/output.c b/code/tools/lcc/src/output.c index a9c93e7..d68f0e3 100644 --- a/code/tools/lcc/src/output.c +++ b/code/tools/lcc/src/output.c @@ -80,7 +80,7 @@ void vfprint(FILE *f, char *bp, const char *fmt, va_list ap) { static char format[] = "%f"; char buf[128]; format[1] = *fmt; - sprintf(buf, format, va_arg(ap, double)); + snprintf(buf, sizeof(buf), format, va_arg(ap, double)); bp = outs(buf, f, bp); } ; break; diff --git a/code/tools/lcc/src/simp.c b/code/tools/lcc/src/simp.c index ea26ab6..dfcb848 100644 --- a/code/tools/lcc/src/simp.c +++ b/code/tools/lcc/src/simp.c @@ -182,7 +182,7 @@ static int subi(long x, long y, long min, long max, int needconst) { static int subd(double x, double y, double min, double max, int needconst) { return addd(x, -y, min, max, needconst); } -Tree constexpr(int tok) { +Tree constantexpr(int tok) { Tree p; needconst++; @@ -192,7 +192,7 @@ Tree constexpr(int tok) { } int intexpr(int tok, int n) { - Tree p = constexpr(tok); + Tree p = constantexpr(tok); needconst++; if (p->op == CNST+I || p->op == CNST+U) diff --git a/code/tools/lcc/src/stmt.c b/code/tools/lcc/src/stmt.c index 9c3bdbe..ed220d4 100644 --- a/code/tools/lcc/src/stmt.c +++ b/code/tools/lcc/src/stmt.c @@ -119,7 +119,7 @@ void statement(int loop, Swtch swp, int lev) { static char stop[] = { IF, ID, 0 }; Tree p; t = gettok(); - p = constexpr(0); + p = constantexpr(0); if (generic(p->op) == CNST && isint(p->type)) { if (swp) { needconst++; @@ -184,8 +184,9 @@ void statement(int loop, Swtch swp, int lev) { branch(p->u.l.label); t = gettok(); } else - error("missing label in goto\n"); expect(';'); - break; + error("missing label in goto\n"); + expect(';'); + break; case ID: if (getchr() == ':') { stmtlabel(); diff --git a/code/tools/lcc/src/tree.c b/code/tools/lcc/src/tree.c index d2b6a91..e8e9e1f 100644 --- a/code/tools/lcc/src/tree.c +++ b/code/tools/lcc/src/tree.c @@ -86,7 +86,7 @@ static Tree root1(Tree p) { warning("reference to `%t' elided\n", p->type); if (isptr(p->kids[0]->type) && isvolatile(p->kids[0]->type->type)) warning("reference to `volatile %t' elided\n", p->type); - /* fall thru */ + /* fall through */ case CVI: case CVF: case CVU: case CVP: case NEG: case BCOM: case FIELD: if (warn++ == 0)