# bootstrap.conf (GNU coreutils) version 2011-10-06
# Written by Gary V. Vaughan, 2010

# Copyright (C) 2010, 2011 Free Software Foundation, Inc.

# This file is part of GNU coreutils.
#
# GNU coreutils 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.
#
# GNU coreutils 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/>.


## -------------- ##
## Configuration. ##
## -------------- ##

# List of programs, minimum versions, and software urls required to
# bootstrap, maintain and release GNU coreutils.

# Build prerequisites
buildreq='
        bison    -     http://www.gnu.org/s/bison
        git      1.4.4 http://git-scm.com
        gperf    -     http://www.gnu.org/s/gperf
        gzip     -     http://www.gnu.org/s/gzip
        makeinfo -     http://www.gnu.org/s/texinfo
        patch    -     http://www.gnu.org/s/patch
        perl     5.5   http://perl.com
        rsync    -     http://www.samba.org/rsync
        tar      -     http://www.gnu.org/s/tar
        xz       -     http://tukaani.org/xz
'

# Instructions on how to install packages in $buildreq.
buildreq_readme='README-prereq'

# File that should exist in the top directory of a checked out hierarchy,
# but not in a distribution tarball.
checkout_only_file='README-hacking'

# Non-default gnulib directory options.
gnulib_name=libcoreutils
gnulib_mk=gnulib.mk
local_gl_dir=gl
tests_base=gnulib-tests

# Additional gnulib-tool options to use.
gnulib_tool_options='
        --no-changelog
        --avoid=canonicalize-lgpl
        --avoid=dummy
        --with-tests
'

# gnulib modules used by this package.
gnulib_modules='
        acl
        alignof
        alloca
        announce-gen
        areadlink-with-size
        argmatch
        argv-iter
        assert
        autobuild
        backupfile
        base64
        c-strcase
        c-strtod
        c-strtold
        calloc-gnu
        canon-host
        canonicalize
        chown
        cloexec
        closein
        closeout
        config-h
        configmake
        crypto/md5
        crypto/sha1
        crypto/sha256
        crypto/sha512
        cycle-check
        d-ino
        d-type
        di-set
        diacrit
        dirfd
        dirname
        do-release-commit-and-tag
        dtoastr
        dup2
        environ
        error
        euidaccess
        exclude
        exitfail
        faccessat
        fadvise
        fchdir
        fclose
        fcntl
        fcntl-safer
        fdl
        fdutimensat
        file-type
        fileblocks
        filemode
        filenamecat
        filevercmp
        fnmatch-gnu
        fopen-safer
        fprintftime
        freopen
        freopen-safer
        fseeko
        fsusage
        fsync
        ftello
        ftoastr
        fts
        full-read
        full-write
        getgroups
        gethrxtime
        getline
        getloadavg
        getndelim2
        getopt-gnu
        getpagesize
        getpass-gnu
        gettext
        gettime
        gettimeofday
        getugroups
        getusershell
        git-version-gen
        gitlog-to-changelog
        gnu-make
        gnu-web-doc-update
        gnumakefile
        gnupload
        group-member
        hard-locale
        hash
        hash-pjw
        heap
        host-os
        human
        idcache
        ignore-value
        inttostr
        inttypes
        isapipe
        isblank
        largefile
        lchmod
        lchown
        ldtoastr
        lib-ignore
        linebuffer
        link
        link-follow
        linkat
        long-options
        lstat
        maintainer-makefile
        malloc-gnu
        manywarnings
        mbrlen
        mbrtowc
        mbsalign
        mbswidth
        memcasecmp
        memchr
        memcmp2
        mempcpy
        memrchr
        mgetgroups
        mkancesdirs
        mkdir
        mkdir-p
        mkstemp
        mktime
        modechange
        mountlist
        mpsort
        netinet_in
        nproc
        obstack
        parse-datetime
        perl
        physmem
        posix-shell
        posixtm
        posixver
        priv-set
        progname
        propername
        pthread
        putenv
        quote
        quotearg
        randint
        randperm
        read-file
        readlink
        readtokens
        readtokens0
        readutmp
        realloc-gnu
        regex
        remove
        rename
        rmdir
        root-dev-ino
        rpmatch
        safe-read
        same
        save-cwd
        savedir
        savewd
        selinux-at
        settime
        sig2str
        sigaction
        ssize_t
        stat-macros
        stat-size
        stat-time
        stdbool
        stdlib-safer
        stpcpy
        stpncpy
        strdup-posix
        strftime
        strsignal
        strtod
        strtoimax
        strtoumax
        symlink
        sys_ioctl
        sys_stat
        sys_wait
        termios
        timer-time
        timespec
        tzset
        uname
        unicodeio
        unistd-safer
        unlink-busy
        unlocked-io
        unsetenv
        update-copyright
        uptime
        useless-if-before-free
        userspec
        utimecmp
        utimens
        vasprintf-posix
        vc-list-files
        verify
        verror
        version-etc-fsf
        wcwidth
        wcswidth
        winsz-ioctl
        winsz-termios
        write-any-file
        xalloc
        xfreopen
        xgetcwd
        xgetgroups
        xgethostname
        xmemcoll
        xnanosleep
        xprintf
        xprintf-posix
        xreadlink
        xstrtod
        xstrtoimax
        xstrtol
        xstrtold
        xstrtoumax
        yesno
