3 BINDIR := $(PREFIX)/bin
4 DATADIR := $(PREFIX)/share
5 MANDIR := $(DATADIR)/man
7 UNAME ?= $(shell uname)
8 CYGWIN = $(findstring CYGWIN, $(UNAME))
9 MINGW = $(findstring MINGW32, $(UNAME))
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)\""
16 #turn on tons of warnings if clang is present
17 # but also turn off the STUPID ONES
22 -Wno-format-nonliteral \
23 -Wno-disabled-macro-expansion \
25 -Wno-missing-prototypes \
28 -Wno-missing-variable-declarations \
29 -Wno-unknown-warning-option
31 #Tiny C Compiler doesn't know what -pedantic-errors is
32 # and instead of ignoring .. just errors.
34 CFLAGS +=-pedantic-errors
36 CFLAGS += -Wno-pointer-sign -fno-common
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
49 ifneq ("$(CYGWIN)", "")
50 #nullify the common variables that
51 #most *nix systems have (for windows)
58 TESTSUITE = testsuite.exe
60 ifneq ("$(MINGW)", "")
61 #nullify the common variables that
62 #most *nix systems have (for windows)
69 TESTSUITE = testsuite.exe
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
113 -shiftimplementation \
118 -bufferoverflowhigh \
137 $(CC) -c $< -o $@ $(CFLAGS)
139 exec-standalone.o: exec.c
140 $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
143 $(CC) -o $@ $^ $(CFLAGS) -lm
145 $(GMQCC): $(OBJ_C) $(OBJ_D)
146 $(CC) -o $@ $^ $(CFLAGS)
148 $(TESTSUITE): $(OBJ_T)
149 $(CC) -o $@ $^ $(CFLAGS)
151 all: $(GMQCC) $(QCVM) $(TESTSUITE)
159 rm -f *.o $(GMQCC) $(QCVM) $(TESTSUITE) *.dat
162 @ splint $(SPLINTFLAGS) *.c *.h
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))
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
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/
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
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
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
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
216 util.o: gmqcc.h opts.def
217 conout.o: gmqcc.h opts.def
218 file.o: gmqcc.h opts.def