bootstrap 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. #! /bin/sh
  2. # Bootstrap this package from checked-out sources.
  3. # Copyright (C) 2003-2023 Free Software Foundation, Inc.
  4. #
  5. # 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
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. # Originally written by Paul Eggert. The canonical version of this
  18. # script is maintained as build-aux/bootstrap in gnulib. However,
  19. # to be useful to your package, you should place a copy of it under
  20. # version control in the top-level directory of your package. The
  21. # intent is that all customization can be done with a bootstrap.conf
  22. # file also maintained in your version control; gnulib comes with a
  23. # template build-aux/bootstrap.conf to get you started.
  24. # Please report bugs or propose patches to [email protected].
  25. scriptversion=2022-07-24.15; # UTC
  26. me="$0"
  27. medir=`dirname "$me"`
  28. # Read the function library and the configuration.
  29. . "$medir"/bootstrap-funclib.sh
  30. usage() {
  31. cat <<EOF
  32. Usage: $me [OPTION]...
  33. Bootstrap this package from the checked-out sources.
  34. Optional environment variables:
  35. GNULIB_SRCDIR Specifies the local directory where gnulib
  36. sources reside. Use this if you already
  37. have gnulib sources on your machine, and
  38. do not want to waste your bandwidth downloading
  39. them again.
  40. GNULIB_URL Cloneable URL of the gnulib repository.
  41. Options:
  42. --gnulib-srcdir=DIRNAME specify the local directory where gnulib
  43. sources reside. Use this if you already
  44. have gnulib sources on your machine, and
  45. you want to use these sources. Defaults
  46. to \$GNULIB_SRCDIR
  47. --gnulib-refdir=DIRNAME specify the local directory where a gnulib
  48. repository (with a .git subdirectory) resides.
  49. Use this if you already have gnulib sources
  50. and history on your machine, and do not want
  51. to waste your bandwidth downloading them again.
  52. Defaults to \$GNULIB_REFDIR
  53. --bootstrap-sync if this bootstrap script is not identical to
  54. the version in the local gnulib sources,
  55. update this script, and then restart it with
  56. --bootstrap-sync if this bootstrap script is not identical to
  57. the version in the local gnulib sources,
  58. update this script, and then restart it with
  59. /bin/sh or the shell \$CONFIG_SHELL
  60. --no-bootstrap-sync do not check whether bootstrap is out of sync
  61. --copy copy files instead of creating symbolic links
  62. --force attempt to bootstrap even if the sources seem
  63. not to have been checked out
  64. --no-git do not use git to update gnulib. Requires that
  65. \$GNULIB_SRCDIR or the --gnulib-srcdir option
  66. points to a gnulib repository with the correct
  67. revision
  68. --skip-po do not download po files
  69. EOF
  70. bootstrap_print_option_usage_hook
  71. cat <<EOF
  72. If the file bootstrap.conf exists in the same directory as this script, its
  73. contents are read as shell variables to configure the bootstrap.
  74. For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
  75. are honored.
  76. Gnulib sources can be fetched in various ways:
  77. * If the environment variable GNULIB_SRCDIR is set (either as an
  78. environment variable or via the --gnulib-srcdir option), then sources
  79. are fetched from that local directory. If it is a git repository and
  80. the configuration variable GNULIB_REVISION is set in bootstrap.conf,
  81. then that revision is checked out.
  82. * Otherwise, if this package is in a git repository with a 'gnulib'
  83. submodule configured, then that submodule is initialized and updated
  84. and sources are fetched from there. If GNULIB_REFDIR is set (either
  85. as an environment variable or via the --gnulib-refdir option) and is
  86. a git repository, then it is used as a reference.
  87. * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
  88. are cloned into that directory using git from \$GNULIB_URL, defaulting
  89. to $default_gnulib_url.
  90. If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
  91. then that revision is checked out.
  92. * Otherwise, the existing Gnulib sources in the 'gnulib' directory are
  93. used. If it is a git repository and the configuration variable
  94. GNULIB_REVISION is set in bootstrap.conf, then that revision is
  95. checked out.
  96. If you maintain a package and want to pin a particular revision of the
  97. Gnulib sources that has been tested with your package, then there are
  98. two possible approaches: either configure a 'gnulib' submodule with the
  99. appropriate revision, or set GNULIB_REVISION (and if necessary
  100. GNULIB_URL) in bootstrap.conf.
  101. Running without arguments will suffice in most cases.
  102. EOF
  103. }
  104. # Parse options.
  105. # Whether to use copies instead of symlinks.
  106. copy=false
  107. # Use git to update gnulib sources
  108. use_git=true
  109. for option
  110. do
  111. case $option in
  112. --help)
  113. usage
  114. exit;;
  115. --version)
  116. set -e
  117. echo "bootstrap $scriptversion"
  118. echo "$copyright"
  119. exit 0
  120. ;;
  121. --gnulib-srcdir=*)
  122. GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
  123. --gnulib-refdir=*)
  124. GNULIB_REFDIR=${option#--gnulib-refdir=};;
  125. --skip-po)
  126. SKIP_PO=t;;
  127. --force)
  128. checkout_only_file=;;
  129. --copy)
  130. copy=true;;
  131. --bootstrap-sync)
  132. bootstrap_sync=true;;
  133. --no-bootstrap-sync)
  134. if test -f "$medir"/bootstrap-funclib.sh; then
  135. bootstrap_sync=false
  136. else
  137. # We have only completed the first phase of an upgrade from a bootstrap
  138. # version < 2022-07-24. Need to do the second phase now.
  139. bootstrap_sync=true
  140. fi
  141. ;;
  142. --no-git)
  143. use_git=false;;
  144. *)
  145. bootstrap_option_hook $option || die "$option: unknown option";;
  146. esac
  147. done
  148. $use_git || test -n "$GNULIB_SRCDIR" \
  149. || die "Error: --no-git requires \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option"
  150. test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
  151. || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option is specified, but does not denote a directory"
  152. if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
  153. die "Bootstrapping from a non-checked-out distribution is risky."
  154. fi
  155. check_build_prerequisites $use_git
  156. if $bootstrap_sync; then
  157. prepare_GNULIB_SRCDIR
  158. upgrade_bootstrap
  159. # Since we have now upgraded if needed, no need to try it a second time below.
  160. bootstrap_sync=false
  161. fi
  162. echo "$0: Bootstrapping from checked-out $package sources..."
  163. # Pass GNULIB_SRCDIR to autopull.sh and autogen.sh.
  164. export GNULIB_SRCDIR
  165. # Pass GNULIB_REFDIR to autopull.sh.
  166. export GNULIB_REFDIR
  167. if $use_git || test -z "$SKIP_PO"; then
  168. "$medir"/autopull.sh \
  169. `if $bootstrap_sync; then echo ' --bootstrap-sync'; else echo ' --no-bootstrap-sync'; fi` \
  170. `if test -z "$checkout_only_file"; then echo ' --force'; fi` \
  171. `if ! $use_git; then echo ' --no-git'; fi` \
  172. `if test -n "$SKIP_PO"; then echo ' --skip-po'; fi` \
  173. || die "autopull.sh failed."
  174. fi
  175. "$medir"/autogen.sh \
  176. `if $copy; then echo ' --copy'; fi` \
  177. `if test -z "$checkout_only_file"; then echo ' --force'; fi` \
  178. || die "autogen.sh failed."
  179. # ----------------------------------------------------------------------------
  180. # Local Variables:
  181. # eval: (add-hook 'before-save-hook 'time-stamp)
  182. # time-stamp-start: "scriptversion="
  183. # time-stamp-format: "%:y-%02m-%02d.%02H"
  184. # time-stamp-time-zone: "UTC0"
  185. # time-stamp-end: "; # UTC"
  186. # End: