]> de.git.xonotic.org Git - xonotic/gmqcc.git/blob - Makefile
replacing an error message in the enum parsing
[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 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 else
29         #Tiny C Compiler doesn't know what -pedantic-errors is
30         # and instead of ignoring .. just errors.
31         ifneq ($(CC), tcc)
32                 CFLAGS +=-pedantic-errors
33         else
34                 CFLAGS += -Wno-pointer-sign -fno-common
35         endif
36 endif
37
38 ifeq ($(track), no)
39     CFLAGS += -DNOTRACK
40 endif
41
42 OBJ_D = util.o code.o ast.o ir.o conout.o ftepp.o opts.o file.o utf8.o correct.o
43 OBJ_T = test.o util.o conout.o file.o
44 OBJ_C = main.o lexer.o parser.o file.o
45 OBJ_X = exec-standalone.o util.o conout.o file.o
46
47 ifneq ("$(CYGWIN)", "")
48         #nullify the common variables that
49         #most *nix systems have (for windows)
50         PREFIX   :=
51         BINDIR   :=
52         DATADIR  :=
53         MANDIR   :=
54         QCVM      = qcvm.exe
55         GMQCC     = gmqcc.exe
56         TESTSUITE = testsuite.exe
57 else
58 ifneq ("$(MINGW)", "")
59         #nullify the common variables that
60         #most *nix systems have (for windows)
61         PREFIX   :=
62         BINDIR   :=
63         DATADIR  :=
64         MANDIR   :=
65         QCVM      = qcvm.exe
66         GMQCC     = gmqcc.exe
67         TESTSUITE = testsuite.exe
68 else
69         #arm support for linux .. we need to allow unaligned accesses
70         #to memory otherwise we just segfault everywhere
71         ifneq (, $(findstring arm, $(shell uname -m)))
72                 CFLAGS += -munaligned-access
73         endif
74
75         QCVM      = qcvm
76         GMQCC     = gmqcc
77         TESTSUITE = testsuite
78 endif
79 endif
80
81 #splint flags
82 SPLINTFLAGS =            \
83     -redef               \
84     -noeffect            \
85     -nullderef           \
86     -usedef              \
87     -type                \
88     -mustfreeonly        \
89     -nullstate           \
90     -varuse              \
91     -mustfreefresh       \
92     -compdestroy         \
93     -compmempass         \
94     -nullpass            \
95     -onlytrans           \
96     -predboolint         \
97     -boolops             \
98     -exportlocal         \
99     -incondefs           \
100     -macroredef          \
101     -retvalint           \
102     -nullret             \
103     -predboolothers      \
104     -globstate           \
105     -dependenttrans      \
106     -branchstate         \
107     -compdef             \
108     -temptrans           \
109     -usereleased         \
110     -warnposix           \
111     -shiftimplementation \
112     +charindex           \
113     -kepttrans           \
114     -unqualifiedtrans    \
115     +matchanyintegral    \
116     -bufferoverflowhigh  \
117     +voidabstract        \
118     -nullassign          \
119     -unrecog             \
120     -casebreak           \
121     -retvalbool          \
122     -retvalother         \
123     -mayaliasunique      \
124     -realcompare         \
125     -observertrans       \
126     -shiftnegative       \
127     -freshtrans          \
128     -abstract            \
129     -statictrans         \
130     -castfcnptr
131
132 #standard rules
133 default: all
134 %.o: %.c
135         $(CC) -c $< -o $@ $(CFLAGS)
136
137 exec-standalone.o: exec.c
138         $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
139
140 $(QCVM): $(OBJ_X)
141         $(CC) -o $@ $^ $(CFLAGS) -lm
142
143 $(GMQCC): $(OBJ_C) $(OBJ_D)
144         $(CC) -o $@ $^ $(CFLAGS)
145
146 $(TESTSUITE): $(OBJ_T)
147         $(CC) -o $@ $^ $(CFLAGS)
148
149 all: $(GMQCC) $(QCVM) $(TESTSUITE)
150
151 check: all
152         @ ./$(TESTSUITE)
153 test: check
154         @ ./$(TESTSUITE)
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