Merge remote branch 'refs/remotes/origin/terencehill/misc_bugfixes'
[xonotic/xonotic-data.pk3dir.git] / Makefile
1 SCM := $(shell if [ -d .svn ]; then echo svn; elif [ -d ../.git ]; then echo git; fi)
2 FTEQCC ?= fteqcc
3 PERL ?= perl
4 PK3NAME ?= `date +../data%Y%m%d.pk3`
5 ZIP ?= 7za a -tzip -mx=9
6 ZIPEXCLUDE ?= -x\!*.pk3 -xr\!\.svn -x\!qcsrc
7 DIFF ?= diff
8
9 FTEQCCFLAGS_WATERMARK ?= -DWATERMARK='"^1$(shell git describe) TEST BUILD"'
10 FTEQCCFLAGS ?= -Werror -Wall -Wno-mundane -O3 -Ono-c -Ono-cs -flo $(FTEQCCFLAGS_EXTRA) $(FTEQCCFLAGS_WATERMARK)
11 FTEQCCFLAGS_PROGS ?= 
12 FTEQCCFLAGS_MENU ?= 
13
14 # NOTE: use -DUSE_FTE instead of -TFTE here!
15 # It will automagically add an engine check with -TID and then change back to -TFTE
16 FTEQCCFLAGS_CSPROGS ?= 
17
18 # xonotic svn build system overrides this by command line argument
19 NEX_BUILDSYSTEM =
20
21 all: qc
22
23 .PHONY: update-cvarcount
24 update-cvarcount:
25         [ "$(NEX_BUILDSYSTEM)" = "" ] || [ "$(NEX_BUILDSYSTEM)" = "1" ]
26         [ "$(NEX_BUILDSYSTEM)" != "" ] || { ! [ -f ../misc/netradiant-XonoticPack/xonotic.game/data/entities.def ] || $(DIFF) scripts/entities.def ../misc/netradiant-XonoticPack/xonotic.game/data/entities.def || { echo entities.def mismatch, please merge ../misc/netradiant-XonoticPack/xonotic.game/data/entities.def and scripts/entities.def; exit 1; }; }
27         [ "$(NEX_BUILDSYSTEM)" != "" ] || { DO_NOT_RUN_MAKE=1 sh update-cvarcount.sh; }
28
29 .PHONY: qc
30 qc: update-cvarcount
31         $(MAKE) qc-recursive
32
33 .PHONY: qc-recursive
34 qc-recursive: menu.dat progs.dat csprogs.dat
35
36 .PHONY: skin
37 skin: gfx/menu/default/skinvalues.txt
38
39 .PHONY: pk3
40 pk3: $(PK3NAME)
41
42 .PHONY: pk3here
43 pk3here: qc
44         $(RM) $(PK3NAME); \
45         set -ex; \
46                 ABSPK3NAME=$(PK3NAME); \
47                 case $$ABSPK3NAME in \
48                         /*) \
49                                 ;; \
50                         *) \
51                                 ABSPK3NAME=$$PWD/$$ABSPK3NAME; \
52                                 ;; \
53                 esac; \
54                 $(ZIP) $(ZIPEXCLUDE) $$ABSPK3NAME .
55
56 .PHONY: clean
57 clean:
58         rm -f progs.dat menu.dat csprogs.dat
59
60 csprogs.dat: qcsrc/client/*.* qcsrc/common/*.* qcsrc/warpzonelib/*.*
61         @echo make[1]: Entering directory \`$(PWD)/qcsrc/client\'
62         cd qcsrc/client && $(FTEQCC) $(FTEQCCFLAGS) $(FTEQCCFLAGS_CSPROGS)
63
64 progs.dat: qcsrc/server/*.* qcsrc/common/*.* qcsrc/server/*/*.* qcsrc/server/*/*/*.* qcsrc/warpzonelib/*.*
65         @echo make[1]: Entering directory \`$(PWD)/qcsrc/server\'
66         cd qcsrc/server && $(FTEQCC) $(FTEQCCFLAGS) $(FTEQCCFLAGS_PROGS)
67
68 menu.dat: qcsrc/menu/*.* qcsrc/menu/*/*.* qcsrc/common/*.*
69         @echo make[1]: Entering directory \`$(PWD)/qcsrc/menu\'
70         cd qcsrc/menu && $(FTEQCC) $(FTEQCCFLAGS) $(FTEQCCFLAGS_MENU)
71
72 gfx/menu/default/skinvalues.txt: qcsrc/menu/skin-customizables.inc
73         $(PERL) qcsrc/menu/skin-customizables.inc > gfx/menu/default/skinvalues.txt
74
75 $(PK3NAME): qc
76         $(RM) $(PK3NAME)
77         set -ex; \
78                 ABSPK3NAME=$(PK3NAME); \
79                 case $$ABSPK3NAME in \
80                         /*) \
81                                 ;; \
82                         *) \
83                                 ABSPK3NAME=$$PWD/$$ABSPK3NAME; \
84                                 ;; \
85                 esac; \
86                 TDIR=`mktemp -d -t xonoticpk3.XXXXXX`; \
87                 cp -v progs.dat csprogs.dat menu.dat $$TDIR/; \
88                 svn export --force . $$TDIR; \
89                 cd $$TDIR; \
90                 $(ZIP) $$ABSPK3NAME .
91
92 .PHONY: testcase
93 testcase:
94         cd qcsrc/testcase && $(FTEQCC) $(FTEQCCFLAGS) $(FTEQCCFLAGS_CSPROGS) -DTESTCASE="$$TESTCASE"
95
96 .PHONY: update commit diff log logv logupdate logvupdate revert
97 update: $(SCM)-update
98 commit: $(SCM)-commit
99 diff: $(SCM)-diff
100 log: $(SCM)-log
101 logv: $(SCM)-logv
102 revert: $(SCM)-revert
103 logupdate: log update
104 logvupdate: logv update
105
106 .PHONY: svn-update
107 svn-update:
108         cd .. && svn update
109
110 .PHONY: svn-commit
111 svn-commit:
112         cd .. && svn commit
113
114 .PHONY: svn-diff
115 svn-diff:
116         cd .. && svn diff
117
118 .PHONY: svn-log
119 svn-log:
120         cd .. && svn log -r HEAD:BASE
121
122 .PHONY: svn-logv
123 svn-logv:
124         cd .. && svn log -r HEAD:BASE -v
125
126 .PHONY: svn-revert
127 svn-revert:
128         svn revert -- $(FILE)
129
130 .PHONY: git-update
131 git-update:
132         git pull origin
133
134 .PHONY: git-commit
135 git-commit:
136         git commit -a || true
137         if echo -n 'Also send to server? Hit Enter for yes, ^C for no. '; read -r L; then \
138                 git config svn-remote.svn.url svn://svn.icculus.org/xonotic; \
139                 git config svn-remote.svn.fetch trunk:refs/remotes/origin/master; \
140                 git svn dcommit; \
141         fi
142
143 .PHONY: git-diff
144 git-diff:
145         git diff; git diff origin/master..HEAD; true
146
147 .PHONY: git-log
148 git-log:
149         git fetch && git log HEAD..origin/master
150
151 .PHONY: git-logv
152 git-logv:
153         git fetch && git log -v HEAD..origin/master
154
155 .PHONY: git-revert
156 git-revert:
157         git checkout -- $(FILE)