From: TimePath Date: Thu, 31 Dec 2015 13:22:37 +0000 (+1100) Subject: Makefile: factor out qcc X-Git-Tag: xonotic-v0.8.2~1348 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=cdac5ca35ff47628a38853206e6fc4cb0c41ca24;p=xonotic%2Fxonotic-data.pk3dir.git Makefile: factor out qcc --- diff --git a/qcsrc/Makefile b/qcsrc/Makefile index ac418a5fa..a0848a185 100644 --- a/qcsrc/Makefile +++ b/qcsrc/Makefile @@ -1,8 +1,7 @@ SCM := $(shell if [ -d .svn ]; then echo svn; elif [ -d ../.git ]; then echo git; fi) PERL ?= perl -QCCFLAGS_WATERMARK ?= -DWATERMARK='"$(shell git describe)"' +QCCFLAGS_WATERMARK ?= $(shell git describe) QCC ?= gmqcc -QCCDEFS_EXTRA ?= -DGMQCC NDEBUG ?= 1 BUILD_MOD ?= 0 @@ -13,7 +12,7 @@ QCCFLAGS_WTFS ?= \ -Wno-field-redeclared QCCDEFS ?= \ - $(QCCFLAGS_WATERMARK) \ + -DWATERMARK="$(QCCFLAGS_WATERMARK)" \ -DNDEBUG=$(NDEBUG) \ -DBUILD_MOD=$(BUILD_MOD) \ $(QCCDEFS_EXTRA) @@ -47,28 +46,24 @@ $(QCCVERSIONFILE): $(RM) qccversion.* echo This file intentionally left blank. > $@ +export QCC +export CPP +export QCCDEFS +export QCCFLAGS + ../csprogs.dat: client/progs.inc $(QCCVERSIONFILE) - $(CC) -xc -I. $(QCCDEFS) -DCSQC -E -MMD -MP -MT $@ -Wall -Wundef -Werror -CC -o tmp/client.qc $< - @$(CC) -xc -I. $(QCCDEFS) -DCSQC -E -dM 1>tmp/client_macros.txt -H 2>tmp/client_includes.txt $< - @sed -i 's/^# \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\2)\n#pragma line(\1)/g' tmp/client.qc @echo make[1]: Entering directory \`$(PWD)/client\' - cd client && $(QCC) $(QCCFLAGS) -o ../$@ ../tmp/client.qc + ./qcc.sh client $@ $< -include tmp/client.d ../progs.dat: server/progs.inc $(QCCVERSIONFILE) - $(CC) -xc -I. $(QCCDEFS) -DSVQC -E -MMD -MP -MT $@ -Wall -Wundef -Werror -CC -o tmp/server.qc $< - @$(CC) -xc -I. $(QCCDEFS) -DSVQC -E -dM 1>tmp/server_macros.txt -H 2>tmp/server_includes.txt $< - @sed -i 's/^# \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\2)\n#pragma line(\1)/g' tmp/server.qc @echo make[1]: Entering directory \`$(PWD)/server\' - cd server && $(QCC) $(QCCFLAGS) -o ../$@ ../tmp/server.qc + ./qcc.sh server $@ $< -include tmp/server.d ../menu.dat: menu/progs.inc $(QCCVERSIONFILE) - $(CC) -xc -I. $(QCCDEFS) -DMENUQC -E -MMD -MP -MT $@ -Wall -Wundef -Werror -CC -o tmp/menu.qc $< - @$(CC) -xc -I. $(QCCDEFS) -DMENUQC -E -dM 1>tmp/menu_macros.txt -H 2>tmp/menu_includes.txt $< - @sed -i 's/^# \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\2)\n#pragma line(\1)/g' tmp/menu.qc @echo make[1]: Entering directory \`$(PWD)/menu\' - cd menu && $(QCC) $(QCCFLAGS) -o ../$@ ../tmp/menu.qc + ./qcc.sh menu $@ $< -include tmp/menu.d .PHONY: testcase diff --git a/qcsrc/qcc.sh b/qcsrc/qcc.sh new file mode 100755 index 000000000..f0a734a6e --- /dev/null +++ b/qcsrc/qcc.sh @@ -0,0 +1,26 @@ +#!/bin/sh +set -eu + +MODE=$1 +IN=$3 +OUT=$2 + +QCC=${QCC} +QCCIDENT="-DGMQCC" + +case ${MODE} in + client) PROG=CSQC + ;; + menu) PROG=MENUQC + ;; + server) PROG=SVQC + ;; +esac + +CPP="${CPP} -I. ${QCCIDENT} ${QCCDEFS} -D${PROG}" +set -x +${CPP} -CC -MMD -MP -MT ${OUT} -Wall -Wundef -Werror -o tmp/${MODE}.qc ${IN} +${CPP} -dM 1>tmp/${MODE}_macros.txt -H 2>tmp/${MODE}_includes.txt ${IN} +sed -i 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' tmp/${MODE}.qc +cd ${MODE} +${QCC} ${QCCFLAGS} -o ../${OUT} ../tmp/${MODE}.qc