]> de.git.xonotic.org Git - xonotic/gmqcc.git/blob - Makefile
on linux we need -lm for sqrt
[xonotic/gmqcc.git] / Makefile
1 CC     ?= clang
2 CFLAGS += -Wall -I. -pedantic-errors
3
4 #turn on tons of warnings if clang is present
5 ifeq ($(CC), clang)
6         CFLAGS +=                  \
7                 -Weverything                  \
8                 -Wno-missing-prototypes       \
9                 -Wno-unused-parameter         \
10                 -Wno-sign-compare             \
11                 -Wno-implicit-fallthrough     \
12                 -Wno-sign-conversion          \
13                 -Wno-conversion               \
14                 -Wno-disabled-macro-expansion \
15                 -Wno-padded                   \
16                 -Wno-format-nonliteral
17
18 endif
19 ifeq ($(track), no)
20     CFLAGS += -DNOTRACK
21 endif
22
23 OBJ     = \
24           util.o      \
25           code.o      \
26           ast.o       \
27           ir.o        \
28           error.o
29 OBJ_A = test/ast-test.o
30 OBJ_I = test/ir-test.o
31 OBJ_C = main.o lexer.o parser.o
32 OBJ_X = exec-standalone.o util.o
33
34 #default is compiler only
35 default: gmqcc
36 %.o: %.c
37         $(CC) -c $< -o $@ $(CFLAGS)
38
39 exec-standalone.o: exec.c
40         $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
41
42 # test targets
43 test_ast: $(OBJ_A) $(OBJ)
44         $(CC) -o $@ $^ $(CFLAGS)
45 test_ir:  $(OBJ_I) $(OBJ)
46         $(CC) -o $@ $^ $(CFLAGS)
47 qcvm:     $(OBJ_X)
48         $(CC) -o $@ $^ $(CFLAGS) -lm
49 exec.o: execloop.h
50 exec-standalone.o: execloop.h
51 test: test_ast test_ir
52
53 # compiler target
54 gmqcc: $(OBJ_C) $(OBJ)
55         $(CC) -o $@ $^ $(CFLAGS)
56
57 #all target is test and all
58 all: test gmqcc
59
60 clean:
61         rm -f *.o gmqcc qcvm test_ast test_ir test/*.o
62         
63