]> git.xonotic.org Git - xonotic/gmqcc.git/blob - Makefile
grammar
[xonotic/gmqcc.git] / Makefile
1 include include.mk
2
3 UNAME  ?= $(shell uname)
4 CYGWIN  = $(findstring CYGWIN, $(UNAME))
5 MINGW   = $(findstring MINGW,  $(UNAME))
6
7 # turn on tons of warnings if clang is present
8 # but also turn off the STUPID ONES
9 ifeq ($(CC), clang)
10         CFLAGS +=                              \
11             -Weverything                       \
12             -Wno-padded                        \
13             -Wno-format-nonliteral             \
14             -Wno-disabled-macro-expansion      \
15             -Wno-conversion                    \
16             -Wno-float-equal                   \
17             -Wno-unknown-warning-option        \
18             -Wno-cast-align                    \
19             -Wno-assign-enum                   \
20             -Wno-empty-body                    \
21             -Wno-date-time                     \
22             -pedantic-errors
23 else
24         ifneq ($(CC), g++)
25                 CFLAGS += -Wmissing-prototypes -Wstrict-prototypes
26         endif
27
28         ifneq ($(CC), tcc)
29                 CFLAGS += -pedantic-errors
30         else
31                 CFLAGS += -Wno-pointer-sign -fno-common
32         endif
33 endif
34
35 ifneq ($(shell git describe --always 2>/dev/null),)
36         CFLAGS += -DGMQCC_GITINFO="\"$(shell git describe --always)\""
37 endif
38
39 ifeq ($(shell valgrind --version 2>/dev/null),)
40         CFLAGS += -DNVALGRIND
41 endif
42
43 # do this last otherwise there is whitespace in the command output and
44 # it makes my OCD act up
45 CFLAGS += $(OPTIONAL_CFLAGS)
46 LDFLAGS += $(OPTIONAL_LDFLAGS)
47
48 #we have duplicate object files when dealing with creating a simple list
49 #for dependinces. To combat this we use some clever recrusive-make to
50 #filter the list and remove duplicates which we use for make depend
51 RMDUP = $(if $1,$(firstword $1) $(call RMDUP,$(filter-out $(firstword $1),$1)))
52 DEPS := $(call RMDUP, $(OBJ_P) $(OBJ_T) $(OBJ_C) $(OBJ_X))
53
54 ifneq ("$(CYGWIN)", "")
55         #nullify the common variables that
56         #most *nix systems have (for windows)
57         PREFIX   :=
58         BINDIR   :=
59         DATADIR  :=
60         MANDIR   :=
61         QCVM      = qcvm.exe
62         GMQCC     = gmqcc.exe
63         TESTSUITE = testsuite.exe
64         PAK       = gmqpak.exe
65         CFLAGS   += -DNVALGRIND
66 else
67 ifneq ("$(MINGW)", "")
68         #nullify the common variables that
69         #most *nix systems have (for windows)
70         PREFIX   :=
71         BINDIR   :=
72         DATADIR  :=
73         MANDIR   :=
74         QCVM      = qcvm.exe
75         GMQCC     = gmqcc.exe
76         TESTSUITE = testsuite.exe
77         PAK       = gmqpak.exe
78         CFLAGS   += -DNVALGRIND
79 else
80         QCVM      = qcvm
81         GMQCC     = gmqcc
82         TESTSUITE = testsuite
83         PAK       = gmqpak
84 endif
85 endif
86
87 #standard rules
88 c.o:
89         $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
90
91 $(QCVM): $(OBJ_X)
92         $(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
93
94 $(GMQCC): $(OBJ_C) $(OBJ_D)
95         $(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
96
97 $(TESTSUITE): $(OBJ_T)
98         $(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
99
100 $(PAK): $(OBJ_P)
101         $(CC) -o $@ $^ $(LDFLAGS)
102
103 all: $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK)
104
105 check: all
106         @ ./$(TESTSUITE)
107 test: all
108         @ ./$(TESTSUITE)
109
110 strip: $(GMQCC) $(QCVM) $(TESTSUITE)
111         strip $(GMQCC)
112         strip $(QCVM)
113         strip $(TESTSUITE)
114
115 clean:
116         rm -rf *.o $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK) *.dat gource.mp4 *.exe gm-qcc.tgz ./cov-int
117
118 depend:
119         @ makedepend -Y -w 65536 2> /dev/null $(subst .o,.c,$(DEPS))
120
121
122 coverity:
123         @cov-build --dir cov-int $(MAKE)
124         @tar czf gm-qcc.tgz cov-int
125         @rm -rf cov-int
126         @echo gm-qcc.tgz generated, submit for analysis
127
128 #install rules
129 install: install-gmqcc install-qcvm install-gmqpak install-doc
130 install-gmqcc: $(GMQCC)
131         install -d -m755               $(DESTDIR)$(BINDIR)
132         install    -m755  $(GMQCC)     $(DESTDIR)$(BINDIR)/$(GMQCC)
133 install-qcvm: $(QCVM)
134         install -d -m755               $(DESTDIR)$(BINDIR)
135         install    -m755  $(QCVM)      $(DESTDIR)$(BINDIR)/$(QCVM)
136 install-gmqpak: $(PAK)
137         install -d -m755               $(DESTDIR)$(BINDIR)
138         install    -m755  $(PAK)       $(DESTDIR)$(BINDIR)/$(PAK)
139 install-doc:
140         install -d -m755               $(DESTDIR)$(MANDIR)/man1
141         install    -m644  doc/gmqcc.1  $(DESTDIR)$(MANDIR)/man1/
142         install    -m644  doc/qcvm.1   $(DESTDIR)$(MANDIR)/man1/
143         install    -m644  doc/gmqpak.1 $(DESTDIR)$(MANDIR)/man1/
144
145 # DO NOT DELETE
146
147 ansi.o: platform.h gmqcc.h opts.def
148 util.o: gmqcc.h opts.def platform.h
149 hash.o: gmqcc.h opts.def
150 stat.o: gmqcc.h opts.def
151 fs.o: gmqcc.h opts.def platform.h
152 opts.o: gmqcc.h opts.def
153 conout.o: gmqcc.h opts.def
154 pak.o: gmqcc.h opts.def
155 test.o: gmqcc.h opts.def platform.h
156 main.o: gmqcc.h opts.def lexer.h
157 lexer.o: gmqcc.h opts.def lexer.h
158 parser.o: parser.h gmqcc.h opts.def lexer.h ast.h ir.h
159 code.o: gmqcc.h opts.def
160 ast.o: gmqcc.h opts.def ast.h ir.h parser.h lexer.h
161 ir.o: gmqcc.h opts.def ir.h
162 ftepp.o: gmqcc.h opts.def lexer.h
163 utf8.o: gmqcc.h opts.def
164 correct.o: gmqcc.h opts.def
165 fold.o: ast.h ir.h gmqcc.h opts.def parser.h lexer.h
166 intrin.o: parser.h gmqcc.h opts.def lexer.h ast.h ir.h
167 exec.o: gmqcc.h opts.def