ed08d182f2a0823bc637439ec7e21b06d780d627
[awesomized/libmemcached] / config / autorun.sh
1 #!/bin/sh
2 # Copyright (C) 2011 Brian Aker, brian@tangent.org
3 # All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
7 #
8 # 1. Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # 3. The name of the author may not be used to endorse or promote products
14 # derived from this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 die() { echo "$@"; exit 1; }
29
30 run() {
31 echo "$ARGV0: running \`$@' $ARGS"
32 $@ $ARGS
33 }
34
35 # Try to locate a program by using which, and verify that the file is an
36 # executable
37 locate_binary() {
38 for f in $@
39 do
40 file=`which $f 2>/dev/null | grep -v '^no '`
41 if test -n "$file" -a -x "$file"; then
42 echo $file
43 return 0
44 fi
45 done
46
47 echo ""
48 return 1
49 }
50
51
52 AUTORECONF_FLAGS=" --install --verbose -Wall"
53
54 if test -f config/pre_hook.sh
55 then
56 . config/pre_hook.sh
57 fi
58
59 if test x$AUTORECONF = x; then
60 AUTORECONF=`locate_binary autoreconf`
61 if test x$AUTORECONF = x; then
62 die "Did not find a supported autoconf"
63 fi
64 fi
65
66 run $AUTORECONF $AUTORECONF_FLAGS || die "Can't execute autoreconf"