]> git.tuebingen.mpg.de Git - paraslash.git/blob - Makefile.in
f453ed054939cfeeab02be5a34aeb9f292a7fa50
[paraslash.git] / Makefile.in
1 prefix := @prefix@
2 exec_prefix := @exec_prefix@
3
4 # These two use prefix and exec_prefix
5 BINDIR := @bindir@
6 datarootdir := @datarootdir@
7
8 PACKAGE_TARNAME := @PACKAGE_TARNAME@
9 PACKAGE_VERSION := @PACKAGE_VERSION@
10
11 INSTALL := @install@
12 GENGETOPT := @gengetopt@
13 HELP2MAN := @help2man@
14
15 ggo_descriptions_declared := @ggo_descriptions_declared@
16 object_executable_matrix := @object_executable_matrix@
17
18 executables := @executables@
19 recv_objs := @recv_objs@
20 filter_objs := @filter_objs@
21 client_objs := @client_objs@
22 gui_objs := @gui_objs@
23 audiod_objs := @audiod_objs@
24 audioc_objs := @audioc_objs@
25 fade_objs := @fade_objs@
26 server_objs := @server_objs@
27 write_objs := @write_objs@
28 afh_objs := @afh_objs@
29 play_objs := @play_objs@
30
31 speex_cppflags := @speex_cppflags@
32 opus_cppflags := @opus_cppflags@
33 arch_cppflags := @arch_cppflags@
34 osl_cppflags := @osl_cppflags@
35 id3tag_cppflags := @id3tag_cppflags@
36 openssl_cppflags := @openssl_cppflags@
37 ogg_cppflags := @ogg_cppflags@
38 mad_cppflags := @mad_cppflags@
39 faad_cppflags := @faad_cppflags@
40 curses_cppflags := @curses_cppflags@
41 ao_cppflags := @ao_cppflags@
42
43 clock_gettime_ldflags := @clock_gettime_ldflags@
44 id3tag_ldflags := @id3tag_ldflags@
45 ogg_ldflags := @ogg_ldflags@
46 vorbis_ldflags := @vorbis_ldflags@
47 speex_ldflags := @speex_ldflags@
48 opus_ldflags := @opus_ldflags@
49 faad_ldflags := @faad_ldflags@
50 mad_ldflags := @mad_ldflags@
51 flac_ldflags := @flac_ldflags@
52 oss_ldflags := @oss_ldflags@
53 alsa_ldflags := @alsa_ldflags@
54 ao_ldflags := @ao_ldflags@
55 readline_ldflags := @readline_ldflags@
56 samplerate_ldflags := @samplerate_ldflags@
57 osl_ldflags := @osl_ldflags@
58 openssl_ldflags := @openssl_ldflags@
59 gcrypt_ldflags := @gcrypt_ldflags@
60 socket_ldflags := @socket_ldflags@
61 nsl_ldflags := @nsl_ldflags@
62 curses_ldflags := @curses_ldflags@
63 core_audio_ldflags := @core_audio_ldflags@
64
65 VARDIR := /var/paraslash
66 MANDIR := $(datarootdir)/man/man1
67 STRIP := $(CROSS_COMPILE)strip
68 HOSTCC ?= cc
69 MKDIR_P := mkdir -p
70 prefixed_executables := $(addprefix para_, $(executables))
71
72 build_date := $(shell date)
73 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
74 uname_rs := $(shell uname -rs)
75 cc_version := $(shell $(CC) --version | head -n 1)
76 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
77
78 m4_ggo_dir := m4/gengetopt
79 test_dir := t
80 ifeq ("$(origin O)", "command line")
81         build_dir := $(O)
82 else
83         build_dir := build
84 endif
85 ggo_dir := $(build_dir)/ggo
86 object_dir := $(build_dir)/objects
87 dep_dir := $(build_dir)/deps
88 man_dir := $(build_dir)/man/man1
89 cmdline_dir := $(build_dir)/cmdline
90 m4depdir := $(build_dir)/m4deps
91 help2man_dir := $(build_dir)/help2man
92 hostbin_dir := $(build_dir)/host/bin
93
94 # sort removes duplicate words, which is all we need here
95 all_objs := $(sort $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
96         $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
97         $(write_objs) $(afh_objs) $(play_objs))
98 deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
99 m4_deps := $(addprefix $(m4depdir)/, $(addsuffix .m4d, $(executables)))
100
101 # now prefix all objects with object dir
102 recv_objs := $(addprefix $(object_dir)/, $(recv_objs))
103 filter_objs := $(addprefix $(object_dir)/, $(filter_objs))
104 client_objs := $(addprefix $(object_dir)/, $(client_objs))
105 gui_objs := $(addprefix $(object_dir)/, $(gui_objs))
106 audiod_objs := $(addprefix $(object_dir)/, $(audiod_objs))
107 audioc_objs := $(addprefix $(object_dir)/, $(audioc_objs))
108 fade_objs := $(addprefix $(object_dir)/, $(fade_objs))
109 server_objs := $(addprefix $(object_dir)/, $(server_objs))
110 write_objs := $(addprefix $(object_dir)/, $(write_objs))
111 afh_objs := $(addprefix $(object_dir)/, $(afh_objs))
112 play_objs := $(addprefix $(object_dir)/, $(play_objs))
113
114
115 DEBUG_CPPFLAGS += -g -Wunused -Wundef -W
116 DEBUG_CPPFLAGS += -Wredundant-decls
117 DEBUG_CPPFLAGS += -Wall -Wno-sign-compare -Wno-unknown-pragmas
118 DEBUG_CPPFLAGS += -Wformat-security
119 DEBUG_CPPFLAGS += -Wmissing-format-attribute
120
121 ifeq ($(uname_s),Linux)
122         CPPFLAGS += -fdata-sections -ffunction-sections
123         LDFLAGS += -Wl,--gc-sections
124         CPPFLAGS += -Wstrict-prototypes
125         CPPFLAGS += -Wshadow
126         # causes warnings on *BSD for the feature test macros
127         CPPFLAGS += -Wunused-macros
128 endif
129 CPPFLAGS += -Os
130 CPPFLAGS += -Wuninitialized
131 CPPFLAGS += -Wchar-subscripts
132 CPPFLAGS += -DBINDIR='"$(BINDIR)"'
133 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
134 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
135 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
136 CPPFLAGS += -Werror-implicit-function-declaration
137 CPPFLAGS += -Wmissing-noreturn
138 CPPFLAGS += -Wbad-function-cast
139 CPPFLAGS += -fno-strict-aliasing
140 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
141 CPPFLAGS += $(arch_cppflags)
142 CPPFLAGS += -I/usr/local/include
143 CPPFLAGS += -I$(cmdline_dir)
144 CPPFLAGS += $(osl_cppflags)
145
146 LDFLAGS += $(clock_gettime_ldflags)
147
148 man_pages := $(patsubst %, $(man_dir)/%.1, $(prefixed_executables))
149
150 autocrap := config.h.in configure
151 tarball_pfx := $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)
152 tarball_delete := $(addprefix $(tarball_pfx)/,\
153         web .changelog_before_cvs .changelog_cvs .gitignore)
154 tarball := $(tarball_pfx).tar.bz2
155
156 # To put more focus on warnings, be less verbose as default
157 # Use 'make V=1' to see the full commands
158 ifeq ("$(origin V)", "command line")
159         Q :=
160 else
161         Q := @
162 endif
163
164 .PHONY: dep all clean distclean maintainer-clean install man tarball
165 all: dep $(prefixed_executables) $(man_pages)
166 dep: $(deps)
167 man: $(man_pages)
168 tarball: $(tarball)
169
170 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \
171                 $(help2man_dir) $(hostbin_dir):
172         $(Q) $(MKDIR_P) $@
173
174 -include $(m4_ggo_dir)/makefile
175
176 # When in doubt, use brute force (Ken Thompson)
177 TOUPPER = \
178 $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\
179 $(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\
180 $(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\
181 $(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\
182 $(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\
183 $(subst z,Z,$1))))))))))))))))))))))))))
184
185 %_command_list.h: %.cmd %.c
186         @[ -z "$(Q)" ] || echo 'GEN $@'
187         $(Q) ./command_util.sh h < $< >$@
188 %_command_list.man: %.cmd %.c
189         @[ -z "$(Q)" ] || echo 'GEN $@'
190         $(Q) ./command_util.sh man < $< > $@
191 %_completion.h: %.cmd %.c
192         @[ -z "$(Q)" ] || echo 'GEN $@'
193         $(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
194                 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
195
196 server_command_list.h server_command_list.man server_completion.h: command.c
197 afs_command_list.h afs_command_list.man afs_completion.h: afs.c aft.c attribute.c
198 audiod_command_list.h audiod_command_list.man audiod_completion.h: audiod_command.c
199
200 server_command_lists_man = server_command_list.man afs_command_list.man
201 $(man_dir)/para_server.1: $(help2man_dir)/para_server $(server_command_lists_man) | $(man_dir)
202         @[ -z "$(Q)" ] || echo 'MAN $<'
203         $(Q) opts="`for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
204         $(HELP2MAN) $$opts ./$< > $@
205
206 $(man_dir)/para_audiod.1: $(help2man_dir)/para_audiod audiod_command_list.man | $(man_dir)
207         @[ -z "$(Q)" ] || echo 'MAN $<'
208         $(Q) $(HELP2MAN) -N -i audiod_command_list.man ./$< > $@
209
210 $(man_dir)/para_play.1: $(help2man_dir)/para_play play_command_list.man | $(man_dir)
211         @[ -z "$(Q)" ] || echo 'MAN $<'
212         $(Q) $(HELP2MAN) -N -i play_command_list.man ./$< > $@
213
214 $(man_dir)/%.1: $(help2man_dir)/% | $(man_dir)
215         @[ -z "$(Q)" ] || echo 'MAN $<'
216         $(Q) $(HELP2MAN) -N ./$< > $@
217
218 $(hostbin_dir)/error2: error2.c | $(hostbin_dir)
219         @[ -z "$(Q)" ] || echo 'HCC $<'
220         $(Q) $(HOSTCC) -o $@ $<
221 error2.h: $(hostbin_dir)/error2
222         @[ -z "$(Q)" ] || echo 'ER2 $<'
223         @echo "$(object_executable_matrix)" | $< > $@
224
225 $(object_dir)/%.o: %.c | $(object_dir)
226 $(object_dir)/opus%.o: CPPFLAGS += $(opus_cppflags)
227 $(object_dir)/gui%.o: CPPFLAGS += $(curses_cppflags)
228 $(object_dir)/spx%.o: CPPFLAGS += $(speex_cppflags)
229 $(object_dir)/%.cmdline.o: CPPFLAGS += -Wno-unused-function
230
231 $(object_dir)/mp3_afh.o: CPPFLAGS += $(id3tag_cppflags)
232 $(object_dir)/crypt.o: CPPFLAGS += $(openssl_cppflags)
233 $(object_dir)/mp3dec_filter.o: CPPFLAGS += $(mad_cppflags)
234 $(object_dir)/compress_filter.o: CPPFLAGS += -O3
235 $(object_dir)/ao_write.o: CPPFLAGS += $(ao_cppflags)
236
237 $(object_dir)/aacdec_filter.o \
238 $(object_dir)/aac_common.o \
239 $(object_dir)/aac_afh.o \
240 : CPPFLAGS += $(faad_cppflags)
241
242 $(object_dir)/spx_common.o \
243 $(object_dir)/spxdec_filter.o \
244 $(object_dir)/spx_afh.o \
245 $(object_dir)/oggdec_filter.o \
246 $(object_dir)/ogg_afh.o \
247 $(object_dir)/ogg_afh_common.o \
248 : CPPFLAGS += $(ogg_cppflags)
249
250 $(object_dir)/%.o: %.c | $(object_dir)
251         @[ -z "$(Q)" ] || echo 'CC $<'
252         $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
253
254 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
255         @[ -z "$(Q)" ] || echo 'CC $<'
256         $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
257
258 $(object_dir)/%.o: %.c | $(object_dir)
259         @[ -z "$(Q)" ] || echo 'CC $<'
260         $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
261
262 $(dep_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(dep_dir)
263         @[ -z "$(Q)" ] || echo 'DEP $<'
264         $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
265                 $(CPPFLAGS) $< > $@
266
267 $(dep_dir)/%.d: %.c | $(dep_dir)
268         @[ -z "$(Q)" ] || echo 'DEP $<'
269         $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
270                 $(CPPFLAGS) $< > $@
271
272 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
273 -include $(deps)
274 -include $(m4_deps)
275 endif
276
277 para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags)
278 para_write para_play para_audiod: LDFLAGS += $(ao_ldflags) $(core_audio_ldflags)
279 para_client para_audioc para_play : LDFLAGS += $(readline_ldflags)
280 para_server: LDFLAGS += $(osl_ldflags)
281 para_gui: LDFLAGS += $(curses_ldflags)
282 para_server \
283 para_client \
284 para_audiod \
285 :LDFLAGS += \
286         $(openssl_ldflags) \
287         $(gcrypt_ldflags)
288
289 para_audiod \
290 para_filter \
291 para_play \
292 : LDFLAGS += \
293         $(mad_ldflags) \
294         $(samplerate_ldflags) \
295         -lm
296
297 para_write \
298 para_play \
299 para_audiod \
300 para_fade \
301 : LDFLAGS += \
302         $(oss_ldflags) \
303         $(alsa_ldflags)
304
305 para_server \
306 para_filter \
307 para_audiod \
308 para_play \
309 para_afh \
310 para_recv \
311 : LDFLAGS += \
312         $(ogg_ldflags) \
313         $(vorbis_ldflags) \
314         $(speex_ldflags) \
315         $(opus_ldflags) \
316         $(faad_ldflags) \
317         $(flac_ldflags)
318
319 para_server \
320 para_client \
321 para_audioc \
322 para_audiod \
323 para_recv \
324 : LDFLAGS += \
325         $(socket_ldflags) $(nsl_ldflags)
326
327 $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs)))
328 $(prefixed_executables):
329         @[ -z "$(Q)" ] || echo 'LD $@'
330         $(Q) $(CC) $^ -o $@ $(LDFLAGS)
331
332 clean:
333         @[ -z "$(Q)" ] || echo 'CLEAN'
334         $(Q) rm -f $(prefixed_executables)
335         $(Q) rm -rf $(object_dir)
336
337 clean2: clean
338         @[ -z "$(Q)" ] || echo 'CLEAN2'
339         $(Q) rm -f *_command_list.* *_completion.h
340         $(Q) rm -rf $(build_dir)
341 distclean: clean2 test-clean
342         @[ -z "$(Q)" ] || echo 'DISTCLEAN'
343         $(Q) rm -f Makefile autoscan.log config.status config.log
344         $(Q) rm -rf autom4te.cache
345         $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
346
347 maintainer-clean: distclean
348         rm -f *.tar.bz2 config.h configure config.h.in
349         rm -rf web_sync
350
351 install: all man
352         $(MKDIR_P) $(BINDIR) $(MANDIR)
353         $(INSTALL) -s --strip-program $(STRIP) -m 755 \
354                 $(prefixed_executables) $(BINDIR)
355         $(INSTALL) -m 644 $(man_pages) $(MANDIR)
356         $(MKDIR_P) $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
357
358 $(tarball):
359         rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
360         git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
361                 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
362         $(MKDIR_P) $(tarball_pfx)
363         ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
364         cp -r $(autocrap) $(tarball_pfx)
365         tar rf $(tarball_pfx).tar $(tarball_pfx)/*
366         bzip2 -9 $(tarball_pfx).tar
367         ls -l $(tarball_pfx).tar.bz2
368         rm -rf $(tarball_pfx)
369 include $(test_dir)/makefile.test