3 # Copyright (c) 2006-2008 Ed Schouten <ed@80386.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 pt_BR ru sv tr uk vi zh_CN'
32 # Default compilation switches
35 CFG_CURSES_HEADER
=ncurses
36 CFG_CURSES_LIB
=ncursesw
43 unset CFG_SETPROCTITLE
53 # Operating system defaults
54 [ "$OS" != "" ] || OS
=`uname`
60 [ "$CONFDIR" = "" ] && CONFDIR
=/etc
61 [ "$PREFIX" = "" ] && PREFIX
=/usr
65 LDFLAGS
="$LDFLAGS -lresolv"
66 [ "$PREFIX" = "" ] && PREFIX
=/opt
/local
70 [ "$PREFIX" = "" ] && PREFIX
=/usr
/local
71 [ "$MANDIR" = "" ] && MANDIR
=$PREFIX/man
74 [ "$CONFDIR" = "" ] && CONFDIR
=/etc
75 [ "$PREFIX" = "" ] && PREFIX
=/usr
79 [ "$CONFDIR" = "" ] && CONFDIR
=/etc
80 [ "$PREFIX" = "" ] && PREFIX
=/usr
84 [ "$PREFIX" = "" ] && PREFIX
=/usr
/pkg
88 [ "$PREFIX" = "" ] && PREFIX
=/usr
/local
89 [ "$MANDIR" = "" ] && MANDIR
=$PREFIX/man
94 [ "$PREFIX" = "" ] && PREFIX
=/opt
/sfw
95 LDFLAGS
="$LDFLAGS -lresolv"
96 [ "$INSTALL" = "" ] && INSTALL
=ginstall
99 echo "Warning: unknown operating system: $OS"
101 [ "$PREFIX" = "" ] && PREFIX
=/usr
/local
105 [ "$CONFDIR" = "" ] && CONFDIR
=$PREFIX/etc
106 CONFFILE
=$CONFDIR/$APP_NAME.conf
107 [ "$LINGUAS" = "" ] && LINGUAS
=$APP_LINGUAS
108 [ "$MANDIR" = "" ] && MANDIR
=$PREFIX/share
/man
109 TRANSDIR
=$PREFIX/share
/locale
110 [ "$CC" = "" ] && CC
=cc
111 [ "$INSTALL" = "" ] && INSTALL
=install
112 MANPARTS
="00-man 02-man 04-man 06-man"
113 MANREGEX
="-e 's|%%CONFFILE%%|$CONFFILE|'"
115 # Command line options
147 alsa|ao|coreaudio|null|oss|pulse
)
166 CFG_CURSES_HEADER
=ncurses
167 CFG_CURSES_LIB
=ncurses
170 CFG_CURSES_HEADER
=xcurses
171 CFG_CURSES_LIB
=XCurses
175 echo "Error: unknown option: $1"
176 echo "See the README file for a list of valid options"
185 PKG_CFLAGS
="`pkg-config --cflags $2 2> /dev/null`"
188 echo "Error: $1 not found"
191 eval CFLAGS
$3="\"\$CFLAGS$3 \$PKG_CFLAGS\""
193 LDFLAGS
="$LDFLAGS `pkg-config --libs $2`"
196 [ "$CFLAGS" = "" ] && CFLAGS
="-O"
197 CFLAGS
="$CFLAGS -DAPP_NAME=\\\"$APP_NAME\\\" \
198 -DAPP_VERSION=\\\"$APP_VERSION\\\" \
199 -I$PREFIX/include -I$PREFIX/include/ncursesw \
200 -I$PREFIX/include/ncurses -DCURSES_HEADER=\\<$CFG_CURSES_HEADER.h\\>"
203 echo "Error: Glib not found"
206 CFLAGS_main
="-DAUDIO_OUTPUT=\\\"$CFG_AO\\\" -DCONFFILE=\\\"$CONFFILE\\\""
207 LDFLAGS
="$LDFLAGS -L$PREFIX/lib -l$CFG_CURSES_LIB"
208 SRCS
="audio_file audio_output_$CFG_AO config gui_browser gui_draw \
209 gui_input gui_msgbar gui_playq gui_vfslist main playq playq_party \
210 playq_xmms vfs vfs_playlist vfs_regular"
213 test_pkgconfig
"GLib" "glib-2.0" ""
214 test_pkgconfig
"GLib threading library" "gthread-2.0" ""
217 if [ "$CFG_DBUS" != "" ]
219 test_pkgconfig
"dbus-glib" "dbus-glib-1" ""
220 CFLAGS
="$CFLAGS -DBUILD_DBUS -I."
222 DEPENDS_EXTRA_dbus
="dbus_binding.h"
225 # HTTP and Scrobbler code need cURL
226 if [ "$CFG_HTTP" != "" -o "$CFG_SCROBBLER" != "" ]
228 if [ "$CFG_HTTP" != "" ]
230 CFLAGS
="$CFLAGS -DBUILD_HTTP"
231 SRCS
="$SRCS vfs_http"
233 if [ "$CFG_SCROBBLER" != "" ]
235 CFLAGS
="$CFLAGS -DBUILD_SCROBBLER"
236 SRCS
="$SRCS md5 scrobbler util"
237 MANPARTS
="$MANPARTS 05-scrobbler"
239 test_pkgconfig
"cURL" "libcurl" ""
242 if [ "$CFG_MODPLUG" != "" ]
244 CFLAGS
="$CFLAGS -DBUILD_MODPLUG"
245 test_pkgconfig
"libmodplug" "libmodplug" "_audio_format_modplug"
246 SRCS
="$SRCS audio_format_modplug"
249 if [ "$CFG_MP3" != "" ]
251 CFLAGS
="$CFLAGS -DBUILD_MP3"
252 LDFLAGS
="$LDFLAGS -lmad -lid3tag"
253 #test_pkgconfig "libmad" "mad" "_audio_format_mp3"
254 #test_pkgconfig "libid3tag" "id3tag" "_audio_format_mp3"
255 SRCS
="$SRCS audio_format_mp3"
258 [ "$CFG_RES_INIT" != "" ] && CFLAGS
="$CFLAGS -DBUILD_RES_INIT"
259 # setproctitle() usage
260 [ "$CFG_SETPROCTITLE" != "" ] && CFLAGS_gui_playq
="-DBUILD_SETPROCTITLE"
262 if [ "$CFG_SNDFILE" != "" ]
264 CFLAGS
="$CFLAGS -DBUILD_SNDFILE"
265 LDFLAGS
="$LDFLAGS -lsndfile"
266 SRCS
="$SRCS audio_format_sndfile"
269 [ "$CFG_STRICT" != "" ] && CFLAGS
="$CFLAGS -Wall -Wmissing-prototypes -Wsign-compare -Werror"
270 [ "$CFG_DEBUG" != "" ] && CFLAGS
="$CFLAGS -g -DBUILD_DEBUG"
271 # Translation support
272 # Remove all broken translations
275 for i
in `echo $LINGUAS | xargs -n 1 | sort | uniq`
277 for j
in $APP_LINGUAS
281 CFG_LINGUAS
="$CFG_LINGUAS $i"
286 echo "Warning: unknown language: $i"
288 if [ "$CFG_LINGUAS" != "" ]
290 CFLAGS
="$CFLAGS -DBUILD_NLS"
291 CFLAGS_main
="$CFLAGS_main -DTRANSDIR=\\\"$TRANSDIR\\\""
294 if [ "$CFG_VORBIS" != "" ]
296 CFLAGS
="$CFLAGS -DBUILD_VORBIS"
297 LDFLAGS
="$LDFLAGS -lvorbisfile"
298 SRCS
="$SRCS audio_format_vorbis"
301 if [ "$CFG_XSPF" != "" ]
303 CFLAGS
="$CFLAGS -DBUILD_XSPF"
304 LDFLAGS
="$LDFLAGS -lspiff"
305 SRCS
="$SRCS util vfs_xspf"
306 PLAYQ_DUMPFILE
="autosave.xspf"
308 PLAYQ_DUMPFILE
="autosave.pls"
310 CFLAGS_config
="$CFLAGS_config -DPLAYQ_DUMPFILE=\\\"$PLAYQ_DUMPFILE\\\""
311 MANREGEX
="$MANREGEX -e 's|%%PLAYQ_DUMPFILE%%|$PLAYQ_DUMPFILE|'"
313 # Audio output options
317 CFLAGS
="$CFLAGS -DBUILD_ALSA"
318 LDFLAGS
="$LDFLAGS -lasound"
319 MANPARTS
="$MANPARTS 03-alsa"
322 CFLAGS
="$CFLAGS -DBUILD_AO"
323 CFLAGS_main
="$CFLAGS_main -DCLOSE_STDERR"
324 LDFLAGS
="$LDFLAGS -lao"
325 MANPARTS
="$MANPARTS 03-ao"
329 LDFLAGS
="$LDFLAGS -framework CoreAudio"
334 CFLAGS
="$CFLAGS -DOSS_HEADER=\\<soundcard.h\\>"
335 LDFLAGS
="$LDFLAGS -lossaudio"
336 OSS_DEVICE
="/dev/audio"
339 # The OSS-through-ALSA compat may generate noise
340 [ "$OS" = "Linux" ] && CFLAGS_main
="$CFLAGS_main -DCLOSE_STDERR"
341 CFLAGS
="$CFLAGS -DOSS_HEADER=\\<sys/soundcard.h\\>"
342 OSS_DEVICE
="/dev/dsp"
346 CFLAGS
="$CFLAGS -DBUILD_OSS -I$PREFIX/lib/oss/include"
347 CFLAGS_config
="$CFLAGS_config -DOSS_DEVICE=\\\"$OSS_DEVICE\\\""
348 MANPARTS
="$MANPARTS 03-oss"
349 MANREGEX
="$MANREGEX -e 's|%%OSS_DEVICE%%|$OSS_DEVICE|'"
352 CFLAGS
="$CFLAGS -DBUILD_PULSE"
353 test_pkgconfig
"PulseAudio" "libpulse-simple" "_audio_output_pulse"
357 if [ "$CFG_VOLUME" != "" ]
359 CFLAGS
="$CFLAGS -DBUILD_VOLUME"
360 MANPARTS
="$MANPARTS 01-volume"
363 echo "Configuration:"
364 echo "- Installing $APP_NAME$CFG_BINEXT in $BINDIR"
365 echo "- Installing manual page in $MANDIR"
366 echo "- Using $CONFFILE configuration file"
367 [ "$CFG_LINGUAS" != "" ] && echo "- Installing translations$CFG_LINGUAS in $TRANSDIR"
368 echo "- Using -l$CFG_CURSES_LIB and <$CFG_CURSES_HEADER.h>"
369 echo "- Using $CFG_AO audio output"
370 [ "$CFG_DBUS" != "" ] && echo "- Support for DBus integration"
371 [ "$CFG_HTTP" != "" ] && echo "- Support for HTTP streams"
372 [ "$CFG_MODPLUG" != "" ] && echo "- Support for libmodplug"
373 [ "$CFG_MP3" != "" ] && echo "- Support for MP3"
374 [ "$CFG_SCROBBLER" != "" ] && echo "- Support for AudioScrobbler"
375 [ "$CFG_SNDFILE" != "" ] && echo "- Support for libsndfile"
376 [ "$CFG_VORBIS" != "" ] && echo "- Support for Ogg Vorbis"
377 [ "$CFG_XSPF" != "" ] && echo "- Support for XSPF (\`Spiff')"
380 # Perform a simple compiler test
381 eval $CC $SRCDIR/src
/conftest.c
$CFLAGS $LDFLAGS -o conftest
$CFG_BINEXT
384 echo "Error: some dependencies are missing"
385 echo "See the README file for a list of dependencies"
388 rm -f conftest
$CFG_BINEXT
391 # Don't generate duplicate rules
392 SRCS
=`echo $SRCS | xargs -n 1 | sort | uniq`
400 for i
in `echo $MANPARTS | xargs -n 1 | sort | uniq`
402 MANFILES
="$MANFILES $SRCDIR/man/$i"
406 all: $APP_NAME$CFG_BINEXT $APP_NAME.1.gz $SRCDIR/$APP_NAME.conf.sample $MOS
407 $APP_NAME$CFG_BINEXT: $OBJS
408 # Linking $APP_NAME$CFG_BINEXT
409 $DOIT$CC $OBJS $LDFLAGS -o $APP_NAME$CFG_BINEXT
410 $APP_NAME.1.gz: $MANFILES Makefile
411 # Generating manual page $APP_NAME.1.gz
412 ${DOIT}sed $MANREGEX $MANFILES | gzip -9 > $APP_NAME.1.gz
414 # Removing $APP_NAME$CFG_BINEXT $APP_NAME.1.gz dbus_binding.h *.mo *.o
415 ${DOIT}rm -f $APP_NAME$CFG_BINEXT $APP_NAME.1.gz dbus_binding.h *.mo *.o
418 ${DOIT}rm -f Makefile
419 Makefile: $0 `dirname $0`/depends
420 # WARNING: Your Makefile is outdated. Please re-run $0!
421 dbus_binding.h: Makefile $SRCDIR/src/dbus.xml
422 # Generating dbus_binding.h
423 ${DOIT}dbus-binding-tool --mode=glib-server --prefix=dbus_server --output=dbus_binding.h $SRCDIR/src/dbus.xml
425 # Installing \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
426 ${DOIT}mkdir -p \$(DESTDIR)$BINDIR
427 $DOIT$INSTALL $CFG_STRIP $APP_NAME$CFG_BINEXT \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
428 # Installing \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
429 ${DOIT}mkdir -p \$(DESTDIR)$MANDIR/man1
430 $DOIT$INSTALL -m 444 $APP_NAME.1.gz \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
431 # Installing \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
432 ${DOIT}mkdir -p \$(DESTDIR)$CONFDIR
433 $DOIT$INSTALL -m 444 $SRCDIR/$APP_NAME.conf.sample \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
435 for i
in $CFG_LINGUAS
437 echo " # Installing \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
438 echo " ${DOIT}mkdir -p \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES"
439 echo " $DOIT$INSTALL -m 444 $i.mo \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
443 # Uninstalling \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
444 ${DOIT}rm -f \$(DESTDIR)$BINDIR/$APP_NAME$CFG_BINEXT
445 # Uninstalling \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
446 ${DOIT}rm -f \$(DESTDIR)$MANDIR/man1/$APP_NAME.1.gz
447 # Uninstalling \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
448 ${DOIT}rm -f \$(DESTDIR)$CONFDIR/$APP_NAME.conf.sample
450 for i
in $CFG_LINGUAS
452 echo " # Uninstalling \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
453 echo " ${DOIT}rm -f \$(DESTDIR)$TRANSDIR/$i/LC_MESSAGES/$APP_NAME.mo"
459 for j
in `eval echo \\\$DEPENDS_\$i`
461 DEPS
="$DEPS $SRCDIR/src/$j.h"
463 echo "$i.o: Makefile $SRCDIR/src/$i.c $SRCDIR/src/stdinc.h $DEPS `eval echo \\\$DEPENDS_EXTRA_\$i`"
464 echo " # Compiling $i.o"
465 echo " $DOIT$CC -c $SRCDIR/src/$i.c $CFLAGS `eval echo \\\$CFLAGS_\$i` -o $i.o"
467 for i
in $CFG_LINGUAS
469 echo "$i.mo: $SRCDIR/po/$i.po"
470 echo " # Generating translation $i.mo"
471 echo " ${DOIT}msgfmt -o $i.mo $SRCDIR/po/$i.po"
474 echo "Run \`make' to compile $APP_NAME"