Mercurial > octave
comparison bootstrap-funclib.sh @ 32477:e6d339b9309d
maint: Update gnulib.
* bootstrap.conf (GNULIB_REVISION):
Update to 7a38f30f925db7d486460c18df41413f3c7ef74b.
* bootstrap, autogen.sh, autopull.sh, bootstrap-funclib.sh: Update with
./bootstrap --bootstrap-sync.
* build-aux/gnulib-bootstrap-git-fetch.diff: Refresh patch for new gnulib
version.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Mon, 20 Nov 2023 18:41:06 +0100 |
parents | e98fb9b4be86 |
children | c51b07a71421 |
comparison
equal
deleted
inserted
replaced
32476:9ad5b8864d3e | 32477:e6d339b9309d |
---|---|
1 # A library of shell functions for autopull.sh, autogen.sh, and bootstrap. | 1 # A library of shell functions for autopull.sh, autogen.sh, and bootstrap. |
2 | 2 |
3 # Copyright (C) 2003-2022 Free Software Foundation, Inc. | 3 scriptlibversion=2023-08-29.21; # UTC |
4 | |
5 # Copyright (C) 2003-2023 Free Software Foundation, Inc. | |
4 # | 6 # |
5 # This program is free software: you can redistribute it and/or modify | 7 # This program is free software: you can redistribute it and/or modify |
6 # it under the terms of the GNU General Public License as published by | 8 # it under the terms of the GNU General Public License as published by |
7 # the Free Software Foundation, either version 3 of the License, or | 9 # the Free Software Foundation, either version 3 of the License, or |
8 # (at your option) any later version. | 10 # (at your option) any later version. |
21 # version control in the top-level directory of your package. The | 23 # version control in the top-level directory of your package. The |
22 # intent is that all customization can be done with a bootstrap.conf | 24 # intent is that all customization can be done with a bootstrap.conf |
23 # file also maintained in your version control; gnulib comes with a | 25 # file also maintained in your version control; gnulib comes with a |
24 # template build-aux/bootstrap.conf to get you started. | 26 # template build-aux/bootstrap.conf to get you started. |
25 | 27 |
26 scriptversion=2022-07-24.15; # UTC | |
27 | |
28 nl=' | 28 nl=' |
29 ' | 29 ' |
30 | 30 |
31 # Ensure file names are sorted consistently across platforms. | 31 # Ensure file names are sorted consistently across platforms. |
32 LC_ALL=C | 32 LC_ALL=C |
36 PERL="${PERL-perl}" | 36 PERL="${PERL-perl}" |
37 | 37 |
38 default_gnulib_url=https://git.savannah.gnu.org/git/gnulib.git | 38 default_gnulib_url=https://git.savannah.gnu.org/git/gnulib.git |
39 | 39 |
40 # Copyright year, for the --version output. | 40 # Copyright year, for the --version output. |
41 copyright_year=`echo "$scriptversion" | sed -e 's/[^0-9].*//'` | 41 copyright_year=`echo "$scriptlibversion" | sed -e 's/[^0-9].*//'` |
42 copyright="Copyright (C) ${copyright_year} Free Software Foundation, Inc. | 42 copyright="Copyright (C) ${copyright_year} Free Software Foundation, Inc. |
43 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. | 43 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. |
44 This is free software: you are free to change and redistribute it. | 44 This is free software: you are free to change and redistribute it. |
45 There is NO WARRANTY, to the extent permitted by law." | 45 There is NO WARRANTY, to the extent permitted by law." |
46 | 46 |
301 esac | 301 esac |
302 | 302 |
303 # Handle the still-experimental Automake-NG programs specially. | 303 # Handle the still-experimental Automake-NG programs specially. |
304 # They remain named as the mainstream Automake programs ("automake", | 304 # They remain named as the mainstream Automake programs ("automake", |
305 # and "aclocal") to avoid gratuitous incompatibilities with | 305 # and "aclocal") to avoid gratuitous incompatibilities with |
306 # pre-existing usages (by, say, autoreconf, or custom autogen.sh | 306 # preexisting usages (by, say, autoreconf, or custom autogen.sh |
307 # scripts), but correctly identify themselves (as being part of | 307 # scripts), but correctly identify themselves (as being part of |
308 # "GNU automake-ng") when asked their version. | 308 # "GNU automake-ng") when asked their version. |
309 case $app in | 309 case $app in |
310 automake-ng|aclocal-ng) | 310 automake-ng|aclocal-ng) |
311 app=${app%-ng} | 311 app=${app%-ng} |
458 if test -n "$GNULIB_SRCDIR"; then | 458 if test -n "$GNULIB_SRCDIR"; then |
459 # Use GNULIB_SRCDIR directly. | 459 # Use GNULIB_SRCDIR directly. |
460 # We already checked that $GNULIB_SRCDIR references a directory. | 460 # We already checked that $GNULIB_SRCDIR references a directory. |
461 # Verify that it contains a gnulib checkout. | 461 # Verify that it contains a gnulib checkout. |
462 test -f "$GNULIB_SRCDIR/gnulib-tool" \ | 462 test -f "$GNULIB_SRCDIR/gnulib-tool" \ |
463 || die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified, but does not contain gnulib-tool" | 463 || die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified," \ |
464 "but does not contain gnulib-tool" | |
464 elif $use_git; then | 465 elif $use_git; then |
465 gnulib_path=$(git_modules_config submodule.gnulib.path) | 466 gnulib_path=$(git_modules_config submodule.gnulib.path) |
466 test -z "$gnulib_path" && gnulib_path=gnulib | 467 test -z "$gnulib_path" && gnulib_path=gnulib |
467 | 468 |
468 # Get gnulib files. Populate $gnulib_path, possibly updating a | 469 # Get gnulib files. Populate $gnulib_path, possibly updating a |
499 git submodule update -- "$gnulib_path" || exit $? | 500 git submodule update -- "$gnulib_path" || exit $? |
500 | 501 |
501 elif [ ! -d "$gnulib_path" ]; then | 502 elif [ ! -d "$gnulib_path" ]; then |
502 echo "$0: getting gnulib files..." | 503 echo "$0: getting gnulib files..." |
503 | 504 |
504 trap cleanup_gnulib 1 2 13 15 | 505 trap cleanup_gnulib HUP INT PIPE TERM |
505 | 506 |
506 shallow= | 507 shallow= |
507 if test -z "$GNULIB_REVISION"; then | 508 if test -z "$GNULIB_REVISION"; then |
508 if git clone -h 2>&1 | grep -- --depth > /dev/null; then | 509 if git clone -h 2>&1 | grep -- --depth > /dev/null; then |
509 shallow='--depth 2' | 510 shallow='--depth 2' |
519 # support cloning by commit hash. So attempt a shallow fetch by commit | 520 # support cloning by commit hash. So attempt a shallow fetch by commit |
520 # hash to minimize the amount of data downloaded and changes needed to | 521 # hash to minimize the amount of data downloaded and changes needed to |
521 # be processed, which can drastically reduce download and processing | 522 # be processed, which can drastically reduce download and processing |
522 # time for checkout. If the fetch by commit fails, a shallow fetch can | 523 # time for checkout. If the fetch by commit fails, a shallow fetch can |
523 # not be performed because we do not know what the depth of the commit | 524 # not be performed because we do not know what the depth of the commit |
524 # is without fetching all commits. So fallback to fetching all commits. | 525 # is without fetching all commits. So fall back to fetching all |
526 # commits. | |
525 git -C "$gnulib_path" init | 527 git -C "$gnulib_path" init |
526 git -C "$gnulib_path" remote add origin \ | 528 git -C "$gnulib_path" remote add origin \ |
527 ${GNULIB_URL:-$default_gnulib_url} | 529 ${GNULIB_URL:-$default_gnulib_url} |
528 git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \ | 530 git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \ |
529 || git -C "$gnulib_path" fetch origin \ | 531 || git -C "$gnulib_path" fetch origin \ |
530 || cleanup_gnulib | 532 || cleanup_gnulib |
531 git -C "$gnulib_path" reset --hard FETCH_HEAD | 533 git -C "$gnulib_path" reset --hard FETCH_HEAD |
532 fi | 534 fi |
533 | 535 |
534 trap - 1 2 13 15 | 536 trap - HUP INT PIPE TERM |
535 | 537 |
536 elif test -n "$GNULIB_REVISION" \ | 538 elif test -n "$GNULIB_REVISION" \ |
537 && ! git --git-dir="$gnulib_path"/.git cat-file \ | 539 && ! git --git-dir="$gnulib_path"/.git cat-file \ |
538 commit "$GNULIB_REVISION"; then | 540 commit "$GNULIB_REVISION"; then |
539 git --git-dir="$gnulib_path"/.git fetch | 541 git --git-dir="$gnulib_path"/.git fetch |
540 fi | 542 fi |
541 fi | 543 fi |
542 GNULIB_SRCDIR=$gnulib_path | 544 GNULIB_SRCDIR=$gnulib_path |
543 # Verify that the submodule contains a gnulib checkout. | 545 # Verify that the submodule contains a gnulib checkout. |
544 test -f "$gnulib_path/gnulib-tool" \ | 546 test -f "$gnulib_path/gnulib-tool" \ |
545 || die "Error: $gnulib_path is supposed to contain a gnulib checkout, but does not contain gnulib-tool" | 547 || die "Error: $gnulib_path is supposed to contain a gnulib checkout," \ |
548 "but does not contain gnulib-tool" | |
546 fi | 549 fi |
547 | 550 |
548 # XXX Should this be done if $use_git is false? | 551 # XXX Should this be done if $use_git is false? |
549 if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \ | 552 if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \ |
550 && ! git_modules_config submodule.gnulib.url >/dev/null; then | 553 && ! git_modules_config submodule.gnulib.url >/dev/null; then |
561 | 564 |
562 # -------- Upgrading bootstrap to the version found in GNULIB_SRCDIR. -------- | 565 # -------- Upgrading bootstrap to the version found in GNULIB_SRCDIR. -------- |
563 | 566 |
564 upgrade_bootstrap () | 567 upgrade_bootstrap () |
565 { | 568 { |
566 { cmp -s "$medir"/bootstrap "$GNULIB_SRCDIR/top/bootstrap" \ | 569 if test -f "$medir"/bootstrap-funclib.sh; then |
567 && cmp -s "$medir"/bootstrap-funclib.sh "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" \ | 570 update_lib=true |
568 && cmp -s "$medir"/autopull.sh "$GNULIB_SRCDIR/top/autopull.sh" \ | 571 { cmp -s "$medir"/bootstrap "$GNULIB_SRCDIR/top/bootstrap" \ |
569 && cmp -s "$medir"/autogen.sh "$GNULIB_SRCDIR/top/autogen.sh"; \ | 572 && cmp -s "$medir"/bootstrap-funclib.sh \ |
570 } || { | 573 "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" \ |
571 echo "$0: updating bootstrap & companions and restarting..." | 574 && cmp -s "$medir"/autopull.sh "$GNULIB_SRCDIR/top/autopull.sh" \ |
575 && cmp -s "$medir"/autogen.sh "$GNULIB_SRCDIR/top/autogen.sh"; \ | |
576 } | |
577 else | |
578 update_lib=false | |
579 cmp -s "$medir"/bootstrap "$GNULIB_SRCDIR/build-aux/bootstrap" | |
580 fi || { | |
581 if $update_lib; then | |
582 echo "$0: updating bootstrap & companions and restarting..." | |
583 else | |
584 echo "$0: updating bootstrap and restarting..." | |
585 fi | |
572 case $(sh -c 'echo "$1"' -- a) in | 586 case $(sh -c 'echo "$1"' -- a) in |
573 a) ignored=--;; | 587 a) ignored=--;; |
574 *) ignored=ignored;; | 588 *) ignored=ignored;; |
575 esac | 589 esac |
590 u=$update_lib | |
576 exec sh -c \ | 591 exec sh -c \ |
577 '{ if test -f "$1"; then cp "$1" "$3"; else cp "$2" "$3"; fi; } && { if test -f "$4"; then cp "$4" "$5"; else rm -f "$5"; fi; } && { if test -f "$6"; then cp "$6" "$7"; else rm -f "$7"; fi; } && { if test -f "$8"; then cp "$8" "$9"; else rm -f "$9"; fi; } && shift && shift && shift && shift && shift && shift && shift && shift && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \ | 592 '{ if '$u' && test -f "$1"; then cp "$1" "$3"; else cp "$2" "$3"; fi; } && |
593 { if '$u' && test -f "$4"; then cp "$4" "$5"; else rm -f "$5"; fi; } && | |
594 { if '$u' && test -f "$6"; then cp "$6" "$7"; else rm -f "$7"; fi; } && | |
595 { if '$u' && test -f "$8"; then cp "$8" "$9"; else rm -f "$9"; fi; } && | |
596 shift && shift && shift && shift && shift && | |
597 shift && shift && shift && shift && | |
598 exec "${CONFIG_SHELL-/bin/sh}" "$@"' \ | |
578 $ignored \ | 599 $ignored \ |
579 "$GNULIB_SRCDIR/top/bootstrap" "$GNULIB_SRCDIR/build-aux/bootstrap" "$medir/bootstrap" \ | 600 "$GNULIB_SRCDIR/top/bootstrap" "$GNULIB_SRCDIR/build-aux/bootstrap" \ |
601 "$medir/bootstrap" \ | |
580 "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" "$medir/bootstrap-funclib.sh" \ | 602 "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" "$medir/bootstrap-funclib.sh" \ |
581 "$GNULIB_SRCDIR/top/autopull.sh" "$medir/autopull.sh" \ | 603 "$GNULIB_SRCDIR/top/autopull.sh" "$medir/autopull.sh" \ |
582 "$GNULIB_SRCDIR/top/autogen.sh" "$medir/autogen.sh" \ | 604 "$GNULIB_SRCDIR/top/autogen.sh" "$medir/autogen.sh" \ |
583 "$0" "$@" --no-bootstrap-sync | 605 "$0" "$@" --no-bootstrap-sync |
584 } | 606 } |
590 use_gnulib=false | 612 use_gnulib=false |
591 else | 613 else |
592 use_gnulib=true | 614 use_gnulib=true |
593 fi | 615 fi |
594 | 616 |
617 # -------- Fetch auxiliary files from the network. -------------------------- | |
618 | |
619 autopull_usage() { | |
620 cat <<EOF | |
621 Usage: $me [OPTION]... | |
622 Bootstrap this package from the checked-out sources. | |
623 | |
624 Optional environment variables: | |
625 GNULIB_SRCDIR Specifies the local directory where gnulib | |
626 sources reside. Use this if you already | |
627 have gnulib sources on your machine, and | |
628 you want to use these sources. | |
629 GNULIB_REFDIR Specifies the local directory where a gnulib | |
630 repository (with a .git subdirectory) resides. | |
631 Use this if you already have gnulib sources | |
632 and history on your machine, and do not want | |
633 to waste your bandwidth downloading them again. | |
634 GNULIB_URL URL of the gnulib repository. The default is | |
635 $default_gnulib_url, | |
636 which is Gnulib's upstream repository. | |
637 | |
638 Options: | |
639 --bootstrap-sync if this bootstrap script is not identical to | |
640 the version in the local gnulib sources, | |
641 update this script, and then restart it with | |
642 /bin/sh or the shell \$CONFIG_SHELL | |
643 --no-bootstrap-sync do not check whether bootstrap is out of sync | |
644 --force attempt to bootstrap even if the sources seem | |
645 not to have been checked out | |
646 --no-git do not use git to update gnulib. Requires that | |
647 \$GNULIB_SRCDIR or the --gnulib-srcdir option | |
648 points to a gnulib repository with the correct | |
649 revision | |
650 --skip-po do not download po files | |
651 EOF | |
652 bootstrap_print_option_usage_hook | |
653 cat <<EOF | |
654 If the file bootstrap.conf exists in the same directory as this script, its | |
655 contents are read as shell variables to configure the bootstrap. | |
656 | |
657 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR | |
658 are honored. | |
659 | |
660 Gnulib sources can be fetched in various ways: | |
661 | |
662 * If the environment variable GNULIB_SRCDIR is set (either as an | |
663 environment variable or via the --gnulib-srcdir option), then sources | |
664 are fetched from that local directory. If it is a git repository and | |
665 the configuration variable GNULIB_REVISION is set in bootstrap.conf, | |
666 then that revision is checked out. | |
667 | |
668 * Otherwise, if this package is in a git repository with a 'gnulib' | |
669 submodule configured, then that submodule is initialized and updated | |
670 and sources are fetched from there. If GNULIB_REFDIR is set (either | |
671 as an environment variable or via the --gnulib-refdir option) and is | |
672 a git repository, then it is used as a reference. | |
673 | |
674 * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources | |
675 are cloned into that directory using git from \$GNULIB_URL, defaulting | |
676 to $default_gnulib_url. | |
677 If the configuration variable GNULIB_REVISION is set in bootstrap.conf, | |
678 then that revision is checked out. | |
679 | |
680 * Otherwise, the existing Gnulib sources in the 'gnulib' directory are | |
681 used. If it is a git repository and the configuration variable | |
682 GNULIB_REVISION is set in bootstrap.conf, then that revision is | |
683 checked out. | |
684 | |
685 If you maintain a package and want to pin a particular revision of the | |
686 Gnulib sources that has been tested with your package, then there are | |
687 two possible approaches: either configure a 'gnulib' submodule with the | |
688 appropriate revision, or set GNULIB_REVISION (and if necessary | |
689 GNULIB_URL) in bootstrap.conf. | |
690 | |
691 Running without arguments will suffice in most cases. | |
692 EOF | |
693 } | |
694 | |
695 # Fetch auxiliary files that are omitted from the version control | |
696 # repository of this package. | |
697 autopull() | |
698 { | |
699 # Ensure that CDPATH is not set. Otherwise, the output from cd | |
700 # would cause trouble in at least one use below. | |
701 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH | |
702 | |
703 # Parse options. | |
704 | |
705 # Use git to update gnulib sources | |
706 use_git=true | |
707 | |
708 for option | |
709 do | |
710 case $option in | |
711 --help) | |
712 autopull_usage | |
713 return;; | |
714 --version) | |
715 set -e | |
716 echo "autopull.sh $scriptlibversion" | |
717 echo "$copyright" | |
718 return 0 | |
719 ;; | |
720 --skip-po) | |
721 SKIP_PO=t;; | |
722 --force) | |
723 checkout_only_file=;; | |
724 --bootstrap-sync) | |
725 bootstrap_sync=true;; | |
726 --no-bootstrap-sync) | |
727 bootstrap_sync=false;; | |
728 --no-git) | |
729 use_git=false;; | |
730 *) | |
731 bootstrap_option_hook $option || die "$option: unknown option";; | |
732 esac | |
733 done | |
734 | |
735 $use_git || test -n "$GNULIB_SRCDIR" \ | |
736 || die "Error: --no-git requires \$GNULIB_SRCDIR environment variable" \ | |
737 "or --gnulib-srcdir option" | |
738 test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \ | |
739 || die "Error: \$GNULIB_SRCDIR environment variable" \ | |
740 "or --gnulib-srcdir option is specified," \ | |
741 "but does not denote a directory" | |
742 | |
743 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then | |
744 die "Running this script from a non-checked-out distribution is risky." | |
745 fi | |
746 | |
747 check_build_prerequisites $use_git | |
748 | |
749 if $use_gnulib || $bootstrap_sync; then | |
750 prepare_GNULIB_SRCDIR | |
751 if $bootstrap_sync; then | |
752 upgrade_bootstrap | |
753 fi | |
754 fi | |
755 | |
756 # Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6. | |
757 # Also find the compatible sha1 utility on the BSDs | |
758 if test x"$SKIP_PO" = x; then | |
759 find_tool SHA1SUM sha1sum gsha1sum shasum sha1 | |
760 fi | |
761 | |
762 # See if we can use gnulib's git-merge-changelog merge driver. | |
763 if $use_git && test -d .git && check_exists git; then | |
764 if git config merge.merge-changelog.driver >/dev/null ; then | |
765 : | |
766 elif check_exists git-merge-changelog; then | |
767 echo "$0: initializing git-merge-changelog driver" | |
768 git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver' | |
769 git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B' | |
770 else | |
771 echo "$0: consider installing git-merge-changelog from gnulib" | |
772 fi | |
773 fi | |
774 | |
775 case $SKIP_PO in | |
776 '') | |
777 if test -d po; then | |
778 update_po_files po $package || return | |
779 fi | |
780 | |
781 if test -d runtime-po; then | |
782 update_po_files runtime-po $package-runtime || return | |
783 fi;; | |
784 esac | |
785 | |
786 # --------------------------------------------------------------------------- | |
787 | |
788 bootstrap_post_pull_hook \ | |
789 || die "bootstrap_post_pull_hook failed" | |
790 | |
791 # Don't proceed if there are uninitialized submodules. In particular, | |
792 # autogen.sh will remove dangling links, which might be links into | |
793 # uninitialized submodules. | |
794 # But it's OK if the 'gnulib' submodule is uninitialized, as long as | |
795 # GNULIB_SRCDIR is set. | |
796 if $use_git; then | |
797 # Uninitialized submodules are listed with an initial dash. | |
798 uninitialized=`git submodule | grep '^-' | awk '{ print $2 }'` | |
799 if test -n "$GNULIB_SRCDIR"; then | |
800 uninitialized=`echo "$uninitialized" | grep -v '^gnulib$'` | |
801 fi | |
802 if test -n "$uninitialized"; then | |
803 uninit_comma=`echo "$uninitialized" | tr '\n' ',' | sed -e 's|,$|.|'` | |
804 die "Some git submodules are not initialized: "$uninit_comma \ | |
805 "Either use option '--no-git'," \ | |
806 "or run 'git submodule update --init' and bootstrap again." | |
807 fi | |
808 fi | |
809 | |
810 if test -f "$medir"/autogen.sh; then | |
811 echo "$0: done. Now you can run '$medir/autogen.sh'." | |
812 fi | |
813 } | |
814 | |
815 # ----------------------------- Get translations. ----------------------------- | |
816 | |
817 download_po_files() { | |
818 subdir=$1 | |
819 domain=$2 | |
820 echo "$me: getting translations into $subdir for $domain..." | |
821 cmd=$(printf "$po_download_command_format" "$subdir" "$domain") | |
822 eval "$cmd" | |
823 } | |
824 | |
825 # Mirror .po files to $po_dir/.reference and copy only the new | |
826 # or modified ones into $po_dir. Also update $po_dir/LINGUAS. | |
827 # Note po files that exist locally only are left in $po_dir but will | |
828 # not be included in LINGUAS and hence will not be distributed. | |
829 update_po_files() { | |
830 # Directory containing primary .po files. | |
831 # Overwrite them only when we're sure a .po file is new. | |
832 po_dir=$1 | |
833 domain=$2 | |
834 | |
835 # Mirror *.po files into this dir. | |
836 # Usually contains *.s1 checksum files. | |
837 ref_po_dir="$po_dir/.reference" | |
838 | |
839 test -d $ref_po_dir || mkdir $ref_po_dir || return | |
840 download_po_files $ref_po_dir $domain \ | |
841 && ls "$ref_po_dir"/*.po 2>/dev/null | | |
842 sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return | |
843 | |
844 langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g') | |
845 test "$langs" = '*' && langs=x | |
846 for po in $langs; do | |
847 case $po in x) continue;; esac | |
848 new_po="$ref_po_dir/$po.po" | |
849 cksum_file="$ref_po_dir/$po.s1" | |
850 if ! test -f "$cksum_file" || | |
851 ! test -f "$po_dir/$po.po" || | |
852 ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then | |
853 echo "$me: updated $po_dir/$po.po..." | |
854 cp "$new_po" "$po_dir/$po.po" \ | |
855 && $SHA1SUM < "$new_po" > "$cksum_file" || return | |
856 fi | |
857 done | |
858 } | |
859 | |
860 # -------- Generate files automatically from existing sources. -------------- | |
861 | |
862 autogen_usage() { | |
863 cat <<EOF | |
864 Usage: $me [OPTION]... | |
865 Bootstrap this package from the checked-out sources. | |
866 | |
867 Optional environment variables: | |
868 GNULIB_SRCDIR Specifies the local directory where gnulib | |
869 sources reside. Use this if you already | |
870 have gnulib sources on your machine, and | |
871 you want to use these sources. | |
872 | |
873 Options: | |
874 --copy copy files instead of creating symbolic links | |
875 --force attempt to bootstrap even if the sources seem | |
876 not to have been checked out | |
877 EOF | |
878 bootstrap_print_option_usage_hook | |
879 cat <<EOF | |
880 If the file bootstrap.conf exists in the same directory as this script, its | |
881 contents are read as shell variables to configure the bootstrap. | |
882 | |
883 For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR | |
884 are honored. | |
885 | |
886 Gnulib sources are assumed to be present: | |
887 * in \$GNULIB_SRCDIR, if that environment variable is set, | |
888 * otherwise, in the 'gnulib' submodule, if such a submodule is configured, | |
889 * otherwise, in the 'gnulib' subdirectory. | |
890 | |
891 Running without arguments will suffice in most cases. | |
892 EOF | |
893 } | |
894 | |
895 | |
896 version_controlled_file() { | |
897 parent=$1 | |
898 file=$2 | |
899 if test -d .git; then | |
900 git rm -n "$file" > /dev/null 2>&1 | |
901 elif test -d .svn; then | |
902 svn log -r HEAD "$file" > /dev/null 2>&1 | |
903 elif test -d CVS; then | |
904 grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null | | |
905 grep '^/[^/]*/[0-9]' > /dev/null | |
906 else | |
907 warn_ "no version control for $file?" | |
908 false | |
909 fi | |
910 } | |
911 | |
912 # Strip blank and comment lines to leave significant entries. | |
913 gitignore_entries() { | |
914 sed '/^#/d; /^$/d' "$@" | |
915 } | |
916 | |
917 # If $STR is not already on a line by itself in $FILE, insert it at the start. | |
918 # Entries are inserted at the start of the ignore list to ensure existing | |
919 # entries starting with ! are not overridden. Such entries support | |
920 # whitelisting exceptions after a more generic blacklist pattern. | |
921 insert_if_absent() { | |
922 file=$1 | |
923 str=$2 | |
924 test -f $file || touch $file | |
925 test -r $file || die "Error: failed to read ignore file: $file" | |
926 duplicate_entries=$(gitignore_entries $file | sort | uniq -d) | |
927 if [ "$duplicate_entries" ] ; then | |
928 die "Error: Duplicate entries in $file: " $duplicate_entries | |
929 fi | |
930 linesold=$(gitignore_entries $file | wc -l) | |
931 linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l) | |
932 if [ $linesold != $linesnew ] ; then | |
933 { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \ | |
934 || die "insert_if_absent $file $str: failed" | |
935 fi | |
936 } | |
937 | |
938 # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with | |
939 # insert_if_absent. | |
940 insert_vc_ignore() { | |
941 vc_ignore_file="$1" | |
942 pattern="$2" | |
943 case $vc_ignore_file in | |
944 *.gitignore) | |
945 # A .gitignore entry that does not start with '/' applies | |
946 # recursively to subdirectories, so prepend '/' to every | |
947 # .gitignore entry. | |
948 pattern=$(echo "$pattern" | sed s,^,/,);; | |
949 esac | |
950 insert_if_absent "$vc_ignore_file" "$pattern" | |
951 } | |
952 | |
953 symlink_to_dir() | |
954 { | |
955 src=$1/$2 | |
956 dst=${3-$2} | |
957 | |
958 test -f "$src" && { | |
959 | |
960 # If the destination directory doesn't exist, create it. | |
961 # This is required at least for "lib/uniwidth/cjk.h". | |
962 dst_dir=$(dirname "$dst") | |
963 if ! test -d "$dst_dir"; then | |
964 mkdir -p "$dst_dir" | |
965 | |
966 # If we've just created a directory like lib/uniwidth, | |
967 # tell version control system(s) it's ignorable. | |
968 # FIXME: for now, this does only one level | |
969 parent=$(dirname "$dst_dir") | |
970 for dot_ig in x $vc_ignore; do | |
971 test $dot_ig = x && continue | |
972 ig=$parent/$dot_ig | |
973 insert_vc_ignore $ig "${dst_dir##*/}/" | |
974 done | |
975 fi | |
976 | |
977 if $copy; then | |
978 { | |
979 test ! -h "$dst" || { | |
980 echo "$me: rm -f $dst" && | |
981 rm -f "$dst" | |
982 } | |
983 } && | |
984 test -f "$dst" && | |
985 cmp -s "$src" "$dst" || { | |
986 echo "$me: cp -fp $src $dst" && | |
987 cp -fp "$src" "$dst" | |
988 } | |
989 else | |
990 # Leave any existing symlink alone, if it already points to the source, | |
991 # so that broken build tools that care about symlink times | |
992 # aren't confused into doing unnecessary builds. Conversely, if the | |
993 # existing symlink's timestamp is older than the source, make it afresh, | |
994 # so that broken tools aren't confused into skipping needed builds. See | |
995 # <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00326.html>. | |
996 test -h "$dst" && | |
997 src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 && | |
998 dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 && | |
999 test "$src_i" = "$dst_i" && | |
1000 both_ls=$(ls -dt "$src" "$dst") && | |
1001 test "X$both_ls" = "X$dst$nl$src" || { | |
1002 dot_dots= | |
1003 case $src in | |
1004 /*) ;; | |
1005 *) | |
1006 case /$dst/ in | |
1007 *//* | */../* | */./* | /*/*/*/*/*/) | |
1008 die "invalid symlink calculation: $src -> $dst";; | |
1009 /*/*/*/*/) dot_dots=../../../;; | |
1010 /*/*/*/) dot_dots=../../;; | |
1011 /*/*/) dot_dots=../;; | |
1012 esac;; | |
1013 esac | |
1014 | |
1015 echo "$me: ln -fs $dot_dots$src $dst" && | |
1016 ln -fs "$dot_dots$src" "$dst" | |
1017 } | |
1018 fi | |
1019 } | |
1020 } | |
1021 | |
1022 # Regenerate all autogeneratable files that are omitted from the | |
1023 # version control repository. In particular, regenerate all | |
1024 # aclocal.m4, config.h.in, Makefile.in, configure files with new | |
1025 # versions of autoconf or automake. | |
1026 autogen() | |
1027 { | |
1028 # Ensure that CDPATH is not set. Otherwise, the output from cd | |
1029 # would cause trouble in at least one use below. | |
1030 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH | |
1031 | |
1032 # Environment variables that may be set by the user. | |
1033 : "${AUTOPOINT=autopoint}" | |
1034 : "${AUTORECONF=autoreconf}" | |
1035 | |
1036 if test "$vc_ignore" = auto; then | |
1037 vc_ignore= | |
1038 test -d .git && vc_ignore=.gitignore | |
1039 test -d CVS && vc_ignore="$vc_ignore .cvsignore" | |
1040 fi | |
1041 | |
1042 | |
1043 # Parse options. | |
1044 | |
1045 # Whether to use copies instead of symlinks. | |
1046 copy=false | |
1047 | |
1048 for option | |
1049 do | |
1050 case $option in | |
1051 --help) | |
1052 autogen_usage | |
1053 return;; | |
1054 --version) | |
1055 set -e | |
1056 echo "autogen.sh $scriptlibversion" | |
1057 echo "$copyright" | |
1058 return 0 | |
1059 ;; | |
1060 --force) | |
1061 checkout_only_file=;; | |
1062 --copy) | |
1063 copy=true;; | |
1064 *) | |
1065 bootstrap_option_hook $option || die "$option: unknown option";; | |
1066 esac | |
1067 done | |
1068 | |
1069 test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \ | |
1070 || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir" \ | |
1071 "option is specified, but does not denote a directory" | |
1072 | |
1073 if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then | |
1074 die "Running this script from a non-checked-out distribution is risky." | |
1075 fi | |
1076 | |
1077 if $use_gnulib; then | |
1078 if test -z "$GNULIB_SRCDIR"; then | |
1079 gnulib_path=$(test -f .gitmodules && | |
1080 git config --file .gitmodules submodule.gnulib.path) | |
1081 test -z "$gnulib_path" && gnulib_path=gnulib | |
1082 GNULIB_SRCDIR=$gnulib_path | |
1083 fi | |
1084 fi | |
1085 | |
1086 # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac. | |
1087 found_aux_dir=no | |
1088 grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'])' configure.ac \ | |
1089 >/dev/null && found_aux_dir=yes | |
1090 grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \ | |
1091 >/dev/null && found_aux_dir=yes | |
1092 test $found_aux_dir = yes \ | |
1093 || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it" | |
1094 | |
1095 # If $build_aux doesn't exist, create it now, otherwise some bits | |
1096 # below will malfunction. If creating it, also mark it as ignored. | |
1097 if test ! -d $build_aux; then | |
1098 mkdir $build_aux | |
1099 for dot_ig in x $vc_ignore; do | |
1100 test $dot_ig = x && continue | |
1101 insert_vc_ignore $dot_ig $build_aux/ | |
1102 done | |
1103 fi | |
1104 | |
1105 check_build_prerequisites false | |
1106 | |
1107 use_libtool=0 | |
1108 # We'd like to use grep -E, to see if any of LT_INIT, | |
1109 # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac, | |
1110 # but that's not portable enough (e.g., for Solaris). | |
1111 grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \ | |
1112 && use_libtool=1 | |
1113 grep '^[ ]*LT_INIT' configure.ac >/dev/null \ | |
1114 && use_libtool=1 | |
1115 if test $use_libtool = 1; then | |
1116 find_tool LIBTOOLIZE glibtoolize libtoolize | |
1117 fi | |
1118 | |
1119 if $use_gnulib; then | |
1120 gnulib_tool=$GNULIB_SRCDIR/gnulib-tool | |
1121 <$gnulib_tool || return | |
1122 fi | |
1123 | |
1124 # NOTE: we have to be careful to run both autopoint and libtoolize | |
1125 # before gnulib-tool, since gnulib-tool is likely to provide newer | |
1126 # versions of files "installed" by these two programs. | |
1127 # Then, *after* gnulib-tool (see below), we have to be careful to | |
1128 # run autoreconf in such a way that it does not run either of these | |
1129 # two just-pre-run programs. | |
1130 | |
1131 # Import from gettext. | |
1132 with_gettext=yes | |
1133 grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \ | |
1134 with_gettext=no | |
1135 | |
1136 if test $with_gettext = yes || test $use_libtool = 1; then | |
1137 | |
1138 tempbase=.bootstrap$$ | |
1139 trap "rm -f $tempbase.0 $tempbase.1" HUP INT PIPE TERM | |
1140 | |
1141 > $tempbase.0 > $tempbase.1 && | |
1142 find . ! -type d -print | sort > $tempbase.0 || return | |
1143 | |
1144 if test $with_gettext = yes; then | |
1145 # Released autopoint has the tendency to install macros that have been | |
1146 # obsoleted in current gnulib, so run this before gnulib-tool. | |
1147 echo "$0: $AUTOPOINT --force" | |
1148 $AUTOPOINT --force || return | |
1149 fi | |
1150 | |
1151 # Autoreconf runs aclocal before libtoolize, which causes spurious | |
1152 # warnings if the initial aclocal is confused by the libtoolized | |
1153 # (or worse out-of-date) macro directory. | |
1154 # libtoolize 1.9b added the --install option; but we support back | |
1155 # to libtoolize 1.5.22, where the install action was default. | |
1156 if test $use_libtool = 1; then | |
1157 install= | |
1158 case $($LIBTOOLIZE --help) in | |
1159 *--install*) install=--install ;; | |
1160 esac | |
1161 echo "running: $LIBTOOLIZE $install --copy" | |
1162 $LIBTOOLIZE $install --copy | |
1163 fi | |
1164 | |
1165 find . ! -type d -print | sort >$tempbase.1 | |
1166 old_IFS=$IFS | |
1167 IFS=$nl | |
1168 for file in $(comm -13 $tempbase.0 $tempbase.1); do | |
1169 IFS=$old_IFS | |
1170 parent=${file%/*} | |
1171 version_controlled_file "$parent" "$file" || { | |
1172 for dot_ig in x $vc_ignore; do | |
1173 test $dot_ig = x && continue | |
1174 ig=$parent/$dot_ig | |
1175 insert_vc_ignore "$ig" "${file##*/}" | |
1176 done | |
1177 } | |
1178 done | |
1179 IFS=$old_IFS | |
1180 | |
1181 rm -f $tempbase.0 $tempbase.1 | |
1182 trap - HUP INT PIPE TERM | |
1183 fi | |
1184 | |
1185 # Import from gnulib. | |
1186 | |
1187 if $use_gnulib; then | |
1188 gnulib_tool_options="\ | |
1189 --no-changelog\ | |
1190 --aux-dir=$build_aux\ | |
1191 --doc-base=$doc_base\ | |
1192 --lib=$gnulib_name\ | |
1193 --m4-base=$m4_base/\ | |
1194 --source-base=$source_base/\ | |
1195 --tests-base=$tests_base\ | |
1196 --local-dir=$local_gl_dir\ | |
1197 $gnulib_tool_option_extras\ | |
1198 " | |
1199 if test $use_libtool = 1; then | |
1200 case "$gnulib_tool_options " in | |
1201 *' --libtool '*) ;; | |
1202 *) gnulib_tool_options="$gnulib_tool_options --libtool" ;; | |
1203 esac | |
1204 fi | |
1205 echo "$0: $gnulib_tool $gnulib_tool_options --import ..." | |
1206 $gnulib_tool $gnulib_tool_options --import $gnulib_modules \ | |
1207 || die "gnulib-tool failed" | |
1208 | |
1209 for file in $gnulib_files; do | |
1210 symlink_to_dir "$GNULIB_SRCDIR" $file \ | |
1211 || die "failed to symlink $file" | |
1212 done | |
1213 fi | |
1214 | |
1215 bootstrap_post_import_hook \ | |
1216 || die "bootstrap_post_import_hook failed" | |
1217 | |
1218 # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some | |
1219 # gnulib-populated directories. Such .m4 files would cause aclocal to fail. | |
1220 # The following requires GNU find 4.2.3 or newer. Considering the usual | |
1221 # portability constraints of this script, that may seem a very demanding | |
1222 # requirement, but it should be ok. Ignore any failure, which is fine, | |
1223 # since this is only a convenience to help developers avoid the relatively | |
1224 # unusual case in which a symlinked-to .m4 file is git-removed from gnulib | |
1225 # between successive runs of this script. | |
1226 find "$m4_base" "$source_base" \ | |
1227 -depth \( -name '*.m4' -o -name '*.[ch]' \) \ | |
1228 -type l -xtype l -delete > /dev/null 2>&1 | |
1229 | |
1230 # Invoke autoreconf with --force --install to ensure upgrades of tools | |
1231 # such as ylwrap. | |
1232 AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS" | |
1233 AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive" | |
1234 | |
1235 # Tell autoreconf not to invoke autopoint or libtoolize; they were run above. | |
1236 echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS" | |
1237 AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \ | |
1238 || die "autoreconf failed" | |
1239 | |
1240 # Get some extra files from gnulib, overriding existing files. | |
1241 for file in $gnulib_extra_files; do | |
1242 case $file in | |
1243 */INSTALL) dst=INSTALL;; | |
1244 build-aux/*) dst=$build_aux/${file#build-aux/};; | |
1245 *) dst=$file;; | |
1246 esac | |
1247 symlink_to_dir "$GNULIB_SRCDIR" $file $dst \ | |
1248 || die "failed to symlink $file" | |
1249 done | |
1250 | |
1251 if test $with_gettext = yes; then | |
1252 # Create gettext configuration. | |
1253 echo "$0: Creating po/Makevars from po/Makevars.template ..." | |
1254 rm -f po/Makevars | |
1255 sed ' | |
1256 /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/ | |
1257 /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/ | |
1258 /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'| | |
1259 /^XGETTEXT_OPTIONS *=/{ | |
1260 s/$/ \\/ | |
1261 a\ | |
1262 '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+} | |
1263 } | |
1264 ' po/Makevars.template >po/Makevars \ | |
1265 || die 'cannot generate po/Makevars' | |
1266 | |
1267 # If the 'gettext' module is in use, grab the latest Makefile.in.in. | |
1268 # If only the 'gettext-h' module is in use, assume autopoint already | |
1269 # put the correct version of this file into place. | |
1270 case $gnulib_modules in | |
1271 *gettext-h*) ;; | |
1272 *gettext*) | |
1273 cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \ | |
1274 || die "cannot create po/Makefile.in.in" | |
1275 ;; | |
1276 esac | |
1277 | |
1278 if test -d runtime-po; then | |
1279 # Similarly for runtime-po/Makevars, but not quite the same. | |
1280 rm -f runtime-po/Makevars | |
1281 sed ' | |
1282 /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/ | |
1283 /^subdir *=.*/s/=.*/= runtime-po/ | |
1284 /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/ | |
1285 /^XGETTEXT_OPTIONS *=/{ | |
1286 s/$/ \\/ | |
1287 a\ | |
1288 '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+} | |
1289 } | |
1290 ' po/Makevars.template >runtime-po/Makevars \ | |
1291 || die 'cannot generate runtime-po/Makevars' | |
1292 | |
1293 # Copy identical files from po to runtime-po. | |
1294 (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po) | |
1295 fi | |
1296 fi | |
1297 | |
1298 bootstrap_epilogue | |
1299 | |
1300 echo "$0: done. Now you can run './configure'." | |
1301 } | |
1302 | |
595 # ---------------------------------------------------------------------------- | 1303 # ---------------------------------------------------------------------------- |
596 | 1304 |
597 # Local Variables: | 1305 # Local Variables: |
598 # eval: (add-hook 'before-save-hook 'time-stamp) | 1306 # eval: (add-hook 'before-save-hook 'time-stamp) |
599 # time-stamp-start: "scriptversion=" | 1307 # time-stamp-start: "scriptlibversion=" |
600 # time-stamp-format: "%:y-%02m-%02d.%02H" | 1308 # time-stamp-format: "%:y-%02m-%02d.%02H" |
601 # time-stamp-time-zone: "UTC0" | 1309 # time-stamp-time-zone: "UTC0" |
602 # time-stamp-end: "; # UTC" | 1310 # time-stamp-end: "; # UTC" |
603 # End: | 1311 # End: |