Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 323 lines (254 sloc) 7.756 kb
#!/bin/sh
TEMP_C=.tmp.c
TEMP_EXE=.tmp
if [ -z $CC ]; then
CC=cc
fi
HAVE_ALSA=auto
HAVE_OSS=auto
HAVE_PORTAUDIO=auto
HAVE_OPENAL=auto
HAVE_LIBAO=auto
HAVE_MUROAR=auto
HAVE_ROAR=auto
HAVE_PULSE=auto
HAVE_JACK=auto
HAVE_COREAUDIO=auto
HAVE_SAMPLERATE=auto
HAVE_SYSLOG=auto
PREFIX=/usr/local
RSD_VERSION=1.2
### Command line stuff
MODULES="alsa oss libao portaudio openal pulse samplerate roar muroar jack coreaudio syslog"
print_help()
{
echo "Usage:"
echo " --prefix=\$prefix: Installs under \$prefix directory"
echo " --disable-\$module: Disables module"
echo " --enable-\$module: Forcefully enables module (not recommended)"
echo ""
echo "Modules:"
echo " $MODULES"
}
### Parse stuff :V
while [ ! -z "$1" ]
do
case "$1" in
--prefix=*)
prefix="`echo $1 | sed -e 's|^--prefix=||' -e 's|^\(.*\)/$|\1|'`"
if [ "$prefix" != "$1" ]; then
PREFIX="$prefix"
fi
;;
--enable-*)
enable=`echo $1 | sed 's|^--enable-||'`
[ -z $enable ] && echo "Not valid module." && print_help && exit 1
if [ -z "`echo $MODULES | grep $enable`" ]; then
echo "Not valid module."
print_help
exit 1
fi
eval HAVE_`echo $enable | tr '[a-z]' '[A-Z]'`=yes
;;
--disable-*)
disable=`echo $1 | sed 's|^--disable-||'`
[ -z $disable ] && echo "Not valid module." && print_help && exit 1
if [ -z "`echo $MODULES | grep $disable`" ]; then
echo "Not valid module."
print_help
exit 1
fi
eval HAVE_`echo $disable | tr '[a-z]' '[A-Z]'`=no
;;
-h|--help)
print_help
exit 0
;;
*)
print_help
exit 1
;;
esac
shift
done
check_lib()
{
ECHOBUF="Checking function $3 in $2 ... "
echo "void $3(void); int main(void) { $3(); return 0; }" > $TEMP_C
eval HAVE_$1=no
answer=no
$CC -o $TEMP_EXE $TEMP_C $CFLAGS $2 2>/dev/null >/dev/null && answer=yes && eval HAVE_$1=yes
echo $ECHOBUF $answer
rm -rf $TEMP_C $TEMP_EXE
}
check_header()
{
ECHOBUF="Checking presence of header file $2 ... "
echo "#include<$2>" > $TEMP_C
echo "int main(void) { return 0; }" >> $TEMP_C
eval HAVE_$1=no
answer=no
$CC -o $TEMP_EXE $TEMP_C 2>/dev/null >/dev/null && answer=yes && eval HAVE_$1=yes
echo $ECHOBUF $answer
rm -rf $TEMP_C $TEMP_EXE
}
check_switch()
{
ECHOBUF="Checking for availability of switch $2 ... "
echo "int main(void) { return 0; }" > $TEMP_C
eval HAVE_$1=no
answer=no
$CC -o $TEMP_EXE $TEMP_C $2 2>/dev/null >/dev/null && answer=yes && eval HAVE_$1=yes
echo $ECHOBUF $answer
rm -rf $TEMP_C $TEMP_EXE
}
check_switch GNU99 -std=gnu99
check_switch C99 -std=c99
check_switch WEXTRA -Wextra
if [ $HAVE_GNU99 = yes ]; then
CFLAGS="$CFLAGS -std=gnu99 -Wall"
elif [ $HAVE_C99 = yes ]; then
CFLAGS="$CFLAGS -std=c99 -Wall"
else
echo "The C compiler \"$CC\" does not seem to support C99. Cannot build."
exit 1
fi
if [ $HAVE_WEXTRA = yes ]; then
CFLAGS="$CFLAGS -Wextra"
fi
check_lib PTHREAD -lpthread pthread_create
if [ $HAVE_PTHREAD = no ]; then
echo "Couldn't find pthread library. Cannot build."
exit 1
fi
[ $HAVE_ALSA = auto ] && check_lib ALSA -lasound snd_pcm_open
check_header SYS_SOUNDCARD_H sys/soundcard.h
check_header SOUNDCARD_H soundcard.h
check_lib OSSAUDIO -lossaudio _oss_ioctl
[ $HAVE_LIBAO = auto ] && check_lib LIBAO -lao ao_open_live
[ $HAVE_ROAR = auto ] && check_lib ROAR -lroar roar_vs_new
[ $HAVE_PULSE = auto ] && check_lib PULSE -lpulse-simple pa_simple_new
[ $HAVE_MUROAR = auto ] && check_lib MUROAR -lmuroar muroar_stream
if [ ! -z "`uname -a | grep Darwin`" ]; then
[ $HAVE_OPENAL = auto ] && check_lib OPENAL "-framework OpenAL" alcOpenDevice
else
[ $HAVE_OPENAL = auto ] && check_lib OPENAL -lopenal alcOpenDevice
fi
[ $HAVE_PORTAUDIO = auto ] && check_lib PORTAUDIO -lportaudio Pa_OpenStream
[ $HAVE_JACK = auto ] && check_lib JACK -ljack jack_port_get_latency_range
if [ ! -z "`uname -a | grep Darwin`" ]; then
[ $HAVE_COREAUDIO = auto ] && check_lib COREAUDIO "-framework AudioUnit" AudioUnitInitialize
else
HAVE_COREAUDIO=no
fi
[ $HAVE_SAMPLERATE = auto ] && check_lib SAMPLERATE -lsamplerate src_callback_new
[ $HAVE_SYSLOG = auto ] && check_lib SYSLOG -lc openlog
check_lib RT -lrt clock_gettime
check_lib DECNET -ldnet dnet_conn
if [ $HAVE_OSS = auto ]; then
if [ $HAVE_SYS_SOUNDCARD_H = yes ]; then
HAVE_OSS=yes
elif [ $HAVE_SOUNDCARD_H = yes ]; then
HAVE_OSS=yes
else
HAVE_OSS=no
fi
fi
#### Output stuff to config.{h,mk}
echo "" > src/config.h
echo "" > src/config.mk
echo "#ifndef __CONFIG_H" >> src/config.h
echo "#define __CONFIG_H" >> src/config.h
echo "#define RSD_VERSION \"$RSD_VERSION\"" >> src/config.h
echo "RSD_VERSION = $RSD_VERSION" >> src/config.mk
echo "CC = $CC" >> src/config.mk
echo "CFLAGS = $CFLAGS" >> src/config.mk
if [ $HAVE_ALSA = yes ]; then
echo "#define _ALSA 1" >> src/config.h
echo "HAVE_ALSA = 1" >> src/config.mk
fi
if [ $HAVE_SYS_SOUNDCARD_H = yes ]; then
echo "#define HAVE_SYS_SOUNDCARD_H 1" >> src/config.h
fi
if [ $HAVE_SOUNDCARD_H = yes ]; then
echo "#define HAVE_SOUNDCARD_H 1" >> src/config.h
fi
if [ $HAVE_OSS = yes ]; then
echo "#define _OSS 1" >> src/config.h
echo "HAVE_OSS = 1" >> src/config.mk
fi
if [ $HAVE_LIBAO = yes ]; then
echo "#define _AO 1" >> src/config.h
echo "HAVE_LIBAO = 1" >> src/config.mk
fi
if [ $HAVE_ROAR = yes ]; then
echo "#define _ROARVS 1" >> src/config.h
echo "HAVE_ROARVS = 1" >> src/config.mk
fi
if [ $HAVE_PULSE = yes ]; then
echo "#define _PULSE 1" >> src/config.h
echo "HAVE_PULSE = 1" >> src/config.mk
fi
if [ $HAVE_MUROAR = yes ]; then
echo "#define _MUROAR 1" >> src/config.h
echo "HAVE_MUROAR = 1" >> src/config.mk
fi
if [ $HAVE_OPENAL = yes ]; then
echo "#define _AL 1" >> src/config.h
echo "HAVE_AL = 1" >> src/config.mk
fi
if [ $HAVE_PORTAUDIO = yes ]; then
echo "#define _PORTA 1" >> src/config.h
echo "HAVE_PORTAUDIO = 1" >> src/config.mk
fi
if [ $HAVE_JACK = yes ]; then
echo "#define _JACK 1" >> src/config.h
echo "HAVE_JACK = 1" >> src/config.mk
fi
if [ $HAVE_COREAUDIO = yes ]; then
echo "#define _COREAUDIO 1" >> src/config.h
echo "HAVE_COREAUDIO = 1" >> src/config.mk
fi
if [ $HAVE_SAMPLERATE = yes ]; then
echo "#define HAVE_SAMPLERATE 1" >> src/config.h
echo "HAVE_SAMPLERATE = 1" >> src/config.mk
fi
if [ $HAVE_SYSLOG = yes ]; then
echo "#define HAVE_SYSLOG 1" >> src/config.h
echo "HAVE_SYSLOG = 1" >> src/config.mk
fi
if [ $HAVE_RT = yes ]; then
echo "NEED_RT = 1" >> src/config.mk
fi
if [ $HAVE_OSSAUDIO = yes ]; then
echo "NEED_OSSAUDIO = 1" >> src/config.mk
fi
if [ $HAVE_DECNET = yes ]; then
echo "#define HAVE_DECNET 1" >> src/config.h
fi
echo "PREFIX = $PREFIX" >> src/config.mk
echo "#endif" >> src/config.h
### Output log
echo ""
echo ""
echo "============================"
echo "Configuration successful."
echo "============================"
echo " ALSA: $HAVE_ALSA"
echo " OSS: $HAVE_OSS"
echo " libAO: $HAVE_LIBAO"
echo " PortAudio: $HAVE_PORTAUDIO"
echo " JACK: $HAVE_JACK"
echo " Roar VS: $HAVE_ROAR"
echo " OpenAL: $HAVE_OPENAL"
echo " muRoar: $HAVE_MUROAR"
echo " PulseAudio: $HAVE_PULSE"
echo " CoreAudio: $HAVE_COREAUDIO"
echo " libsamplerate: $HAVE_SAMPLERATE"
echo " syslog: $HAVE_SYSLOG"
echo ""
echo " Prefix: $PREFIX"
echo " CC: $CC"
echo " CFLAGS: $CFLAGS"
echo ""
echo ":: Type 'make' to compile ('gmake' for BSD systems)."
Jump to Line
Something went wrong with that request. Please try again.