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