configure2 4.69 KB
Newer Older
1 2
#!/bin/sh

3
dvdread_sh_version=4.2.1
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
dvdread_sh_major=`echo $dvdread_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/libdvdread]"
  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 "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
PREFIX=/usr/local/
INSTALLSTRIP=-s
USEDEBUG=-g
optimizations="-O3"

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
  ;;
  --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
99
test -z "$incdir" && dvdread_incdir=$PREFIX/include/dvdread
100 101 102 103 104 105 106 107 108 109 110

targetos=`uname -s`
case $targetos in
  Darwin)
    SHLDFLAGS="-dynamiclib -Wl,-single_module -Wl,-read_only_relocs,suppress"
  ;;
  *)
    SHLDFLAGS="-shared"
  ;;
esac

111 112 113 114 115 116 117 118 119 120 121 122 123
echo -n "Checking if we're big-endian... "
bigendian=no
TMPD=`mktemp -d`
TMPC=$TMPD/endian.c
TMPO=$TMPD/endian.o
cat > $TMPC <<EOF
unsigned int endian = 'B' << 24 | 'I' << 16 | 'G' << 8 | 'E';
EOF
$cc $optimizations $cflags -c -o $TMPO $TMPC
od -A n -t x1 $TMPO | grep -q '42 *49 *47 *45' && bigendian=yes
rm -rf $TMPD
echo "$bigendian"

124 125 126 127 128 129 130 131 132 133 134 135
echo -n "Checking for -mno-ms-bitfields flag support... "
no_ms_bitfields=no
TMPD=`mktemp -d`
TMPC=$TMPD/no_ms_bitfields.c
TMPO=$TMPD/no_ms_bitfields.o
cat > $TMPC <<EOF
int main(void) { return 0; }
EOF
$cc $optimizations $cflags -mno-ms-bitfields -c -o $TMPO $TMPC && no_ms_bitfields=yes && cflags="$cflags -mno-ms-bitfields"
rm -rf $TMPD
echo "$no_ms_bitfields"

136
cat > config.mak << EOF
137 138 139 140 141
# Automatically generated by configure, do not edit
PREFIX=$PREFIX
libdir=$libdir
shlibdir=$shlibdir
incdir=$incdir
142
dvdread_incdir=$dvdread_incdir
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
BUILD_SHARED=$SHARED
BUILD_STATIC=$STATIC
SHLIB_VERSION=$dvdread_sh_version
SHLIB_MAJOR=$dvdread_sh_major
CC=$cc
MAKE=$make
CFLAGS=$optimizations $cflags
LDFLAGS=$ldflags
SHLDFLAGS=$SHLDFLAGS
INSTALLSTRIP=$INSTALLSTRIP
USEDEBUG=$USEDEBUG

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
164
test "$bigendian" = "yes" && echo "#define WORDS_BIGENDIAN" >> config.h || echo "#undef WORDS_BIGENDIAN" >> config.h
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181

# 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"