]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/Makefile
Use 7za when available
[xonotic/xonotic-data.pk3dir.git] / qcsrc / Makefile
1 QCCFLAGS_WATERMARK ?= $(shell git describe --tags --dirty=*)
2 CPP := cc -xc -E
3 QCC ?= gmqcc
4 NDEBUG ?= 1
5 PROGS_OUT ?= $(CURDIR)/..
6 BUILD_MOD ?= 0
7
8 ifndef Zip
9     ifneq ($(shell which zip),)
10         Zip := zip -9
11     endif
12     ifneq ($(shell which 7za),)
13         Zip := 7za a -tzip -mx=9
14     endif
15     ifndef Zip
16         $(error "No zip in ($(PATH))")
17     endif
18 endif
19
20 QCCVERSIONFILE := qccversion.$(shell (cd server && $(QCC) --version) > qccversion.txt && git hash-object qccversion.txt)
21
22 # We eventually need to get rid of these
23 QCCFLAGS_WTFS ?= \
24         -Wno-field-redeclared
25
26 QCCDEFS ?= \
27         -DWATERMARK="$(QCCFLAGS_WATERMARK)" \
28         -DNDEBUG=$(NDEBUG) \
29         -DBUILD_MOD=$(BUILD_MOD) \
30         $(QCCDEFS_EXTRA)
31
32 # -Ooverlap-locals is required
33 QCCFLAGS ?= \
34         -std=gmqcc \
35         -Ooverlap-locals \
36         -O3 \
37         -Werror -Wall \
38         $(QCCFLAGS_WTFS) \
39         -flno -futf8 -fno-bail-on-werror \
40         -frelaxed-switch -freturn-assignments \
41         $(QCCFLAGS_EXTRA)
42
43 # xonotic build system overrides this by command line argument to turn off the update-cvarcount step
44 XON_BUILDSYSTEM =
45
46 .PHONY: all
47 all: qc pk3
48
49 .PHONY: qc
50 qc: $(PROGS_OUT)/menu.dat $(PROGS_OUT)/progs.dat $(PROGS_OUT)/csprogs.dat
51
52 .PHONY: pk3
53 pk3: qc
54         $(eval PROG=csprogs)
55         $(eval VER=${QCCFLAGS_WATERMARK})
56         $(eval PK3=${PROG}-${VER}.pk3)
57         $(eval TXT=${PROG}-${VER}.txt)
58         $(eval DAT=${PROG}-${VER}.dat)
59         $(eval LNO=${PROG}-${VER}.lno)
60         @ echo "http://xonotic.org" > ${TXT}
61         @ ln -f $(PROGS_OUT)/${PROG}.dat ${DAT}
62         @ ln -f $(PROGS_OUT)/${PROG}.lno ${LNO}
63         @ rm -f *.pk3
64         $(Zip) ${PK3} ${TXT} ${DAT} ${LNO}
65         @ rm ${TXT} ${DAT} ${LNO}
66
67 dirtree:
68         @mkdir -p ../.tmp
69
70 .PHONY: clean
71 clean: | dirtree
72         rm -f $(PROGS_OUT)/csprogs.dat
73         rm -f $(PROGS_OUT)/progs.dat
74         rm -f $(PROGS_OUT)/menu.dat
75         rm -f ../.tmp/*.qc
76         rm -f ../.tmp/*.d
77         rm -f ../.tmp/*.txt
78
79 $(QCCVERSIONFILE):
80         $(RM) qccversion.*
81         echo This file intentionally left blank. > $@
82
83 export QCC
84 export CPP
85 export QCCDEFS
86 export QCCFLAGS
87
88 $(PROGS_OUT)/csprogs.dat: client/progs.inc $(QCCVERSIONFILE) | dirtree
89         @echo make[1]: Entering directory \`$(PWD)/client\'
90         sh ./qcc.sh client $@ $<
91 -include ../.tmp/client.d
92
93 $(PROGS_OUT)/progs.dat: server/progs.inc $(QCCVERSIONFILE) | dirtree
94         @echo make[1]: Entering directory \`$(PWD)/server\'
95         sh ./qcc.sh server $@ $<
96 -include ../.tmp/server.d
97
98 $(PROGS_OUT)/menu.dat: menu/progs.inc $(QCCVERSIONFILE) | dirtree
99         @echo make[1]: Entering directory \`$(PWD)/menu\'
100         sh ./qcc.sh menu $@ $<
101 -include ../.tmp/menu.d
102
103 .PHONY: testcase
104 testcase:
105         cd testcase && $(QCC) $(QCCDEFS) $(QCCFLAGS) -DTESTCASE="$$TESTCASE"