3 # Copyright (c) 2006-2008 Ed Schouten <ed@fxq.nl>
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
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
30 APP_LINGUAS
='ca da de es fi ga nl pl ru sv tr vi'
32 # Default compilation switches
35 CFG_CURSES_HEADER
=ncurses
36 CFG_CURSES_LIB
=ncursesw
42 unset CFG_SETPROCTITLE
52 # Operating system defaults
53 [ "$OS" != "" ] || OS
=`uname`
59 [ "$CONFDIR" = "" ] && CONFDIR
=/etc
60 [ "$PREFIX" = "" ] && PREFIX
=/usr
64 LDFLAGS
="$LDFLAGS -lresolv"
65 [ "$PREFIX" = "" ] && PREFIX
=/opt
/local
69 [ "$PREFIX" = "" ] && PREFIX
=/usr
/local
70 [ "$MANDIR" = "" ] && MANDIR
=$PREFIX/man
74 [ "$CONFDIR" = "" ] && CONFDIR
=/etc
75 [ "$PREFIX" = "" ] && PREFIX
=/usr
79 [ "$PREFIX" = "" ] && PREFIX
=/usr
/pkg
83 [ "$PREFIX" = "" ] && PREFIX
=/usr
/local
84 [ "$MANDIR" = "" ] && MANDIR
=$PREFIX/man
89 [ "$PREFIX" = "" ] && PREFIX
=/opt
/sfw
90 LDFLAGS
="$LDFLAGS -lresolv"
91 [ "$INSTALL" = "" ] && INSTALL
=ginstall
94 echo "Warning: unknown operating system"
96 [ "$PREFIX" = "" ] && PREFIX
=/usr
/local
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
139 alsa|ao|coreaudio|null|oss|pulse
)
158 CFG_CURSES_HEADER
=ncurses
159 CFG_CURSES_LIB
=ncurses
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"
177 PKG_CFLAGS
="`pkg-config --cflags $2 2> /dev/null`"
180 echo "Error: $1 not found"
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\\>"
195 echo "Error: Glib not found"
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"
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" != "" ]
211 if [ "$CFG_HTTP" != "" ]
213 CFLAGS
="$CFLAGS -DBUILD_HTTP"
214 SRCS
="$SRCS vfs_http"
216 if [ "$CFG_SCROBBLER" != "" ]
218 CFLAGS
="$CFLAGS -DBUILD_SCROBBLER"
219 SRCS
="$SRCS md5 scrobbler util"
220 MANPARTS
="$MANPARTS 05-scrobbler"
222 test_pkgconfig
"cURL" "libcurl" ""
225 if [ "$CFG_MODPLUG" != "" ]
227 CFLAGS
="$CFLAGS -DBUILD_MODPLUG"
228 test_pkgconfig
"libmodplug" "libmodplug" "_audio_format_modplug"
229 SRCS
="$SRCS audio_format_modplug"
232 if [ "$CFG_MP3" != "" ]
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"
241 [ "$CFG_RES_INIT" != "" ] && CFLAGS
="$CFLAGS -DBUILD_RES_INIT"
242 # setproctitle() usage
243 [ "$CFG_SETPROCTITLE" != "" ] && CFLAGS_gui_playq
="-DBUILD_SETPROCTITLE"
245 if [ "$CFG_SNDFILE" != "" ]
247 CFLAGS
="$CFLAGS -DBUILD_SNDFILE"
248 LDFLAGS
="$LDFLAGS -lsndfile"
249 SRCS
="$SRCS audio_format_sndfile"
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
258 for i
in `echo $LINGUAS | xargs -n 1 | sort | uniq`
260 for j
in $APP_LINGUAS
264 CFG_LINGUAS
="$CFG_LINGUAS $i"
269 echo "Warning: unknown language: $i"
271 if [ "$CFG_LINGUAS" != "" ]
273 CFLAGS
="$CFLAGS -DBUILD_NLS"
274 CFLAGS_main
="$CFLAGS_main -DTRANSDIR=\\\"$TRANSDIR\\\""
277 if [ "$CFG_VORBIS" != "" ]
279 CFLAGS
="$CFLAGS -DBUILD_VORBIS"
280 LDFLAGS
="$LDFLAGS -lvorbisfile"
281 SRCS
="$SRCS audio_format_vorbis"
284 if [ "$CFG_XSPF" != "" ]
286 CFLAGS
="$CFLAGS -DBUILD_XSPF"
287 LDFLAGS
="$LDFLAGS -lspiff"
288 SRCS
="$SRCS util vfs_xspf"
289 PLAYQ_DUMPFILE
="autosave.xspf"
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
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"
311 LDFLAGS
="$LDFLAGS -framework CoreAudio"
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"
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|'"
334 CFLAGS
="$CFLAGS -DBUILD_PULSE"
335 test_pkgconfig
"PulseAudio" "libpulse-simple" "_audio_output_pulse"
339 if [ "$CFG_VOLUME" != "" ]
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')"
361 # Perform a simple compiler test
362 eval $CC $SRCDIR/src
/conftest.c
$CFLAGS $LDFLAGS -o conftest
$CFG_BINEXT
365 echo "Error: some dependencies are missing"
366 echo "See the README file for a list of dependencies"
369 rm conftest
$CFG_BINEXT
371 # Don't generate duplicate rules
372 SRCS
=`echo $SRCS | xargs -n 1 | sort | uniq`
380 for i
in `echo $MANPARTS | xargs -n 1 | sort | uniq`
382 MANFILES
="$MANFILES $SRCDIR/man/$i"
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
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
398 ${DOIT}rm -f Makefile
399 Makefile: $0 `dirname $0`/depends
400 # WARNING: Your Makefile is outdated. Please re-run $0!
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"
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"
436 for j
in `eval echo \\\$DEPENDS_\$i`
438 DEPS
="$DEPS $SRCDIR/src/$j.h"
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"
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"
451 echo "Run \`make' to compile $APP_NAME"