]>
Commit | Line | Data |
---|---|---|
3e549e52 | 1 | #!/bin/sh |
3e549e52 | 2 | |
0ac0576e | 3 | set -e |
3e549e52 | 4 | |
96a5a328 | 5 | [ ! -e .gitmodules ] || [ ! -e .git ] || { |
0ac0576e VB |
6 | echo "autogen.sh: updating git submodules" |
7 | git submodule init | |
8 | git submodule update | |
3e549e52 VB |
9 | } |
10 | ||
971d12ce VB |
11 | case "$(uname)" in |
12 | Darwin) | |
13 | LIBTOOLIZE=${LIBTOOLIZE:-glibtoolize} | |
14 | ;; | |
15 | *) | |
16 | LIBTOOLIZE=${LIBTOOLIZE:-libtoolize} | |
17 | ;; | |
18 | esac | |
bb1666fe VB |
19 | AUTORECONF=${AUTORECONF:-autoreconf} |
20 | ACLOCAL=${ACLOCAL:-aclocal} | |
21 | AUTOCONF=${AUTOCONF:-autoconf} | |
22 | AUTOHEADER=${AUTOHEADER:-autoheader} | |
23 | AUTOMAKE=${AUTOMAKE:-automake} | |
24 | ||
17cd6a2e VB |
25 | # Check we have all tools installed |
26 | check_command() { | |
27 | command -v "${1}" > /dev/null 2>&1 || { | |
28 | >&2 echo "autogen.sh: could not find \`$1'. \`$1' is required to run autogen.sh." | |
29 | exit 1 | |
30 | } | |
31 | } | |
32 | check_command "$LIBTOOLIZE" | |
33 | check_command "$AUTORECONF" | |
34 | check_command "$ACLOCAL" | |
35 | check_command "$AUTOCONF" | |
36 | check_command "$AUTOHEADER" | |
37 | check_command "$AUTOMAKE" | |
38 | ||
79790b96 VB |
39 | # Absence of pkg-config or misconfiguration can make some odd error |
40 | # messages, we check if it is installed correctly. See: | |
41 | # https://blogs.oracle.com/mandy/entry/autoconf_weirdness | |
42 | # | |
43 | # We cannot just check for pkg-config command, we need to check for | |
44 | # PKG_* macros. The pkg-config command can be defined in ./configure, | |
45 | # we cannot tell anything when not present. | |
46 | check_pkg_config() { | |
47 | grep -q '^AC_DEFUN.*PKG_CHECK_MODULES' aclocal.m4 || { | |
48 | cat <<EOF >&2 | |
49 | autogen.sh: could not find PKG_CHECK_MODULES macro. | |
50 | ||
51 | Either pkg-config is not installed on your system or | |
52 | \`pkg.m4' is missing or not found by aclocal. | |
53 | ||
54 | If \`pkg.m4' is installed at an unusual location, re-run | |
55 | \`autogen.sh' by setting \`ACLOCAL_FLAGS': | |
56 | ||
57 | ACLOCAL_FLAGS="-I <prefix>/share/aclocal" ./autogen.sh | |
58 | ||
59 | EOF | |
60 | exit 1 | |
61 | } | |
62 | } | |
63 | ||
64 | ||
0ac0576e | 65 | echo "autogen.sh: start libtoolize to get ltmain.sh" |
bb1666fe | 66 | ${LIBTOOLIZE} --copy --force |
0ac0576e | 67 | echo "autogen.sh: reconfigure with autoreconf" |
e9b22e1e | 68 | ${AUTORECONF} -vif -I m4 || { |
0ac0576e | 69 | echo "autogen.sh: autoreconf has failed ($?), let's do it manually" |
e9b22e1e VB |
70 | for dir in $PWD *; do |
71 | [ -d "$dir" ] || continue | |
72 | [ -f "$dir"/configure.ac ] || [ -f "$dir"/configure.in ] || continue | |
6a8ed660 | 73 | echo "autogen.sh: configure `basename $dir`" |
79790b96 | 74 | (cd "$dir" && ${ACLOCAL} -I m4 ${ACLOCAL_FLAGS}) |
448796a1 VB |
75 | if [ x"$dir" = x"$PWD" ]; then |
76 | (cd "$dir" && check_pkg_config) | |
77 | fi | |
bb1666fe | 78 | (cd "$dir" && ${LIBTOOLIZE} --automake --copy --force) |
79790b96 | 79 | (cd "$dir" && ${ACLOCAL} -I m4 ${ACLOCAL_FLAGS}) |
bb1666fe VB |
80 | (cd "$dir" && ${AUTOCONF} --force) |
81 | (cd "$dir" && ${AUTOHEADER}) | |
82 | (cd "$dir" && ${AUTOMAKE} --add-missing --copy --force-missing) | |
3e549e52 | 83 | done |
3e549e52 VB |
84 | } |
85 | ||
0ac0576e | 86 | echo "autogen.sh: for the next step, run ./configure" |
3e549e52 | 87 | |
0ac0576e | 88 | exit 0 |