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 vi zh_CN'
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
73 [ "$CONFDIR" = "" ] && CONFDIR
=/etc
74 [ "$PREFIX" = "" ] && PREFIX
=/usr
78 [ "$CONFDIR" = "" ] && CONFDIR
=/etc
79 [ "$PREFIX" = "" ] && PREFIX
=/usr
83 [ "$PREFIX" = "" ] && PREFIX
=/usr
/pkg
87 [ "$PREFIX" = "" ] && PREFIX
=/usr
/local
88 [ "$MANDIR" = "" ] && MANDIR
=$PREFIX/man
93 [ "$PREFIX" = "" ] && PREFIX
=/opt
/sfw
94 LDFLAGS
="$LDFLAGS -lresolv"
95 [ "$INSTALL" = "" ] && INSTALL
=ginstall
98 echo "Warning: unknown operating system: $OS"
100 [ "$PREFIX" = "" ] && PREFIX
=/usr
/local
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
143 alsa|ao|coreaudio|null|oss|pulse
)
162 CFG_CURSES_HEADER
=ncurses
163 CFG_CURSES_LIB
=ncurses
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"
181 PKG_CFLAGS
="`pkg-config --cflags $2 2> /dev/null`"
184 echo "Error: $1 not found"
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\\>"
199 echo "Error: Glib not found"
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"
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" != "" ]
215 if [ "$CFG_HTTP" != "" ]
217 CFLAGS
="$CFLAGS -DBUILD_HTTP"
218 SRCS
="$SRCS vfs_http"
220 if [ "$CFG_SCROBBLER" != "" ]
222 CFLAGS
="$CFLAGS -DBUILD_SCROBBLER"
223 SRCS
="$SRCS md5 scrobbler util"
224 MANPARTS
="$MANPARTS 05-scrobbler"
226 test_pkgconfig
"cURL" "libcurl" ""
229 if [ "$CFG_MODPLUG" != "" ]
231 CFLAGS
="$CFLAGS -DBUILD_MODPLUG"
232 test_pkgconfig
"libmodplug" "libmodplug" "_audio_format_modplug"
233 SRCS
="$SRCS audio_format_modplug"
236 if [ "$CFG_MP3" != "" ]
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"
245 [ "$CFG_RES_INIT" != "" ] && CFLAGS
="$CFLAGS -DBUILD_RES_INIT"
246 # setproctitle() usage
247 [ "$CFG_SETPROCTITLE" != "" ] && CFLAGS_gui_playq
="-DBUILD_SETPROCTITLE"
249 if [ "$CFG_SNDFILE" != "" ]
251 CFLAGS
="$CFLAGS -DBUILD_SNDFILE"
252 LDFLAGS
="$LDFLAGS -lsndfile"
253 SRCS
="$SRCS audio_format_sndfile"
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
262 for i
in `echo $LINGUAS | xargs -n 1 | sort | uniq`
264 for j
in $APP_LINGUAS
268 CFG_LINGUAS
="$CFG_LINGUAS $i"
273 echo "Warning: unknown language: $i"
275 if [ "$CFG_LINGUAS" != "" ]
277 CFLAGS
="$CFLAGS -DBUILD_NLS"
278 CFLAGS_main
="$CFLAGS_main -DTRANSDIR=\\\"$TRANSDIR\\\""
281 if [ "$CFG_VORBIS" != "" ]
283 CFLAGS
="$CFLAGS -DBUILD_VORBIS"
284 LDFLAGS
="$LDFLAGS -lvorbisfile"
285 SRCS
="$SRCS audio_format_vorbis"
288 if [ "$CFG_XSPF" != "" ]
290 CFLAGS
="$CFLAGS -DBUILD_XSPF"
291 LDFLAGS
="$LDFLAGS -lspiff"
292 SRCS
="$SRCS util vfs_xspf"
293 PLAYQ_DUMPFILE
="autosave.xspf"
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
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"
316 LDFLAGS
="$LDFLAGS -framework CoreAudio"
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"
333 CFLAGS
="$CFLAGS -DBUILD_OSS"
334 CFLAGS_config
="$CFLAGS_config -DOSS_DEVICE=\\\"$OSS_DEVICE\\\""
335 MANPARTS
="$MANPARTS 03-oss"
336 MANREGEX
="$MANREGEX -e 's|%%OSS_DEVICE%%|$OSS_DEVICE|'"
339 CFLAGS
="$CFLAGS -DBUILD_PULSE"
340 test_pkgconfig
"PulseAudio" "libpulse-simple" "_audio_output_pulse"
344 if [ "$CFG_VOLUME" != "" ]
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')"
366 # Perform a simple compiler test
367 eval $CC $SRCDIR/src
/conftest.c
$CFLAGS $LDFLAGS -o conftest
$CFG_BINEXT
370 echo "Error: some dependencies are missing"
371 echo "See the README file for a list of dependencies"
374 rm conftest
$CFG_BINEXT
376 # Don't generate duplicate rules
377 SRCS
=`echo $SRCS | xargs -n 1 | sort | uniq`
385 for i
in `echo $MANPARTS | xargs -n 1 | sort | uniq`
387 MANFILES
="$MANFILES $SRCDIR/man/$i"
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
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
404 ${DOIT}rm -f Makefile
405 Makefile: $0 `dirname $0`/depends
406 # WARNING: Your Makefile is outdated. Please re-run $0!
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"
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"
442 for j
in `eval echo \\\$DEPENDS_\$i`
444 DEPS
="$DEPS $SRCDIR/src/$j.h"
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"
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"
457 echo "Run \`make' to compile $APP_NAME"