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