e457e490858eea0fc4bbee90b0088347a53c2a52
[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 := persistent regularity
18
19 DEBUG_CPPFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
20 DEBUG_CPPFLAGS += -Wredundant-decls
21 # produces false positives
22 # DEBUG_CPPFLAGS += -Wunreachable-code
23 # DEBUG_CPPFLAGS += -Wwrite-strings
24
25 # invalid option for gcc-3.3.3
26 # DEBUG_CPPFLAGS += -Wextra
27 # DEBUG_CPPFLAGS += -Wold-style-definition
28 # DEBUG_CPPFLAGS += -Wdeclaration-after-statement
29
30 # many warnings about trivial stuff
31 # CPPFLAGS += -Wconversion
32
33 ifeq ($(uname_s),Linux)
34 CPPFLAGS += -fdata-sections -ffunction-sections
35 LDFLAGS += -Wl,--gc-sections
36 CPPFLAGS += -Wstrict-prototypes
37 CPPFLAGS += -Wshadow
38 endif
39 CPPFLAGS += -Os
40 CPPFLAGS += -Wall
41 CPPFLAGS += -Wuninitialized
42 CPPFLAGS += -Wchar-subscripts
43 CPPFLAGS += -Wformat-security
44 CPPFLAGS += -DBINDIR='"$(BINDIR)"'
45 CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
46 CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
47 CPPFLAGS += -DCODENAME='"$(codename)"'
48 CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
49 CPPFLAGS += -Werror-implicit-function-declaration
50 CPPFLAGS += -Wmissing-format-attribute
51 CPPFLAGS += -Wmissing-noreturn
52 CPPFLAGS += -Wunused-macros
53 CPPFLAGS += -Wbad-function-cast
54 CPPFLAGS += -fno-strict-aliasing
55 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
56 CPPFLAGS += @SSL_CPPFLAGS@
57 CPPFLAGS += @ncurses_cppflags@
58 CPPFLAGS += @arch_cppflags@
59 CPPFLAGS += -I/usr/local/include
60 CPPFLAGS += -I$(cmdline_dir)
61 CPPFLAGS += @osl_cppflags@
62 CPPFLAGS += -DGIT_VERSION='"$(GIT_VERSION)"'
63
64 man_pages := $(patsubst %, man/man1/%.1, @executables@)
65 man_pages_in := $(patsubst %, web/%.man.in.html, @executables@)
66
67 ggo_dir := ggo
68 object_dir := objects
69 man_dir := man/man1
70
71 m4_ggos := afh audioc audiod client filter gui recv server write
72 all_ggos := $(m4_ggos) dccp_recv alsa_write oss_write fade http_recv \
73 osx_write udp_recv amp_filter compress_filter file_write \
74 mp3dec_filter prebuffer_filter
75 ggo_generated := $(addsuffix .ggo, $(addprefix $(ggo_dir)/,$(m4_ggos)))
76 cmdline_generated := $(addprefix $(cmdline_dir)/,$(addsuffix .cmdline.c, $(all_ggos)) \
77 $(addsuffix .cmdline.h, $(all_ggos)))
78
79 autocrap := config.h.in configure
80 tarball_pfx := @PACKAGE_TARNAME@-$(PACKAGE_VERSION)
81 tarball_delete := $(addprefix $(tarball_pfx)/,\
82 web versions .changelog_before_cvs .changelog_cvs .gitignore\
83 $(ggo_dir) skencil)
84 tarball := @PACKAGE_TARNAME@-$(PACKAGE_VERSION).tar.bz2
85
86 # To put more focus on warnings, be less verbose as default
87 # Use 'make V=1' to see the full commands
88 ifdef V
89 ifeq ("$(origin V)", "command line")
90 BUILD_VERBOSE = $(V)
91 endif
92 endif
93 ifndef BUILD_VERBOSE
94 BUILD_VERBOSE = 0
95 endif
96 ifeq ($(BUILD_VERBOSE),1)
97 Q =
98 else
99 Q = @
100 endif
101
102 .PHONY: all clean distclean maintainer-clean install man tarball\
103 .FORCE-GIT-VERSION-FILE
104 all: @executables@ $(man_pages)
105 man: $(man_pages)
106 tarball: $(tarball)
107
108 GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
109 @./GIT-VERSION-GEN GIT-VERSION-FILE
110 -include GIT-VERSION-FILE
111 @executables@: GIT-VERSION-FILE
112
113 -include $(ggo_dir)/makefile
114
115 %_command_list.c: %.cmd
116 @[ -z "$(Q)" ] || echo 'GEN $@'
117 $(Q) ./command_util.sh c < $< >$@
118 %_command_list.h: %.cmd
119 @[ -z "$(Q)" ] || echo 'GEN $@'
120 $(Q) ./command_util.sh h < $< >$@
121 %_command_list.man: %.cmd
122 @[ -z "$(Q)" ] || echo 'GEN $@'
123 $(Q) ./command_util.sh man < $< > $@
124
125 server_command_lists_ch = server_command_list.c afs_command_list.c \
126 server_command_list.h afs_command_list.h
127 server_command_lists_man = server_command_list.man afs_command_list.man
128 man/man1/para_server.1: para_server $(server_command_lists_man) | $(man_dir)
129 @[ -z "$(Q)" ] || echo 'HELP2MAN $<'
130 $(Q) opts="-h --detailed-help -N `for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
131 help2man $$opts ./para_server > $@
132
133 man/man1/para_audiod.1: para_audiod audiod_command_list.man | $(man_dir)
134 @[ -z "$(Q)" ] || echo 'HELP2MAN $<'
135 $(Q) help2man -h --detailed-help -N -i audiod_command_list.man ./para_audiod > $@
136
137 man/man1/%.1: % | $(man_dir)
138 @[ -z "$(Q)" ] || echo 'HELP2MAN $<'
139 $(Q) help2man -h --detailed-help -N ./$< > $@
140
141 man/html/%.html: man/man1/%.1
142 @[ -z "$(Q)" ] || echo 'MAN2HTML $<'
143 $(Q) mkdir -p man/html
144 $(Q) man2html $< > $@
145
146 web/%.man.in.html: man/man1/%.1
147 @[ -z "$(Q)" ] || echo 'MAN2HTML $<'
148 $(Q) mkdir -p man/html
149 $(Q) man2html $< | sed -e '/^<\/BODY>/,$$d' -e '1,/<\/HEAD><BODY>/d' > $@
150
151 $(object_dir):
152 mkdir -p $@
153 $(man_dir):
154 mkdir -p $@
155
156 $(object_dir)/oggdec_filter.o: oggdec_filter.c | $(object_dir)
157 @[ -z "$(Q)" ] || echo 'CC $<'
158 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @oggvorbis_cppflags@ $<
159
160 $(object_dir)/ogg_afh.o: ogg_afh.c | $(object_dir)
161 @[ -z "$(Q)" ] || echo 'CC $<'
162 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @oggvorbis_cppflags@ $<
163
164 $(object_dir)/ogg_afh_common.o: ogg_afh_common.c | $(object_dir)
165 @[ -z "$(Q)" ] || echo 'CC $<'
166 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @oggvorbis_cppflags@ $<
167
168 $(object_dir)/mp3dec_filter.o: mp3dec_filter.c | $(object_dir)
169 @[ -z "$(Q)" ] || echo 'CC $<'
170 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
171
172 $(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir)
173 @[ -z "$(Q)" ] || echo 'CC $<'
174 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
175
176 $(object_dir)/aac_common.o: aac_common.c | $(object_dir)
177 @[ -z "$(Q)" ] || echo 'CC $<'
178 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
179
180 $(object_dir)/aac_afh.o: aac_afh.c | $(object_dir)
181 @[ -z "$(Q)" ] || echo 'CC $<'
182 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
183
184 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
185 @[ -z "$(Q)" ] || echo 'CC $<'
186 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
187
188 $(object_dir)/%.o: %.c | $(object_dir)
189 @[ -z "$(Q)" ] || echo 'CC $<'
190 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
191
192 $(object_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(object_dir)
193 @[ -z "$(Q)" ] || echo 'DEP $<'
194 $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
195
196 $(object_dir)/%.d: %.c | $(object_dir)
197 @[ -z "$(Q)" ] || echo 'DEP $<'
198 $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
199
200 recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
201 filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
202 client_objs := $(addprefix $(object_dir)/, @client_objs@)
203 gui_objs := $(addprefix $(object_dir)/, @gui_objs@)
204 audiod_objs := $(addprefix $(object_dir)/, @audiod_objs@)
205 audioc_objs := $(addprefix $(object_dir)/, @audioc_objs@)
206 fade_objs := $(addprefix $(object_dir)/, @fade_objs@)
207 server_objs := $(addprefix $(object_dir)/, @server_objs@)
208 write_objs := $(addprefix $(object_dir)/, @write_objs@)
209 afh_objs := $(addprefix $(object_dir)/, @afh_objs@)
210
211 all_objs := $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
212 $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
213 $(write_objs) $(afh_objs)
214
215 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
216 -include $(all_objs:.o=.d)
217 endif
218
219 para_recv: $(recv_objs)
220 @[ -z "$(Q)" ] || echo 'LD $@'
221 $(Q) $(CC) $(LDFLAGS) $(recv_objs) -o $@ @recv_ldflags@
222
223 para_filter: $(filter_objs)
224 @[ -z "$(Q)" ] || echo 'LD $@'
225 $(Q) $(CC) $(LDFLAGS) $(filter_objs) -o $@ @filter_ldflags@
226
227 para_client: $(client_objs)
228 @[ -z "$(Q)" ] || echo 'LD $@'
229 $(Q) $(CC) $(LDFLAGS) -o $@ $(client_objs) @client_ldflags@
230
231 para_gui: $(gui_objs)
232 @[ -z "$(Q)" ] || echo 'LD $@'
233 $(Q) $(CC) $(LDFLAGS) -o $@ $(gui_objs) -lncurses
234
235 para_audiod: audiod_command_list.c audiod_command_list.h $(audiod_objs)
236 @[ -z "$(Q)" ] || echo 'LD $@'
237 $(Q) $(CC) $(LDFLAGS) -o $@ $(audiod_objs) @audiod_ldflags@
238
239 para_audioc: $(audioc_objs)
240 @[ -z "$(Q)" ] || echo 'LD $@'
241 $(Q) $(CC) $(LDFLAGS) -o $@ $(audioc_objs) @audioc_ldflags@
242
243 para_fade: $(fade_objs)
244 @[ -z "$(Q)" ] || echo 'LD $@'
245 $(Q) $(CC) $(LDFLAGS) -o $@ $(fade_objs) @fade_ldflags@
246
247 para_server: $(server_command_lists_ch) $(server_objs)
248 @[ -z "$(Q)" ] || echo 'LD $@'
249 $(Q) $(CC) $(LDFLAGS) -o $@ $(server_objs) @server_ldflags@
250
251 para_write: $(write_objs)
252 @[ -z "$(Q)" ] || echo 'LD $@'
253 $(Q) $(CC) $(LDFLAGS) -o $@ $(write_objs) @write_ldflags@
254
255 para_afh: $(afh_objs)
256 @[ -z "$(Q)" ] || echo 'LD $@'
257 $(Q) $(CC) $(LDFLAGS) -o $@ $(afh_objs) @afh_ldflags@
258
259 clean:
260 @[ -z "$(Q)" ] || echo 'CLEAN'
261 $(Q) rm -f @executables@ $(object_dir)/*.o
262
263 clean2: clean
264 @[ -z "$(Q)" ] || echo 'CLEAN2'
265 $(Q) rm -rf man $(object_dir)
266 $(Q) rm -f *_command_list.*
267
268 distclean: clean2
269 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
270 $(Q) rm -f Makefile autoscan.log config.status config.log
271 $(Q) rm -rf autom4te.cache aclocal.m4
272 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
273
274 maintainer-clean: distclean
275 rm -f $(ggo_generated) *.tar.bz2 \
276 config.h configure \
277 config.h.in skencil/*.pdf skencil/*.ps
278 rm -rf web_sync $(cmdline_dir)
279
280 install: all man
281 mkdir -p $(BINDIR) $(MANDIR)
282 $(install_sh) -s -m 755 @executables@ $(BINDIR)
283 $(install_sh) -m 644 $(man_pages) $(MANDIR)
284 mkdir -p $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
285
286 $(tarball): $(cmdline_generated)
287 rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
288 git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
289 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
290 mkdir -p $(tarball_pfx)/$(cmdline_dir)
291 echo $(GIT_VERSION) > $(tarball_pfx)/VERSION
292 cp -r $(autocrap) $(tarball_pfx)
293 cp -r $(cmdline_generated) $(tarball_pfx)/$(cmdline_dir)
294 tar rf $(tarball_pfx).tar $(tarball_pfx)/*
295 rm -rf $(tarball_pfx)
296 bzip2 -9 $(tarball_pfx).tar
297 rm -f $(tarball_pfx).tar
298 ls -l $(tarball_pfx).tar.bz2
299 %.ps: %.sk
300 sk2ps $< > $@
301 %.pdf: %.ps
302 ps2pdf - - < $< > $@
303