#!/bin/sh #set -x TF_C=testit.c TF_E=./testit CC=cc CCTF="$CC -o $TF_E $TF_C" test_lib () { echo > $TF_C echo -n "checking for $1... " shift; LIBS='' while [ "$1" != '--' ] do LIBS="$LIBS -l$1" shift; done shift; while [ "$1" != '' ] do echo "#include <$1>" >> $TF_C shift; done echo 'int main (void) { return 0; }' >> $TF_C $CCTF $LIBS 2> /dev/null; R=$? if [ "$R" = '0' ] then echo 'yes' else echo 'no' fi return $R } test_lib_defmake () { def="$1" subdir="$2" shift shift lib="$2" [ "$subdir" = '%' ] && subdir='' if test_lib $@ then echo "#define $def" >&3 [ "$subdir" != '' ] && \ echo "subdir_$subdir=$subdir" >&4 echo "lib_$lib=-l$lib" >&4 else [ "$subdir" != '' ] && \ echo "subdir_$subdir=" >&4 echo "lib_$lib=" >&4 fi } exec 3> config.h 4> Makefile.conf cat >&3 << EOF //config.h: #ifndef _ROARAUDIO_CONFIG_H_ #define _ROARAUDIO_CONFIG_H_ EOF { echo '/* uname: ' $(uname -a) '*/' echo '/* Date : ' $(date) '*/' echo } >&3 test_lib 'Math Library' m -- math.h && echo '#define ROAR_HAVE_LIBM' >&3 if test_lib 'realtime Library' rt -- sys/mman.h mqueue.h semaphore.h then { echo '#define ROAR_HAVE_LIBRT' echo '#define ROAR_NEED_LIBRT' } >&3 fi echo >&3 test_lib_defmake ROAR_HAVE_ESD libroaresd EsounD esd -- esd.h test_lib_defmake ROAR_HAVE_LIBAO % libao ao -- ao/ao.h ao/plugin.h test_lib_defmake ROAR_HAVE_LIBVORBIS % libvorbis vorbis -- vorbis/codec.h test_lib_defmake ROAR_HAVE_LIBVORBISFILE % libvorbisfile vorbisfile -- vorbis/vorbisfile.h test_lib_defmake ROAR_HAVE_LIBSPEEX % libspeex speex -- speex/speex.h speex/speex_stereo.h test_lib_defmake ROAR_HAVE_LIBCELT % libcelt celt -- celt/celt.h celt/celt_header.h test_lib_defmake ROAR_HAVE_LIBOGGZ % liboggz oggz -- oggz/oggz.h test_lib_defmake ROAR_HAVE_LIBSNDFILE % libsndfile sndfile -- sndfile.h test_lib_defmake ROAR_HAVE_LIBFISHSOUND roarfish libfishsound fishsound -- fishsound/fishsound.h test_lib_defmake ROAR_HAVE_LIBPULSE libroarpulse libpulse pulse -- pulse/pulseaudio.h pulse/simple.h test_lib_defmake ROAR_HAVE_LIBY2 libroaryiff libyiff Y2 -- Y2/Y.h Y2/Ylib.h # add a better test here test_lib 'linux sendfile()' -- sys/sendfile.h && echo '#define ROAR_HAVE_LINUX_SENDFILE' >&3 echo -n 'checking for mlock()... ' echo '#include ' > $TF_C echo 'int main (void) { mlock((void*)0, 0); return 0; }' >> $TF_C if $CCTF 2> /dev/null; then echo '#define ROAR_HAVE_MLOCK' >&3 echo yes else echo no fi echo -n 'checking for safe 32 bit integer overflow... ' cat > $TF_C << EOF #include #include #define TYPE uint32_t #define MAX ((TYPE)4294967295U) int main (void) { TYPE a = MAX; a += 2; if ( a == 1 ) { printf("#define ROAR_HAVE_SAFE_OVERFLOW\n"); return 0; } return 1; } EOF if $CCTF 2> /dev/null; then $TF_E >&3 if [ "$?" = '0' ] then echo yes else echo no fi else echo 'no (can not compile!, no stdint.h?)' fi cat >&3 << EOF #endif //ll EOF rm -f $TF_C $TF_E mv config.h include/roaraudio/ echo 'config.h created and moved into include/roaraudio/' #ll