]> git.xonotic.org Git - xonotic/gmqcc.git/blob - Makefile
flatten the use of strcpy, 90% of the cases we already knew the length of the string...
[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
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     -abstract            \
164     -statictrans         \
165     -castfcnptr
166
167 #standard rules
168 default: all
169 %.o: %.c
170         $(CC) -c $< -o $@ $(CFLAGS)
171
172 exec-standalone.o: exec.c
173         $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
174
175 $(QCVM): $(OBJ_X)
176         $(CC) -o $@ $^ $(CFLAGS) -lm
177
178 $(GMQCC): $(OBJ_C) $(OBJ_D)
179         $(CC) -o $@ $^ $(CFLAGS) -lm
180
181 $(TESTSUITE): $(OBJ_T)
182         $(CC) -o $@ $^ $(CFLAGS) -lm
183
184 $(PAK): $(OBJ_P)
185         $(CC) -o $@ $^ $(CFLAGS)
186
187 all: $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK)
188
189 check: all
190         @ ./$(TESTSUITE)
191 test: all
192         @ ./$(TESTSUITE)
193
194 clean:
195         rm -f *.o $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK) *.dat gource.mp4
196
197 splint:
198         @  splint $(SPLINTFLAGS) *.c *.h
199
200 gource:
201         @ gource $(GOURCEFLAGS)
202
203 gource-record:
204         @ gource $(GOURCEFLAGS) -o - | ffmpeg $(FFMPEGFLAGS) gource.mp4
205
206 depend:
207         @makedepend    -Y -w 65536 2> /dev/null \
208                 $(subst .o,.c,$(OBJ_D))
209         @makedepend -a -Y -w 65536 2> /dev/null \
210                 $(subst .o,.c,$(OBJ_T))
211         @makedepend -a -Y -w 65536 2> /dev/null \
212                 $(subst .o,.c,$(OBJ_C))
213         @makedepend -a -Y -w 65536 2> /dev/null \
214                 $(subst .o,.c,$(OBJ_X))
215         @makedepend -a -Y -w 65536 2> /dev/null \
216                 $(subst .o,.c,$(OBJ_P))
217
218 #install rules
219 install: install-gmqcc install-qcvm install-doc
220 install-gmqcc: $(GMQCC)
221         install -d -m755               $(DESTDIR)$(BINDIR)
222         install    -m755  $(GMQCC)     $(DESTDIR)$(BINDIR)/gmqcc
223 install-qcvm: $(QCVM)
224         install -d -m755               $(DESTDIR)$(BINDIR)
225         install    -m755  $(QCVM)      $(DESTDIR)$(BINDIR)/qcvm
226 install-doc:
227         install -d -m755               $(DESTDIR)$(MANDIR)/man1
228         install    -m644  doc/gmqcc.1  $(DESTDIR)$(MANDIR)/man1/
229         install    -m644  doc/qcvm.1   $(DESTDIR)$(MANDIR)/man1/
230
231 uninstall:
232         rm $(DESTDIR)$(BINDIR)/gmqcc
233         rm $(DESTDIR)$(BINDIR)/qcvm
234         rm $(DESTDIR)$(MANDIR)/man1/doc/gmqcc.1
235         rm $(DESTDIR)$(MANDIR)/man1/doc/qcvm.1
236
237 # DO NOT DELETE
238
239 util.o: gmqcc.h opts.def
240 code.o: gmqcc.h opts.def
241 ast.o: gmqcc.h opts.def ast.h ir.h
242 ir.o: gmqcc.h opts.def ir.h
243 conout.o: gmqcc.h opts.def
244 ftepp.o: gmqcc.h opts.def lexer.h
245 opts.o: gmqcc.h opts.def
246 fs.o: gmqcc.h opts.def
247 utf8.o: gmqcc.h opts.def
248 correct.o: gmqcc.h opts.def
249
250 test.o: gmqcc.h opts.def
251 util.o: gmqcc.h opts.def
252 conout.o: gmqcc.h opts.def
253 fs.o: gmqcc.h opts.def
254
255 main.o: gmqcc.h opts.def lexer.h
256 lexer.o: gmqcc.h opts.def lexer.h
257 parser.o: gmqcc.h opts.def lexer.h ast.h ir.h intrin.h
258 fs.o: gmqcc.h opts.def
259
260 util.o: gmqcc.h opts.def
261 conout.o: gmqcc.h opts.def
262 fs.o: gmqcc.h opts.def
263
264 util.o: gmqcc.h opts.def
265 fs.o: gmqcc.h opts.def
266 conout.o: gmqcc.h opts.def
267 opts.o: gmqcc.h opts.def
268 pak.o: gmqcc.h opts.def