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