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