autogen.sh 4.13 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
if automake-1.10 --version >/dev/null 2>&1; then
  automake_version="-1.10"
elif automake-1.9 --version >/dev/null 2>&1; then
47 48 49 50
  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
51 52 53 54 55 56 57 58 59 60 61 62 63 64
  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" ;;
65
    1.10*)                            automake_version="-1.10" ;;
andre's avatar
andre committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79
  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
80
  echo "$0"': this project requires automake >= 1.5.  Please upgrade your version of automake to at least 1.5'
andre's avatar
andre committed
81 82 83
  exit 1
fi

84 85
AUTOMAKE="automake${automake_version}"
ACLOCAL="aclocal${automake_version}"
andre's avatar
andre committed
86

87 88 89 90 91
#
# do we need pkg-config?
#

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

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

 apt-get install pkgconfig

EOF
    fi
andre's avatar
andre committed
107
    exit 1
108 109 110 111
  fi
fi


112 113 114
#
# autogoat bootstrap process
# 
andre's avatar
andre committed
115

116 117 118 119 120
ACLOCAL=${ACLOCAL:-aclocal}
AUTOCONF=${AUTOCONF:-autoconf}
AUTOHEADER=${AUTOHEADER:-autoheader}
AUTOMAKE=${AUTOMAKE:-automake}

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

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

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

171 172 173 174 175
 ./configure

EOF
fi