]> git.ipfire.org Git - thirdparty/lldpd.git/blob - autogen.sh
Merge pull request #391 from Polynomial-C/1.0.5-gentoo_seccomp
[thirdparty/lldpd.git] / autogen.sh
1 #!/bin/sh
2
3 set -e
4
5 [ ! -e .gitmodules ] || [ ! -e .git ] || {
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 # 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
65 echo "autogen.sh: start libtoolize to get ltmain.sh"
66 ${LIBTOOLIZE} --copy --force
67 echo "autogen.sh: reconfigure with autoreconf"
68 ${AUTORECONF} -vif -I m4 || {
69 echo "autogen.sh: autoreconf has failed ($?), let's do it manually"
70 for dir in $PWD *; do
71 [ -d "$dir" ] || continue
72 [ -f "$dir"/configure.ac ] || [ -f "$dir"/configure.in ] || continue
73 echo "autogen.sh: configure `basename $dir`"
74 (cd "$dir" && ${ACLOCAL} -I m4 ${ACLOCAL_FLAGS})
75 if [ x"$dir" = x"$PWD" ]; then
76 (cd "$dir" && check_pkg_config)
77 fi
78 (cd "$dir" && ${LIBTOOLIZE} --automake --copy --force)
79 (cd "$dir" && ${ACLOCAL} -I m4 ${ACLOCAL_FLAGS})
80 (cd "$dir" && ${AUTOCONF} --force)
81 (cd "$dir" && ${AUTOHEADER})
82 (cd "$dir" && ${AUTOMAKE} --add-missing --copy --force-missing)
83 done
84 }
85
86 echo "autogen.sh: for the next step, run ./configure"
87
88 exit 0