aa5ef11f11b60b2f9955c596c60b522e78c4dde4
[xonotic/gmqcc.git] / Makefile
1 DESTDIR :=
2 PREFIX := /usr/local
3 BINDIR := $(PREFIX)/bin
4
5 CC     ?= clang
6 CFLAGS += -Wall -I. -fomit-frame-pointer -fno-stack-protector -fno-common
7 #turn on tons of warnings if clang is present
8 ifeq ($(CC), clang)
9         CFLAGS +=                  \
10                 -Weverything                  \
11                 -Wno-missing-prototypes       \
12                 -Wno-unused-parameter         \
13                 -Wno-sign-compare             \
14                 -Wno-implicit-fallthrough     \
15                 -Wno-sign-conversion          \
16                 -Wno-conversion               \
17                 -Wno-disabled-macro-expansion \
18                 -Wno-padded                   \
19                 -Wno-format-nonliteral
20
21 endif
22 ifeq ($(track), no)
23     CFLAGS += -DNOTRACK
24 endif
25
26 OBJ     =             \
27           util.o      \
28           code.o      \
29           ast.o       \
30           ir.o        \
31           con.o       \
32           ftepp.o
33
34 OBJ_T = test.o util.o con.o
35 OBJ_C = main.o lexer.o parser.o
36 OBJ_X = exec-standalone.o util.o con.o
37
38
39 default: gmqcc
40 %.o: %.c
41         $(CC) -c $< -o $@ $(CFLAGS)
42
43 exec-standalone.o: exec.c
44         $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
45
46 qcvm: $(OBJ_X)
47         $(CC) -o $@ $^ $(CFLAGS) -lm
48
49 gmqcc: $(OBJ_C) $(OBJ)
50         $(CC) -o $@ $^ $(CFLAGS)
51
52 test: $(OBJ_T)
53         $(CC) -o $@ $^ $(CFLAGS)
54         
55 runtests:
56         ./test
57
58 all: gmqcc qcvm test
59
60 clean:
61         rm -f *.o gmqcc qcvm test *.dat
62
63
64 $(OBJ) $(OBJ_C) $(OBJ_X): gmqcc.h
65 main.o: lexer.h
66 parser.o: ast.h lexer.h
67 ast.o: ast.h ir.h
68 ir.o: ir.h
69
70 install: install-gmqcc install-qcvm
71 install-gmqcc: gmqcc
72         install -d -m755          $(DESTDIR)$(BINDIR)
73         install    -m755  gmqcc   $(DESTDIR)$(BINDIR)/gmqcc
74 install-qcvm: qcvm
75         install -d -m755          $(DESTDIR)$(BINDIR)
76         install    -m755  qcvm    $(DESTDIR)$(BINDIR)/qcvm