Fix compilation on Ubuntu precise.
[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 := spectral gravity
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 LDFLAGS += @clock_gettime_ldflags@
83
84 man_pages := $(patsubst %, $(man_dir)/%.1, @executables@)
85
86 autocrap := config.h.in configure
87 tarball_pfx := @PACKAGE_TARNAME@-$(PACKAGE_VERSION)
88 tarball_delete := $(addprefix $(tarball_pfx)/,\
89 web .changelog_before_cvs .changelog_cvs .gitignore\
90 skencil)
91 tarball := @PACKAGE_TARNAME@-$(PACKAGE_VERSION).tar.bz2
92
93 # To put more focus on warnings, be less verbose as default
94 # Use 'make V=1' to see the full commands
95 ifeq ("$(origin V)", "command line")
96 Q :=
97 else
98 Q := @
99 endif
100
101 .PHONY: dep all clean distclean maintainer-clean install man tarball
102 all: dep @executables@ $(man_pages)
103 dep: $(deps)
104 man: $(man_pages)
105 tarball: $(tarball)
106
107 $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir):
108 $(Q) $(MKDIR_P) $@
109
110 -include $(m4_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.h: %.cmd %.c
122 @[ -z "$(Q)" ] || echo 'GEN $@'
123 $(Q) ./command_util.sh h < $< >$@
124 %_command_list.man: %.cmd %.c
125 @[ -z "$(Q)" ] || echo 'GEN $@'
126 $(Q) ./command_util.sh man < $< > $@
127 %_completion.h: %.cmd %.c
128 @[ -z "$(Q)" ] || echo 'GEN $@'
129 $(Q) ./command_util.sh compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \
130 $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@
131
132 server_command_list.h server_command_list.man server_completion.h: command.c
133 afs_command_list.h afs_command_list.man afs_completion.h: afs.c aft.c attribute.c
134 audiod_command_list.h audiod_command_list.man audiod_completion.h: audiod_command.c
135
136 server_command_lists_man = server_command_list.man afs_command_list.man
137 $(man_dir)/para_server.1: para_server $(server_command_lists_man) | $(man_dir)
138 @[ -z "$(Q)" ] || echo 'MAN $<'
139 $(Q) opts="-h --detailed-help -N `for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
140 $(HELP2MAN) $$opts ./para_server > $@
141
142 $(man_dir)/para_audiod.1: para_audiod audiod_command_list.man | $(man_dir)
143 @[ -z "$(Q)" ] || echo 'MAN $<'
144 $(Q) $(HELP2MAN) -h --detailed-help -N -i audiod_command_list.man ./para_audiod > $@
145
146 $(man_dir)/para_play.1: para_play play_command_list.man | $(man_dir)
147 @[ -z "$(Q)" ] || echo 'MAN $<'
148 $(Q) $(HELP2MAN) -h --detailed-help -N -i play_command_list.man ./para_play > $@
149
150 $(man_dir)/%.1: % | $(man_dir)
151 @[ -z "$(Q)" ] || echo 'MAN $<'
152 $(Q) $(HELP2MAN) -h --detailed-help -N ./$< > $@
153
154 $(object_dir)/crypt.o: crypt.c | $(object_dir)
155 @[ -z "$(Q)" ] || echo 'CC $<'
156 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @openssl_cppflags@ $<
157 $(object_dir)/spx_common.o: spx_common.c | $(object_dir)
158 @[ -z "$(Q)" ] || echo 'CC $<'
159 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
160
161 $(object_dir)/spxdec_filter.o: spxdec_filter.c | $(object_dir)
162 @[ -z "$(Q)" ] || echo 'CC $<'
163 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
164
165 $(object_dir)/spx_afh.o: spx_afh.c | $(object_dir)
166 @[ -z "$(Q)" ] || echo 'CC $<'
167 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
168
169 $(object_dir)/oggdec_filter.o: oggdec_filter.c | $(object_dir)
170 @[ -z "$(Q)" ] || echo 'CC $<'
171 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
172
173 $(object_dir)/ogg_afh.o: ogg_afh.c | $(object_dir)
174 @[ -z "$(Q)" ] || echo 'CC $<'
175 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
176
177 $(object_dir)/ogg_afh_common.o: ogg_afh_common.c | $(object_dir)
178 @[ -z "$(Q)" ] || echo 'CC $<'
179 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
180
181 $(object_dir)/mp3dec_filter.o: mp3dec_filter.c | $(object_dir)
182 @[ -z "$(Q)" ] || echo 'CC $<'
183 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
184
185 $(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir)
186 @[ -z "$(Q)" ] || echo 'CC $<'
187 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
188
189 $(object_dir)/aac_common.o: aac_common.c | $(object_dir)
190 @[ -z "$(Q)" ] || echo 'CC $<'
191 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
192
193 $(object_dir)/aac_afh.o: aac_afh.c | $(object_dir)
194 @[ -z "$(Q)" ] || echo 'CC $<'
195 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
196
197 $(object_dir)/mp3_afh.o: mp3_afh.c | $(object_dir)
198 @[ -z "$(Q)" ] || echo 'CC $<'
199 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @id3tag_cppflags@ $<
200
201 $(object_dir)/gui%.o: gui%.c | $(object_dir)
202 @[ -z "$(Q)" ] || echo 'CC $<'
203 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @curses_cppflags@ $<
204 $(object_dir)/ao_write.o: ao_write.c | $(object_dir)
205 @[ -z "$(Q)" ] || echo 'CC $<'
206 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ao_cppflags@ $<
207
208 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
209 @[ -z "$(Q)" ] || echo 'CC $<'
210 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
211
212 $(object_dir)/%.o: %.c | $(object_dir)
213 @[ -z "$(Q)" ] || echo 'CC $<'
214 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
215
216 $(dep_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(dep_dir)
217 @[ -z "$(Q)" ] || echo 'DEP $<'
218 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
219 $(CPPFLAGS) $< > $@
220
221 $(dep_dir)/%.d: %.c | $(dep_dir)
222 @[ -z "$(Q)" ] || echo 'DEP $<'
223 $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \
224 $(CPPFLAGS) $< > $@
225
226 all_objs := @recv_objs@ @filter_objs@ @client_objs@ @gui_objs@ \
227 @audiod_objs@ @audioc_objs@ @fade_objs@ @server_objs@ \
228 @write_objs@ @afh_objs@ @play_objs@
229 deps := $(addprefix $(dep_dir)/, $(all_objs:.o=.d))
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 play_objs := $(addprefix $(object_dir)/, @play_objs@)
242
243 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
244 -include $(deps)
245 endif
246
247 para_recv: $(recv_objs)
248 @[ -z "$(Q)" ] || echo 'LD $@'
249 $(Q) $(CC) $(recv_objs) -o $@ @recv_ldflags@ $(LDFLAGS)
250
251 para_filter: $(filter_objs)
252 @[ -z "$(Q)" ] || echo 'LD $@'
253 $(Q) $(CC) $(filter_objs) -o $@ @filter_ldflags@ $(LDFLAGS)
254
255 para_client: $(client_objs)
256 @[ -z "$(Q)" ] || echo 'LD $@'
257 $(Q) $(CC) -o $@ $(client_objs) @client_ldflags@ $(LDFLAGS)
258
259 para_gui: $(gui_objs)
260 @[ -z "$(Q)" ] || echo 'LD $@'
261 $(Q) $(CC) -o $@ $(gui_objs) @gui_ldflags@ $(LDFLAGS)
262
263 para_audiod: $(audiod_objs)
264 @[ -z "$(Q)" ] || echo 'LD $@'
265 $(Q) $(CC) -o $@ $(audiod_objs) @audiod_ldflags@ $(LDFLAGS)
266
267 para_audioc: $(audioc_objs)
268 @[ -z "$(Q)" ] || echo 'LD $@'
269 $(Q) $(CC) -o $@ $(audioc_objs) @audioc_ldflags@ $(LDFLAGS)
270
271 para_fade: $(fade_objs)
272 @[ -z "$(Q)" ] || echo 'LD $@'
273 $(Q) $(CC) -o $@ $(fade_objs) @fade_ldflags@ $(LDFLAGS)
274
275 para_server: $(server_objs)
276 @[ -z "$(Q)" ] || echo 'LD $@'
277 $(Q) $(CC) -o $@ $(server_objs) @server_ldflags@ $(LDFLAGS)
278
279 para_write: $(write_objs)
280 @[ -z "$(Q)" ] || echo 'LD $@'
281 $(Q) $(CC) -o $@ $(write_objs) @write_ldflags@ $(LDFLAGS)
282
283 para_afh: $(afh_objs)
284 @[ -z "$(Q)" ] || echo 'LD $@'
285 $(Q) $(CC) -o $@ $(afh_objs) @afh_ldflags@ $(LDFLAGS)
286
287 para_play: $(play_objs)
288 @[ -z "$(Q)" ] || echo 'LD $@'
289 $(Q) $(CC) -o $@ $(play_objs) @play_ldflags@ $(LDFLAGS)
290
291 clean:
292 @[ -z "$(Q)" ] || echo 'CLEAN'
293 $(Q) rm -f @executables@
294 $(Q) rm -rf $(object_dir)
295
296 clean2: clean
297 @[ -z "$(Q)" ] || echo 'CLEAN2'
298 $(Q) rm -f *_command_list.* *_completion.h
299 $(Q) rm -rf $(build_dir)
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
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