Work inspired by matt knox
[m6w6/libmemcached] / config / autorun.sh
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 AUTOMAKE_FLAGS="--add-missing --copy --force"
14 # AUTOCONF=${AUTOCONF:-autoconf}
15
16 ARGV0=$0
17 ARGS="$@"
18
19
20 run() {
21 echo "$ARGV0: running \`$@' $ARGS"
22 $@ $ARGS
23 }
24
25 ## jump out if one of the programs returns 'false'
26 set -e
27
28 ## We do not currently support glibtoolize
29 if test x$LIBTOOLIZE = x; then
30 if test \! "x`which glibtoolize 2> /dev/null | grep -v '^no'`" = x; then
31 LIBTOOLIZE=glibtoolize
32 elif test \! "x`which libtoolize-1.5 2> /dev/null | grep -v '^no'`" = x; then
33 LIBTOOLIZE=libtoolize-1.5
34 elif test \! "x`which libtoolize 2> /dev/null | grep -v '^no'`" = x; then
35 LIBTOOLIZE=libtoolize
36 else
37 echo "libtoolize 1.5.x wasn't found, exiting"; exit 0
38 fi
39 fi
40
41 ## suse has aclocal and aclocal-1.9
42 if test x$ACLOCAL = x; then
43 if test \! "x`which aclocal-1.10 2> /dev/null | grep -v '^no'`" = x; then
44 ACLOCAL=aclocal-1.10
45 elif test \! "x`which aclocal-1.9 2> /dev/null | grep -v '^no'`" = x; then
46 ACLOCAL=aclocal-1.9
47 elif test \! "x`which aclocal19 2> /dev/null | grep -v '^no'`" = x; then
48 ACLOCAL=aclocal19
49 elif test \! "x`which aclocal 2> /dev/null | grep -v '^no'`" = x; then
50 ACLOCAL=aclocal
51 else
52 echo "automake 1.9.x (aclocal) wasn't found, exiting"; exit 0
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 automake-1.9 2> /dev/null | grep -v '^no'`" = x; then
60 AUTOMAKE=automake-1.9
61 elif test \! "x`which automake19 2> /dev/null | grep -v '^no'`" = x; then
62 AUTOMAKE=automake19
63 elif test \! "x`which automake 2> /dev/null | grep -v '^no'`" = x; then
64 AUTOMAKE=automake
65 else
66 echo "automake 1.9.x wasn't found, exiting"; exit 0
67 fi
68 fi
69
70
71 ## macosx has autoconf-2.59 and autoconf-2.60
72 if test x$AUTOCONF = x; then
73 if test \! "x`which autoconf-2.59 2> /dev/null | grep -v '^no'`" = x; then
74 AUTOCONF=autoconf-2.59
75 elif test \! "x`which autoconf259 2> /dev/null | grep -v '^no'`" = x; then
76 AUTOCONF=autoconf259
77 elif test \! "x`which autoconf 2> /dev/null | grep -v '^no'`" = x; then
78 AUTOCONF=autoconf
79 else
80 echo "autoconf 2.59+ wasn't found, exiting"; exit 0
81 fi
82 fi
83
84 if test x$AUTOHEADER = x; then
85 if test \! "x`which autoheader-2.59 2> /dev/null | grep -v '^no'`" = x; then
86 AUTOHEADER=autoheader-2.59
87 elif test \! "x`which autoheader259 2> /dev/null | grep -v '^no'`" = x; then
88 AUTOHEADER=autoheader259
89 elif test \! "x`which autoheader 2> /dev/null | grep -v '^no'`" = x; then
90 AUTOHEADER=autoheader
91 else
92 echo "autoconf 2.59+ (autoheader) wasn't found, exiting"; exit 0
93 fi
94 fi
95
96
97 # --force means overwrite ltmain.sh script if it already exists
98 run $LIBTOOLIZE $LIBTOOLIZE_FLAGS || die "Can't execute libtoolize"
99
100 run $ACLOCAL $ACLOCAL_FLAGS || die "Can't execute aclocal"
101 run $AUTOHEADER || die "Can't execute autoheader"
102
103 # --add-missing instructs automake to install missing auxiliary files
104 # and --force to overwrite them if they already exist
105 run $AUTOMAKE $AUTOMAKE_FLAGS || die "Can't execute automake"
106 run $AUTOCONF || die "Can't execute autoconf"
107
108 echo -n "Automade with: "
109 $AUTOMAKE --version | head -1
110 echo -n "Configured with: "
111 $AUTOCONF --version | head -1
112