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