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