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