'

# Other locale categories that need message catalogs.
extra_locale_categories=LC_TIME

# Additional options to xgettext.
xgettext_options=$xgettext_options'
        --from-code=UTF-8
'


## --------------- ##
## Hook functions. ##
## --------------- ##

# coreutils_force_changelog
# -------------------------
# Automake requires that ChangeLog exist.
coreutils_force_changelog ()
{
    $debug_cmd

    touch ChangeLog || exit 1
}
func_add_hook func_gnulib_tool coreutils_force_changelog


# coreutils_cleanup_changelog
# ---------------------------
# Remove the empty ChangeLog we created earlier.
zile_cleanup_changelog ()
{
    $debug_cmd

    test -n Changelog || rm ChangeLog || exit 1
}
func_add_hook func_fini coreutils_cleanup_changelog


# coreutils_inject_makefile_macro_assignments
# -------------------------------------------
# Automatically ensure that we declare all the Automake variables
# assigned only with `+=' in the includable `gnulib.mk' files generated
# by `gnulib-tool'.  This function doesn't maintain the `=' assignments
# in `Makefile.am', so you could end up with old unused entries if you
# don't prune the dead code regularly.
coreutils_inject_makefile_macro_assignments ()
{
    $debug_cmd

    # For all directories containing a `gnulib-tool' generated
    # `$gnulib_mk'...
    for dir in lib gnulib-tests
    do
      M="$dir/Makefile.am"

      # Contains the path of a temporary file containing edited
      # Makefile.am if changes were necessary.
      T=

      # Files in this directory that might append to macros.
      files="$M"
      if test x"$M" != "$dir/$gnulib_mk"; then
        files="$files $dir/$gnulib_mk"
      fi

      # ...list each macro assigned with `+='...
      for macro in `$SED -n 's|#.*$||
          / *+= */{
              s| *+=.*$||
              p
          }' $files | sort -u`
      do
        # ...which is not first assigned with `=' in either `gnulib.mk'
        # or 'Makefile.am' in the same directory...
        if cat $files \
            |$SED -e 's|#.*$||' \
            |func_grep_q "^$macro *= *"; then :
        else
          func_verbose "injecting initial \`$macro =' to \`$M'"

          # ...then inject an `=' assignment above the `include
          # gnulib.mk' line.
          test -n "$T" || {
            T="${M}T$$"
            trap 'x=$?; rm $T; exit $x' 1 2 13 15

            $SED '/^include '"$gnulib_mk"'/,$d' "$M" > "$T"
          }
          echo "$macro =" >> "$T"
        fi
      done #/macro

      # If we injected any macro assignments, tidy up our file droppings.
      test x = "x$T" || {
        func_echo "edited \`$M' (backup in \`$M~')"

        $SED -n '/^include '"$gnulib_mk"'/,$p' "$M" >> "$T"
        mv -f "$M" "$M~"
        mv -f "$T" "$M"
        trap - 1 2 13 15
      }

    done   #/dir
}
func_add_hook func_gnulib_tool coreutils_inject_makefile_macro_assignments


# coreutils_fixup_gnulib_tests_paths
# ----------------------------------
# Change paths in gnulib-tests/gnulib.mk from "../.." to "..".
coreutils_fixup_gnulib_tests_paths ()
{
    $debug_cmd

    $SED -i '' -e 's,\.\./\.\.,..,g' \
      gnulib-tests/gnulib.mk
}
func_add_hook func_fini coreutils_fixup_gnulib_tests_paths


# coreutils_optimise_po_makefile_grep
# -----------------------------------
# Since this is a "GNU" package, replace this line
#   if LC_ALL=C grep 'GNU @PACKAGE@' $(top_srcdir)/* 2>/dev/null \
#      | grep -v 'libtool:' >/dev/null; then
# with this:
#   if true; then
# Why?  That pipeline searches all files in $(top_srcdir), and if you
# happen to have large files (or apparently large sparse files), the
# first grep may well run out of memory.
coreutils_optimise_po_makefile_grep ()
{
    $debug_cmd

    perl -pi -e 's/if LC_ALL=C grep .GNU .PACKAGE.*; then/if true; then/' \
      po/Makefile.in.in
}
func_add_hook func_fini coreutils_optimise_po_makefile_grep


# Local variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "# bootstrap.conf (GNU coreutils) version "
# time-stamp-format: "%:y-%02m-%02d"
# time-stamp-end: "$"
# End:
