Merge branch 'terencehill/cl_forceplayercolors_3' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / Makefile
1 CPP := cc -xc -E
2 QCC ?= ../../../../gmqcc/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) $(PROGS_OUT)/csprogs.lno
76         $(RM) $(PROGS_OUT)/menu.lno
77         $(RM) $(PROGS_OUT)/progs.lno
78         $(RM) $(WORKDIR)/*.d
79         $(RM) $(WORKDIR)/*.qc
80         $(RM) $(WORKDIR)/*.txt
81         $(RM) $(WORKDIR)/qccversion.*
82         $(RM) csprogs-*.pk3
83
84 .PHONY: qc
85 qc: $(PROGS_OUT)/csprogs.dat $(PROGS_OUT)/menu.dat $(PROGS_OUT)/progs.dat
86
87 .PHONY: pk3
88 pk3: csprogs-$(VER).pk3
89
90
91
92
93
94 %-$(VER).pk3: $(PROGS_OUT)/%.dat
95         $(eval PROG=$*)
96         $(eval PK3=$(PROG)-$(VER).pk3)
97         $(eval TXT=$(PROG)-$(VER).txt)
98         $(eval DAT=$(PROG)-$(VER).dat)
99         $(eval LNO=$(PROG)-$(VER).lno)
100         @ echo "http://xonotic.org" > $(TXT)
101         @ cp -f $(PROGS_OUT)/$(PROG).dat $(DAT)
102         @ cp -f $(PROGS_OUT)/$(PROG).lno $(LNO)
103         @ $(RM) csprogs-*.pk3
104         $(ZIP) $(PK3) $(TXT) $(DAT) $(LNO)
105         @ $(RM) $(TXT) $(DAT) $(LNO)
106
107 QCCVERSION := $(shell cd lib && $(QCC) --version)
108 QCCVERSIONFILE := $(WORKDIR)/qccversion.$(shell echo ${QCCVERSION} | git hash-object --stdin)
109 $(QCCVERSIONFILE): | $(WORKDIR)
110         @ $(RM) $(WORKDIR)/qccversion.*
111         @ echo $(QCCVERSION) > $@
112
113 export WORKDIR
114 export CPP
115 export QCC
116 export QCCDEFS
117 export QCCFLAGS
118
119 $(PROGS_OUT)/csprogs.dat: client/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
120         @ echo make[1]: Entering directory \`$(CURDIR)/client\'
121         ./tools/qcc.sh client $@ $<
122 -include $(WORKDIR)/client.d
123
124 $(PROGS_OUT)/progs.dat: server/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
125         @ echo make[1]: Entering directory \`$(CURDIR)/server\'
126         ./tools/qcc.sh server $@ $<
127 -include $(WORKDIR)/server.d
128
129 $(PROGS_OUT)/menu.dat: menu/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
130         @ echo make[1]: Entering directory \`$(CURDIR)/menu\'
131         ./tools/qcc.sh menu $@ $<
132 -include $(WORKDIR)/menu.d