fd: Improve error handling of write_nonblock().
[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 := heterogeneous vacuum
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 endif
49 CPPFLAGS += -Os
50 CPPFLAGS += -Wuninitialized
51 CPPFLAGS += -Wchar-subscripts
52 CPPFLAGS += -DBINDIR='"$(BINDIR)"'
53 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
54 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
55 CPPFLAGS += -DCODENAME='"$(codename)"'
56 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
57 CPPFLAGS += -Werror-implicit-function-declaration
58 CPPFLAGS += -Wmissing-noreturn
59 CPPFLAGS += -Wunused-macros
60 CPPFLAGS += -Wbad-function-cast
61 CPPFLAGS += -fno-strict-aliasing
62 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
63 CPPFLAGS += @arch_cppflags@
64 CPPFLAGS += -I/usr/local/include
65 CPPFLAGS += -I$(cmdline_dir)
66 CPPFLAGS += @osl_cppflags@
67
68 man_pages := $(patsubst %, man/man1/%.1, @executables@)
69
70 ggo_dir := ggo
71 object_dir := objects
72 man_dir := man/man1
73 test_dir := t
74
75 m4_ggos := afh audioc audiod client filter gui recv server write ao_write
76 all_ggos := $(m4_ggos) dccp_recv alsa_write oss_write fade http_recv \
77 osx_write udp_recv amp_filter compress_filter file_write \
78 mp3dec_filter prebuffer_filter
79 ggo_generated := $(addsuffix .ggo, $(addprefix $(ggo_dir)/,$(m4_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 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 # When in doubt, use brute force (Ken Thompson)
113 TOUPPER = \
114 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
115 $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
116 $(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
117 $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
118 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
119 $(subst z,Z,$1))))))))))))))))))))))))))
120
121 %_command_list.c: %.cmd
122 @[ -z "$(Q)" ] || echo 'GEN $@'
123 $(Q) ./command_util.sh c < $< >$@
124 %_command_list.h: %.cmd
125 @[ -z "$(Q)" ] || echo 'GEN $@'
126 $(Q) ./command_util.sh h < $< >$@
127 %_command_list.man: %.cmd
128 @[ -z "$(Q)" ] || echo 'GEN $@'
129 $(Q) ./command_util.sh man < $< > $@
130 %_completion.h: %.cmd
131 @[ -z "$(Q)" ] || echo 'GEN $@'
132 $(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
133 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
134
135 server_command_lists_man = server_command_list.man afs_command_list.man
136 man/man1/para_server.1: para_server $(server_command_lists_man) | $(man_dir)
137 @[ -z "$(Q)" ] || echo 'MAN $<'
138 $(Q) opts="-h --detailed-help -N `for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
139 $(HELP2MAN) $$opts ./para_server > $@
140
141 man/man1/para_audiod.1: para_audiod audiod_command_list.man | $(man_dir)
142 @[ -z "$(Q)" ] || echo 'MAN $<'
143 $(Q) $(HELP2MAN) -h --detailed-help -N -i audiod_command_list.man ./para_audiod > $@
144
145 man/man1/%.1: % | $(man_dir)
146 @[ -z "$(Q)" ] || echo 'MAN $<'
147 $(Q) $(HELP2MAN) -h --detailed-help -N ./$< > $@
148
149 man/html/%.html: man/man1/%.1
150 @[ -z "$(Q)" ] || echo 'MAN2HTML $<'
151 $(Q) mkdir -p man/html
152 $(Q) man2html $< > $@
153
154 web/%.man.in.html: man/man1/%.1
155 @[ -z "$(Q)" ] || echo 'MAN2HTML $<'
156 $(Q) mkdir -p man/html
157 $(Q) man2html $< | sed -e '/^<\/BODY>/,$$d' -e '1,/<\/HEAD><BODY>/d' > $@
158
159 $(object_dir):
160 mkdir -p $@
161 $(man_dir):
162 mkdir -p $@
163
164 $(object_dir)/crypt.o: crypt.c | $(object_dir)
165 @[ -z "$(Q)" ] || echo 'CC $<'
166 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @openssl_cppflags@ $<
167 $(object_dir)/spx_common.o: spx_common.c | $(object_dir)
168 @[ -z "$(Q)" ] || echo 'CC $<'
169 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
170
171 $(object_dir)/spxdec_filter.o: spxdec_filter.c | $(object_dir)
172 @[ -z "$(Q)" ] || echo 'CC $<'
173 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
174
175 $(object_dir)/spx_afh.o: spx_afh.c | $(object_dir)
176 @[ -z "$(Q)" ] || echo 'CC $<'
177 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
178
179 $(object_dir)/oggdec_filter.o: oggdec_filter.c | $(object_dir)
180 @[ -z "$(Q)" ] || echo 'CC $<'
181 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
182
183 $(object_dir)/ogg_afh.o: ogg_afh.c | $(object_dir)
184 @[ -z "$(Q)" ] || echo 'CC $<'
185 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
186
187 $(object_dir)/ogg_afh_common.o: ogg_afh_common.c | $(object_dir)
188 @[ -z "$(Q)" ] || echo 'CC $<'
189 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
190
191 $(object_dir)/mp3dec_filter.o: mp3dec_filter.c | $(object_dir)
192 @[ -z "$(Q)" ] || echo 'CC $<'
193 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
194
195 $(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir)
196 @[ -z "$(Q)" ] || echo 'CC $<'
197 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
198
199 $(object_dir)/aac_common.o: aac_common.c | $(object_dir)
200 @[ -z "$(Q)" ] || echo 'CC $<'
201 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
202
203 $(object_dir)/aac_afh.o: aac_afh.c | $(object_dir)
204 @[ -z "$(Q)" ] || echo 'CC $<'
205 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
206
207 $(object_dir)/gui%.o: gui%.c | $(object_dir)
208 @[ -z "$(Q)" ] || echo 'CC $<'
209 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @curses_cppflags@ $<
210 $(object_dir)/ao_write.o: ao_write.c | $(object_dir)
211 @[ -z "$(Q)" ] || echo 'CC $<'
212 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ao_cppflags@ $<
213
214 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
215 @[ -z "$(Q)" ] || echo 'CC $<'
216 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
217
218 $(object_dir)/%.o: %.c | $(object_dir)
219 @[ -z "$(Q)" ] || echo 'CC $<'
220 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
221
222 $(object_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(object_dir)
223 @[ -z "$(Q)" ] || echo 'DEP $<'
224 $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
225
226 $(object_dir)/%.d: %.c | $(object_dir)
227 @[ -z "$(Q)" ] || echo 'DEP $<'
228 $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
229
230
231 recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
232 filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
233 client_objs := $(addprefix $(object_dir)/, @client_objs@)
234 gui_objs := $(addprefix $(object_dir)/, @gui_objs@)
235 audiod_objs := $(addprefix $(object_dir)/, @audiod_objs@)
236 audioc_objs := $(addprefix $(object_dir)/, @audioc_objs@)
237 fade_objs := $(addprefix $(object_dir)/, @fade_objs@)
238 server_objs := $(addprefix $(object_dir)/, @server_objs@)
239 write_objs := $(addprefix $(object_dir)/, @write_objs@)
240 afh_objs := $(addprefix $(object_dir)/, @afh_objs@)
241
242 all_objs := $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
243 $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
244 $(write_objs) $(afh_objs)
245
246 deps := $(all_objs:.o=.d)
247
248 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
249 -include $(deps)
250 endif
251
252 para_recv: $(recv_objs)
253 @[ -z "$(Q)" ] || echo 'LD $@'
254 $(Q) $(CC) $(LDFLAGS) $(recv_objs) -o $@ @recv_ldflags@
255
256 para_filter: $(filter_objs)
257 @[ -z "$(Q)" ] || echo 'LD $@'
258 $(Q) $(CC) $(LDFLAGS) $(filter_objs) -o $@ @filter_ldflags@
259
260 para_client: $(client_objs)
261 @[ -z "$(Q)" ] || echo 'LD $@'
262 $(Q) $(CC) $(LDFLAGS) -o $@ $(client_objs) @client_ldflags@
263
264 para_gui: $(gui_objs)
265 @[ -z "$(Q)" ] || echo 'LD $@'
266 $(Q) $(CC) $(LDFLAGS) -o $@ $(gui_objs) -lcurses
267
268 para_audiod: $(audiod_objs)
269 @[ -z "$(Q)" ] || echo 'LD $@'
270 $(Q) $(CC) $(LDFLAGS) -o $@ $(audiod_objs) @audiod_ldflags@
271
272 para_audioc: $(audioc_objs)
273 @[ -z "$(Q)" ] || echo 'LD $@'
274 $(Q) $(CC) $(LDFLAGS) -o $@ $(audioc_objs) @audioc_ldflags@
275
276 para_fade: $(fade_objs)
277 @[ -z "$(Q)" ] || echo 'LD $@'
278 $(Q) $(CC) $(LDFLAGS) -o $@ $(fade_objs) @fade_ldflags@
279
280 para_server: $(server_objs)
281 @[ -z "$(Q)" ] || echo 'LD $@'
282 $(Q) $(CC) $(LDFLAGS) -o $@ $(server_objs) @server_ldflags@
283
284 para_write: $(write_objs)
285 @[ -z "$(Q)" ] || echo 'LD $@'
286 $(Q) $(CC) $(LDFLAGS) -o $@ $(write_objs) @write_ldflags@
287
288 para_afh: $(afh_objs)
289 @[ -z "$(Q)" ] || echo 'LD $@'
290 $(Q) $(CC) $(LDFLAGS) -o $@ $(afh_objs) @afh_ldflags@
291
292 clean:
293 @[ -z "$(Q)" ] || echo 'CLEAN'
294 $(Q) rm -f @executables@ $(object_dir)/*.o
295
296 clean2: clean
297 @[ -z "$(Q)" ] || echo 'CLEAN2'
298 $(Q) rm -rf man $(object_dir) $(cmdline_dir)
299 $(Q) rm -f *_command_list.* *_completion.h $(ggo_generated)
300 distclean: clean2 test-clean
301 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
302 $(Q) rm -f Makefile autoscan.log config.status config.log
303 $(Q) rm -rf autom4te.cache aclocal.m4
304 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
305
306 maintainer-clean: distclean
307 rm -f *.tar.bz2 \
308 config.h configure \
309 config.h.in skencil/*.pdf skencil/*.ps
310 rm -rf web_sync
311
312 install: all man
313 mkdir -p $(BINDIR) $(MANDIR)
314 $(install_sh) -s -m 755 @executables@ $(BINDIR)
315 $(install_sh) -m 644 $(man_pages) $(MANDIR)
316 mkdir -p $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
317
318 $(tarball):
319 rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
320 git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
321 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
322 mkdir -p $(tarball_pfx)
323 ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
324 cp -r $(autocrap) $(tarball_pfx)
325 tar rf $(tarball_pfx).tar $(tarball_pfx)/*
326 bzip2 -9 $(tarball_pfx).tar
327 ls -l $(tarball_pfx).tar.bz2
328 rm -rf $(tarball_pfx)
329 %.ps: %.sk
330 sk2ps $< > $@
331 %.pdf: %.ps
332 ps2pdf - - < $< > $@
333
334 include $(test_dir)/makefile.test