autogen.sh 1.34 KB
Newer Older
1
2
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash

## have() check for a program
# Usage: have [-r|-o] [-m <error message>] <program>
#
# Options:
#   -o:           The <program> is optional; don't exit on failure [default]
#   -r:           The <program> is required; exit if not found
#   -m <message>: Message to show if program is not found in place of the
#                 default one.
have () {
  local optional=true, message=""
  
  for o; do
    case "$o" in
      -o) optional=true;;
      -r) optional=false;;
      -m) message="$1"; shift;;
      *) break;;
    esac
    shift
  done
  
  echo -n "checking for \`$1'...	"
  cmd="`which "$1" 2>/dev/null`"
  if [ "x$cmd" = "x" ]; then
    echo "not found!" >&2
    if [ "x$message" != "x" ]; then
      echo "$message" >&2
    else
      echo "The program \`$1' cannot be found on your system." >&2
      if $optional; then
        echo "Continuing without." >&2
      else
        echo "Cannot continue without it;" \
             "please fix this problem and retry." >&2
      fi
    fi
    $optional && return 1 || exit 127
  else
    echo "ok, \`$cmd'."
  fi
  
  return 0
}

# check for needed autotools
have -r automake
have -r autoconf
have -r autoheader
have -r autoreconf
have -r libtool
have -r libtoolize

mkdir -p build/aux          || exit 1
mkdir -p build/m4           || exit 1
autoreconf -vfi             || exit 1

#~ ./configure "$@"