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