Add a Danish translation as well.
[herrie-working.git] / herrie / configure
blob0ad11c483ce0fd9207542847b15e7368bd168d9f
1 #!/bin/sh
2 #
3 # Copyright (c) 2006-2008 Ed Schouten <ed@fxq.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=1.9.1
30 APP_LINGUAS='ca da de es fi ga nl pl ru sv tr vi'
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 Linux)
73 CFG_AO=alsa
74 [ "$CONFDIR" = "" ] && CONFDIR=/etc
75 [ "$PREFIX" = "" ] && PREFIX=/usr
77 NetBSD)
78 CFG_SETPROCTITLE=yes
79 [ "$PREFIX" = "" ] && PREFIX=/usr/pkg
81 OpenBSD)
82 CFG_SETPROCTITLE=yes
83 [ "$PREFIX" = "" ] && PREFIX=/usr/local
84 [ "$MANDIR" = "" ] && MANDIR=$PREFIX/man
86 SunOS)
87 CFG_AO=ao
88 unset CFG_HTTP
89 [ "$PREFIX" = "" ] && PREFIX=/opt/sfw
90 LDFLAGS="$LDFLAGS -lresolv"
91 [ "$INSTALL" = "" ] && INSTALL=ginstall
94 echo "Warning: unknown operating system"
95 CFG_AO=ao
96 [ "$PREFIX" = "" ] && PREFIX=/usr/local
97 esac
98 SRCDIR=`dirname $0`
99 BINDIR=$PREFIX/bin
100 [ "$CONFDIR" = "" ] && CONFDIR=$PREFIX/etc
101 CONFFILE=$CONFDIR/$APP_NAME.conf
102 [ "$LINGUAS" = "" ] && LINGUAS=$APP_LINGUAS
103 [ "$MANDIR" = "" ] && MANDIR=$PREFIX/share/man
104 TRANSDIR=$PREFIX/share/locale
105 [ "$CC" = "" ] && CC=cc
106 [ "$INSTALL" = "" ] && INSTALL=install
107 MANPARTS="00-man 02-man 04-man 06-man"
108 MANREGEX="-e 's|%%CONFFILE%%|$CONFFILE|'"
110 # Command line options
111 while [ $# -gt 0 ]
113 case $1 in
114 no_http)
115 unset CFG_HTTP
117 no_modplug)
118 unset CFG_MODPLUG
120 no_mp3)
121 unset CFG_MP3
123 no_scrobbler)
124 unset CFG_SCROBBLER
126 no_sndfile)
127 unset CFG_SNDFILE
129 no_nls)
130 unset LINGUAS
132 no_vorbis)
133 unset CFG_VORBIS
135 no_xspf)
136 unset CFG_XSPF
139 alsa|ao|coreaudio|null|oss|pulse)
140 CFG_AO=$1
143 no_strip)
144 unset CFG_STRIP
146 debug)
147 CFG_DEBUG=yes
148 unset CFG_STRIP
150 strict)
151 CFG_STRICT=yes
153 verbose)
154 unset DOIT
157 ncurses)
158 CFG_CURSES_HEADER=ncurses
159 CFG_CURSES_LIB=ncurses
161 xcurses)
162 CFG_CURSES_HEADER=xcurses
163 CFG_CURSES_LIB=XCurses
167 echo "Error: unknown option: $1"
168 echo "See the README file for a list of valid options"
169 exit 1
170 esac
172 shift
173 done
175 test_pkgconfig()
177 PKG_CFLAGS="`pkg-config --cflags $2 2> /dev/null`"
178 if [ $? -ne 0 ]
179 then
180 echo "Error: $1 not found"
181 exit 1
183 eval CFLAGS$3="\"\$CFLAGS$3 \$PKG_CFLAGS\""
185 LDFLAGS="$LDFLAGS `pkg-config --libs $2`"
188 [ "$CFLAGS" = "" ] && CFLAGS="-O"
189 CFLAGS="$CFLAGS -DAPP_NAME=\\\"$APP_NAME\\\" \
190 -DAPP_VERSION=\\\"$APP_VERSION\\\" \
191 -I$PREFIX/include -I$PREFIX/include/ncursesw \
192 -I$PREFIX/include/ncurses -DCURSES_HEADER=\\<$CFG_CURSES_HEADER.h\\>"
193 if [ $? -ne 0 ]
194 then
195 echo "Error: Glib not found"
196 exit 1
198 CFLAGS_main="-DAUDIO_OUTPUT=\\\"$CFG_AO\\\" -DCONFFILE=\\\"$CONFFILE\\\""
199 LDFLAGS="$LDFLAGS -L$PREFIX/lib -l$CFG_CURSES_LIB"
200 SRCS="audio_file audio_output_$CFG_AO config gui_browser gui_draw \
201 gui_input gui_msgbar gui_playq gui_vfslist main playq playq_party \
202 playq_xmms vfs vfs_playlist vfs_regular"
204 # We always use glib
205 test_pkgconfig "GLib" "glib-2.0" ""
206 test_pkgconfig "GLib threading library" "gthread-2.0" ""
208 # HTTP and Scrobbler code need cURL
209 if [ "$CFG_HTTP" != "" -o "$CFG_SCROBBLER" != "" ]
210 then
211 if [ "$CFG_HTTP" != "" ]
212 then
213 CFLAGS="$CFLAGS -DBUILD_HTTP"
214 SRCS="$SRCS vfs_http"
216 if [ "$CFG_SCROBBLER" != "" ]
217 then
218 CFLAGS="$CFLAGS -DBUILD_SCROBBLER"
219 SRCS="$SRCS md5 scrobbler util"
220 MANPARTS="$MANPARTS 05-scrobbler"
222 test_pkgconfig "cURL" "libcurl" ""
224 # Modplug support
225 if [ "$CFG_MODPLUG" != "" ]
226 then
227 CFLAGS="$CFLAGS -DBUILD_MODPLUG"
228 test_pkgconfig "libmodplug" "libmodplug" "_audio_format_modplug"
229 SRCS="$SRCS audio_format_modplug"
231 # MP3 support
232 if [ "$CFG_MP3" != "" ]
233 then
234 CFLAGS="$CFLAGS -DBUILD_MP3"
235 LDFLAGS="$LDFLAGS -lmad -lid3tag"
236 #test_pkgconfig "libmad" "mad" "_audio_format_mp3"
237 #test_pkgconfig "libid3tag" "id3tag" "_audio_format_mp3"
238 SRCS="$SRCS audio_format_mp3"
240 # res_init() usage
241 [ "$CFG_RES_INIT" != "" ] && CFLAGS="$CFLAGS -DBUILD_RES_INIT"
242 # setproctitle() usage
243 [ "$CFG_SETPROCTITLE" != "" ] && CFLAGS_gui_playq="-DBUILD_SETPROCTITLE"
244 # libsndfile support
245 if [ "$CFG_SNDFILE" != "" ]
246 then
247 CFLAGS="$CFLAGS -DBUILD_SNDFILE"
248 LDFLAGS="$LDFLAGS -lsndfile"
249 SRCS="$SRCS audio_format_sndfile"
251 # Strict compilation
252 [ "$CFG_STRICT" != "" ] && CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wsign-compare -Werror"
253 [ "$CFG_STRICT" != "" ] && CFLAGS="$CFLAGS -g -DBUILD_DEBUG"
254 # Translation support
255 # Remove all broken translations
256 unset CFG_LINGUAS
257 unset MOS
258 for i in `echo $LINGUAS | xargs -n 1 | sort | uniq`
260 for j in $APP_LINGUAS
262 if [ "$i" = "$j" ]
263 then
264 CFG_LINGUAS="$CFG_LINGUAS $i"
265 MOS="$MOS $i.mo"
266 continue 2
268 done
269 echo "Warning: unknown language: $i"
270 done
271 if [ "$CFG_LINGUAS" != "" ]
272 then
273 CFLAGS="$CFLAGS -DBUILD_NLS"
274 CFLAGS_main="$CFLAGS_main -DTRANSDIR=\\\"$TRANSDIR\\\""
276 # Ogg Vorbis support
277 if [ "$CFG_VORBIS" != "" ]
278 then
279 CFLAGS="$CFLAGS -DBUILD_VORBIS"
280 LDFLAGS="$LDFLAGS -lvorbisfile"
281 SRCS="$SRCS audio_format_vorbis"
283 # XSPF support
284 if [ "$CFG_XSPF" != "" ]
285 then
286 CFLAGS="$CFLAGS -DBUILD_XSPF"
287 LDFLAGS="$LDFLAGS -lspiff"
288 SRCS="$SRCS util vfs_xspf"
289 PLAYQ_DUMPFILE="autosave.xspf"
290 else
291 PLAYQ_DUMPFILE="autosave.pls"
293 CFLAGS_config="$CFLAGS_config -DPLAYQ_DUMPFILE=\\\"$PLAYQ_DUMPFILE\\\""
294 MANREGEX="$MANREGEX -e 's|%%PLAYQ_DUMPFILE%%|$PLAYQ_DUMPFILE|'"
296 # Audio output options
297 case $CFG_AO in
298 alsa)
299 CFLAGS="$CFLAGS -DBUILD_ALSA"
300 LDFLAGS="$LDFLAGS -lasound"
301 MANPARTS="$MANPARTS 03-alsa"
304 CFLAGS="$CFLAGS -DBUILD_AO"
305 CFLAGS_main="$CFLAGS_main -DCLOSE_STDERR"
306 LDFLAGS="$LDFLAGS -lao"
307 MANPARTS="$MANPARTS 03-ao"
309 coreaudio)
310 CFG_VOLUME=yes
311 LDFLAGS="$LDFLAGS -framework CoreAudio"
313 oss)
314 case $OS in
315 NetBSD|OpenBSD)
316 CFLAGS="$CFLAGS -DOSS_HEADER=\\<soundcard.h\\>"
317 LDFLAGS="$LDFLAGS -lossaudio"
318 OSS_DEVICE="/dev/audio"
321 # The OSS-through-ALSA compat may generate noise
322 [ "$OS" = "Linux" ] && CFLAGS_main="$CFLAGS_main -DCLOSE_STDERR"
323 CFLAGS="$CFLAGS -DOSS_HEADER=\\<sys/soundcard.h\\>"
324 OSS_DEVICE="/dev/dsp"
326 esac
327 CFG_VOLUME=yes
328 CFLAGS="$CFLAGS -DBUILD_OSS"
329 CFLAGS_config="$CFLAGS_config -DOSS_DEVICE=\\\"$OSS_DEVICE\\\""
330 MANPARTS="$MANPARTS 03-oss"
331 MANREGEX="$MANREGEX -e 's|%%OSS_DEVICE%%|$OSS_DEVICE|'"
333 pulse)
334 CFLAGS="$CFLAGS -DBUILD_PULSE"
335 test_pkgconfig "PulseAudio" "libpulse-simple" "_audio_output_pulse"
337 esac
339 if [ "$CFG_VOLUME" != "" ]
340 then
341 CFLAGS="$CFLAGS -DBUILD_VOLUME"
342 MANPARTS="$MANPARTS 01-volume"
345 echo "Configuration:"
346 echo "- Installing $APP_NAME$CFG_BINEXT in $BINDIR"
347 echo "- Installing manual page in $MANDIR"
348 echo "- Using $CONFFILE configuration file"
349 [ "$CFG_LINGUAS" != "" ] && echo "- Installing translations$CFG_LINGUAS in $TRANSDIR"
350 echo "- Using -l$CFG_CURSES_LIB and <$CFG_CURSES_HEADER.h>"
351 echo "- Using $CFG_AO audio output"
352 [ "$CFG_HTTP" != "" ] && echo "- Support for HTTP streams"
353 [ "$CFG_MODPLUG" != "" ] && echo "- Support for libmodplug"
354 [ "$CFG_MP3" != "" ] && echo "- Support for MP3"
355 [ "$CFG_SCROBBLER" != "" ] && echo "- Support for AudioScrobbler"
356 [ "$CFG_SNDFILE" != "" ] && echo "- Support for libsndfile"
357 [ "$CFG_VORBIS" != "" ] && echo "- Support for Ogg Vorbis"
358 [ "$CFG_XSPF" != "" ] && echo "- Support for XSPF (\`Spiff')"
359 echo
361 # Perform a simple compiler test
362 eval $CC $SRCDIR/src/conftest.c $CFLAGS $LDFLAGS -o conftest$CFG_BINEXT
363 if [ $? -ne 0 ]
364 then
365 echo "Error: some dependencies are missing"
366 echo "See the README file for a list of dependencies"
367 exit 1
369 rm conftest$CFG_BINEXT
371 # Don't generate duplicate rules
372 SRCS=`echo $SRCS | xargs -n 1 | sort | uniq`
374 unset OBJS
375 for i in $SRCS
377 OBJS="$OBJS $i.o"
378 done
379 unset MANFILES
380 for i in `echo $MANPARTS | xargs -n 1 | sort | uniq`
382 MANFILES="$MANFILES $SRCDIR/man/$i"
383 done
385 (cat << EOF
386 all: $APP_NAME$CFG_BINEXT $APP_NAME.1.gz $SRCDIR/$APP_NAME.conf.sample $MOS
387 $APP_NAME$CFG_BINEXT: $OBJS
388 # Linking $APP_NAME$CFG_BINEXT
389 $DOIT$CC $OBJS $LDFLAGS -o $APP_NAME$CFG_BINEXT
390 $APP_NAME.1.gz: $MANFILES Makefile
391 # Generating manual page $APP_NAME.1.gz
392 ${DOIT}sed $MANREGEX $MANFILES | gzip -9 > $APP_NAME.1.gz
393 clean:
394 # Removing $APP_NAME$CFG_BINEXT $APP_NAME.1.gz *.mo *.o
395 ${DOIT}rm -f $APP_NAME$CFG_BINEXT $APP_NAME.1.gz *.mo *.o
396 distclean: clean
397 # Removing Makefile
398 ${DOIT}rm -f Makefile
399 Makefile: $0 `dirname $0`/depends
400 # WARNING: Your Makefile is outdated. Please re-run $0!
401 install: all
402 # Installing \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
403 ${DOIT}mkdir -p \$(DESTDIR)$BINDIR
404 $DOIT$INSTALL $CFG_STRIP $APP_NAME$CFG_BINEXT \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
405 # Installing \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
406 ${DOIT}mkdir -p \$(DESTDIR)$MANDIR/man1
407 $DOIT$INSTALL -m 444 $APP_NAME.1.gz \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
408 # Installing \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
409 ${DOIT}mkdir -p \$(DESTDIR)$CONFDIR
410 $DOIT$INSTALL -m 444 $SRCDIR/$APP_NAME.conf.sample \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
412 for i in $CFG_LINGUAS
414 echo " # Installing \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
415 echo " ${DOIT}mkdir -p \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES"
416 echo " $DOIT$INSTALL -m 444 $i.mo \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
417 done
418 cat << EOF
419 uninstall:
420 # Uninstalling \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
421 ${DOIT}rm -f \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
422 # Uninstalling \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
423 ${DOIT}rm -f \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
424 # Uninstalling \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
425 ${DOIT}rm -f \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
427 for i in $CFG_LINGUAS
429 echo " # Uninstalling \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
430 echo " ${DOIT}rm -f \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
431 done
432 . $SRCDIR/depends
433 for i in $SRCS
435 unset DEPS
436 for j in `eval echo \\\$DEPENDS_\$i`
438 DEPS="$DEPS $SRCDIR/src/$j.h"
439 done
440 echo "$i.o: Makefile $SRCDIR/src/$i.c $SRCDIR/src/stdinc.h $DEPS"
441 echo " # Compiling $i.o"
442 echo " $DOIT$CC -c $SRCDIR/src/$i.c $CFLAGS `eval echo \\\$CFLAGS_\$i` -o $i.o"
443 done
444 for i in $CFG_LINGUAS
446 echo "$i.mo: $SRCDIR/po/$i.po"
447 echo " # Generating translation $i.mo"
448 echo " ${DOIT}msgfmt -o $i.mo $SRCDIR/po/$i.po"
449 done) > Makefile
451 echo "Run \`make' to compile $APP_NAME"