]> git.xonotic.org Git - xonotic/gmqcc.git/blob - Makefile
Got it working on arm :)
[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. -pedantic-errors -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 endif
26 ifeq ($(track), no)
27     CFLAGS += -DNOTRACK
28 endif
29
30 OBJ_D = util.o code.o ast.o ir.o conout.o ftepp.o opts.o file.o utf8.o
31 OBJ_T = test.o util.o conout.o file.o
32 OBJ_C = main.o lexer.o parser.o file.o
33 OBJ_X = exec-standalone.o util.o conout.o file.o
34
35 ifneq ("$(CYGWIN)", "")
36         #nullify the common variables that
37         #most *nix systems have (for windows)
38         PREFIX   :=
39         BINDIR   :=
40         DATADIR  :=
41         MANDIR   :=
42         QCVM      = qcvm.exe
43         GMQCC     = gmqcc.exe
44         TESTSUITE = testsuite.exe
45 else
46 ifneq ("$(MINGW)", "")
47         #nullify the common variables that
48         #most *nix systems have (for windows)
49         PREFIX   :=
50         BINDIR   :=
51         DATADIR  :=
52         MANDIR   :=
53         QCVM      = qcvm.exe
54         GMQCC     = gmqcc.exe
55         TESTSUITE = testsuite.exe
56 else
57         #arm support for linux .. we need to allow unaligned accesses
58         #to memory otherwise we just segfault everywhere
59         ifneq (, $(findstring $(shell uname -m), "arm"))
60                 CFLAGS += -munaligned-access
61         endif
62
63         QCVM      = qcvm
64         GMQCC     = gmqcc
65         TESTSUITE = testsuite
66 endif
67 endif
68
69 #standard rules
70 default: all
71 %.o: %.c
72         $(CC) -c $< -o $@ $(CFLAGS)
73
74 exec-standalone.o: exec.c
75         $(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
76
77 $(QCVM): $(OBJ_X)
78         $(CC) -o $@ $^ $(CFLAGS) -lm
79
80 $(GMQCC): $(OBJ_C) $(OBJ_D)
81         $(CC) -o $@ $^ $(CFLAGS)
82
83 $(TESTSUITE): $(OBJ_T)
84         $(CC) -o $@ $^ $(CFLAGS)
85
86 all: $(GMQCC) $(QCVM) $(TESTSUITE)
87
88 check: all
89         @ ./$(TESTSUITE)
90
91 clean:
92         rm -f *.o $(GMQCC) $(QCVM) $(TESTSUITE) *.dat
93
94 # deps
95 $(OBJ_D) $(OBJ_C) $(OBJ_X): gmqcc.h opts.def
96 main.o:   lexer.h
97 parser.o: ast.h lexer.h
98 lexer.o:  lexer.h
99 ast.o:    ast.h ir.h
100 ir.o:     ir.h
101
102 #install rules
103 install: install-gmqcc install-qcvm install-doc
104 install-gmqcc: $(GMQCC)
105         install -d -m755               $(DESTDIR)$(BINDIR)
106         install    -m755  $(GMQCC)     $(DESTDIR)$(BINDIR)/gmqcc
107 install-qcvm: $(QCVM)
108         install -d -m755               $(DESTDIR)$(BINDIR)
109         install    -m755  $(QCVM)      $(DESTDIR)$(BINDIR)/qcvm
110 install-doc:
111         install -d -m755               $(DESTDIR)$(MANDIR)/man1
112         install    -m755  doc/gmqcc.1  $(DESTDIR)$(MANDIR)/man1/
113         install    -m755  doc/qcvm.1   $(DESTDIR)$(MANDIR)/man1/