| 1 | #!/usr/bin/env bash |
|---|
| 2 | # Taken from lighthttpd server (BSD). Thanks Jan! |
|---|
| 3 | # Run this to generate all the initial makefiles, etc. |
|---|
| 4 | |
|---|
| 5 | die() { echo "$@"; exit 1; } |
|---|
| 6 | |
|---|
| 7 | # LIBTOOLIZE=${LIBTOOLIZE:-libtoolize} |
|---|
| 8 | LIBTOOLIZE_FLAGS=" --automake --copy --force" |
|---|
| 9 | # ACLOCAL=${ACLOCAL:-aclocal} |
|---|
| 10 | ACLOCAL_FLAGS="-I m4" |
|---|
| 11 | # AUTOHEADER=${AUTOHEADER:-autoheader} |
|---|
| 12 | # AUTOMAKE=${AUTOMAKE:-automake} |
|---|
| 13 | # --add-missing instructs automake to install missing auxiliary files |
|---|
| 14 | # --copy tells it to make copies and not symlinks |
|---|
| 15 | AUTOMAKE_FLAGS="--gnu --add-missing --copy --force" |
|---|
| 16 | # AUTOCONF=${AUTOCONF:-autoconf} |
|---|
| 17 | |
|---|
| 18 | ARGV0=$0 |
|---|
| 19 | ARGS="$@" |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | run() { |
|---|
| 23 | echo "$ARGV0: running \`$@' $ARGS" |
|---|
| 24 | $@ $ARGS |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | ## jump out if one of the programs returns 'false' |
|---|
| 28 | set -e |
|---|
| 29 | |
|---|
| 30 | if test x$LIBTOOLIZE = x; then |
|---|
| 31 | if test \! "x`which glibtoolize 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 32 | LIBTOOLIZE=glibtoolize |
|---|
| 33 | elif test \! "x`which libtoolize-1.5 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 34 | LIBTOOLIZE=libtoolize-1.5 |
|---|
| 35 | elif test \! "x`which libtoolize 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 36 | LIBTOOLIZE=libtoolize |
|---|
| 37 | elif test \! "x`which glibtoolize 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 38 | LIBTOOLIZE=glibtoolize |
|---|
| 39 | else |
|---|
| 40 | echo "libtoolize 1.5.x wasn't found, exiting"; exit 1 |
|---|
| 41 | fi |
|---|
| 42 | fi |
|---|
| 43 | |
|---|
| 44 | if test x$ACLOCAL = x; then |
|---|
| 45 | if test \! "x`which aclocal-1.10 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 46 | ACLOCAL=aclocal-1.10 |
|---|
| 47 | elif test \! "x`which aclocal110 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 48 | ACLOCAL=aclocal110 |
|---|
| 49 | elif test \! "x`which aclocal 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 50 | ACLOCAL=aclocal |
|---|
| 51 | else |
|---|
| 52 | echo "automake 1.10.x (aclocal) wasn't found, exiting"; exit 1 |
|---|
| 53 | fi |
|---|
| 54 | fi |
|---|
| 55 | |
|---|
| 56 | if test x$AUTOMAKE = x; then |
|---|
| 57 | if test \! "x`which automake-1.10 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 58 | AUTOMAKE=automake-1.10 |
|---|
| 59 | elif test \! "x`which automake110 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 60 | AUTOMAKE=automake110 |
|---|
| 61 | elif test \! "x`which automake 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 62 | AUTOMAKE=automake |
|---|
| 63 | else |
|---|
| 64 | echo "automake 1.10.x wasn't found, exiting"; exit 1 |
|---|
| 65 | fi |
|---|
| 66 | fi |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | ## macosx has autoconf-2.59 and autoconf-2.60 |
|---|
| 70 | if test x$AUTOCONF = x; then |
|---|
| 71 | if test \! "x`which autoconf-2.59 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 72 | AUTOCONF=autoconf-2.59 |
|---|
| 73 | elif test \! "x`which autoconf259 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 74 | AUTOCONF=autoconf259 |
|---|
| 75 | elif test \! "x`which autoconf 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 76 | AUTOCONF=autoconf |
|---|
| 77 | else |
|---|
| 78 | echo "autoconf 2.59+ wasn't found, exiting"; exit 1 |
|---|
| 79 | fi |
|---|
| 80 | fi |
|---|
| 81 | |
|---|
| 82 | if test x$AUTOHEADER = x; then |
|---|
| 83 | if test \! "x`which autoheader-2.59 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 84 | AUTOHEADER=autoheader-2.59 |
|---|
| 85 | elif test \! "x`which autoheader259 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 86 | AUTOHEADER=autoheader259 |
|---|
| 87 | elif test \! "x`which autoheader 2> /dev/null | grep -v '^no'`" = x; then |
|---|
| 88 | AUTOHEADER=autoheader |
|---|
| 89 | else |
|---|
| 90 | echo "autoconf 2.59+ (autoheader) wasn't found, exiting"; exit 1 |
|---|
| 91 | fi |
|---|
| 92 | fi |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | # --force means overwrite ltmain.sh script if it already exists |
|---|
| 96 | run $LIBTOOLIZE $LIBTOOLIZE_FLAGS || die "Can't execute libtoolize" |
|---|
| 97 | |
|---|
| 98 | run $ACLOCAL $ACLOCAL_FLAGS || die "Can't execute aclocal" |
|---|
| 99 | run $AUTOHEADER || die "Can't execute autoheader" |
|---|
| 100 | run $AUTOMAKE $AUTOMAKE_FLAGS || die "Can't execute automake" |
|---|
| 101 | run $AUTOCONF || die "Can't execute autoconf" |
|---|
| 102 | echo -n "Automade with: " |
|---|
| 103 | $AUTOMAKE --version | head -1 |
|---|
| 104 | echo -n "Configured with: " |
|---|
| 105 | $AUTOCONF --version | head -1 |
|---|