Use curses_cppflags only for building gui.o.
[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 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 += @arch_cppflags@
58 CPPFLAGS += -I/usr/local/include
59 CPPFLAGS += -I$(cmdline_dir)
60 CPPFLAGS += @osl_cppflags@
61 CPPFLAGS += -DGIT_VERSION='"$(GIT_VERSION)"'
62
63 man_pages := $(patsubst %, man/man1/%.1, @executables@)
64 man_pages_in := $(patsubst %, web/%.man.in.html, @executables@)
65
66 ggo_dir := ggo
67 object_dir := objects
68 man_dir := man/man1
69
70 m4_ggos := afh audioc audiod client filter gui recv server write
71 all_ggos := $(m4_ggos) dccp_recv alsa_write oss_write fade http_recv \
72 osx_write udp_recv amp_filter compress_filter file_write \
73 mp3dec_filter prebuffer_filter
74 ggo_generated := $(addsuffix .ggo, $(addprefix $(ggo_dir)/,$(m4_ggos)))
75 cmdline_generated := $(addprefix $(cmdline_dir)/,$(addsuffix .cmdline.c, $(all_ggos)) \
76 $(addsuffix .cmdline.h, $(all_ggos)))
77
78 autocrap := config.h.in configure
79 tarball_pfx := @PACKAGE_TARNAME@-$(PACKAGE_VERSION)
80 tarball_delete := $(addprefix $(tarball_pfx)/,\
81 web versions .changelog_before_cvs .changelog_cvs .gitignore\
82 $(ggo_dir) skencil)
83 tarball := @PACKAGE_TARNAME@-$(PACKAGE_VERSION).tar.bz2
84
85 # To put more focus on warnings, be less verbose as default
86 # Use 'make V=1' to see the full commands
87 ifdef V
88 ifeq ("$(origin V)", "command line")
89 BUILD_VERBOSE = $(V)
90 endif
91 endif
92 ifndef BUILD_VERBOSE
93 BUILD_VERBOSE = 0
94 endif
95 ifeq ($(BUILD_VERBOSE),1)
96 Q =
97 else
98 Q = @
99 endif
100
101 .PHONY: dep all clean distclean maintainer-clean install man tarball\
102 .FORCE-GIT-VERSION-FILE
103 all: dep @executables@ $(man_pages)
104 dep: $(deps)
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)/spx_common.o: spx_common.c | $(object_dir)
157 @[ -z "$(Q)" ] || echo 'CC $<'
158 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
159
160 $(object_dir)/spxdec_filter.o: spxdec_filter.c | $(object_dir)
161 @[ -z "$(Q)" ] || echo 'CC $<'
162 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
163
164 $(object_dir)/spx_afh.o: spx_afh.c | $(object_dir)
165 @[ -z "$(Q)" ] || echo 'CC $<'
166 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
167
168 $(object_dir)/oggdec_filter.o: oggdec_filter.c | $(object_dir)
169 @[ -z "$(Q)" ] || echo 'CC $<'
170 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
171
172 $(object_dir)/ogg_afh.o: ogg_afh.c | $(object_dir)
173 @[ -z "$(Q)" ] || echo 'CC $<'
174 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
175
176 $(object_dir)/ogg_afh_common.o: ogg_afh_common.c | $(object_dir)
177 @[ -z "$(Q)" ] || echo 'CC $<'
178 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @ogg_cppflags@ $<
179
180 $(object_dir)/mp3dec_filter.o: mp3dec_filter.c | $(object_dir)
181 @[ -z "$(Q)" ] || echo 'CC $<'
182 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
183
184 $(object_dir)/aacdec_filter.o: aacdec_filter.c | $(object_dir)
185 @[ -z "$(Q)" ] || echo 'CC $<'
186 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
187
188 $(object_dir)/aac_common.o: aac_common.c | $(object_dir)
189 @[ -z "$(Q)" ] || echo 'CC $<'
190 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
191
192 $(object_dir)/aac_afh.o: aac_afh.c | $(object_dir)
193 @[ -z "$(Q)" ] || echo 'CC $<'
194 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
195
196 $(object_dir)/gui%.o: gui%.c | $(object_dir)
197 @[ -z "$(Q)" ] || echo 'CC $<'
198 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @curses_cppflags@ $<
199
200 $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
201 @[ -z "$(Q)" ] || echo 'CC $<'
202 $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
203
204 $(object_dir)/%.o: %.c | $(object_dir)
205 @[ -z "$(Q)" ] || echo 'CC $<'
206 $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
207
208 $(object_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c | $(object_dir)
209 @[ -z "$(Q)" ] || echo 'DEP $<'
210 $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
211
212 $(object_dir)/%.d: %.c | $(object_dir)
213 @[ -z "$(Q)" ] || echo 'DEP $<'
214 $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
215
216
217 recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
218 filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
219 client_objs := $(addprefix $(object_dir)/, @client_objs@)
220 gui_objs := $(addprefix $(object_dir)/, @gui_objs@)
221 audiod_objs := $(addprefix $(object_dir)/, @audiod_objs@)
222 audioc_objs := $(addprefix $(object_dir)/, @audioc_objs@)
223 fade_objs := $(addprefix $(object_dir)/, @fade_objs@)
224 server_objs := $(addprefix $(object_dir)/, @server_objs@)
225 write_objs := $(addprefix $(object_dir)/, @write_objs@)
226 afh_objs := $(addprefix $(object_dir)/, @afh_objs@)
227
228 all_objs := $(recv_objs) $(filter_objs) $(client_objs) $(gui_objs) \
229 $(audiod_objs) $(audioc_objs) $(fade_objs) $(server_objs) \
230 $(write_objs) $(afh_objs)
231
232 deps := $(all_objs:.o=.d)
233
234 ifeq ($(findstring clean, $(MAKECMDGOALS)),)
235 -include $(deps)
236 endif
237
238 para_recv: $(recv_objs)
239 @[ -z "$(Q)" ] || echo 'LD $@'
240 $(Q) $(CC) $(LDFLAGS) $(recv_objs) -o $@ @recv_ldflags@
241
242 para_filter: $(filter_objs)
243 @[ -z "$(Q)" ] || echo 'LD $@'
244 $(Q) $(CC) $(LDFLAGS) $(filter_objs) -o $@ @filter_ldflags@
245
246 para_client: $(client_objs)
247 @[ -z "$(Q)" ] || echo 'LD $@'
248 $(Q) $(CC) $(LDFLAGS) -o $@ $(client_objs) @client_ldflags@
249
250 para_gui: $(gui_objs)
251 @[ -z "$(Q)" ] || echo 'LD $@'
252 $(Q) $(CC) $(LDFLAGS) -o $@ $(gui_objs) -lcurses
253
254 para_audiod: audiod_command_list.c audiod_command_list.h $(audiod_objs)
255 @[ -z "$(Q)" ] || echo 'LD $@'
256 $(Q) $(CC) $(LDFLAGS) -o $@ $(audiod_objs) @audiod_ldflags@
257
258 para_audioc: $(audioc_objs)
259 @[ -z "$(Q)" ] || echo 'LD $@'
260 $(Q) $(CC) $(LDFLAGS) -o $@ $(audioc_objs) @audioc_ldflags@
261
262 para_fade: $(fade_objs)
263 @[ -z "$(Q)" ] || echo 'LD $@'
264 $(Q) $(CC) $(LDFLAGS) -o $@ $(fade_objs) @fade_ldflags@
265
266 para_server: $(server_command_lists_ch) $(server_objs)
267 @[ -z "$(Q)" ] || echo 'LD $@'
268 $(Q) $(CC) $(LDFLAGS) -o $@ $(server_objs) @server_ldflags@
269
270 para_write: $(write_objs)
271 @[ -z "$(Q)" ] || echo 'LD $@'
272 $(Q) $(CC) $(LDFLAGS) -o $@ $(write_objs) @write_ldflags@
273
274 para_afh: $(afh_objs)
275 @[ -z "$(Q)" ] || echo 'LD $@'
276 $(Q) $(CC) $(LDFLAGS) -o $@ $(afh_objs) @afh_ldflags@
277
278 clean:
279 @[ -z "$(Q)" ] || echo 'CLEAN'
280 $(Q) rm -f @executables@ $(object_dir)/*.o
281
282 clean2: clean
283 @[ -z "$(Q)" ] || echo 'CLEAN2'
284 $(Q) rm -rf man $(object_dir)
285 $(Q) rm -f *_command_list.*
286
287 distclean: clean2
288 @[ -z "$(Q)" ] || echo 'DISTCLEAN'
289 $(Q) rm -f Makefile autoscan.log config.status config.log
290 $(Q) rm -rf autom4te.cache aclocal.m4
291 $(Q) rm -f GPATH GRTAGS GSYMS GTAGS
292
293 maintainer-clean: distclean
294 rm -f $(ggo_generated) *.tar.bz2 \
295 config.h configure \
296 config.h.in skencil/*.pdf skencil/*.ps
297 rm -rf web_sync $(cmdline_dir)
298
299 install: all man
300 mkdir -p $(BINDIR) $(MANDIR)
301 $(install_sh) -s -m 755 @executables@ $(BINDIR)
302 $(install_sh) -m 644 $(man_pages) $(MANDIR)
303 mkdir -p $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
304
305 $(tarball): $(cmdline_generated)
306 rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
307 git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
308 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
309 mkdir -p $(tarball_pfx)/$(cmdline_dir)
310 echo $(GIT_VERSION) > $(tarball_pfx)/VERSION
311 cp -r $(autocrap) $(tarball_pfx)
312 cp -r $(cmdline_generated) $(tarball_pfx)/$(cmdline_dir)
313 tar rf $(tarball_pfx).tar $(tarball_pfx)/*
314 rm -rf $(tarball_pfx)
315 bzip2 -9 $(tarball_pfx).tar
316 rm -f $(tarball_pfx).tar
317 ls -l $(tarball_pfx).tar.bz2
318 %.ps: %.sk
319 sk2ps $< > $@
320 %.pdf: %.ps
321 ps2pdf - - < $< > $@
322