#!/bin/sh dvdnav_sh_version=4.2.0 dvdnav_sh_major=`echo $dvdnav_sh_version | awk -F. '{print $1}'` cc=gcc make=make # find source path source_path="`dirname \"$0\"`" source_path_used="yes" if test -z "$source_path" -o "$source_path" = "." ; then source_path="`pwd`" source_path_used="no" else source_path="`cd \"$source_path\" && pwd`" echo "$source_path" | grep -q '[[:blank:]]' && die "Out of tree builds are impossible with whitespace in source path." fi show_help(){ echo "Usage: configure [options]" echo "Options: [defaults in brackets after descriptions]" echo echo "Standard options:" echo " --help print this message" echo " --prefix=PREFIX install in PREFIX [$PREFIX]" echo " --libdir=DIR install libs in DIR [PREFIX/lib]" echo " --shlibdir=DIR install shared libs in DIR [PREFIX/lib]" echo " --incdir=DIR install includes in DIR [PREFIX/include/dvdnav]" echo " --enable-static build static libraries [default=yes]" echo " --disable-static do not build static libraries [default=no]" echo " --enable-shared build shared libraries [default=no]" echo " --disable-shared do not build shared libraries [default=yes]" echo " --enable-debug compile with debug symbols [default=yes]" echo " --disable-debug compile without debug symbols [default=no]" echo " --with-dvdread=PATH compile libdvdnav with an external libdvdread" echo "Advanced options (experts only):" echo " --cc=CC use C compiler CC [$cc]" echo " --make=MAKE use specified make [$make]" echo " --extra-cflags=ECFLAGS add ECFLAGS to CFLAGS" echo " --extra-ldflags=ELDFLAGS add ELDFLAGS to LDFLAGS" echo "Developer options:" echo " --disable-strip disable stripping of executables and shared libraries" echo " --disable-opts disable compiler optimizations" exit 1 } SHARED=yes STATIC=yes DVDREAD_CONFIG=dvdread-config PREFIX=/usr/local/ INSTALLSTRIP=-s USEDEBUG=-g optimizations="-O2" threadlib="-lpthread" for opt do optval=`echo $opt | cut -d '=' -f 2-` case "$opt" in --enable-shared) SHARED=yes ;; --disable-shared) SHARED=no ;; --enable-static) STATIC=yes ;; --disable-static) STATIC=no ;; --with-dvdread-config=*) DVDREAD_CONFIG="$optval" ;; --prefix=*) PREFIX="$optval" ;; --libdir=*) libdir="$optval" ;; --shlibdir=*) shlibdir="$optval" ;; --incdir=*) incdir="$optval" ;; --cc=*) cc="$optval" ;; --make=*) make="$optval" ;; --extra-cflags=*) cflags="$cflags $optval" ;; --extra-ldflags=*) ldflags="$ldflags $optval" ;; --disable-strip) INSTALLSTRIP= ;; --disable-opts) optimizations="" ;; --disable-debug) USEDEBUG="" ;; --enable-debug) USEDEBUG="-g" ;; --help) show_help ;; esac done PREFIX=`cd $PREFIX && pwd` test -z "$libdir" && libdir=$PREFIX/lib test -z "$shlibdir" && shlibdir=$PREFIX/lib test -z "$incdir" && incdir=$PREFIX/include/dvdnav dvdread=no $DVDREAD_CONFIG --prefix >> /dev/null 2>&1 && dvdread=yes test "$dvdread" != "yes" && $DVDREAD_CONFIG --exists >> /dev/null 2>&1 && dvdread=yes if test "$dvdread" != "yes" ; then echo "$DVDREAD_CONFIG returned an error. Can't proceed" exit 1 fi dvdread_cflags=`$DVDREAD_CONFIG --cflags` dvdread_libs=`$DVDREAD_CONFIG --libs` targetos=`uname -s` case $targetos in Darwin) SHLDFLAGS="-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress" ;; *) SHLDFLAGS="-shared" ;; esac cat > config.mak << EOF # Automatically generated by configure, do not edit PREFIX=$PREFIX libdir=$libdir shlibdir=$shlibdir incdir=$incdir THREADLIB=$threadlib BUILD_SHARED=$SHARED BUILD_STATIC=$STATIC SHLIB_VERSION=$dvdnav_sh_version SHLIB_MAJOR=$dvdnav_sh_major CC=$cc MAKE=$make CFLAGS=$optimizations $cflags LDFLAGS=$ldflags SHLDFLAGS=$SHLDFLAGS INSTALLSTRIP=$INSTALLSTRIP USEDEBUG=$USEDEBUG DVDREAD_CFLAGS=$dvdread_cflags DVDREAD_LIBS=$dvdread_libs SRC_PATH="$source_path" SRC_PATH_BARE=$source_path EOF cat > config.h << EOF /* Automatically generated by configure, do not edit */ #include "version.h" EOF # build tree in object directory if source path is different from current one if test "$source_path_used" != "no"; then FILES="\ Makefile \ misc \ " for f in $FILES ; do ln -sf "$source_path/$f" $f done fi [ -d obj ] || mkdir -p obj echo echo "Done, type 'make install' to build and install"