]> git.xonotic.org Git - xonotic/gmqcc.git/blob - Makefile
Merge branch 'master' of github.com:graphitemaster/gmqcc
[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
13 CFLAGS += -DGMQCC_GITINFO="`git describe`"
14 #turn on tons of warnings if clang is present
15 # but also turn off the STUPID ONES
16 ifeq ($(CC), clang)
17         CFLAGS +=                         \
18                 -Weverything                  \
19                 -Wno-padded                   \
20                 -Wno-format-nonliteral        \
21                 -Wno-disabled-macro-expansion \
22                 -Wno-conversion               \
23                 -Wno-missing-prototypes       \
24                 -Wno-float-equal              \
25                 -Wno-cast-align
26 else
27         #Tiny C Compiler doesn't know what -pedantic-errors is
28         # and instead of ignoring .. just errors.
29         ifneq ($(CC), tcc)
30                 CFLAGS +=-pedantic-errors
31         else
32                 CFLAGS += -Wno-pointer-sign -fno-common
33         endif
34 endif
35
36 ifeq ($(track), no)
37     CFLAGS += -DNOTRACK
38 endif
39
40 OBJ_D = util.o code.o ast.o ir.o conout.o ftepp.o opts.o file.o utf8.o correct.o
41 OBJ_T = test.o util.o conout.o file.o
42 OBJ_C = main.o lexer.o parser.o file.o
43 OBJ_X = exec-standalone.o util.o conout.o file.o
44
45 ifneq ("$(CYGWIN)", "")
46         #nullify the common variables that
47         #most *nix systems have (for windows)
48         PREFIX   :=
49         BINDIR   :=
50         DATADIR  :=
51         MANDIR   :=
52         QCVM      = qcvm.exe
53         GMQCC     = gmqcc.exe
54         TESTSUITE = testsuite.exe
55 else
56 ifneq ("$(MINGW)", "")
57         #nullify the common variables that
58         #most *nix systems have (for windows)
59         PREFIX   :=
60         BINDIR   :=
61         DATADIR  :=
62         MANDIR   :=
63         QCVM      = qcvm.exe
64         GMQCC     = gmqcc.exe
65         TESTSUITE = testsuite.exe
66 else
67         #arm support for linux .. we need to allow unaligned accesses
68         #to memory otherwise we just segfault everywhere
69         ifneq (, $(findstring arm, $(shell uname -m)))
70                 CFLAGS += -munaligned-access
71         endif
72
73         QCVM      = qcvm
74         GMQCC     = gmqcc
75         TESTSUITE = testsuite
76 endif
77 endif
78
79 #splint flags
80 SPLINTFLAGS =            \
81     -redef               \
82     -noeffect            \
83     -nullderef           \
84     -usedef              \
85     -type                \
86     -mustfreeonly        \
87     -nullstate           \
88     -varuse              \
89     -mustfreefresh       \
90     -compdestroy         \
91     -compmempass         \
92     -nullpass            \
93     -onlytrans           \
94     -predboolint         \
95     -boolops             \
96     -exportlocal         \
97     -incondefs           \
98     -macroredef          \
99     -retvalint           \
100     -nullret             \
101     -predboolothers      \
102     -globstate           \
103     -dependenttrans      \
104     -branchstate         \
105     -compdef             \
106     -temptrans           \
107     -usereleased         \
108     -warnposix           \
109     -shiftimplementation \
110     +charindex           \
111     -kepttrans           \
112     -unqualifiedtrans    \
113     +matchanyintegral    \
114     -bufferoverflowhigh  \
115     +voidabstract        \
116     -nullassign          \
117     -unrecog             \
118     -casebreak           \
119     -retvalbool          \
120     -retvalother         \
121     -mayaliasunique      \
122     -realcompare         \
123     -observertrans       \
124     -shiftnegative       \
125     -freshtrans          \
126     -abstract            \
127     -statictrans         \
128     -castfcnptr
129
130 #standard rules
131 default: all
132 %.o: %.c
133         $(CC) -c $< -o $@ $(CFLAGS)
134
135 exec-standalone.o: exec.c
136         $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
137
138 $(QCVM): $(OBJ_X)
139         $(CC) -o $@ $^ $(CFLAGS) -lm
140
141 $(GMQCC): $(OBJ_C) $(OBJ_D)
142         $(CC) -o $@ $^ $(CFLAGS)
143
144 $(TESTSUITE): $(OBJ_T)
145         $(CC) -o $@ $^ $(CFLAGS)
146
147 all: $(GMQCC) $(QCVM) $(TESTSUITE)
148
149 check: all
150         @ ./$(TESTSUITE)
151
152 # alias to check because test.o exists and people will get confused
153 # about the undefined references to X.
154 test: check
155
156 clean:
157         rm -f *.o $(GMQCC) $(QCVM) $(TESTSUITE) *.dat
158
159 splint:
160         @  splint $(SPLINTFLAGS) *.c *.h
161
162 depend:
163         @makedepend    -Y -w 65536 2> /dev/null \
164                 $(subst .o,.c,$(OBJ_D))
165         @makedepend -a -Y -w 65536 2> /dev/null \
166                 $(subst .o,.c,$(OBJ_T))
167         @makedepend -a -Y -w 65536 2> /dev/null \
168                 $(subst .o,.c,$(OBJ_C))
169         @makedepend -a -Y -w 65536 2> /dev/null \
170                 $(subst .o,.c,$(OBJ_X))
171
172 #install rules
173 install: install-gmqcc install-qcvm install-doc
174 install-gmqcc: $(GMQCC)
175         install -d -m755               $(DESTDIR)$(BINDIR)
176         install    -m755  $(GMQCC)     $(DESTDIR)$(BINDIR)/gmqcc
177 install-qcvm: $(QCVM)
178         install -d -m755               $(DESTDIR)$(BINDIR)
179         install    -m755  $(QCVM)      $(DESTDIR)$(BINDIR)/qcvm
180 install-doc:
181         install -d -m755               $(DESTDIR)$(MANDIR)/man1
182         install    -m755  doc/gmqcc.1  $(DESTDIR)$(MANDIR)/man1/
183         install    -m755  doc/qcvm.1   $(DESTDIR)$(MANDIR)/man1/
184
185 # DO NOT DELETE
186
187 util.o: gmqcc.h opts.def
188 code.o: gmqcc.h opts.def
189 ast.o: gmqcc.h opts.def ast.h ir.h
190 ir.o: gmqcc.h opts.def ir.h
191 conout.o: gmqcc.h opts.def
192 ftepp.o: gmqcc.h opts.def lexer.h
193 opts.o: gmqcc.h opts.def
194 file.o: gmqcc.h opts.def
195 utf8.o: gmqcc.h opts.def
196 correct.o: gmqcc.h opts.def
197
198 test.o: gmqcc.h opts.def
199 util.o: gmqcc.h opts.def
200 conout.o: gmqcc.h opts.def
201 file.o: gmqcc.h opts.def
202
203 main.o: gmqcc.h opts.def lexer.h
204 lexer.o: gmqcc.h opts.def lexer.h
205 parser.o: gmqcc.h opts.def lexer.h ast.h ir.h
206 file.o: gmqcc.h opts.def
207
208 util.o: gmqcc.h opts.def
209 conout.o: gmqcc.h opts.def
210 file.o: gmqcc.h opts.def