]> git.xonotic.org Git - xonotic/gmqcc.git/blob - Makefile
Fix dependincies
[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 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)
44
45 #we have duplicate object files when dealing with creating a simple list
46 #for dependinces. To combat this we use some clever recrusive-make to
47 #filter the list and remove duplicates which we use for make depend
48 RMDUP = $(if $1,$(firstword $1) $(call RMDUP,$(filter-out $(firstword $1),$1)))
49 DEPS := $(call RMDUP, $(OBJ_P) $(OBJ_T) $(OBJ_C) $(OBJ_X))
50
51 ifneq ("$(CYGWIN)", "")
52         #nullify the common variables that
53         #most *nix systems have (for windows)
54         PREFIX   :=
55         BINDIR   :=
56         DATADIR  :=
57         MANDIR   :=
58         QCVM      = qcvm.exe
59         GMQCC     = gmqcc.exe
60         TESTSUITE = testsuite.exe
61         PAK       = gmqpak.exe
62         CFLAGS   += -DNVALGRIND
63 else
64 ifneq ("$(MINGW)", "")
65         #nullify the common variables that
66         #most *nix systems have (for windows)
67         PREFIX   :=
68         BINDIR   :=
69         DATADIR  :=
70         MANDIR   :=
71         QCVM      = qcvm.exe
72         GMQCC     = gmqcc.exe
73         TESTSUITE = testsuite.exe
74         PAK       = gmqpak.exe
75         CFLAGS   += -DNVALGRIND
76 else
77         QCVM      = qcvm
78         GMQCC     = gmqcc
79         TESTSUITE = testsuite
80         PAK       = gmqpak
81 endif
82 endif
83
84 #standard rules
85 c.o:
86         $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS)
87
88 exec-standalone.o: exec.c
89         $(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) -DQCVM_EXECUTOR=1
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 clean:
111         rm -rf *.o $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK) *.dat gource.mp4 *.exe gm-qcc.tgz ./cov-int
112
113 splint:
114         @  splint $(SPLINTFLAGS) *.c *.h
115
116 gource:
117         @ gource $(GOURCEFLAGS)
118
119 gource-record:
120         @ gource $(GOURCEFLAGS) -o - | ffmpeg $(FFMPEGFLAGS) gource.mp4
121
122 depend:
123         @ makedepend -Y -w 65536 2> /dev/null $(subst .o,.c,$(DEPS))
124
125
126 coverity:
127         @cov-build --dir cov-int $(MAKE)
128         @tar czf gm-qcc.tgz cov-int
129         @rm -rf cov-int
130         @echo gm-qcc.tgz generated, submit for analysis
131
132 #install rules
133 install: install-gmqcc install-qcvm install-gmqpak install-doc
134 install-gmqcc: $(GMQCC)
135         install -d -m755               $(DESTDIR)$(BINDIR)
136         install    -m755  $(GMQCC)     $(DESTDIR)$(BINDIR)/$(GMQCC)
137 install-qcvm: $(QCVM)
138         install -d -m755               $(DESTDIR)$(BINDIR)
139         install    -m755  $(QCVM)      $(DESTDIR)$(BINDIR)/$(QCVM)
140 install-gmqpak: $(PAK)
141         install -d -m755               $(DESTDIR)$(BINDIR)
142         install    -m755  $(PAK)       $(DESTDIR)$(BINDIR)/$(PAK)
143 install-doc:
144         install -d -m755               $(DESTDIR)$(MANDIR)/man1
145         install    -m644  doc/gmqcc.1  $(DESTDIR)$(MANDIR)/man1/
146         install    -m644  doc/qcvm.1   $(DESTDIR)$(MANDIR)/man1/
147         install    -m644  doc/gmqpak.1 $(DESTDIR)$(MANDIR)/man1/
148
149 # DO NOT DELETE
150
151 util.o: gmqcc.h opts.def
152 fs.o: gmqcc.h opts.def
153 conout.o: gmqcc.h opts.def
154 opts.o: gmqcc.h opts.def
155 pak.o: gmqcc.h opts.def
156 stat.o: gmqcc.h opts.def
157 test.o: gmqcc.h opts.def
158 main.o: gmqcc.h opts.def lexer.h
159 lexer.o: gmqcc.h opts.def lexer.h
160 parser.o: parser.h gmqcc.h opts.def lexer.h ast.h ir.h
161 code.o: gmqcc.h opts.def
162 ast.o: gmqcc.h opts.def ast.h ir.h parser.h lexer.h
163 ir.o: gmqcc.h opts.def ir.h
164 ftepp.o: gmqcc.h opts.def lexer.h
165 utf8.o: gmqcc.h opts.def
166 correct.o: gmqcc.h opts.def
167 fold.o: ast.h ir.h gmqcc.h opts.def parser.h lexer.h
168 intrin.o: parser.h gmqcc.h opts.def lexer.h ast.h ir.h