]> git.xonotic.org Git - xonotic/gmqcc.git/blob - Makefile
Merge branch 'master' into cooking
[xonotic/gmqcc.git] / Makefile
1 DESTDIR :=
2 OPTIONAL:=
3 PREFIX  := /usr/local
4 BINDIR  := $(PREFIX)/bin
5 DATADIR := $(PREFIX)/share
6 MANDIR  := $(DATADIR)/man
7
8 UNAME  ?= $(shell uname)
9 CYGWIN  = $(findstring CYGWIN,  $(UNAME))
10 MINGW   = $(findstring MINGW32, $(UNAME))
11
12 CC     ?= clang
13 CFLAGS += -Wall -Wextra -Werror -I. -fno-strict-aliasing -fsigned-char $(OPTIONAL)
14 ifneq ($(shell git describe --always 2>/dev/null),)
15     CFLAGS += -DGMQCC_GITINFO="\"$(shell git describe --always)\""
16 endif
17 #turn on tons of warnings if clang is present
18 # but also turn off the STUPID ONES
19 ifeq ($(CC), clang)
20         CFLAGS +=                              \
21             -Weverything                       \
22             -Wno-padded                        \
23             -Wno-format-nonliteral             \
24             -Wno-disabled-macro-expansion      \
25             -Wno-conversion                    \
26             -Wno-missing-prototypes            \
27             -Wno-float-equal                   \
28             -Wno-cast-align                    \
29             -Wno-missing-variable-declarations \
30             -Wno-unknown-warning-option
31 else
32         #Tiny C Compiler doesn't know what -pedantic-errors is
33         # and instead of ignoring .. just errors.
34         ifneq ($(CC), tcc)
35                 CFLAGS +=-pedantic-errors -ffunction-sections -fdata-sections -Wl,-gc-sections
36         else
37                 CFLAGS += -Wno-pointer-sign -fno-common
38         endif
39 endif
40
41 ifeq ($(track), no)
42         CFLAGS += -DNOTRACK
43 endif
44
45 OBJ_D = util.o code.o ast.o ir.o conout.o ftepp.o opts.o fs.o utf8.o correct.o
46 OBJ_P = util.o fs.o conout.o opts.o pak.o
47 OBJ_T = test.o util.o conout.o fs.o
48 OBJ_C = main.o lexer.o parser.o fs.o
49 OBJ_X = exec-standalone.o util.o conout.o fs.o
50
51 ifneq ("$(CYGWIN)", "")
52         #nullify the common variables that
53         #most *nix systems have (for windows)
54         PREFIX   :=
55         BINDIR   :=
56         DATADIR  :=
57         MANDIR   :=
58         QCVM      = qcvm.exe
59         GMQCC     = gmqcc.exe
60         TESTSUITE = testsuite.exe
61         PAK       = pak.exe
62 else
63 ifneq ("$(MINGW)", "")
64         #nullify the common variables that
65         #most *nix systems have (for windows)
66         PREFIX   :=
67         BINDIR   :=
68         DATADIR  :=
69         MANDIR   :=
70         QCVM      = qcvm.exe
71         GMQCC     = gmqcc.exe
72         TESTSUITE = testsuite.exe
73         PAK       = pak.exe
74 else
75         #arm support for linux .. we need to allow unaligned accesses
76         #to memory otherwise we just segfault everywhere
77         ifneq (, $(findstring arm, $(shell uname -m)))
78                 CFLAGS += -munaligned-access
79         endif
80
81         QCVM      = qcvm
82         GMQCC     = gmqcc
83         TESTSUITE = testsuite
84         PAK       = pak
85 endif
86 endif
87
88 #gource flags
89 GOURCEFLAGS=                  \
90     --date-format "%d %B, %Y" \
91     --seconds-per-day 0.01    \
92     --auto-skip-seconds 1     \
93     --title "GMQCC"           \
94     --key                     \
95     --camera-mode overview    \
96     --highlight-all-users     \
97     --file-idle-time 0        \
98     --hide progress,mouse     \
99     --stop-at-end             \
100     --max-files 99999999999   \
101     --max-file-lag 0.000001   \
102     --bloom-multiplier 1.3    \
103     -1280x720
104
105 #ffmpeg flags for gource
106 FFMPEGFLAGS=                  \
107     -y                        \
108     -r 60                     \
109     -f image2pipe             \
110     -vcodec ppm               \
111     -i -                      \
112     -vcodec libx264           \
113     -preset ultrafast         \
114     -crf 1                    \
115     -threads 0                \
116     -bf 0
117
118 #splint flags
119 SPLINTFLAGS =            \
120     -redef               \
121     -noeffect            \
122     -nullderef           \
123     -usedef              \
124     -type                \
125     -mustfreeonly        \
126     -nullstate           \
127     -varuse              \
128     -mustfreefresh       \
129     -compdestroy         \
130     -compmempass         \
131     -nullpass            \
132     -onlytrans           \
133     -predboolint         \
134     -boolops             \
135     -exportlocal         \
136     -incondefs           \
137     -macroredef          \
138     -retvalint           \
139     -nullret             \
140     -predboolothers      \
141     -globstate           \
142     -dependenttrans      \
143     -branchstate         \
144     -compdef             \
145     -temptrans           \
146     -usereleased         \
147     -warnposix           \
148     -shiftimplementation \
149     +charindex           \
150     -kepttrans           \
151     -unqualifiedtrans    \
152     +matchanyintegral    \
153     +voidabstract        \
154     -nullassign          \
155     -unrecog             \
156     -casebreak           \
157     -retvalbool          \
158     -retvalother         \
159     -mayaliasunique      \
160     -realcompare         \
161     -observertrans       \
162     -shiftnegative       \
163     -freshtrans          \
164     -abstract            \
165     -statictrans         \
166     -castfcnptr
167
168 #standard rules
169 default: all
170 %.o: %.c
171         $(CC) -c $< -o $@ $(CFLAGS)
172
173 exec-standalone.o: exec.c
174         $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
175
176 $(QCVM): $(OBJ_X)
177         $(CC) -o $@ $^ $(CFLAGS) -lm
178
179 $(GMQCC): $(OBJ_C) $(OBJ_D)
180         $(CC) -o $@ $^ $(CFLAGS) -lm
181
182 $(TESTSUITE): $(OBJ_T)
183         $(CC) -o $@ $^ $(CFLAGS) -lm
184
185 $(PAK): $(OBJ_P)
186         $(CC) -o $@ $^ $(CFLAGS)
187
188 all: $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK)
189
190 check: all
191         @ ./$(TESTSUITE)
192 test: all
193         @ ./$(TESTSUITE)
194
195 clean:
196         rm -f *.o $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK) *.dat gource.mp4
197
198 splint:
199         @  splint $(SPLINTFLAGS) *.c *.h
200
201 gource:
202         @ gource $(GOURCEFLAGS)
203
204 gource-record:
205         @ gource $(GOURCEFLAGS) -o - | ffmpeg $(FFMPEGFLAGS) gource.mp4
206
207 depend:
208         @makedepend    -Y -w 65536 2> /dev/null \
209                 $(subst .o,.c,$(OBJ_D))
210         @makedepend -a -Y -w 65536 2> /dev/null \
211                 $(subst .o,.c,$(OBJ_T))
212         @makedepend -a -Y -w 65536 2> /dev/null \
213                 $(subst .o,.c,$(OBJ_C))
214         @makedepend -a -Y -w 65536 2> /dev/null \
215                 $(subst .o,.c,$(OBJ_X))
216         @makedepend -a -Y -w 65536 2> /dev/null \
217                 $(subst .o,.c,$(OBJ_P))
218
219 #install rules
220 install: install-gmqcc install-qcvm install-doc
221 install-gmqcc: $(GMQCC)
222         install -d -m755               $(DESTDIR)$(BINDIR)
223         install    -m755  $(GMQCC)     $(DESTDIR)$(BINDIR)/gmqcc
224 install-qcvm: $(QCVM)
225         install -d -m755               $(DESTDIR)$(BINDIR)
226         install    -m755  $(QCVM)      $(DESTDIR)$(BINDIR)/qcvm
227 install-doc:
228         install -d -m755               $(DESTDIR)$(MANDIR)/man1
229         install    -m644  doc/gmqcc.1  $(DESTDIR)$(MANDIR)/man1/
230         install    -m644  doc/qcvm.1   $(DESTDIR)$(MANDIR)/man1/
231
232 uninstall:
233         rm $(DESTDIR)$(BINDIR)/gmqcc
234         rm $(DESTDIR)$(BINDIR)/qcvm
235         rm $(DESTDIR)$(MANDIR)/man1/doc/gmqcc.1
236         rm $(DESTDIR)$(MANDIR)/man1/doc/qcvm.1
237
238 # DO NOT DELETE
239
240 util.o: gmqcc.h opts.def
241 code.o: gmqcc.h opts.def
242 ast.o: gmqcc.h opts.def ast.h ir.h
243 ir.o: gmqcc.h opts.def ir.h
244 conout.o: gmqcc.h opts.def
245 ftepp.o: gmqcc.h opts.def lexer.h
246 opts.o: gmqcc.h opts.def
247 fs.o: gmqcc.h opts.def
248 utf8.o: gmqcc.h opts.def
249 correct.o: gmqcc.h opts.def
250
251 test.o: gmqcc.h opts.def
252 util.o: gmqcc.h opts.def
253 conout.o: gmqcc.h opts.def
254 fs.o: gmqcc.h opts.def
255
256 main.o: gmqcc.h opts.def lexer.h
257 lexer.o: gmqcc.h opts.def lexer.h
258 parser.o: gmqcc.h opts.def lexer.h ast.h ir.h intrin.h
259 fs.o: gmqcc.h opts.def
260
261 util.o: gmqcc.h opts.def
262 conout.o: gmqcc.h opts.def
263 fs.o: gmqcc.h opts.def
264
265 util.o: gmqcc.h opts.def
266 fs.o: gmqcc.h opts.def
267 conout.o: gmqcc.h opts.def
268 opts.o: gmqcc.h opts.def
269 pak.o: gmqcc.h opts.def