Store gengetopt commandline files in a separate dir.
[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 := simultaneous independence
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
63 BINARIES = para_server para_client para_audioc para_recv \
64 para_filter para_write para_afh @extra_binaries@
65 man_binaries := $(BINARIES)
66 man_pages := $(patsubst %, man/man1/%.1, $(man_binaries))
67 man_pages_in := $(patsubst %, web/%.man.in.html, $(man_binaries))
68
69 ggo_dir := ggo
70
71 m4_ggos := afh audioc audiod client filter gui recv server write
72 all_ggos := $(m4_ggos) dccp_recv oggdec_filter 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 .PHONY: clean distclean maintainer-clean install man tarball
87 all: $(BINARIES) $(man_pages)
88 man: $(man_pages)
89 tarball: $(tarball)
90
91 *.o: para.h config.h gcc-compat.h
92
93 Makefile.deps: $(wildcard *.c *.h) $(cmdline_generated)
94 gcc -MM -MG -I$(cmdline_dir) @faad_cppflags@ @mad_cppflags@ @oggvorbis_cppflags@ *.c > $@
95 -include Makefile.deps
96 -include $(ggo_dir)/makefile
97
98 %_command_list.c: %.cmd
99 ./command_util.sh c < $< >$@
100 %_command_list.h: %.cmd
101 ./command_util.sh h < $< >$@
102 %_command_list.man: %.cmd
103 ./command_util.sh man < $< > $@
104
105 server_command_lists_ch = server_command_list.c afs_command_list.c \
106 server_command_list.h afs_command_list.h
107 server_command_lists_man = server_command_list.man afs_command_list.man
108 man/man1/para_server.1: para_server $(server_command_lists_man)
109 mkdir -p man/man1
110 opts="-h --detailed-help -N `for i in $(server_command_lists_man); do printf "%s\n" "-i $$i"; done`"; \
111 help2man $$opts ./para_server > $@
112
113 man/man1/para_audiod.1: para_audiod audiod_command_list.man
114 mkdir -p man/man1
115 help2man -h --detailed-help -N -i audiod_command_list.man ./para_audiod > $@
116
117 man/man1/%.1: %
118 mkdir -p man/man1
119 help2man -h --detailed-help -N ./$< > $@
120
121 man/html/%.html: man/man1/%.1
122 mkdir -p man/html
123 man2html $< > $@
124
125 web/%.man.in.html: man/man1/%.1
126 man2html $< | sed -e '/^<\/BODY>/,$$d' -e '1,/<\/HEAD><BODY>/d' > $@
127
128
129 oggdec_filter.o: oggdec_filter.c
130 $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @oggvorbis_cppflags@ $<
131 ogg_afh.o: ogg_afh.c
132 $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @oggvorbis_cppflags@ $<
133
134 mp3dec_filter.o: mp3dec_filter.c
135 $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @mad_cppflags@ $<
136
137 aacdec_filter.o: aacdec_filter.c
138 $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
139
140 aac_common.o: aac_common.c
141 $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
142
143 aac_afh.o: aac_afh.c
144 $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
145
146 $(cmdline_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c
147 @mkdir -p $(cmdline_dir)
148 $(CC) -c $(CPPFLAGS) -o $@ $<
149
150 %.o: %.c
151 $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
152
153 para_recv: @recv_objs@
154 $(CC) $(LDFLAGS) @recv_objs@ -o $@ @recv_ldflags@
155
156 para_filter: @filter_objs@
157 $(CC) $(LDFLAGS) @filter_objs@ -o $@ @filter_ldflags@
158
159 para_client: @client_objs@
160 $(CC) $(LDFLAGS) -o $@ @client_objs@ @client_ldflags@
161
162 para_gui: @gui_objs@
163 $(CC) $(LDFLAGS) -o $@ @gui_objs@ -lncurses
164
165 para_audiod: @audiod_objs@ audiod_command_list.c audiod_command_list.h
166 $(CC) $(LDFLAGS) -o $@ @audiod_objs@ @audiod_ldflags@
167
168 para_audioc: @audioc_objs@
169 $(CC) $(LDFLAGS) -o $@ @audioc_objs@ @audioc_ldflags@
170
171 para_fade: @fade_objs@
172 $(CC) $(LDFLAGS) -o $@ @fade_objs@ @fade_ldflags@
173
174 para_server: @server_objs@ $(server_command_lists_ch)
175 $(CC) $(LDFLAGS) -o $@ @server_objs@ @server_ldflags@
176
177 para_write: @write_objs@
178 $(CC) $(LDFLAGS) -o $@ @write_objs@ @write_ldflags@
179
180 para_afh: @afh_objs@
181 $(CC) $(LDFLAGS) -o $@ @afh_objs@ @afh_ldflags@
182
183 clean:
184 rm -f *.o $(BINARIES)
185 rm -f *_command_list.*
186 rm -rf man
187 distclean: clean
188 rm -f Makefile autoscan.log config.status config.log && \
189 rm -rf web/sync/* autom4te.cache aclocal.m4
190 rm -f GPATH GRTAGS GSYMS GTAGS
191
192 maintainer-clean: distclean
193 rm -f $(ggo_generated) *.tar.bz2 \
194 config.h configure \
195 config.h.in skencil/*.pdf skencil/*.ps
196 rm -rf web_sync
197
198 install: all man
199 mkdir -p $(BINDIR) $(MANDIR)
200 $(install_sh) -s -m 755 $(BINARIES) $(BINDIR)
201 $(install_sh) -m 644 $(man_pages) $(MANDIR)
202 mkdir -p $(VARDIR) >/dev/null 2>&1 || true # not fatal, so don't complain
203
204 $(tarball): $(cmdline_generated)
205 rm -rf $(tarball_pfx).tar.bz2 $(tarball_pfx)
206 git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
207 | tar --delete $(tarball_delete) > $(tarball_pfx).tar
208 mkdir -p $(tarball_pfx)/$(cmdline_dir)
209 cp -r $(autocrap) $(tarball_pfx)
210 cp -r $(cmdline_generated) $(tarball_pfx)/$(cmdline_dir)
211 tar rf $(tarball_pfx).tar $(tarball_pfx)/*
212 rm -rf $(tarball_pfx)
213 bzip2 -9 $(tarball_pfx).tar
214 rm -f $(tarball_pfx).tar
215 ls -l $(tarball_pfx).tar.bz2
216 %.ps: %.sk
217 sk2ps $< > $@
218 %.pdf: %.ps
219 ps2pdf - - < $< > $@
220