Avoid warning when compiling with clang.
[paraslash.git] / Makefile.in
1 prefix := @prefix@
2 exec_prefix := @exec_prefix@
3
4 BINDIR := @bindir@
5 VARDIR := /var/paraslash
6 PKGDATADIR := @datarootdir@/@PACKAGE_NAME@
7 MANDIR := @datarootdir@/man/man1
8 PACKAGE_VERSION := @PACKAGE_VERSION@
9 PACKAGE_STRING := @PACKAGE_STRING@
10 install_sh := @install_sh@
11 cmdline_dir := @cmdline_dir@
12 executables := @executables@
13
14 build_date := $(shell date)
15 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
16 uname_rs := $(shell uname -rs)
17 cc_version := $(shell $(CC) --version | head -n 1)
18 codename := nested assignment
19
20 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
21
22 DEBUG_CPPFLAGS += -g -Wunused -Wundef -W
23 DEBUG_CPPFLAGS += -Wredundant-decls
24 DEBUG_CPPFLAGS += -Wall -Wno-sign-compare -Wno-unknown-pragmas
25 DEBUG_CPPFLAGS += -Wformat-security
26 DEBUG_CPPFLAGS += -Wmissing-format-attribute
27 # produces false positives
28 # DEBUG_CPPFLAGS += -Wunreachable-code
29 # DEBUG_CPPFLAGS += -Wwrite-strings
30
31 # invalid option for gcc-3.3.3
32 # DEBUG_CPPFLAGS += -Wextra
33 # DEBUG_CPPFLAGS += -Wold-style-definition
34 # DEBUG_CPPFLAGS += -Wdeclaration-after-statement
35 # DEBUG_CPPFLAGS += -Wsuggest-attribute=const
36
37 # many warnings about trivial stuff
38 # CPPFLAGS += -Wconversion
39
40 ifeq ($(uname_s),Linux)
41 CPPFLAGS += -fdata-sections -ffunction-sections
42 LDFLAGS += -Wl,--gc-sections
43 CPPFLAGS += -Wstrict-prototypes
44 CPPFLAGS += -Wshadow
45 endif
46 CPPFLAGS += -Os
47 CPPFLAGS += -Wuninitialized
48 CPPFLAGS += -Wchar-subscripts
49 CPPFLAGS += -DBINDIR='"$(BINDIR)"'
50 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
51 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
52 CPPFLAGS += -DCODENAME='"$(codename)"'
53 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
54 CPPFLAGS += -Werror-implicit-function-declaration
55 CPPFLAGS += -Wmissing-noreturn
56 CPPFLAGS += -Wunused-macros
57 CPPFLAGS += -Wbad-function-cast
58 CPPFLAGS += -fno-strict-aliasing
59 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
60 CPPFLAGS += @arch_cppflags@
61 CPPFLAGS += -I/usr/local/include
62 CPPFLAGS += -I$(cmdline_dir)
63 CPPFLAGS += @osl_cppflags@
64
65 man_pages := $(patsubst %, man/man1/%.1, @executables@)
66 man_pages_in := $(patsubst %, web/%.man.in.html, @executables@)
67
68 ggo_dir := ggo
69 object_dir := objects
70 man_dir := man/man1
71 test_dir := t
72
73 m4_ggos := afh audioc audiod client filter gui recv server write ao_write
74 all_ggos := $(m4_ggos) dccp_recv alsa_write oss_write fade http_recv \
75 osx_write udp_recv amp_filter compress_filter file_write \
76 mp3dec_filter prebuffer_filter
77 ggo_generated := $(addsuffix .ggo, $(addprefix $(ggo_dir)/,$(m4_ggos)))
78 cmdline_generated := $(addprefix $(cmdline_dir)/,$(addsuffix .cmdline.c, $(all_ggos)) \
79 $(addsuffix .cmdline.h, $(all_ggos)))
80
81 autocrap := config.h.in configure
82 tarball_pfx := @PACKAGE_TARNAME@-$(PACKAGE_VERSION)
83 tarball_delete := $(addprefix $(tarball_pfx)/,\
84 web versions .changelog_before_cvs .changelog_cvs .gitignore\
85 $(ggo_dir) skencil)
86 tarball := @PACKAGE_TARNAME@-$(PACKAGE_VERSION).tar.bz2
87
88 # To put more focus on warnings, be less verbose as default
89 # Use 'make V=1' to see the full commands
90 ifdef V
91 ifeq ("$(origin V)", "command line")
92 BUILD_VERBOSE = $(V)
93 endif
94 endif
95 ifndef BUILD_VERBOSE
96 BUILD_VERBOSE = 0
97 endif
98 ifeq ($(BUILD_VERBOSE),0)
99 Q = @
100 else
101 Q =
102 endif
103
104 .PHONY: dep all clean distclean maintainer-clean install man tarball
105 all: dep @executables@ $(man_pages)
106 dep: $(deps)
107 man: $(man_pages)
108 tarball: $(tarball)
109
110 -include $(ggo_dir)/makefile
111
112 %_command_list.c: %.cmd
113 @[ -z "$(Q)" ] || echo 'GEN $@'
114 $(Q) ./command_util.sh c < $< >$@
115 %_command_list.h: %.cmd
116 @[ -z "$(Q)" ] || echo 'GEN $@'
117 $(Q) ./command_util.sh h < $< >$@
118 %_command_list.man: %.cmd
119 @[ -z "$(Q)" ] || echo 'GEN $@'
120 $(Q) ./command_util.sh man < $< > $@
121
122 server_command_lists_ch = server_command_list.c afs_command_list.c \
123 server_command_list.h afs_command_list.h
124 server_command_lists_man = server_command_list.man afs_command_list.man
125 man/man1/para_server.1: para_server $(server_command_lists_man) | $(man_dir)
126 @[ -z "$(Q)" ] || echo 'HELP2MAN $<'
127 $(Q) opts="-h --detailed-help -N `for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
128 help2man $$opts ./para_server > $@
129
130 man/man1/para_audiod.1: para_audiod audiod_command_list.man | $(man_dir)
131 @[ -z "$(Q)" ] || echo 'HELP2MAN $<'
132 $(Q) help2man -h --detailed-help -N -i audiod_command_list.man ./para_audiod > $@
133
134 man/man1/%.1: % | $(man_dir)
135 @[ -z "$(Q)" ] || echo 'HELP2MAN $<'
136 $(Q) help2man -h --detailed-help -N ./$< > $@
137
138 man/html/%.html: man/man1/%.1
139 @[ -z "$(Q)" ] || echo 'MAN2HTML $<'
140 $(Q) mkdir -p man/html
141 $(Q) man2html $< > $@
142
143 web/%.man.in.html: man/man1/%.1
144 @[ -z "$(Q)" ] || echo 'MAN2HTML $<'
145 $(Q) mkdir -p man/html
146 $(Q) man2html $< | sed -e '/^<\/BODY>/,$$d' -e '1,/<\/HEAD><BODY>/d' > $@
147
148 $(object_dir):
149 mkdir -p $@
150 $(man_dir):
151 mkdir -p $@
152
153 $(object_dir)/crypt.o: crypt.c | $(object_dir)
154 @[ -z "$(Q)" ] || echo 'CC $<'
155 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @openssl_cppflags@ $<
156 $(object_dir)/spx_common.o: spx_common.c | $(object_dir)
157 @[ -z "$(Q)" ] || echo 'CC $<'
158 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
159
160 $(object_dir)/spxdec_filter.o: spxdec_filter.c | $(object_dir)
161 @[ -z "$(Q)" ] || echo 'CC $<'
162 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
163
164 $(object_dir)/spx_afh.o: spx_afh.c | $(object_dir)
165 @[ -z "$(Q)" ] || echo 'CC $<'
166 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
167
168 $(object_dir)/oggdec_filter.o: oggdec_filter.c | $(object_dir)
169 @[ -z "$(Q)" ] || echo 'CC $<'
170 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
171
172 $(object_dir)/ogg_afh.o: ogg_afh.c | $(object_dir)
173 @[ -z "$(Q)" ] || echo 'CC $<'
174 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
175
176 $(object_dir)/ogg_afh_common.o: ogg_afh_common.c | $(object_dir)
177 @[ -z "$(Q)" ] || echo 'CC $<'
178 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
179
180 $(object_dir)/mp3dec_filter.o: mp3dec_filter.c | $(object_dir)
181 @[ -z "$(Q)" ] || echo 'CC $<'
182 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
183
184 $(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir)
185 @[ -z "$(Q)" ] || echo 'CC $<'
186 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
187
188 $(object_dir)/aac_common.o: aac_common.c | $(object_dir)
189 @[ -z "$(Q)" ] || echo 'CC $<'
190 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
191
192 $(object_dir)/aac_afh.o: aac_afh.c | $(object_dir)
193 @[ -z "$(Q)" ] || echo 'CC $<'
194 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
195
196 $(object_dir)/gui%.o: gui%.c | $(object_dir)
197 @[ -z "$(Q)" ] || echo 'CC $<'
198 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @curses_cppflags@ $<
199 $(object_dir)/ao_write.o: ao_write.c | $(object_dir)
200 @[ -z "$(Q)" ] || echo 'CC $<'
201 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ao_cppflags@ $<
202
203 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
204 @[ -z "$(Q)" ] || echo 'CC $<'
205 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
206
207 $(object_dir)/%.o: %.c | $(object_dir)
208 @[ -z "$(Q)" ] || echo 'CC $<'
209 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
210
211 $(object_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(object_dir)
212 @[ -z "$(Q)" ] || echo 'DEP $<'
213 $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
214
215 $(object_dir)/%.d: %.c | $(object_dir)
216 @[ -z "$(Q)" ] || echo 'DEP $<'
217 $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
218
219
220 recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
221 filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
222 client_objs := $(addprefix $(object_dir)/, @client_objs@)
223 gui_objs := $(addprefix $(object_dir)/, @gui_objs@)
224 audiod_objs := $(addprefix $(object_dir)/, @audiod_objs@)
225 audioc_objs := $(addprefix $(object_dir)/, @audioc_objs@)
226 fade_objs := $(addprefix $(object_dir)/, @fade_objs@)
227 server_objs := $(addprefix $(object_dir)/, @server_objs@)
228 write_objs := $(addprefix $(object_dir)/, @write_objs@)
229 afh_objs := $(addprefix $(object_dir)/, @afh_objs@)
230
231 all_objs := $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
232 $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
233 $(write_objs) $(afh_objs)
234
235 deps := $(all_objs:.o=.d)
236
237 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
238 -include $(deps)
239 endif
240
241 para_recv: $(recv_objs)
242 @[ -z "$(Q)" ] || echo 'LD $@'
243 $(Q) $(CC) $(LDFLAGS) $(recv_objs) -o $@ @recv_ldflags@
244
245 para_filter: $(filter_objs)
246 @[ -z "$(Q)" ] || echo 'LD $@'
247 $(Q) $(CC) $(LDFLAGS) $(filter_objs) -o $@ @filter_ldflags@
248
249 para_client: $(client_objs)
250 @[ -z "$(Q)" ] || echo 'LD $@'
251 $(Q) $(CC) $(LDFLAGS) -o $@ $(client_objs) @client_ldflags@
252
253 para_gui: $(gui_objs)
254 @[ -z "$(Q)" ] || echo 'LD $@'
255 $(Q) $(CC) $(LDFLAGS) -o $@ $(gui_objs) -lcurses
256
257 para_audiod: audiod_command_list.c audiod_command_list.h $(audiod_objs)
258 @[ -z "$(Q)" ] || echo 'LD $@'
259 $(Q) $(CC) $(LDFLAGS) -o $@ $(audiod_objs) @audiod_ldflags@
260
261 para_audioc: $(audioc_objs)
262 @[ -z "$(Q)" ] || echo 'LD $@'
263 $(Q) $(CC) $(LDFLAGS) -o $@ $(audioc_objs) @audioc_ldflags@
264
265 para_fade: $(fade_objs)
266 @[ -z "$(Q)" ] || echo 'LD $@'
267 $(Q) $(CC) $(LDFLAGS) -o $@ $(fade_objs) @fade_ldflags@
268
269 para_server: $(server_command_lists_ch) $(server_objs)
270 @[ -z "$(Q)" ] || echo 'LD $@'
271 $(Q) $(CC) $(LDFLAGS) -o $@ $(server_objs) @server_ldflags@
272
273 para_write: $(write_objs)
274 @[ -z "$(Q)" ] || echo 'LD $@'
275 $(Q) $(CC) $(LDFLAGS) -o $@ $(write_objs) @write_ldflags@
276
277 para_afh: $(afh_objs)
278 @[ -z "$(Q)" ] || echo 'LD $@'
279 $(Q) $(CC) $(LDFLAGS) -o $@ $(afh_objs) @afh_ldflags@
280
281 clean:
282 @[ -z "$(Q)" ] || echo 'CLEAN'
283 $(Q) rm -f @executables@ $(object_dir)/*.o
284
285 clean2: clean
286 @[ -z "$(Q)" ] || echo 'CLEAN2'
287 $(Q) rm -rf man $(object_dir)
288 $(Q) rm -f *_command_list.*
289
290 distclean: clean2 test-clean
291 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
292 $(Q) rm -f Makefile autoscan.log config.status config.log
293 $(Q) rm -rf autom4te.cache aclocal.m4
294 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
295
296 maintainer-clean: distclean
297 rm -f $(ggo_generated) *.tar.bz2 \
298 config.h configure \
299 config.h.in skencil/*.pdf skencil/*.ps
300 rm -rf web_sync $(cmdline_dir)
301
302 install: all man
303 mkdir -p $(BINDIR) $(MANDIR)
304 $(install_sh) -s -m 755 @executables@ $(BINDIR)
305 $(install_sh) -m 644 $(man_pages) $(MANDIR)
306 mkdir -p $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
307
308 $(tarball): $(cmdline_generated)
309 rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
310 git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
311 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
312 mkdir -p $(tarball_pfx)/$(cmdline_dir)
313 ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
314 cp -r $(autocrap) $(tarball_pfx)
315 cp -r $(cmdline_generated) $(tarball_pfx)/$(cmdline_dir)
316 tar rf $(tarball_pfx).tar $(tarball_pfx)/*
317 rm -rf $(tarball_pfx)
318 bzip2 -9 $(tarball_pfx).tar
319 rm -f $(tarball_pfx).tar
320 ls -l $(tarball_pfx).tar.bz2
321 %.ps: %.sk
322 sk2ps $< > $@
323 %.pdf: %.ps
324 ps2pdf - - < $< > $@
325
326 include $(test_dir)/makefile.test