Properly support team field on trigger_multiple
[xonotic/xonotic-data.pk3dir.git] / qcsrc / Makefile
1 CPP := cc -xc -E
2 QCC ?= gmqcc
3
4 PROGS_OUT ?= ..
5 WORKDIR ?= ../.tmp
6
7 QCCFLAGS_WATERMARK ?= $(shell git describe --tags --dirty='~')
8 VER = $(subst *,\*,$(QCCFLAGS_WATERMARK))
9 NDEBUG ?= 1
10 XONOTIC ?= 1
11 ENABLE_EFFECTINFO ?= 0
12 ENABLE_DEBUGDRAW ?= 0
13 ENABLE_DEBUGTRACE ?= 0
14 BUILD_MOD ?=
15
16 ifndef ZIP
17         ifneq ($(shell which zip 2>/dev/null),)
18                 ZIP := zip -9
19         endif
20         ifneq ($(shell which 7z 2>/dev/null),)
21                 ZIP := 7z a -tzip -mx=9
22         endif
23         ifneq ($(shell which 7za 2>/dev/null),)
24                 ZIP := 7za a -tzip -mx=9
25         endif
26     ifndef ZIP
27         $(warning "No zip / 7z / 7za in ($(PATH))")
28         ZIP := : zip_not_found
29     endif
30 endif
31
32 # We eventually need to get rid of these
33 QCCFLAGS_WTFS ?= \
34         -Wno-field-redeclared
35
36 QCCDEFS ?= \
37         -DXONOTIC=$(XONOTIC) \
38         -DWATERMARK="$(QCCFLAGS_WATERMARK)" \
39         -DNDEBUG=$(NDEBUG) \
40         -DENABLE_EFFECTINFO=$(ENABLE_EFFECTINFO) \
41         -DENABLE_DEBUGDRAW=$(ENABLE_DEBUGDRAW) \
42         -DENABLE_DEBUGTRACE=$(ENABLE_DEBUGTRACE) \
43         $(if $(BUILD_MOD), -DBUILD_MOD="$(BUILD_MOD)" -I$(BUILD_MOD), ) \
44         $(QCCDEFS_EXTRA)
45
46 # -Ooverlap-locals is required
47 QCCFLAGS ?= \
48         -std=gmqcc \
49         -Ooverlap-locals \
50         -O3 \
51         -Werror -Wall \
52         $(QCCFLAGS_WTFS) \
53         -flno -futf8 -fno-bail-on-werror \
54         -frelaxed-switch -freturn-assignments \
55         $(QCCFLAGS_EXTRA)
56
57
58
59 .PHONY: all
60 all: qc pk3
61
62 $(WORKDIR):
63         @mkdir -p $@
64
65 .PHONY: clean
66 clean: | $(WORKDIR)
67         $(RM) $(PROGS_OUT)/csprogs.dat
68         $(RM) $(PROGS_OUT)/menu.dat
69         $(RM) $(PROGS_OUT)/progs.dat
70         $(RM) $(WORKDIR)/*.d
71         $(RM) $(WORKDIR)/*.qc
72         $(RM) $(WORKDIR)/*.txt
73
74 .PHONY: qc
75 qc: $(PROGS_OUT)/csprogs.dat $(PROGS_OUT)/menu.dat $(PROGS_OUT)/progs.dat
76
77 .PHONY: pk3
78 pk3: csprogs-$(VER).pk3
79
80
81
82
83
84 %-$(VER).pk3: $(PROGS_OUT)/%.dat
85         $(eval PROG=$*)
86         $(eval PK3=$(PROG)-$(VER).pk3)
87         $(eval TXT=$(PROG)-$(VER).txt)
88         $(eval DAT=$(PROG)-$(VER).dat)
89         $(eval LNO=$(PROG)-$(VER).lno)
90         @ echo "http://xonotic.org" > $(TXT)
91         @ ln -f $(PROGS_OUT)/$(PROG).dat $(DAT)
92         @ ln -f $(PROGS_OUT)/$(PROG).lno $(LNO)
93         @ $(RM) *.pk3
94         $(ZIP) $(PK3) $(TXT) $(DAT) $(LNO)
95         @ $(RM) $(TXT) $(DAT) $(LNO)
96
97 QCCVERSION := $(shell cd lib && $(QCC) --version)
98 QCCVERSIONFILE := $(WORKDIR)/qccversion.$(shell echo ${QCCVERSION} | git hash-object --stdin)
99 $(QCCVERSIONFILE): | $(WORKDIR)
100         @ $(RM) $(WORKDIR)/qccversion.*
101         @ echo $(QCCVERSION) > $@
102
103 export WORKDIR
104 export CPP
105 export QCC
106 export QCCDEFS
107 export QCCFLAGS
108
109 $(PROGS_OUT)/csprogs.dat: client/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
110         @ echo make[1]: Entering directory \`$(CURDIR)/client\'
111         ./tools/qcc.sh client $@ $<
112 -include $(WORKDIR)/client.d
113
114 $(PROGS_OUT)/progs.dat: server/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
115         @ echo make[1]: Entering directory \`$(CURDIR)/server\'
116         ./tools/qcc.sh server $@ $<
117 -include $(WORKDIR)/server.d
118
119 $(PROGS_OUT)/menu.dat: menu/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
120         @ echo make[1]: Entering directory \`$(CURDIR)/menu\'
121         ./tools/qcc.sh menu $@ $<
122 -include $(WORKDIR)/menu.d