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