06c86eb622247a2944f26a762e6f0986cdc2fe25
[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
13 build_date := $(shell date)
14 uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
15 uname_rs := $(shell uname -rs)
16 cc_version := $(shell $(CC) --version | head -n 1)
17 codename := deterministic entropy
18
19 GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
20
21 DEBUG_CPPFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
22 DEBUG_CPPFLAGS += -Wredundant-decls
23 # produces false positives
24 # DEBUG_CPPFLAGS += -Wunreachable-code
25 # DEBUG_CPPFLAGS += -Wwrite-strings
26
27 # invalid option for gcc-3.3.3
28 # DEBUG_CPPFLAGS += -Wextra
29 # DEBUG_CPPFLAGS += -Wold-style-definition
30 # DEBUG_CPPFLAGS += -Wdeclaration-after-statement
31
32 # many warnings about trivial stuff
33 # CPPFLAGS += -Wconversion
34
35 ifeq ($(uname_s),Linux)
36 CPPFLAGS += -fdata-sections -ffunction-sections
37 LDFLAGS += -Wl,--gc-sections
38 CPPFLAGS += -Wstrict-prototypes
39 CPPFLAGS += -Wshadow
40 endif
41 CPPFLAGS += -Os
42 CPPFLAGS += -Wall
43 CPPFLAGS += -Wuninitialized
44 CPPFLAGS += -Wchar-subscripts
45 CPPFLAGS += -Wformat-security
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-format-attribute
53 CPPFLAGS += -Wmissing-noreturn
54 CPPFLAGS += -Wunused-macros
55 CPPFLAGS += -Wbad-function-cast
56 CPPFLAGS += -fno-strict-aliasing
57 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
58 CPPFLAGS += @SSL_CPPFLAGS@
59 CPPFLAGS += @ncurses_cppflags@
60 CPPFLAGS += @arch_cppflags@
61 CPPFLAGS += -I/usr/local/include
62 CPPFLAGS += -I$(cmdline_dir)
63 CPPFLAGS += @osl_cppflags@
64
65 man_pages := $(patsubst %, man/man1/%.1, @executables@)
66 man_pages_in := $(patsubst %, web/%.man.in.html, @executables@)
67
68 ggo_dir := ggo
69 object_dir := objects
70 man_dir := man/man1
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),1)
98 Q =
99 else
100 Q = @
101 endif
102
103 .PHONY: dep all clean distclean maintainer-clean install man tarball
104 all: dep @executables@ $(man_pages)
105 dep: $(deps)
106 man: $(man_pages)
107 tarball: $(tarball)
108
109 -include $(ggo_dir)/makefile
110
111 %_command_list.c: %.cmd
112 @[ -z "$(Q)" ] || echo 'GEN $@'
113 $(Q) ./command_util.sh c < $< >$@
114 %_command_list.h: %.cmd
115 @[ -z "$(Q)" ] || echo 'GEN $@'
116 $(Q) ./command_util.sh h < $< >$@
117 %_command_list.man: %.cmd
118 @[ -z "$(Q)" ] || echo 'GEN $@'
119 $(Q) ./command_util.sh man < $< > $@
120
121 server_command_lists_ch = server_command_list.c afs_command_list.c \
122 server_command_list.h afs_command_list.h
123 server_command_lists_man = server_command_list.man afs_command_list.man
124 man/man1/para_server.1: para_server $(server_command_lists_man) | $(man_dir)
125 @[ -z "$(Q)" ] || echo 'HELP2MAN $<'
126 $(Q) opts="-h --detailed-help -N `for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
127 help2man $$opts ./para_server > $@
128
129 man/man1/para_audiod.1: para_audiod audiod_command_list.man | $(man_dir)
130 @[ -z "$(Q)" ] || echo 'HELP2MAN $<'
131 $(Q) help2man -h --detailed-help -N -i audiod_command_list.man ./para_audiod > $@
132
133 man/man1/%.1: % | $(man_dir)
134 @[ -z "$(Q)" ] || echo 'HELP2MAN $<'
135 $(Q) help2man -h --detailed-help -N ./$< > $@
136
137 man/html/%.html: man/man1/%.1
138 @[ -z "$(Q)" ] || echo 'MAN2HTML $<'
139 $(Q) mkdir -p man/html
140 $(Q) man2html $< > $@
141
142 web/%.man.in.html: man/man1/%.1
143 @[ -z "$(Q)" ] || echo 'MAN2HTML $<'
144 $(Q) mkdir -p man/html
145 $(Q) man2html $< | sed -e '/^<\/BODY>/,$$d' -e '1,/<\/HEAD><BODY>/d' > $@
146
147 $(object_dir):
148 mkdir -p $@
149 $(man_dir):
150 mkdir -p $@
151
152 $(object_dir)/spx_common.o: spx_common.c | $(object_dir)
153 @[ -z "$(Q)" ] || echo 'CC $<'
154 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
155
156 $(object_dir)/spxdec_filter.o: spxdec_filter.c | $(object_dir)
157 @[ -z "$(Q)" ] || echo 'CC $<'
158 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
159
160 $(object_dir)/spx_afh.o: spx_afh.c | $(object_dir)
161 @[ -z "$(Q)" ] || echo 'CC $<'
162 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
163
164 $(object_dir)/oggdec_filter.o: oggdec_filter.c | $(object_dir)
165 @[ -z "$(Q)" ] || echo 'CC $<'
166 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
167
168 $(object_dir)/ogg_afh.o: ogg_afh.c | $(object_dir)
169 @[ -z "$(Q)" ] || echo 'CC $<'
170 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
171
172 $(object_dir)/ogg_afh_common.o: ogg_afh_common.c | $(object_dir)
173 @[ -z "$(Q)" ] || echo 'CC $<'
174 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
175
176 $(object_dir)/mp3dec_filter.o: mp3dec_filter.c | $(object_dir)
177 @[ -z "$(Q)" ] || echo 'CC $<'
178 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
179
180 $(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir)
181 @[ -z "$(Q)" ] || echo 'CC $<'
182 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
183
184 $(object_dir)/aac_common.o: aac_common.c | $(object_dir)
185 @[ -z "$(Q)" ] || echo 'CC $<'
186 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
187
188 $(object_dir)/aac_afh.o: aac_afh.c | $(object_dir)
189 @[ -z "$(Q)" ] || echo 'CC $<'
190 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
191
192 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
193 @[ -z "$(Q)" ] || echo 'CC $<'
194 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
195
196 $(object_dir)/%.o: %.c | $(object_dir)
197 @[ -z "$(Q)" ] || echo 'CC $<'
198 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
199
200 $(object_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(object_dir)
201 @[ -z "$(Q)" ] || echo 'DEP $<'
202 $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
203
204 $(object_dir)/%.d: %.c | $(object_dir)
205 @[ -z "$(Q)" ] || echo 'DEP $<'
206 $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
207
208 recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
209 filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
210 client_objs := $(addprefix $(object_dir)/, @client_objs@)
211 gui_objs := $(addprefix $(object_dir)/, @gui_objs@)
212 audiod_objs := $(addprefix $(object_dir)/, @audiod_objs@)
213 audioc_objs := $(addprefix $(object_dir)/, @audioc_objs@)
214 fade_objs := $(addprefix $(object_dir)/, @fade_objs@)
215 server_objs := $(addprefix $(object_dir)/, @server_objs@)
216 write_objs := $(addprefix $(object_dir)/, @write_objs@)
217 afh_objs := $(addprefix $(object_dir)/, @afh_objs@)
218
219 all_objs := $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
220 $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
221 $(write_objs) $(afh_objs)
222
223 deps := $(all_objs:.o=.d)
224
225 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
226 -include $(deps)
227 endif
228
229 para_recv: $(recv_objs)
230 @[ -z "$(Q)" ] || echo 'LD $@'
231 $(Q) $(CC) $(LDFLAGS) $(recv_objs) -o $@ @recv_ldflags@
232
233 para_filter: $(filter_objs)
234 @[ -z "$(Q)" ] || echo 'LD $@'
235 $(Q) $(CC) $(LDFLAGS) $(filter_objs) -o $@ @filter_ldflags@
236
237 para_client: $(client_objs)
238 @[ -z "$(Q)" ] || echo 'LD $@'
239 $(Q) $(CC) $(LDFLAGS) -o $@ $(client_objs) @client_ldflags@
240
241 para_gui: $(gui_objs)
242 @[ -z "$(Q)" ] || echo 'LD $@'
243 $(Q) $(CC) $(LDFLAGS) -o $@ $(gui_objs) -lncurses
244
245 para_audiod: audiod_command_list.c audiod_command_list.h $(audiod_objs)
246 @[ -z "$(Q)" ] || echo 'LD $@'
247 $(Q) $(CC) $(LDFLAGS) -o $@ $(audiod_objs) @audiod_ldflags@
248
249 para_audioc: $(audioc_objs)
250 @[ -z "$(Q)" ] || echo 'LD $@'
251 $(Q) $(CC) $(LDFLAGS) -o $@ $(audioc_objs) @audioc_ldflags@
252
253 para_fade: $(fade_objs)
254 @[ -z "$(Q)" ] || echo 'LD $@'
255 $(Q) $(CC) $(LDFLAGS) -o $@ $(fade_objs) @fade_ldflags@
256
257 para_server: $(server_command_lists_ch) $(server_objs)
258 @[ -z "$(Q)" ] || echo 'LD $@'
259 $(Q) $(CC) $(LDFLAGS) -o $@ $(server_objs) @server_ldflags@
260
261 para_write: $(write_objs)
262 @[ -z "$(Q)" ] || echo 'LD $@'
263 $(Q) $(CC) $(LDFLAGS) -o $@ $(write_objs) @write_ldflags@
264
265 para_afh: $(afh_objs)
266 @[ -z "$(Q)" ] || echo 'LD $@'
267 $(Q) $(CC) $(LDFLAGS) -o $@ $(afh_objs) @afh_ldflags@
268
269 clean:
270 @[ -z "$(Q)" ] || echo 'CLEAN'
271 $(Q) rm -f @executables@ $(object_dir)/*.o
272
273 clean2: clean
274 @[ -z "$(Q)" ] || echo 'CLEAN2'
275 $(Q) rm -rf man $(object_dir)
276 $(Q) rm -f *_command_list.*
277
278 distclean: clean2
279 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
280 $(Q) rm -f Makefile autoscan.log config.status config.log
281 $(Q) rm -rf autom4te.cache aclocal.m4
282 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
283
284 maintainer-clean: distclean
285 rm -f $(ggo_generated) *.tar.bz2 \
286 config.h configure \
287 config.h.in skencil/*.pdf skencil/*.ps
288 rm -rf web_sync $(cmdline_dir)
289
290 install: all man
291 mkdir -p $(BINDIR) $(MANDIR)
292 $(install_sh) -s -m 755 @executables@ $(BINDIR)
293 $(install_sh) -m 644 $(man_pages) $(MANDIR)
294 mkdir -p $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
295
296 $(tarball): $(cmdline_generated)
297 rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
298 git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
299 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
300 mkdir -p $(tarball_pfx)/$(cmdline_dir)
301 ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
302 cp -r $(autocrap) $(tarball_pfx)
303 cp -r $(cmdline_generated) $(tarball_pfx)/$(cmdline_dir)
304 tar rf $(tarball_pfx).tar $(tarball_pfx)/*
305 rm -rf $(tarball_pfx)
306 bzip2 -9 $(tarball_pfx).tar
307 rm -f $(tarball_pfx).tar
308 ls -l $(tarball_pfx).tar.bz2
309 %.ps: %.sk
310 sk2ps $< > $@
311 %.pdf: %.ps
312 ps2pdf - - < $< > $@
313