#!/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 } exec 3> config.h 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 test_lib EsounD esd -- esd.h && echo '#define ROAR_HAVE_ESD' >&3 test_lib libao ao -- ao/ao.h ao/plugin.h && echo '#define ROAR_HAVE_LIBAO' >&3 test_lib libvorbis vorbis -- vorbis/codec.h && echo '#define ROAR_HAVE_LIBVORBIS' >&3 test_lib libvorbisfile vorbisfile -- vorbis/vorbisfile.h && echo '#define ROAR_HAVE_LIBVORBISFILE' >&3 test_lib libspeex speex -- speex/speex.h && echo '#define ROAR_HAVE_LIBSPEEX' >&3 test_lib libcelt celt -- celt/celt.h celt/celt_header.h && echo '#define ROAR_HAVE_LIBCELT' >&3 test_lib liboggz oggz -- oggz/oggz.h && echo '#define ROAR_HAVE_LIBOGGZ' >&3 test_lib libfishsound fishsound -- fishsound/fishsound.h && echo '#define ROAR_HAVE_LIBFISHSOUND' >&3 test_lib libsndfile sndfile -- sndfile.h && echo '#define ROAR_HAVE_LIBSNDFILE' >&3 # 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 save 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