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