]> git.xonotic.org Git - xonotic/gmqcc.git/blob - Makefile
Merge branch 'master' into cooking
[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 -I. -fno-strict-aliasing -fsigned-char -Wno-overlength-strings
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 file.o utf8.o correct.o
45 OBJ_T = test.o util.o conout.o file.o
46 OBJ_C = main.o lexer.o parser.o file.o
47 OBJ_X = exec-standalone.o util.o conout.o file.o
48
49 ifneq ("$(CYGWIN)", "")
50         #nullify the common variables that
51         #most *nix systems have (for windows)
52         PREFIX   :=
53         BINDIR   :=
54         DATADIR  :=
55         MANDIR   :=
56         QCVM      = qcvm.exe
57         GMQCC     = gmqcc.exe
58         TESTSUITE = testsuite.exe
59 else
60 ifneq ("$(MINGW)", "")
61         #nullify the common variables that
62         #most *nix systems have (for windows)
63         PREFIX   :=
64         BINDIR   :=
65         DATADIR  :=
66         MANDIR   :=
67         QCVM      = qcvm.exe
68         GMQCC     = gmqcc.exe
69         TESTSUITE = testsuite.exe
70 else
71         #arm support for linux .. we need to allow unaligned accesses
72         #to memory otherwise we just segfault everywhere
73         ifneq (, $(findstring arm, $(shell uname -m)))
74                 CFLAGS += -munaligned-access
75         endif
76
77         QCVM      = qcvm
78         GMQCC     = gmqcc
79         TESTSUITE = testsuite
80 endif
81 endif
82
83 #splint flags
84 SPLINTFLAGS =            \
85     -redef               \
86     -noeffect            \
87     -nullderef           \
88     -usedef              \
89     -type                \
90     -mustfreeonly        \
91     -nullstate           \
92     -varuse              \
93     -mustfreefresh       \
94     -compdestroy         \
95     -compmempass         \
96     -nullpass            \
97     -onlytrans           \
98     -predboolint         \
99     -boolops             \
100     -exportlocal         \
101     -incondefs           \
102     -macroredef          \
103     -retvalint           \
104     -nullret             \
105     -predboolothers      \
106     -globstate           \
107     -dependenttrans      \
108     -branchstate         \
109     -compdef             \
110     -temptrans           \
111     -usereleased         \
112     -warnposix           \
113     -shiftimplementation \
114     +charindex           \
115     -kepttrans           \
116     -unqualifiedtrans    \
117     +matchanyintegral    \
118     -bufferoverflowhigh  \
119     +voidabstract        \
120     -nullassign          \
121     -unrecog             \
122     -casebreak           \
123     -retvalbool          \
124     -retvalother         \
125     -mayaliasunique      \
126     -realcompare         \
127     -observertrans       \
128     -shiftnegative       \
129     -freshtrans          \
130     -abstract            \
131     -statictrans         \
132     -castfcnptr
133
134 #standard rules
135 default: all
136 %.o: %.c
137         $(CC) -c $< -o $@ $(CFLAGS)
138
139 exec-standalone.o: exec.c
140         $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
141
142 $(QCVM): $(OBJ_X)
143         $(CC) -o $@ $^ $(CFLAGS) -lm
144
145 $(GMQCC): $(OBJ_C) $(OBJ_D)
146         $(CC) -o $@ $^ $(CFLAGS)
147
148 $(TESTSUITE): $(OBJ_T)
149         $(CC) -o $@ $^ $(CFLAGS)
150
151 all: $(GMQCC) $(QCVM) $(TESTSUITE)
152
153 check: all
154         @ ./$(TESTSUITE)
155 test: check
156         @ ./$(TESTSUITE)
157
158 clean:
159         rm -f *.o $(GMQCC) $(QCVM) $(TESTSUITE) *.dat
160
161 splint:
162         @  splint $(SPLINTFLAGS) *.c *.h
163
164 depend:
165         @makedepend    -Y -w 65536 2> /dev/null \
166                 $(subst .o,.c,$(OBJ_D))
167         @makedepend -a -Y -w 65536 2> /dev/null \
168                 $(subst .o,.c,$(OBJ_T))
169         @makedepend -a -Y -w 65536 2> /dev/null \
170                 $(subst .o,.c,$(OBJ_C))
171         @makedepend -a -Y -w 65536 2> /dev/null \
172                 $(subst .o,.c,$(OBJ_X))
173
174 #install rules
175 install: install-gmqcc install-qcvm install-doc
176 install-gmqcc: $(GMQCC)
177         install -d -m755               $(DESTDIR)$(BINDIR)
178         install    -m755  $(GMQCC)     $(DESTDIR)$(BINDIR)/gmqcc
179 install-qcvm: $(QCVM)
180         install -d -m755               $(DESTDIR)$(BINDIR)
181         install    -m755  $(QCVM)      $(DESTDIR)$(BINDIR)/qcvm
182 install-doc:
183         install -d -m755               $(DESTDIR)$(MANDIR)/man1
184         install    -m644  doc/gmqcc.1  $(DESTDIR)$(MANDIR)/man1/
185         install    -m644  doc/qcvm.1   $(DESTDIR)$(MANDIR)/man1/
186
187 uninstall:
188         rm $(DESTDIR)$(BINDIR)/gmqcc
189         rm $(DESTDIR)$(BINDIR)/qcvm
190         rm $(DESTDIR)$(MANDIR)/man1/doc/gmqcc.1
191         rm $(DESTDIR)$(MANDIR)/man1/doc/qcvm.1
192
193 # DO NOT DELETE
194
195 util.o: gmqcc.h opts.def
196 code.o: gmqcc.h opts.def
197 ast.o: gmqcc.h opts.def ast.h ir.h
198 ir.o: gmqcc.h opts.def ir.h
199 conout.o: gmqcc.h opts.def
200 ftepp.o: gmqcc.h opts.def lexer.h
201 opts.o: gmqcc.h opts.def
202 file.o: gmqcc.h opts.def
203 utf8.o: gmqcc.h opts.def
204 correct.o: gmqcc.h opts.def
205
206 test.o: gmqcc.h opts.def
207 util.o: gmqcc.h opts.def
208 conout.o: gmqcc.h opts.def
209 file.o: gmqcc.h opts.def
210
211 main.o: gmqcc.h opts.def lexer.h
212 lexer.o: gmqcc.h opts.def lexer.h
213 parser.o: gmqcc.h opts.def lexer.h ast.h ir.h
214 file.o: gmqcc.h opts.def
215
216 util.o: gmqcc.h opts.def
217 conout.o: gmqcc.h opts.def
218 file.o: gmqcc.h opts.def