]> git.ipfire.org Git - thirdparty/lldpd.git/blob - autogen.sh
build: check for needed commands in autogen.sh
[thirdparty/lldpd.git] / autogen.sh
1 #!/bin/sh
2
3 set -e
4
5 [ ! -d .gitmodules ] || {
6 echo "autogen.sh: updating git submodules"
7 git submodule init
8 git submodule update
9 }
10
11 case "$(uname)" in
12 Darwin)
13 LIBTOOLIZE=${LIBTOOLIZE:-glibtoolize}
14 ;;
15 *)
16 LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}
17 ;;
18 esac
19 AUTORECONF=${AUTORECONF:-autoreconf}
20 ACLOCAL=${ACLOCAL:-aclocal}
21 AUTOCONF=${AUTOCONF:-autoconf}
22 AUTOHEADER=${AUTOHEADER:-autoheader}
23 AUTOMAKE=${AUTOMAKE:-automake}
24
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
39 echo "autogen.sh: start libtoolize to get ltmain.sh"
40 ${LIBTOOLIZE} --copy --force
41 echo "autogen.sh: reconfigure with autoreconf"
42 ${AUTORECONF} -vif -I m4 || {
43 echo "autogen.sh: autoreconf has failed ($?), let's do it manually"
44 for dir in $PWD *; do
45 [ -d "$dir" ] || continue
46 [ -f "$dir"/configure.ac ] || [ -f "$dir"/configure.in ] || continue
47 echo "autogen.sh: configure `basename $dir`"
48 (cd "$dir" && ${ACLOCAL} -I m4)
49 (cd "$dir" && ${LIBTOOLIZE} --automake --copy --force)
50 (cd "$dir" && ${ACLOCAL} -I m4)
51 (cd "$dir" && ${AUTOCONF} --force)
52 (cd "$dir" && ${AUTOHEADER})
53 (cd "$dir" && ${AUTOMAKE} --add-missing --copy --force-missing)
54 done
55 }
56
57 echo "autogen.sh: for the next step, run ./configure"
58
59 exit 0