1141cc406Sopenharmony_ci#!/bin/bash
2141cc406Sopenharmony_citest -n "$srcdir" || srcdir=`dirname "$0"`
3141cc406Sopenharmony_citest -n "$srcdir" || srcdir=.
4141cc406Sopenharmony_ci
5141cc406Sopenharmony_cipatchdir="$srcdir/patches"
6141cc406Sopenharmony_ci
7141cc406Sopenharmony_ci# Suppress warnings about obsolete macros if still needed (#122)
8141cc406Sopenharmony_ciac_dir=$(aclocal --print-ac-dir)
9141cc406Sopenharmony_ciif test -r "$ac_dir/ax_create_stdint_h.m4"; then
10141cc406Sopenharmony_ci    serial=$(awk '/#serial/{ print $2 }' "$ac_dir/ax_create_stdint_h.m4")
11141cc406Sopenharmony_ci    if test "$serial" -lt 21; then
12141cc406Sopenharmony_ci	m4_dir=$(cd $srcdir; autoconf -t 'AC_CONFIG_MACRO_DIR:$%')
13141cc406Sopenharmony_ci	target="$srcdir/$m4_dir/ax_create_stdint_h.m4"
14141cc406Sopenharmony_ci	echo "Copying file to $target"
15141cc406Sopenharmony_ci	cp "$ac_dir/ax_create_stdint_h.m4" "$srcdir/$m4_dir"
16141cc406Sopenharmony_ci	if test "$serial" -lt 20; then
17141cc406Sopenharmony_ci	    echo "patching file $target to #serial 20"
18141cc406Sopenharmony_ci	    patch --quiet $target \
19141cc406Sopenharmony_ci		  "$patchdir/ax_create_stdint_h.19-20.m4.patch"
20141cc406Sopenharmony_ci	fi
21141cc406Sopenharmony_ci	echo "patching file $target to #serial 21"
22141cc406Sopenharmony_ci	patch --quiet "$target" \
23141cc406Sopenharmony_ci	      "$patchdir/ax_create_stdint_h.20-21.m4.patch"
24141cc406Sopenharmony_ci    fi
25141cc406Sopenharmony_cifi
26141cc406Sopenharmony_ci
27141cc406Sopenharmony_ciautoreconf --force --install --verbose --warnings=all "$srcdir"
28141cc406Sopenharmony_cipatch "$srcdir/ltmain.sh" "$patchdir/ltmain.sh.patch"
29141cc406Sopenharmony_cipatch "$srcdir/po/Rules-quot" "$patchdir/Rules-quot.patch"
30141cc406Sopenharmony_ciautoreconf "$srcdir"
31141cc406Sopenharmony_ci
32141cc406Sopenharmony_ci# Taken from https://gitlab.com/utsushi/utsushi/blob/master/bootstrap
33141cc406Sopenharmony_ci#
34141cc406Sopenharmony_ci# Sanity check the result to catch the most common errors that are
35141cc406Sopenharmony_ci# not diagnosed by autoreconf itself (or could use some extra help
36141cc406Sopenharmony_ci# explaining what to do in those cases).
37141cc406Sopenharmony_ci
38141cc406Sopenharmony_ciif grep AX_CXX_COMPILE_STDCXX "$srcdir/configure" >/dev/null 2>&1; then
39141cc406Sopenharmony_ci    cat <<EOF
40141cc406Sopenharmony_ciIt seems 'aclocal' could not find the autoconf macros used to check
41141cc406Sopenharmony_cifor C++ standard's compliance.
42141cc406Sopenharmony_ci
43141cc406Sopenharmony_ciThese macros are available in the 'autoconf-archive'.  If you have
44141cc406Sopenharmony_cithis archive installed, it is probably installed in a location that
45141cc406Sopenharmony_ciis not searched by default.  In that case, please note this via:
46141cc406Sopenharmony_ci
47141cc406Sopenharmony_ci  `autoconf -t AC_INIT:'$3'`
48141cc406Sopenharmony_ci
49141cc406Sopenharmony_ciIf you haven't installed the 'autoconf-archive', please do so and
50141cc406Sopenharmony_cirerun:
51141cc406Sopenharmony_ci
52141cc406Sopenharmony_ci  $0 $*
53141cc406Sopenharmony_ci
54141cc406Sopenharmony_ciIf the 'autoconf-archive' is not packaged for your operating system,
55141cc406Sopenharmony_ciyou can find the sources at:
56141cc406Sopenharmony_ci
57141cc406Sopenharmony_ci  http://www.gnu.org/software/autoconf-archive/
58141cc406Sopenharmony_ci
59141cc406Sopenharmony_ciEOF
60141cc406Sopenharmony_ci    exit 1
61141cc406Sopenharmony_cifi
62