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