#!/bin/sh # check for bash... if [ "$(echo -n)" = '-n' ] then SHELL=$(which bash sh 2> /dev/null | head -n 1) exec $SHELL $0 "$@" fi #set -x TF_C=testit.c TF_E=./testit LDPATH='' INCPATH='' SYSNAME='unknown' SHARED='-shared' echo -n "checking for C compiler... " CC=$(which gcc cc 2> /dev/null | head -n 1) if [ "$CC" = '' ] then echo 'none' exit 1; fi echo $CC #Makefile.conf not yet open, write it later echo -n "checking for sysname... " SYSNAME=$(uname -s) echo "$SYSNAME" while [ "$1" != '' ] do case "$1" in '--help') echo '--help' echo '--ldpath DIR' echo '--incpath DIR' echo '--addpath DIR' echo '--no-LIB' exit 0; ;; '--ldpath') LDPATH="$LDPATH -L$2" shift; ;; '--incpath') INCPATH="$INCPATH -I$2" shift; ;; '--addpath') LDPATH="$LDPATH -L$2/lib/" INCPATH="$INCPATH -I$2/include/" shift; ;; '--no-'*) lib=$(echo "$1" | sed 's/^--no-//') eval no_lib_$lib=true ;; esac; shift; done CCTF="$CC $LDPATH $INCPATH -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 [ "$lib" != '--' ] then eval _no="\$no_lib_$lib"; if [ "$_no" != '' ] then echo "checking for $1... disabled by user" [ "$subdir" != '' ] && \ echo "subdir_$subdir=" >&4 echo "lib_$lib=" >&4 return; fi fi 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 # now write the cc name to Makefile.conf echo "CC=$CC" >&4 echo "LDPATH=$LDPATH" >&4 echo "INCPATH=$INCPATH" >&4 if [ "$SYSNAME" = 'Darwin' ] then echo "Adding $SYSNAME shared lib arguments..." SHARED="$SHARED -fno-common -dynamiclib -compatibility_version 0.1 -current_version 0.1.0" INCPATH="$INCPATH -fno-common" fi echo "SHARED=$SHARED" >&4 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 # #define subdir name -lxxx -- header 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_LIBVORBISENC % libvorbisenc vorbisenc -- vorbis/vorbisenc.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_LIBSHOUT % libshout shout -- shout/shout.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 test_lib_defmake ROAR_HAVE_LIBARTSC libroararts libartsc artsc -- kde/artsc/artsc.h test_lib_defmake ROAR_HAVE_LIBDNET % libdnet dnet -- sys/socket.h netdnet/dn.h netdnet/dnetdb.h test_lib_defmake ROAR_HAVE_IPX % IPX -- netipx/ipx.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 inline funcs... ' echo 'inline int test (void) { return 0; }' > $TF_C echo 'int main (void) { return test(); }' >> $TF_C if $CCTF 2> /dev/null; then echo '#define ROAR_HAVE_INLINE' >&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 echo -n 'checking if cp supports -v... ' if cp -v --help > /dev/null 2> /dev/null then echo "cp_v=-v" >&4 echo yes else echo "cp_v=" >&4 echo no 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