I'll just store the Doxygen docs on herrie.info itself.
[herrie-working.git] / herrie / configure
blobddba13a99c63585e153d639a97fa1740de5f578f
1 #!/bin/sh
2 #
3 # Copyright (c) 2006-2008 Ed Schouten <ed@80386.nl>
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 # SUCH DAMAGE.
28 APP_NAME=herrie
29 APP_VERSION=2.1
30 APP_LINGUAS='ca da de es fi ga nl pl pt_BR ru sv tr uk vi zh_CN'
32 # Default compilation switches
33 CFG_AO=oss
34 unset CFG_BINEXT
35 CFG_CURSES_HEADER=ncurses
36 CFG_CURSES_LIB=ncursesw
37 CFG_HTTP=yes
38 CFG_MODPLUG=yes
39 CFG_MP3=yes
40 CFG_RES_INIT=yes
41 CFG_SCROBBLER=yes
42 unset CFG_SETPROCTITLE
43 CFG_SNDFILE=yes
44 unset CFG_DEBUG
45 unset CFG_STRICT
46 CFG_STRIP=-s
47 unset CFG_VOLUME
48 CFG_VORBIS=yes
49 CFG_XSPF=yes
50 DOIT=@
52 # Operating system defaults
53 [ "$OS" != "" ] || OS=`uname`
54 case $OS in
55 CYGWIN*|Windows_*)
56 CFG_BINEXT=.exe
57 unset CFG_HTTP
58 unset CFG_RES_INIT
59 [ "$CONFDIR" = "" ] && CONFDIR=/etc
60 [ "$PREFIX" = "" ] && PREFIX=/usr
62 Darwin)
63 CFG_AO=coreaudio
64 LDFLAGS="$LDFLAGS -lresolv"
65 [ "$PREFIX" = "" ] && PREFIX=/opt/local
67 FreeBSD)
68 CFG_SETPROCTITLE=yes
69 [ "$PREFIX" = "" ] && PREFIX=/usr/local
70 [ "$MANDIR" = "" ] && MANDIR=$PREFIX/man
72 GNU/kFreeBSD)
73 [ "$CONFDIR" = "" ] && CONFDIR=/etc
74 [ "$PREFIX" = "" ] && PREFIX=/usr
76 Linux)
77 CFG_AO=alsa
78 [ "$CONFDIR" = "" ] && CONFDIR=/etc
79 [ "$PREFIX" = "" ] && PREFIX=/usr
81 NetBSD)
82 CFG_SETPROCTITLE=yes
83 [ "$PREFIX" = "" ] && PREFIX=/usr/pkg
85 OpenBSD)
86 CFG_SETPROCTITLE=yes
87 [ "$PREFIX" = "" ] && PREFIX=/usr/local
88 [ "$MANDIR" = "" ] && MANDIR=$PREFIX/man
90 SunOS)
91 CFG_AO=ao
92 unset CFG_HTTP
93 [ "$PREFIX" = "" ] && PREFIX=/opt/sfw
94 LDFLAGS="$LDFLAGS -lresolv"
95 [ "$INSTALL" = "" ] && INSTALL=ginstall
98 echo "Warning: unknown operating system: $OS"
99 CFG_AO=ao
100 [ "$PREFIX" = "" ] && PREFIX=/usr/local
101 esac
102 SRCDIR=`dirname $0`
103 BINDIR=$PREFIX/bin
104 [ "$CONFDIR" = "" ] && CONFDIR=$PREFIX/etc
105 CONFFILE=$CONFDIR/$APP_NAME.conf
106 [ "$LINGUAS" = "" ] && LINGUAS=$APP_LINGUAS
107 [ "$MANDIR" = "" ] && MANDIR=$PREFIX/share/man
108 TRANSDIR=$PREFIX/share/locale
109 [ "$CC" = "" ] && CC=cc
110 [ "$INSTALL" = "" ] && INSTALL=install
111 MANPARTS="00-man 02-man 04-man 06-man"
112 MANREGEX="-e 's|%%CONFFILE%%|$CONFFILE|'"
114 # Command line options
115 while [ $# -gt 0 ]
117 case $1 in
118 no_http)
119 unset CFG_HTTP
121 no_modplug)
122 unset CFG_MODPLUG
124 no_mp3)
125 unset CFG_MP3
127 no_scrobbler)
128 unset CFG_SCROBBLER
130 no_sndfile)
131 unset CFG_SNDFILE
133 no_nls)
134 unset LINGUAS
136 no_vorbis)
137 unset CFG_VORBIS
139 no_xspf)
140 unset CFG_XSPF
143 alsa|ao|coreaudio|null|oss|pulse)
144 CFG_AO=$1
147 no_strip)
148 unset CFG_STRIP
150 debug)
151 CFG_DEBUG=yes
152 unset CFG_STRIP
154 strict)
155 CFG_STRICT=yes
157 verbose)
158 unset DOIT
161 ncurses)
162 CFG_CURSES_HEADER=ncurses
163 CFG_CURSES_LIB=ncurses
165 xcurses)
166 CFG_CURSES_HEADER=xcurses
167 CFG_CURSES_LIB=XCurses
171 echo "Error: unknown option: $1"
172 echo "See the README file for a list of valid options"
173 exit 1
174 esac
176 shift
177 done
179 test_pkgconfig()
181 PKG_CFLAGS="`pkg-config --cflags $2 2> /dev/null`"
182 if [ $? -ne 0 ]
183 then
184 echo "Error: $1 not found"
185 exit 1
187 eval CFLAGS$3="\"\$CFLAGS$3 \$PKG_CFLAGS\""
189 LDFLAGS="$LDFLAGS `pkg-config --libs $2`"
192 [ "$CFLAGS" = "" ] && CFLAGS="-O"
193 CFLAGS="$CFLAGS -DAPP_NAME=\\\"$APP_NAME\\\" \
194 -DAPP_VERSION=\\\"$APP_VERSION\\\" \
195 -I$PREFIX/include -I$PREFIX/include/ncursesw \
196 -I$PREFIX/include/ncurses -DCURSES_HEADER=\\<$CFG_CURSES_HEADER.h\\>"
197 if [ $? -ne 0 ]
198 then
199 echo "Error: Glib not found"
200 exit 1
202 CFLAGS_main="-DAUDIO_OUTPUT=\\\"$CFG_AO\\\" -DCONFFILE=\\\"$CONFFILE\\\""
203 LDFLAGS="$LDFLAGS -L$PREFIX/lib -l$CFG_CURSES_LIB"
204 SRCS="audio_file audio_output_$CFG_AO config gui_browser gui_draw \
205 gui_input gui_msgbar gui_playq gui_vfslist main playq playq_party \
206 playq_xmms vfs vfs_playlist vfs_regular"
208 # We always use glib
209 test_pkgconfig "GLib" "glib-2.0" ""
210 test_pkgconfig "GLib threading library" "gthread-2.0" ""
212 # HTTP and Scrobbler code need cURL
213 if [ "$CFG_HTTP" != "" -o "$CFG_SCROBBLER" != "" ]
214 then
215 if [ "$CFG_HTTP" != "" ]
216 then
217 CFLAGS="$CFLAGS -DBUILD_HTTP"
218 SRCS="$SRCS vfs_http"
220 if [ "$CFG_SCROBBLER" != "" ]
221 then
222 CFLAGS="$CFLAGS -DBUILD_SCROBBLER"
223 SRCS="$SRCS md5 scrobbler util"
224 MANPARTS="$MANPARTS 05-scrobbler"
226 test_pkgconfig "cURL" "libcurl" ""
228 # Modplug support
229 if [ "$CFG_MODPLUG" != "" ]
230 then
231 CFLAGS="$CFLAGS -DBUILD_MODPLUG"
232 test_pkgconfig "libmodplug" "libmodplug" "_audio_format_modplug"
233 SRCS="$SRCS audio_format_modplug"
235 # MP3 support
236 if [ "$CFG_MP3" != "" ]
237 then
238 CFLAGS="$CFLAGS -DBUILD_MP3"
239 LDFLAGS="$LDFLAGS -lmad -lid3tag"
240 #test_pkgconfig "libmad" "mad" "_audio_format_mp3"
241 #test_pkgconfig "libid3tag" "id3tag" "_audio_format_mp3"
242 SRCS="$SRCS audio_format_mp3"
244 # res_init() usage
245 [ "$CFG_RES_INIT" != "" ] && CFLAGS="$CFLAGS -DBUILD_RES_INIT"
246 # setproctitle() usage
247 [ "$CFG_SETPROCTITLE" != "" ] && CFLAGS_gui_playq="-DBUILD_SETPROCTITLE"
248 # libsndfile support
249 if [ "$CFG_SNDFILE" != "" ]
250 then
251 CFLAGS="$CFLAGS -DBUILD_SNDFILE"
252 LDFLAGS="$LDFLAGS -lsndfile"
253 SRCS="$SRCS audio_format_sndfile"
255 # Strict compilation
256 [ "$CFG_STRICT" != "" ] && CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wsign-compare -Werror"
257 [ "$CFG_STRICT" != "" ] && CFLAGS="$CFLAGS -g -DBUILD_DEBUG"
258 # Translation support
259 # Remove all broken translations
260 unset CFG_LINGUAS
261 unset MOS
262 for i in `echo $LINGUAS | xargs -n 1 | sort | uniq`
264 for j in $APP_LINGUAS
266 if [ "$i" = "$j" ]
267 then
268 CFG_LINGUAS="$CFG_LINGUAS $i"
269 MOS="$MOS $i.mo"
270 continue 2
272 done
273 echo "Warning: unknown language: $i"
274 done
275 if [ "$CFG_LINGUAS" != "" ]
276 then
277 CFLAGS="$CFLAGS -DBUILD_NLS"
278 CFLAGS_main="$CFLAGS_main -DTRANSDIR=\\\"$TRANSDIR\\\""
280 # Ogg Vorbis support
281 if [ "$CFG_VORBIS" != "" ]
282 then
283 CFLAGS="$CFLAGS -DBUILD_VORBIS"
284 LDFLAGS="$LDFLAGS -lvorbisfile"
285 SRCS="$SRCS audio_format_vorbis"
287 # XSPF support
288 if [ "$CFG_XSPF" != "" ]
289 then
290 CFLAGS="$CFLAGS -DBUILD_XSPF"
291 LDFLAGS="$LDFLAGS -lspiff"
292 SRCS="$SRCS util vfs_xspf"
293 PLAYQ_DUMPFILE="autosave.xspf"
294 else
295 PLAYQ_DUMPFILE="autosave.pls"
297 CFLAGS_config="$CFLAGS_config -DPLAYQ_DUMPFILE=\\\"$PLAYQ_DUMPFILE\\\""
298 MANREGEX="$MANREGEX -e 's|%%PLAYQ_DUMPFILE%%|$PLAYQ_DUMPFILE|'"
300 # Audio output options
301 case $CFG_AO in
302 alsa)
303 CFG_VOLUME=yes
304 CFLAGS="$CFLAGS -DBUILD_ALSA"
305 LDFLAGS="$LDFLAGS -lasound"
306 MANPARTS="$MANPARTS 03-alsa"
309 CFLAGS="$CFLAGS -DBUILD_AO"
310 CFLAGS_main="$CFLAGS_main -DCLOSE_STDERR"
311 LDFLAGS="$LDFLAGS -lao"
312 MANPARTS="$MANPARTS 03-ao"
314 coreaudio)
315 CFG_VOLUME=yes
316 LDFLAGS="$LDFLAGS -framework CoreAudio"
318 oss)
319 case $OS in
320 NetBSD|OpenBSD)
321 CFLAGS="$CFLAGS -DOSS_HEADER=\\<soundcard.h\\>"
322 LDFLAGS="$LDFLAGS -lossaudio"
323 OSS_DEVICE="/dev/audio"
326 # The OSS-through-ALSA compat may generate noise
327 [ "$OS" = "Linux" ] && CFLAGS_main="$CFLAGS_main -DCLOSE_STDERR"
328 CFLAGS="$CFLAGS -DOSS_HEADER=\\<sys/soundcard.h\\>"
329 OSS_DEVICE="/dev/dsp"
331 esac
332 CFG_VOLUME=yes
333 CFLAGS="$CFLAGS -DBUILD_OSS -I$PREFIX/lib/oss/include"
334 CFLAGS_config="$CFLAGS_config -DOSS_DEVICE=\\\"$OSS_DEVICE\\\""
335 MANPARTS="$MANPARTS 03-oss"
336 MANREGEX="$MANREGEX -e 's|%%OSS_DEVICE%%|$OSS_DEVICE|'"
338 pulse)
339 CFLAGS="$CFLAGS -DBUILD_PULSE"
340 test_pkgconfig "PulseAudio" "libpulse-simple" "_audio_output_pulse"
342 esac
344 if [ "$CFG_VOLUME" != "" ]
345 then
346 CFLAGS="$CFLAGS -DBUILD_VOLUME"
347 MANPARTS="$MANPARTS 01-volume"
350 echo "Configuration:"
351 echo "- Installing $APP_NAME$CFG_BINEXT in $BINDIR"
352 echo "- Installing manual page in $MANDIR"
353 echo "- Using $CONFFILE configuration file"
354 [ "$CFG_LINGUAS" != "" ] && echo "- Installing translations$CFG_LINGUAS in $TRANSDIR"
355 echo "- Using -l$CFG_CURSES_LIB and <$CFG_CURSES_HEADER.h>"
356 echo "- Using $CFG_AO audio output"
357 [ "$CFG_HTTP" != "" ] && echo "- Support for HTTP streams"
358 [ "$CFG_MODPLUG" != "" ] && echo "- Support for libmodplug"
359 [ "$CFG_MP3" != "" ] && echo "- Support for MP3"
360 [ "$CFG_SCROBBLER" != "" ] && echo "- Support for AudioScrobbler"
361 [ "$CFG_SNDFILE" != "" ] && echo "- Support for libsndfile"
362 [ "$CFG_VORBIS" != "" ] && echo "- Support for Ogg Vorbis"
363 [ "$CFG_XSPF" != "" ] && echo "- Support for XSPF (\`Spiff')"
364 echo
366 # Perform a simple compiler test
367 eval $CC $SRCDIR/src/conftest.c $CFLAGS $LDFLAGS -o conftest$CFG_BINEXT
368 if [ $? -ne 0 ]
369 then
370 echo "Error: some dependencies are missing"
371 echo "See the README file for a list of dependencies"
372 exit 1
374 rm conftest$CFG_BINEXT
376 # Don't generate duplicate rules
377 SRCS=`echo $SRCS | xargs -n 1 | sort | uniq`
379 unset OBJS
380 for i in $SRCS
382 OBJS="$OBJS $i.o"
383 done
384 unset MANFILES
385 for i in `echo $MANPARTS | xargs -n 1 | sort | uniq`
387 MANFILES="$MANFILES $SRCDIR/man/$i"
388 done
390 (cat << EOF
391 all: $APP_NAME$CFG_BINEXT $APP_NAME.1.gz $SRCDIR/$APP_NAME.conf.sample $MOS
392 $APP_NAME$CFG_BINEXT: $OBJS
393 # Linking $APP_NAME$CFG_BINEXT
394 $DOIT$CC $OBJS $LDFLAGS -o $APP_NAME$CFG_BINEXT
395 $APP_NAME.1.gz: $MANFILES Makefile
396 # Generating manual page $APP_NAME.1.gz
397 ${DOIT}sed $MANREGEX $MANFILES | gzip -9 > $APP_NAME.1.gz
398 clean:
399 # Removing $APP_NAME$CFG_BINEXT $APP_NAME.1.gz *.dSYM *.mo *.o
400 ${DOIT}rm -f $APP_NAME$CFG_BINEXT $APP_NAME.1.gz *.mo *.o
401 ${DOIT}rm -Rf *.dSYM
402 distclean: clean
403 # Removing Makefile
404 ${DOIT}rm -f Makefile
405 Makefile: $0 `dirname $0`/depends
406 # WARNING: Your Makefile is outdated. Please re-run $0!
407 install: all
408 # Installing \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
409 ${DOIT}mkdir -p \$(DESTDIR)$BINDIR
410 $DOIT$INSTALL $CFG_STRIP $APP_NAME$CFG_BINEXT \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
411 # Installing \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
412 ${DOIT}mkdir -p \$(DESTDIR)$MANDIR/man1
413 $DOIT$INSTALL -m 444 $APP_NAME.1.gz \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
414 # Installing \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
415 ${DOIT}mkdir -p \$(DESTDIR)$CONFDIR
416 $DOIT$INSTALL -m 444 $SRCDIR/$APP_NAME.conf.sample \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
418 for i in $CFG_LINGUAS
420 echo " # Installing \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
421 echo " ${DOIT}mkdir -p \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES"
422 echo " $DOIT$INSTALL -m 444 $i.mo \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
423 done
424 cat << EOF
425 uninstall:
426 # Uninstalling \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
427 ${DOIT}rm -f \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
428 # Uninstalling \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
429 ${DOIT}rm -f \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
430 # Uninstalling \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
431 ${DOIT}rm -f \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
433 for i in $CFG_LINGUAS
435 echo " # Uninstalling \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
436 echo " ${DOIT}rm -f \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
437 done
438 . $SRCDIR/depends
439 for i in $SRCS
441 unset DEPS
442 for j in `eval echo \\\$DEPENDS_\$i`
444 DEPS="$DEPS $SRCDIR/src/$j.h"
445 done
446 echo "$i.o: Makefile $SRCDIR/src/$i.c $SRCDIR/src/stdinc.h $DEPS"
447 echo " # Compiling $i.o"
448 echo " $DOIT$CC -c $SRCDIR/src/$i.c $CFLAGS `eval echo \\\$CFLAGS_\$i` -o $i.o"
449 done
450 for i in $CFG_LINGUAS
452 echo "$i.mo: $SRCDIR/po/$i.po"
453 echo " # Generating translation $i.mo"
454 echo " ${DOIT}msgfmt -o $i.mo $SRCDIR/po/$i.po"
455 done) > Makefile
457 echo "Run \`make' to compile $APP_NAME"