]> git.xonotic.org Git - xonotic/gmqcc.git/blob - Makefile
Valgrind integration for our memory allocator.
[xonotic/gmqcc.git] / Makefile
1 include include.mk
2
3 UNAME  ?= $(shell uname)
4 CYGWIN  = $(findstring CYGWIN,  $(UNAME))
5 MINGW   = $(findstring MINGW32, $(UNAME))
6
7 CFLAGS += -Wall -Wextra -Werror -Wstrict-aliasing
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             -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 # do this last otherwise there is whitespace in the command output and
38 # it makes my OCD act up
39 CFLAGS += $(OPTIONAL)
40
41 #we have duplicate object files when dealing with creating a simple list
42 #for dependinces. To combat this we use some clever recrusive-make to
43 #filter the list and remove duplicates which we use for make depend
44 RMDUP = $(if $1,$(firstword $1) $(call RMDUP,$(filter-out $(firstword $1),$1)))
45 DEPS := $(call RMDUP, $(OBJ_P) $(OBJ_T) $(OBJ_C) $(OBJ_X))
46
47 ifneq ("$(CYGWIN)", "")
48         #nullify the common variables that
49         #most *nix systems have (for windows)
50         PREFIX   :=
51         BINDIR   :=
52         DATADIR  :=
53         MANDIR   :=
54         QCVM      = qcvm.exe
55         GMQCC     = gmqcc.exe
56         TESTSUITE = testsuite.exe
57         PAK       = gmqpak.exe
58         CFLAGS   += -DNVALGRIND
59 else
60 ifneq ("$(MINGW)", "")
61         #nullify the common variables that
62         #most *nix systems have (for windows)
63         PREFIX   :=
64         BINDIR   :=
65         DATADIR  :=
66         MANDIR   :=
67         QCVM      = qcvm.exe
68         GMQCC     = gmqcc.exe
69         TESTSUITE = testsuite.exe
70         PAK       = gmqpak.exe
71         CFLAGS   += -DNVALGRIND
72 else
73         QCVM      = qcvm
74         GMQCC     = gmqcc
75         TESTSUITE = testsuite
76         PAK       = gmqpak
77 endif
78 endif
79
80 #standard rules
81 %.o: %.c
82         $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) 
83
84 exec-standalone.o: exec.c
85         $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) -DQCVM_EXECUTOR=1
86
87 $(QCVM): $(OBJ_X)
88         $(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
89
90 $(GMQCC): $(OBJ_C) $(OBJ_D)
91         $(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
92
93 $(TESTSUITE): $(OBJ_T)
94         $(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
95
96 $(PAK): $(OBJ_P)
97         $(CC) -o $@ $^ $(LDFLAGS)
98
99 all: $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK)
100
101 check: all
102         @ ./$(TESTSUITE)
103 test: all
104         @ ./$(TESTSUITE)
105
106 clean:
107         rm -rf *.o $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK) *.dat gource.mp4 *.exe gm-qcc.tgz ./cov-int
108
109 splint:
110         @  splint $(SPLINTFLAGS) *.c *.h
111
112 gource:
113         @ gource $(GOURCEFLAGS)
114
115 gource-record:
116         @ gource $(GOURCEFLAGS) -o - | ffmpeg $(FFMPEGFLAGS) gource.mp4
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 util.o: gmqcc.h opts.def
148 fs.o: gmqcc.h opts.def
149 conout.o: gmqcc.h opts.def
150 opts.o: gmqcc.h opts.def
151 pak.o: gmqcc.h opts.def
152 stat.o: gmqcc.h opts.def
153 test.o: gmqcc.h opts.def
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