Optimize vehicle impact code by only calling vlen() if damage would be taken
[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 # Set to empty string to temporarily enable warnings when debugging
33 QCCFLAGS_WERROR ?= \
34         -Werror
35
36 # We eventually need to get rid of these
37 QCCFLAGS_WTFS ?= \
38         -Wno-field-redeclared
39
40 QCCDEFS ?= \
41         -DXONOTIC=$(XONOTIC) \
42         -DWATERMARK="$(QCCFLAGS_WATERMARK)" \
43         -DNDEBUG=$(NDEBUG) \
44         -DENABLE_EFFECTINFO=$(ENABLE_EFFECTINFO) \
45         -DENABLE_DEBUGDRAW=$(ENABLE_DEBUGDRAW) \
46         -DENABLE_DEBUGTRACE=$(ENABLE_DEBUGTRACE) \
47         $(if $(BUILD_MOD), -DBUILD_MOD="$(BUILD_MOD)" -I$(BUILD_MOD), ) \
48         $(QCCDEFS_EXTRA)
49
50 # -Ooverlap-locals is required
51 QCCFLAGS ?= \
52         -std=gmqcc \
53         -Ooverlap-locals \
54         -O3 \
55         $(QCCFLAGS_WERROR) \
56         -Wall \
57         $(QCCFLAGS_WTFS) \
58         -flno -futf8 -fno-bail-on-werror \
59         -frelaxed-switch -freturn-assignments \
60         $(QCCFLAGS_EXTRA)
61
62
63
64 .PHONY: all
65 all: qc pk3
66
67 $(WORKDIR):
68         @mkdir -p $@
69
70 .PHONY: clean
71 clean: | $(WORKDIR)
72         $(RM) $(PROGS_OUT)/csprogs.dat
73         $(RM) $(PROGS_OUT)/menu.dat
74         $(RM) $(PROGS_OUT)/progs.dat
75         $(RM) $(WORKDIR)/*.d
76         $(RM) $(WORKDIR)/*.qc
77         $(RM) $(WORKDIR)/*.txt
78
79 .PHONY: qc
80 qc: $(PROGS_OUT)/csprogs.dat $(PROGS_OUT)/menu.dat $(PROGS_OUT)/progs.dat
81
82 .PHONY: pk3
83 pk3: csprogs-$(VER).pk3
84
85
86
87
88
89 %-$(VER).pk3: $(PROGS_OUT)/%.dat
90         $(eval PROG=$*)
91         $(eval PK3=$(PROG)-$(VER).pk3)
92         $(eval TXT=$(PROG)-$(VER).txt)
93         $(eval DAT=$(PROG)-$(VER).dat)
94         $(eval LNO=$(PROG)-$(VER).lno)
95         @ echo "http://xonotic.org" > $(TXT)
96         @ ln -f $(PROGS_OUT)/$(PROG).dat $(DAT)
97         @ ln -f $(PROGS_OUT)/$(PROG).lno $(LNO)
98         @ $(RM) *.pk3
99         $(ZIP) $(PK3) $(TXT) $(DAT) $(LNO)
100         @ $(RM) $(TXT) $(DAT) $(LNO)
101
102 QCCVERSION := $(shell cd lib && $(QCC) --version)
103 QCCVERSIONFILE := $(WORKDIR)/qccversion.$(shell echo ${QCCVERSION} | git hash-object --stdin)
104 $(QCCVERSIONFILE): | $(WORKDIR)
105         @ $(RM) $(WORKDIR)/qccversion.*
106         @ echo $(QCCVERSION) > $@
107
108 export WORKDIR
109 export CPP
110 export QCC
111 export QCCDEFS
112 export QCCFLAGS
113
114 $(PROGS_OUT)/csprogs.dat: client/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
115         @ echo make[1]: Entering directory \`$(CURDIR)/client\'
116         ./tools/qcc.sh client $@ $<
117 -include $(WORKDIR)/client.d
118
119 $(PROGS_OUT)/progs.dat: server/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
120         @ echo make[1]: Entering directory \`$(CURDIR)/server\'
121         ./tools/qcc.sh server $@ $<
122 -include $(WORKDIR)/server.d
123
124 $(PROGS_OUT)/menu.dat: menu/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
125         @ echo make[1]: Entering directory \`$(CURDIR)/menu\'
126         ./tools/qcc.sh menu $@ $<
127 -include $(WORKDIR)/menu.d