Bump Herrie's version.
[herrie-working.git] / herrie / configure
blobf7b974128c3cec2604ead08b063f5817cf09d833
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.0
30 APP_LINGUAS='ca da de es fi ga nl pl pt_BR ru sv tr 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 CFLAGS="$CFLAGS -DBUILD_ALSA"
304 LDFLAGS="$LDFLAGS -lasound"
305 MANPARTS="$MANPARTS 03-alsa"
308 CFLAGS="$CFLAGS -DBUILD_AO"
309 CFLAGS_main="$CFLAGS_main -DCLOSE_STDERR"
310 LDFLAGS="$LDFLAGS -lao"
311 MANPARTS="$MANPARTS 03-ao"
313 coreaudio)
314 CFG_VOLUME=yes
315 LDFLAGS="$LDFLAGS -framework CoreAudio"
317 oss)
318 case $OS in
319 NetBSD|OpenBSD)
320 CFLAGS="$CFLAGS -DOSS_HEADER=\\<soundcard.h\\>"
321 LDFLAGS="$LDFLAGS -lossaudio"
322 OSS_DEVICE="/dev/audio"
325 # The OSS-through-ALSA compat may generate noise
326 [ "$OS" = "Linux" ] && CFLAGS_main="$CFLAGS_main -DCLOSE_STDERR"
327 CFLAGS="$CFLAGS -DOSS_HEADER=\\<sys/soundcard.h\\>"
328 OSS_DEVICE="/dev/dsp"
330 esac
331 CFG_VOLUME=yes
332 CFLAGS="$CFLAGS -DBUILD_OSS"
333 CFLAGS_config="$CFLAGS_config -DOSS_DEVICE=\\\"$OSS_DEVICE\\\""
334 MANPARTS="$MANPARTS 03-oss"
335 MANREGEX="$MANREGEX -e 's|%%OSS_DEVICE%%|$OSS_DEVICE|'"
337 pulse)
338 CFLAGS="$CFLAGS -DBUILD_PULSE"
339 test_pkgconfig "PulseAudio" "libpulse-simple" "_audio_output_pulse"
341 esac
343 if [ "$CFG_VOLUME" != "" ]
344 then
345 CFLAGS="$CFLAGS -DBUILD_VOLUME"
346 MANPARTS="$MANPARTS 01-volume"
349 echo "Configuration:"
350 echo "- Installing $APP_NAME$CFG_BINEXT in $BINDIR"
351 echo "- Installing manual page in $MANDIR"
352 echo "- Using $CONFFILE configuration file"
353 [ "$CFG_LINGUAS" != "" ] && echo "- Installing translations$CFG_LINGUAS in $TRANSDIR"
354 echo "- Using -l$CFG_CURSES_LIB and <$CFG_CURSES_HEADER.h>"
355 echo "- Using $CFG_AO audio output"
356 [ "$CFG_HTTP" != "" ] && echo "- Support for HTTP streams"
357 [ "$CFG_MODPLUG" != "" ] && echo "- Support for libmodplug"
358 [ "$CFG_MP3" != "" ] && echo "- Support for MP3"
359 [ "$CFG_SCROBBLER" != "" ] && echo "- Support for AudioScrobbler"
360 [ "$CFG_SNDFILE" != "" ] && echo "- Support for libsndfile"
361 [ "$CFG_VORBIS" != "" ] && echo "- Support for Ogg Vorbis"
362 [ "$CFG_XSPF" != "" ] && echo "- Support for XSPF (\`Spiff')"
363 echo
365 # Perform a simple compiler test
366 eval $CC $SRCDIR/src/conftest.c $CFLAGS $LDFLAGS -o conftest$CFG_BINEXT
367 if [ $? -ne 0 ]
368 then
369 echo "Error: some dependencies are missing"
370 echo "See the README file for a list of dependencies"
371 exit 1
373 rm conftest$CFG_BINEXT
375 # Don't generate duplicate rules
376 SRCS=`echo $SRCS | xargs -n 1 | sort | uniq`
378 unset OBJS
379 for i in $SRCS
381 OBJS="$OBJS $i.o"
382 done
383 unset MANFILES
384 for i in `echo $MANPARTS | xargs -n 1 | sort | uniq`
386 MANFILES="$MANFILES $SRCDIR/man/$i"
387 done
389 (cat << EOF
390 all: $APP_NAME$CFG_BINEXT $APP_NAME.1.gz $SRCDIR/$APP_NAME.conf.sample $MOS
391 $APP_NAME$CFG_BINEXT: $OBJS
392 # Linking $APP_NAME$CFG_BINEXT
393 $DOIT$CC $OBJS $LDFLAGS -o $APP_NAME$CFG_BINEXT
394 $APP_NAME.1.gz: $MANFILES Makefile
395 # Generating manual page $APP_NAME.1.gz
396 ${DOIT}sed $MANREGEX $MANFILES | gzip -9 > $APP_NAME.1.gz
397 clean:
398 # Removing $APP_NAME$CFG_BINEXT $APP_NAME.1.gz *.dSYM *.mo *.o
399 ${DOIT}rm -f $APP_NAME$CFG_BINEXT $APP_NAME.1.gz *.mo *.o
400 ${DOIT}rm -Rf *.dSYM
401 distclean: clean
402 # Removing Makefile
403 ${DOIT}rm -f Makefile
404 Makefile: $0 `dirname $0`/depends
405 # WARNING: Your Makefile is outdated. Please re-run $0!
406 install: all
407 # Installing \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
408 ${DOIT}mkdir -p \$(DESTDIR)$BINDIR
409 $DOIT$INSTALL $CFG_STRIP $APP_NAME$CFG_BINEXT \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
410 # Installing \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
411 ${DOIT}mkdir -p \$(DESTDIR)$MANDIR/man1
412 $DOIT$INSTALL -m 444 $APP_NAME.1.gz \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
413 # Installing \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
414 ${DOIT}mkdir -p \$(DESTDIR)$CONFDIR
415 $DOIT$INSTALL -m 444 $SRCDIR/$APP_NAME.conf.sample \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
417 for i in $CFG_LINGUAS
419 echo " # Installing \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
420 echo " ${DOIT}mkdir -p \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES"
421 echo " $DOIT$INSTALL -m 444 $i.mo \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
422 done
423 cat << EOF
424 uninstall:
425 # Uninstalling \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
426 ${DOIT}rm -f \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
427 # Uninstalling \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
428 ${DOIT}rm -f \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
429 # Uninstalling \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
430 ${DOIT}rm -f \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
432 for i in $CFG_LINGUAS
434 echo " # Uninstalling \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
435 echo " ${DOIT}rm -f \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
436 done
437 . $SRCDIR/depends
438 for i in $SRCS
440 unset DEPS
441 for j in `eval echo \\\$DEPENDS_\$i`
443 DEPS="$DEPS $SRCDIR/src/$j.h"
444 done
445 echo "$i.o: Makefile $SRCDIR/src/$i.c $SRCDIR/src/stdinc.h $DEPS"
446 echo " # Compiling $i.o"
447 echo " $DOIT$CC -c $SRCDIR/src/$i.c $CFLAGS `eval echo \\\$CFLAGS_\$i` -o $i.o"
448 done
449 for i in $CFG_LINGUAS
451 echo "$i.mo: $SRCDIR/po/$i.po"
452 echo " # Generating translation $i.mo"
453 echo " ${DOIT}msgfmt -o $i.mo $SRCDIR/po/$i.po"
454 done) > Makefile
456 echo "Run \`make' to compile $APP_NAME"