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 -O2
13 CFLAGS += -DGMQCC_GITINFO="`git describe`"
14 #turn on tons of warnings if clang is present
15 # but also turn off the STUPID ONES
20 -Wno-format-nonliteral \
21 -Wno-disabled-macro-expansion \
23 -Wno-missing-prototypes \
27 #Tiny C Compiler doesn't know what -pedantic-errors is
28 # and instead of ignoring .. just errors.
30 CFLAGS +=-pedantic-errors
32 CFLAGS += -Wno-pointer-sign -fno-common
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
45 ifneq ("$(CYGWIN)", "")
46 #nullify the common variables that
47 #most *nix systems have (for windows)
54 TESTSUITE = testsuite.exe
56 ifneq ("$(MINGW)", "")
57 #nullify the common variables that
58 #most *nix systems have (for windows)
65 TESTSUITE = testsuite.exe
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
82 $(CC) -c $< -o $@ $(CFLAGS)
84 exec-standalone.o: exec.c
85 $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
88 $(CC) -o $@ $^ $(CFLAGS) -lm
90 $(GMQCC): $(OBJ_C) $(OBJ_D)
91 $(CC) -o $@ $^ $(CFLAGS)
93 $(TESTSUITE): $(OBJ_T)
94 $(CC) -o $@ $^ $(CFLAGS)
96 all: $(GMQCC) $(QCVM) $(TESTSUITE)
101 # alias to check because test.o exists and people will get confused
102 # about the undefined references to X.
106 rm -f *.o $(GMQCC) $(QCVM) $(TESTSUITE) *.dat
112 @makedepend -Y -w 65536 2> /dev/null \
113 $(subst .o,.c,$(OBJ_D))
114 @makedepend -a -Y -w 65536 2> /dev/null \
115 $(subst .o,.c,$(OBJ_T))
116 @makedepend -a -Y -w 65536 2> /dev/null \
117 $(subst .o,.c,$(OBJ_C))
118 @makedepend -a -Y -w 65536 2> /dev/null \
119 $(subst .o,.c,$(OBJ_X))
122 install: install-gmqcc install-qcvm install-doc
123 install-gmqcc: $(GMQCC)
124 install -d -m755 $(DESTDIR)$(BINDIR)
125 install -m755 $(GMQCC) $(DESTDIR)$(BINDIR)/gmqcc
126 install-qcvm: $(QCVM)
127 install -d -m755 $(DESTDIR)$(BINDIR)
128 install -m755 $(QCVM) $(DESTDIR)$(BINDIR)/qcvm
130 install -d -m755 $(DESTDIR)$(MANDIR)/man1
131 install -m755 doc/gmqcc.1 $(DESTDIR)$(MANDIR)/man1/
132 install -m755 doc/qcvm.1 $(DESTDIR)$(MANDIR)/man1/
136 util.o: gmqcc.h opts.def
137 code.o: gmqcc.h opts.def
138 ast.o: gmqcc.h opts.def ast.h ir.h
139 ir.o: gmqcc.h opts.def ir.h
140 conout.o: gmqcc.h opts.def
141 ftepp.o: gmqcc.h opts.def lexer.h
142 opts.o: gmqcc.h opts.def
143 file.o: gmqcc.h opts.def
144 utf8.o: gmqcc.h opts.def
145 correct.o: gmqcc.h opts.def
147 test.o: gmqcc.h opts.def
148 util.o: gmqcc.h opts.def
149 conout.o: gmqcc.h opts.def
150 file.o: gmqcc.h opts.def
152 main.o: gmqcc.h opts.def lexer.h
153 lexer.o: gmqcc.h opts.def lexer.h
154 parser.o: gmqcc.h opts.def lexer.h ast.h ir.h
155 file.o: gmqcc.h opts.def
157 util.o: gmqcc.h opts.def
158 conout.o: gmqcc.h opts.def
159 file.o: gmqcc.h opts.def