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