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