1#!/bin/bash 2test -n "$srcdir" || srcdir=`dirname "$0"` 3test -n "$srcdir" || srcdir=. 4 5# When repos are forked on GitLab tags aren't copied thus making 6# git-version-gen producing incorrect version ("UNKNOWN") which in turn causes 7# CI build failures. To workaround this reconstruct version from ChangeLogs 8# files (handy updated on every release). If git describe is not working and we 9# are not in dist package - take version from the top-most ChangeLog file. 10if [ ! -e .tarball-version ] && 11 ! git describe >/dev/null 2>&1; then 12 ls ChangeLogs \ 13 | sort -Vr \ 14 | grep -m1 -P -o '(?<=ChangeLog-).*' > .tarball-version 15 read v < .tarball-version 16 echo >&2 "Package version reconstructed from ChangeLog: $v" 17fi 18 19patchdir="$srcdir/patches" 20 21# Suppress warnings about obsolete macros if still needed (#122) 22ac_dir=$(aclocal --print-ac-dir) 23if test -r "$ac_dir/ax_create_stdint_h.m4"; then 24 serial=$(awk '/#serial/{ print $2 }' "$ac_dir/ax_create_stdint_h.m4") 25 if test "$serial" -lt 21; then 26 m4_dir=$(cd $srcdir; autoconf -t 'AC_CONFIG_MACRO_DIR:$%') 27 target="$srcdir/$m4_dir/ax_create_stdint_h.m4" 28 echo "Copying file to $target" 29 cp "$ac_dir/ax_create_stdint_h.m4" "$srcdir/$m4_dir" 30 if test "$serial" -lt 20; then 31 echo "patching file $target to #serial 20" 32 patch --quiet $target \ 33 "$patchdir/ax_create_stdint_h.19-20.m4.patch" 34 fi 35 echo "patching file $target to #serial 21" 36 patch --quiet "$target" \ 37 "$patchdir/ax_create_stdint_h.20-21.m4.patch" 38 fi 39fi 40 41autoreconf --force --install --verbose --warnings=all "$srcdir" 42patch "$srcdir/ltmain.sh" "$patchdir/ltmain.sh.patch" 43patch "$srcdir/po/Rules-quot" "$patchdir/Rules-quot.patch" 44autoreconf "$srcdir" 45 46# Taken from https://gitlab.com/utsushi/utsushi/blob/master/bootstrap 47# 48# Sanity check the result to catch the most common errors that are 49# not diagnosed by autoreconf itself (or could use some extra help 50# explaining what to do in those cases). 51 52if grep AX_CXX_COMPILE_STDCXX "$srcdir/configure" >/dev/null 2>&1; then 53 cat <<EOF 54It seems 'aclocal' could not find the autoconf macros used to check 55for C++ standard's compliance. 56 57These macros are available in the 'autoconf-archive'. If you have 58this archive installed, it is probably installed in a location that 59is not searched by default. In that case, please note this via: 60 61 `autoconf -t AC_INIT:'$3'` 62 63If you haven't installed the 'autoconf-archive', please do so and 64rerun: 65 66 $0 $* 67 68If the 'autoconf-archive' is not packaged for your operating system, 69you can find the sources at: 70 71 http://www.gnu.org/software/autoconf-archive/ 72 73EOF 74 exit 1 75fi 76