]> de.git.xonotic.org Git - xonotic/gmqcc.git/blob - Makefile
Working on getting gmqcc to work when compiled with tcc
[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 #turn on tons of warnings if clang is present
14 # but also turn off the STUPID ONES
15 ifeq ($(CC), clang)
16         CFLAGS +=                         \
17                 -Weverything                  \
18                 -Wno-padded                   \
19                 -Wno-format-nonliteral        \
20                 -Wno-disabled-macro-expansion \
21                 -Wno-conversion               \
22                 -Wno-missing-prototypes       \
23                 -Wno-float-equal              \
24                 -Wno-cast-align
25 else
26         #Tiny C Compiler doesn't know what -pedantic-errors is
27         # and instead of ignoring .. just errors.
28         ifneq ($(CC), tcc)
29                 CFLAGS +=-pedantic-errors
30         else
31                 CFLAGS += -Wno-pointer-sign -fno-common
32         endif
33 endif
34
35 ifeq ($(track), no)
36     CFLAGS += -DNOTRACK
37 endif
38
39 OBJ_D = util.o code.o ast.o ir.o conout.o ftepp.o opts.o file.o utf8.o
40 OBJ_T = test.o util.o conout.o file.o
41 OBJ_C = main.o lexer.o parser.o file.o
42 OBJ_X = exec-standalone.o util.o conout.o file.o
43
44 ifneq ("$(CYGWIN)", "")
45         #nullify the common variables that
46         #most *nix systems have (for windows)
47         PREFIX   :=
48         BINDIR   :=
49         DATADIR  :=
50         MANDIR   :=
51         QCVM      = qcvm.exe
52         GMQCC     = gmqcc.exe
53         TESTSUITE = testsuite.exe
54 else
55 ifneq ("$(MINGW)", "")
56         #nullify the common variables that
57         #most *nix systems have (for windows)
58         PREFIX   :=
59         BINDIR   :=
60         DATADIR  :=
61         MANDIR   :=
62         QCVM      = qcvm.exe
63         GMQCC     = gmqcc.exe
64         TESTSUITE = testsuite.exe
65 else
66         #arm support for linux .. we need to allow unaligned accesses
67         #to memory otherwise we just segfault everywhere
68         ifneq (, $(findstring arm, $(shell uname -m)))
69                 CFLAGS += -munaligned-access
70         endif
71
72         QCVM      = qcvm
73         GMQCC     = gmqcc
74         TESTSUITE = testsuite
75 endif
76 endif
77
78 #standard rules
79 default: all
80 %.o: %.c
81         $(CC) -c $< -o $@ $(CFLAGS)
82
83 exec-standalone.o: exec.c
84         $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
85
86 $(QCVM): $(OBJ_X)
87         $(CC) -o $@ $^ $(CFLAGS) -lm
88
89 $(GMQCC): $(OBJ_C) $(OBJ_D)
90         $(CC) -o $@ $^ $(CFLAGS)
91
92 $(TESTSUITE): $(OBJ_T)
93         $(CC) -o $@ $^ $(CFLAGS)
94
95 all: $(GMQCC) $(QCVM) $(TESTSUITE)
96
97 check: all
98         @ ./$(TESTSUITE)
99
100 clean:
101         rm -f *.o $(GMQCC) $(QCVM) $(TESTSUITE) *.dat
102
103 # deps
104 $(OBJ_D) $(OBJ_C) $(OBJ_X): gmqcc.h opts.def
105 main.o:   lexer.h
106 parser.o: ast.h lexer.h
107 lexer.o:  lexer.h
108 ast.o:    ast.h ir.h
109 ir.o:     ir.h
110
111 #install rules
112 install: install-gmqcc install-qcvm install-doc
113 install-gmqcc: $(GMQCC)
114         install -d -m755               $(DESTDIR)$(BINDIR)
115         install    -m755  $(GMQCC)     $(DESTDIR)$(BINDIR)/gmqcc
116 install-qcvm: $(QCVM)
117         install -d -m755               $(DESTDIR)$(BINDIR)
118         install    -m755  $(QCVM)      $(DESTDIR)$(BINDIR)/qcvm
119 install-doc:
120         install -d -m755               $(DESTDIR)$(MANDIR)/man1
121         install    -m755  doc/gmqcc.1  $(DESTDIR)$(MANDIR)/man1/
122         install    -m755  doc/qcvm.1   $(DESTDIR)$(MANDIR)/man1/