]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/Makefile
Improve g_freezetag_revive_speed description
[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 -9mD
19         endif
20         ifneq ($(shell which 7z 2>/dev/null),)
21                 ZIP := 7z a -tzip -mx=9 -sdel
22         endif
23         ifneq ($(shell which 7za 2>/dev/null),)
24                 ZIP := 7za a -tzip -mx=9 -sdel
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) $(WORKDIR)/csprogs-*
83         $(RM) $(WORKDIR)/autoexec/csprogs-*.cfg
84         $(RM) csprogs-*.pk3
85
86 .PHONY: qc
87 qc: $(PROGS_OUT)/csprogs.dat $(PROGS_OUT)/menu.dat $(PROGS_OUT)/progs.dat
88
89 .PHONY: sv
90 sv: $(PROGS_OUT)/csprogs.dat $(PROGS_OUT)/progs.dat
91
92 .PHONY: pk3
93 pk3: csprogs-$(VER).pk3
94
95
96
97
98
99 %-$(VER).pk3: $(PROGS_OUT)/%.dat
100         $(eval PROG=$*)
101         $(eval PK3=$(PROG)-$(VER).pk3)
102         $(eval CFG=autoexec/$(PROG)-$(VER).cfg)
103         $(eval DAT=$(PROG)-$(VER).dat)
104         $(eval LNO=$(PROG)-$(VER).lno)
105         @ mkdir -p $(WORKDIR)/autoexec
106         @ echo "// http://xonotic.org" > $(WORKDIR)/$(CFG)
107         @ echo "set csqc_progname $(DAT)" >> $(WORKDIR)/$(CFG)
108         @ cp -f $(PROGS_OUT)/$(PROG).dat $(WORKDIR)/$(DAT)
109         @ cp -f $(PROGS_OUT)/$(PROG).lno $(WORKDIR)/$(LNO)
110         @ $(RM) $(PROG)-*.pk3
111         cd $(WORKDIR) && $(ZIP) $(CURDIR)/$(PK3) $(CFG) $(DAT) $(LNO)
112
113 QCCVERSION := $(shell cd lib && $(QCC) --version)
114 QCCVERSIONFILE := $(WORKDIR)/qccversion.$(shell echo ${QCCVERSION} | git hash-object --stdin)
115 $(QCCVERSIONFILE): | $(WORKDIR)
116         @ $(RM) $(WORKDIR)/qccversion.*
117         @ echo $(QCCVERSION) > $@
118
119 export WORKDIR
120 export CPP
121 export QCC
122 export QCCDEFS
123 export QCCFLAGS
124
125 $(PROGS_OUT)/csprogs.dat: client/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
126         @ echo make[1]: Entering directory \`$(CURDIR)/client\'
127         ./tools/qcc.sh client $@ $<
128 -include $(WORKDIR)/client.d
129
130 $(PROGS_OUT)/progs.dat: server/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
131         @ echo make[1]: Entering directory \`$(CURDIR)/server\'
132         ./tools/qcc.sh server $@ $<
133 -include $(WORKDIR)/server.d
134
135 $(PROGS_OUT)/menu.dat: menu/progs.inc $(QCCVERSIONFILE) | $(WORKDIR)
136         @ echo make[1]: Entering directory \`$(CURDIR)/menu\'
137         ./tools/qcc.sh menu $@ $<
138 -include $(WORKDIR)/menu.d