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