autogen.sh 3.99 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
automake_version="none"
44 45 46 47 48
if automake-1.9 --version >/dev/null 2>&1; then
  automake_version="-1.9"
elif automake-1.8 --version >/dev/null 2>&1; then
  automake_version="-1.8"
elif automake-1.7 --version >/dev/null 2>&1; then
andre's avatar
andre committed
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
  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
77
  echo "$0"': this project requires automake >= 1.5.  Please upgrade your version of automake to at least 1.5'
andre's avatar
andre committed
78 79 80
  exit 1
fi

81 82
AUTOMAKE="automake${automake_version}"
ACLOCAL="aclocal${automake_version}"
andre's avatar
andre committed
83

84 85 86 87 88
#
# do we need pkg-config?
#

if grep -q PKG_CHECK_MODULES configure.*; then
andre's avatar
andre committed
89
  if ! pkg-config --version > /dev/null 2> /dev/null; then
90
    cat << EOF
andre's avatar
andre committed
91
pkg-config is required, but it's not installed or can't be found in your
92 93 94 95 96 97
search path.

EOF
    # be nice to the user if they have fink!
    if test -d /sw ; then
      cat << EOF
andre's avatar
andre committed
98
You can install it via Fink with the command:
99 100 101 102 103

 apt-get install pkgconfig

EOF
    fi
andre's avatar
andre committed
104
    exit 1
105 106 107 108
  fi
fi


109 110 111
#
# autogoat bootstrap process
# 
andre's avatar
andre committed
112

113 114 115 116 117
ACLOCAL=${ACLOCAL:-aclocal}
AUTOCONF=${AUTOCONF:-autoconf}
AUTOHEADER=${AUTOHEADER:-autoheader}
AUTOMAKE=${AUTOMAKE:-automake}

118 119 120 121 122 123 124 125 126
# 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
127
eval "$ACLOCAL -I m4"
128 129 130 131 132 133

# 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"
134
  elif libtoolize --version > /dev/null 2> /dev/null; then
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
    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
151

152
eval "$AUTOCONF"
153
grep -q CONFIG_HEADER configure.* && "$AUTOHEADER"
154 155 156 157 158 159 160 161 162 163 164 165
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"
andre's avatar
andre committed
166 167
 export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/sw/lib/pkgconfig:\$PKG_CONFIG_PATH"

168 169 170 171 172
 ./configure

EOF
fi