From: TimePath Date: Fri, 11 Mar 2016 06:42:26 +0000 (+1100) Subject: Makefile: enhance X-Git-Tag: xonotic-v0.8.2~1130 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=711c5fb3d31c2175a34538c8184edc7eb70ef9ce;p=xonotic%2Fxonotic-data.pk3dir.git Makefile: enhance --- diff --git a/qcsrc/Makefile b/qcsrc/Makefile index d73c52f21..8a049d0b5 100644 --- a/qcsrc/Makefile +++ b/qcsrc/Makefile @@ -1,24 +1,30 @@ -QCCFLAGS_WATERMARK ?= $(shell git describe --tags --dirty=*) CPP := cc -xc -E QCC ?= gmqcc -NDEBUG ?= 1 + PROGS_OUT ?= $(CURDIR)/.. +WORKDIR ?= ../.tmp + +QCCFLAGS_WATERMARK ?= $(shell git describe --tags --dirty='*') +VER = $(QCCFLAGS_WATERMARK) +NDEBUG ?= 1 BUILD_MOD ?= 0 -ifndef Zip - ifneq ($(shell which zip),) - Zip := zip -9 - endif - ifneq ($(shell which 7za),) - Zip := 7za a -tzip -mx=9 - endif - ifndef Zip - $(error "No zip in ($(PATH))") +ifndef ZIP + ifneq ($(shell which zip),) + ZIP := zip -9 + endif + ifneq ($(shell which 7z),) + ZIP := 7z a -tzip -mx=9 + endif + ifneq ($(shell which 7za),) + ZIP := 7za a -tzip -mx=9 + endif + ifndef ZIP + $(warning "No zip in ($(PATH))") + ZIP := : zip_not_found endif endif -QCCVERSIONFILE := qccversion.$(shell (cd server && $(QCC) --version) > qccversion.txt && git hash-object qccversion.txt) - # We eventually need to get rid of these QCCFLAGS_WTFS ?= \ -Wno-field-redeclared @@ -40,66 +46,68 @@ QCCFLAGS ?= \ -frelaxed-switch -freturn-assignments \ $(QCCFLAGS_EXTRA) -# xonotic build system overrides this by command line argument to turn off the update-cvarcount step -XON_BUILDSYSTEM = + .PHONY: all all: qc pk3 +$(WORKDIR): + @mkdir -p $@ + +.PHONY: clean +clean: | $(WORKDIR) + $(RM) $(PROGS_OUT)/csprogs.dat + $(RM) $(PROGS_OUT)/menu.dat + $(RM) $(PROGS_OUT)/progs.dat + $(RM) $(WORKDIR)/*.d + $(RM) $(WORKDIR)/*.qc + $(RM) $(WORKDIR)/*.txt + .PHONY: qc -qc: $(PROGS_OUT)/menu.dat $(PROGS_OUT)/progs.dat $(PROGS_OUT)/csprogs.dat +qc: $(PROGS_OUT)/csprogs.dat $(PROGS_OUT)/menu.dat $(PROGS_OUT)/progs.dat .PHONY: pk3 -pk3: qc - $(eval PROG=csprogs) - $(eval VER=${QCCFLAGS_WATERMARK}) - $(eval PK3=${PROG}-${VER}.pk3) - $(eval TXT=${PROG}-${VER}.txt) - $(eval DAT=${PROG}-${VER}.dat) - $(eval LNO=${PROG}-${VER}.lno) - @ echo "http://xonotic.org" > ${TXT} - @ ln -f $(PROGS_OUT)/${PROG}.dat ${DAT} - @ ln -f $(PROGS_OUT)/${PROG}.lno ${LNO} - @ rm -f *.pk3 - $(Zip) ${PK3} ${TXT} ${DAT} ${LNO} - @ rm ${TXT} ${DAT} ${LNO} - -dirtree: - @mkdir -p ../.tmp +pk3: csprogs-$(VER).pk3 -.PHONY: clean -clean: | dirtree - rm -f $(PROGS_OUT)/csprogs.dat - rm -f $(PROGS_OUT)/progs.dat - rm -f $(PROGS_OUT)/menu.dat - rm -f ../.tmp/*.qc - rm -f ../.tmp/*.d - rm -f ../.tmp/*.txt - -$(QCCVERSIONFILE): - $(RM) qccversion.* - echo This file intentionally left blank. > $@ -export QCC + + + +%-$(VER).pk3: $(PROGS_OUT)/%.dat + $(eval PROG=$*) + $(eval PK3=$(PROG)-$(VER).pk3) + $(eval TXT=$(PROG)-$(VER).txt) + $(eval DAT=$(PROG)-$(VER).dat) + $(eval LNO=$(PROG)-$(VER).lno) + @ echo "http://xonotic.org" > $(TXT) + @ ln -f $(PROGS_OUT)/$(PROG).dat $(DAT) + @ ln -f $(PROGS_OUT)/$(PROG).lno $(LNO) + @ $(RM) *.pk3 + $(ZIP) $(PK3) $(TXT) $(DAT) $(LNO) + @ $(RM) $(TXT) $(DAT) $(LNO) + +QCCVERSION := $(shell $(QCC) --version) +QCCVERSIONFILE := $(WORKDIR)/qccversion.$(shell echo ${QCCVERSION} | git hash-object --stdin) +$(QCCVERSIONFILE): | $(WORKDIR) + @ $(RM) $(WORKDIR)/qccversion.* + @ echo $(QCCVERSION) > $@ + export CPP +export QCC export QCCDEFS export QCCFLAGS -$(PROGS_OUT)/csprogs.dat: client/progs.inc $(QCCVERSIONFILE) | dirtree - @echo make[1]: Entering directory \`$(PWD)/client\' - sh ./qcc.sh client $@ $< --include ../.tmp/client.d - -$(PROGS_OUT)/progs.dat: server/progs.inc $(QCCVERSIONFILE) | dirtree - @echo make[1]: Entering directory \`$(PWD)/server\' - sh ./qcc.sh server $@ $< --include ../.tmp/server.d +$(PROGS_OUT)/csprogs.dat: client/progs.inc $(QCCVERSIONFILE) | $(WORKDIR) + @ echo make[1]: Entering directory \`$(CURDIR)/client\' + @ ./qcc.sh client $@ $< +-include $(WORKDIR)/client.d -$(PROGS_OUT)/menu.dat: menu/progs.inc $(QCCVERSIONFILE) | dirtree - @echo make[1]: Entering directory \`$(PWD)/menu\' - sh ./qcc.sh menu $@ $< --include ../.tmp/menu.d +$(PROGS_OUT)/progs.dat: server/progs.inc $(QCCVERSIONFILE) | $(WORKDIR) + @ echo make[1]: Entering directory \`$(CURDIR)/server\' + @ ./qcc.sh server $@ $< +-include $(WORKDIR)/server.d -.PHONY: testcase -testcase: - cd testcase && $(QCC) $(QCCDEFS) $(QCCFLAGS) -DTESTCASE="$$TESTCASE" +$(PROGS_OUT)/menu.dat: menu/progs.inc $(QCCVERSIONFILE) | $(WORKDIR) + @ echo make[1]: Entering directory \`$(CURDIR)/menu\' + @ ./qcc.sh menu $@ $< +-include $(WORKDIR)/menu.d diff --git a/qcsrc/qcc.sh b/qcsrc/qcc.sh index 1678e668c..b3ad199b8 100755 --- a/qcsrc/qcc.sh +++ b/qcsrc/qcc.sh @@ -18,9 +18,9 @@ case ${MODE} in esac CPP="${CPP} -I. ${QCCIDENT} ${QCCDEFS} -D${PROG}" -set -x ${CPP} -MMD -MP -MT ${OUT} -Wall -Wundef -Werror -o ../.tmp/${MODE}.txt ${IN} ${CPP} -dM 1>../.tmp/${MODE}_macros.txt -H 2>../.tmp/${MODE}_includes.txt ${IN} sed 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' ../.tmp/${MODE}.txt > ../.tmp/${MODE}.qc cd ${MODE} +echo $(basename ${QCC}) ${QCCFLAGS} -o ${OUT} ${MODE}.qc ${QCC} ${QCCFLAGS} -o ${OUT} ../../.tmp/${MODE}.qc