autogen.sh 3.76 KB
Newer Older
andre's avatar
andre committed
1 2
#!/bin/sh

andre's avatar
andre committed
3 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
# autogoat!
# an omnivorous assistant for autotools
#
#         (__) 
#         (oo) 
#   /------\/ 
#  / |    ||   
# *  /\---/\ 
#    ~~   ~~   

# clean function
clean ()
{
  # remove autotools cruft
  rm -f aclocal.m4 configure config.log
  rm -Rf autom4te.cache
  # remove old autotools extra cruft
  rm -f config.guess config.sub missing mkinstalldirs compile depcomp install-sh
  # remove libtool cruft
  rm -f ltmain.sh libtool ltconfig
}


#
# option checking
#

if test "x$1" = "xclean"; then
  set -x
  clean
  set +x
  exit 0
fi

37

38

39 40 41 42
#
# check automake version number -- we require >= 1.5
#

andre's avatar
andre committed
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
automake_version="none"
if automake-1.7 --version >/dev/null 2>&1; then
  automake_version="-1.7"
elif automake-1.6 --version >/dev/null 2>&1; then
  automake_version="-1.6"
elif automake-1.5 --version >/dev/null 2>&1; then
  automake_version="-1.5"
elif automake --version > /dev/null 2>&1; then
  automake_version=""
  case "`automake --version | sed -e '1s/[^0-9]*//' -e q`" in
    0|0.*|1|1.[01234]|1.[01234][-.]*) automake_version="none" ;;
    1.5*)                             automake_version="-1.5" ;;
    1.6*)                             automake_version="-1.6" ;;
    1.7*)                             automake_version="-1.7" ;;
    1.8*)                             automake_version="-1.8" ;;
    1.9*)                             automake_version="-1.9" ;;
  esac
fi

if test "x${automake_version}" = "xnone"; then
  set +x
  echo "you need automake version 1.5 or later"
  exit 1
fi

automake_version_major=`echo "$automake_version" | cut -d. -f2`
automake_version_minor=`echo "$automake_version" | cut -d. -f3`

# need at least automake >= 1.5
if test "$automake_version_major" -lt "5"; then
73
  echo "$0"': this project requires automake >= 1.5.  Please upgrade your version of automake to at least 1.5'
andre's avatar
andre committed
74 75 76 77
  exit 1
fi


78 79 80 81 82
#
# do we need pkg-config?
#

if grep -q PKG_CHECK_MODULES configure.*; then
andre's avatar
andre committed
83
  if ! pkg-config --version > /dev/null 2> /dev/null; then
84
    cat << EOF
andre's avatar
andre committed
85
pkg-config is required, but it's not installed or can't be found in your
86 87 88 89 90 91
search path.

EOF
    # be nice to the user if they have fink!
    if test -d /sw ; then
      cat << EOF
andre's avatar
andre committed
92
You can install it via Fink with the command:
93 94 95 96 97

 apt-get install pkgconfig

EOF
    fi
andre's avatar
andre committed
98
    exit 1
99 100 101 102
  fi
fi


103 104 105
#
# autogoat bootstrap process
# 
andre's avatar
andre committed
106

107 108 109 110 111
ACLOCAL=${ACLOCAL:-aclocal}
AUTOCONF=${AUTOCONF:-autoconf}
AUTOHEADER=${AUTOHEADER:-autoheader}
AUTOMAKE=${AUTOMAKE:-automake}

112 113 114 115 116 117 118 119 120
# clean out old cruft
clean

# add Fink's /sw path to various search directories
if [ -d /sw ]; then
  ACLOCAL="$ACLOCAL -I /sw/share/aclocal"
  FINK_DETECTED=1
fi

thomasvs's avatar
thomasvs committed
121
eval "$ACLOCAL -I m4"
122 123 124 125 126 127

# do we need libtool?
if grep -q PROG_LIBTOOL configure.*; then
  # what's libtoolize called?
  if glibtoolize --version > /dev/null 2> /dev/null; then
    LIBTOOLIZE="glibtoolize"
128
  elif libtoolize --version > /dev/null 2> /dev/null; then
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
    LIBTOOLIZE="libtoolize"
  fi

  # check libtool version -- only support 1.4 or 1.5 for now
  if "$LIBTOOLIZE" --version | egrep -q '1\.4|1\.5'; then
    if grep -q AC_LIBLTDL_CONVENIENCE configure.*; then
      "$LIBTOOLIZE" --ltdl --copy --force
    else
      "$LIBTOOLIZE" --copy --force
    fi
  else
    # libtool version is too old :(
    echo "$0: need libtool >= 1.4 installed"
    exit 1
  fi
fi
andre's avatar
andre committed
145

146
eval "$AUTOCONF"
147
grep -q CONFIG_HEADER configure.* && "$AUTOHEADER"
148 149 150 151 152 153 154 155 156 157 158 159
eval "$AUTOMAKE" --add-missing --copy

# Print warning message if Fink detected
if test "$FINK_DETECTED" = 1; then
  cat << EOF

Fink detected; added /sw/share/aclocal to aclocal's include directories.
Make sure you have CPPFLAGS, LDFLAGS and PKG_CONFIG_PATH including Fink's
distribution directories, e.g.:

 export CPPFLAGS="-I/sw/include \$CPPFLAGS"
 export LDFLAGS="-L/sw/lib \$LDFLAGS"
160 161
 export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/sw/lib/pkgconfig:\$PKG_CONFIG_PATH"

162 163 164 165 166
 ./configure

EOF
fi