# Copyright (C) 2016-2025 Simon Josefsson
# Copyright (C) 2016 Tim Rühsen

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

GNULIB_REVISION=c89cd2fbd3b9f3d7c5a146247256599714c91ec7

# gnulib library name
source_base=gl
tests_base=gl/tests
m4_base=gl/m4
gnulib_name=libgnu
checkout_only_file=

gnulib_modules="
error
getline
getopt-gnu
gettext-h
git-version-gen
gitlog-to-changelog
inline
lib-msvc-compat
lib-symbol-versions
lib-symbol-visibility
manywarnings
progname
readme-release
stdio
strchrnul
strverscmp
update-copyright
valgrind-tests
version-etc
version-stamp
"

unistring_modules="
localcharset
unictype/joiningtype-of
libunistring-optional
unistr/u32-cpy-alloc
uniconv/u8-strconv-to-locale
unistr/u32-strlen
uniconv/u8-strconv-from-locale
unictype/bidiclass-of
unictype/category-M
unictype/category-test
unictype/scripts
uninorm/base
uninorm/nfc
uninorm/u32-normalize
unistr/u32-to-u8
unistr/u8-to-u32
unistr/u32-cmp
"

# Build prerequisites
buildreq="\
autoconf   2.64
automake   1.14
git        1.4.4
perl       5.5
make       -
gperf      3.0.1
gengetopt  -
"

if ! command -v gtkdocize >/dev/null; then
    # Pacify autoreconf's invocation of gtkdocize.
    GTKDOCIZE="true gtkdocize"
    export GTKDOCIZE
fi

# Prime po/*.po from fall-back copy stored in git.
for poin in po/*.po.in; do
    po=$(echo $poin | sed 's/.in//')
    test -f $po || cp -v $poin $po
done
ls po/*.po | sed 's|.*/||; s|\.po$||' > po/LINGUAS

bootstrap_post_import_hook ()
{
  ${GNULIB_SRCDIR}/gnulib-tool --without-tests --libtool --macro-prefix=unistring --lgpl=3orGPLv2 --dir=. --local-dir=unistring --lib=libunistring --source-base=unistring --m4-base=unistring/m4 --doc-base=doc --aux-dir=build-aux --makefile-name=gnulib.mk --avoid=malloc-posix --avoid=malloca --import ${unistring_modules}

  echo Removing older autopoint/libtool M4 macros...
  for f in `cd m4 && ls *.m4`; do
      test -f gl/m4/$f && rm -fv m4/$f
      test -f unistring/m4/$f && rm -fv m4/$f
  done

  if ! gtkdocize --copy; then
      echo "warning: gtkdocize missing -- gtk-doc manual will be missing"
      # rm because gtk-doc.make might be a link to a protected file
      rm -f gtk-doc.make
      echo "EXTRA_DIST =" > gtk-doc.make
      echo "CLEANFILES =" >> gtk-doc.make
  fi

  # Automake requires that ChangeLog exist.
  touch ChangeLog || return 1
}

bootstrap_epilogue ()
{
    # Run automake again.  It seems the first time ./bootstrap runs
    # automake, it will not add some files to am__DIST_COMMON in
    # top-level Makefile.in, but on subsequent runs (for example
    # through autoreconf, which is triggered on 'make release') it
    # will add the files.  The missing files include
    # build-aux/depcomp, build-aux/mdate-sh, build-aux/texinfo.texi,
    # and build-aux/ylwrap.  We want the am__DIST_COMMON value to be
    # identical so that "make dist" and "make release" tarballs are
    # identical and reproducible.
    ${AUTOMAKE=automake} --no-force
}
