bootstrap 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508
  1. #! /bin/sh
  2. # DO NOT EDIT! GENERATED AUTOMATICALLY!
  3. # Bootstrap this package from checked-out sources.
  4. scriptversion=2022-12-27.07; # UTC
  5. # Copyright (C) 2003-2023 Free Software Foundation, Inc.
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. # Originally written by Paul Eggert. The canonical version of this
  20. # script is maintained as top/bootstrap in gnulib. However, to be
  21. # useful to your package, you should place a copy of it under version
  22. # control in the top-level directory of your package. The intent is
  23. # that all customization can be done with a bootstrap.conf file also
  24. # maintained in your version control; gnulib comes with a template
  25. # build-aux/bootstrap.conf to get you started.
  26. # Please report bugs or propose patches to [email protected].
  27. me="$0"
  28. medir=`dirname "$me"`
  29. # Read the function library and the configuration.
  30. # A library of shell functions for autopull.sh, autogen.sh, and bootstrap.
  31. scriptlibversion=2023-06-06.21; # UTC
  32. # Copyright (C) 2003-2023 Free Software Foundation, Inc.
  33. #
  34. # This program is free software: you can redistribute it and/or modify
  35. # it under the terms of the GNU General Public License as published by
  36. # the Free Software Foundation, either version 3 of the License, or
  37. # (at your option) any later version.
  38. #
  39. # This program is distributed in the hope that it will be useful,
  40. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  41. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  42. # GNU General Public License for more details.
  43. #
  44. # You should have received a copy of the GNU General Public License
  45. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  46. # Originally written by Paul Eggert. The canonical version of this
  47. # script is maintained as top/bootstrap-funclib.sh in gnulib. However,
  48. # to be useful to your package, you should place a copy of it under
  49. # version control in the top-level directory of your package. The
  50. # intent is that all customization can be done with a bootstrap.conf
  51. # file also maintained in your version control; gnulib comes with a
  52. # template build-aux/bootstrap.conf to get you started.
  53. nl='
  54. '
  55. # Ensure file names are sorted consistently across platforms.
  56. LC_ALL=C
  57. export LC_ALL
  58. # Honor $PERL, but work even if there is none.
  59. PERL="${PERL-perl}"
  60. default_gnulib_url=https://git.savannah.gnu.org/git/gnulib.git
  61. # Copyright year, for the --version output.
  62. copyright_year=`echo "$scriptlibversion" | sed -e 's/[^0-9].*//'`
  63. copyright="Copyright (C) ${copyright_year} Free Software Foundation, Inc.
  64. License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
  65. This is free software: you are free to change and redistribute it.
  66. There is NO WARRANTY, to the extent permitted by law."
  67. # warnf_ FORMAT-STRING ARG1...
  68. warnf_ ()
  69. {
  70. warnf_format_=$1
  71. shift
  72. nl='
  73. '
  74. case $* in
  75. *$nl*) me_=$(printf "$me"|tr "$nl|" '??')
  76. printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
  77. *) printf "$me: $warnf_format_" "$@" ;;
  78. esac >&2
  79. }
  80. # warn_ WORD1...
  81. warn_ ()
  82. {
  83. # If IFS does not start with ' ', set it and emit the warning in a subshell.
  84. case $IFS in
  85. ' '*) warnf_ '%s\n' "$*";;
  86. *) (IFS=' '; warn_ "$@");;
  87. esac
  88. }
  89. # die WORD1...
  90. die() { warn_ "$@"; exit 1; }
  91. # ------------------------------ Configuration. ------------------------------
  92. # Directory that contains package-specific gnulib modules and/or overrides.
  93. local_gl_dir=gl
  94. # Name of the Makefile.am
  95. # XXX Not used.
  96. gnulib_mk=gnulib.mk
  97. # List of gnulib modules needed.
  98. gnulib_modules=
  99. # Any gnulib files needed that are not in modules.
  100. gnulib_files=
  101. # A function to be called for each unrecognized option. Returns 0 if
  102. # the option in $1 has been processed by the function. Returns 1 if
  103. # the option has not been processed by the function. Override it via
  104. # your own definition in bootstrap.conf
  105. bootstrap_option_hook() { return 1; }
  106. # A function to be called in order to print the --help information
  107. # corresponding to user-defined command-line options.
  108. bootstrap_print_option_usage_hook() { :; }
  109. # A function to be called at the end of autopull.sh.
  110. # Override it via your own definition in bootstrap.conf.
  111. bootstrap_post_pull_hook() { :; }
  112. # A function to be called right after gnulib-tool is run.
  113. # Override it via your own definition in bootstrap.conf.
  114. bootstrap_post_import_hook() { :; }
  115. # A function to be called after everything else in this script.
  116. # Override it via your own definition in bootstrap.conf.
  117. bootstrap_epilogue() { :; }
  118. # The command to download all .po files for a specified domain into a
  119. # specified directory. Fill in the first %s with the destination
  120. # directory and the second with the domain name.
  121. po_download_command_format=\
  122. "wget --mirror --level=1 -nd -nv -A.po -P '%s' \
  123. https://translationproject.org/latest/%s/"
  124. # Prefer a non-empty tarname (4th argument of AC_INIT if given), else
  125. # fall back to the package name (1st argument with munging).
  126. extract_package_name='
  127. /^AC_INIT(\[*/{
  128. s///
  129. /^[^,]*,[^,]*,[^,]*,[ []*\([^][ ,)]\)/{
  130. s//\1/
  131. s/[],)].*//
  132. p
  133. q
  134. }
  135. s/[],)].*//
  136. s/^GNU //
  137. y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
  138. s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g
  139. p
  140. }
  141. '
  142. package=$(${AUTOCONF:-autoconf} --trace AC_INIT:\$4 configure.ac 2>/dev/null)
  143. if test -z "$package"; then
  144. package=$(sed -n "$extract_package_name" configure.ac) \
  145. || die 'cannot find package name in configure.ac'
  146. fi
  147. gnulib_name=lib$package
  148. build_aux=build-aux
  149. source_base=lib
  150. m4_base=m4
  151. doc_base=doc
  152. tests_base=tests
  153. gnulib_extra_files="
  154. build-aux/install-sh
  155. build-aux/mdate-sh
  156. build-aux/texinfo.tex
  157. build-aux/depcomp
  158. build-aux/config.guess
  159. build-aux/config.sub
  160. doc/INSTALL
  161. "
  162. # Additional gnulib-tool options to use. Use "\newline" to break lines.
  163. gnulib_tool_option_extras=
  164. # Other locale categories that need message catalogs.
  165. EXTRA_LOCALE_CATEGORIES=
  166. # Additional xgettext options to use. Use "\\\newline" to break lines.
  167. XGETTEXT_OPTIONS='\\\
  168. --flag=_:1:pass-c-format\\\
  169. --flag=N_:1:pass-c-format\\\
  170. --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
  171. '
  172. # Package bug report address and copyright holder for gettext files
  173. COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
  174. [email protected]
  175. # Files we don't want to import.
  176. # XXX Not used.
  177. excluded_files=
  178. # File that should exist in the top directory of a checked out hierarchy,
  179. # but not in a distribution tarball.
  180. checkout_only_file=README-hacking
  181. # Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
  182. # those files to be generated in directories like lib/, m4/, and po/.
  183. # Or set it to 'auto' to make this script select which to use based
  184. # on which version control system (if any) is used in the source directory.
  185. vc_ignore=auto
  186. # Set this to true in bootstrap.conf to enable --bootstrap-sync by
  187. # default.
  188. bootstrap_sync=false
  189. # Override the default configuration, if necessary.
  190. # Make sure that bootstrap.conf is sourced from the current directory
  191. # if we were invoked as "sh bootstrap".
  192. conffile=`dirname "$me"`/bootstrap.conf
  193. test -r "$conffile" && . "$conffile"
  194. # ------------------------- Build-time prerequisites -------------------------
  195. check_exists() {
  196. if test "$1" = "--verbose"; then
  197. ($2 --version </dev/null) >/dev/null 2>&1
  198. if test $? -ge 126; then
  199. # If not found, run with diagnostics as one may be
  200. # presented with env variables to set to find the right version
  201. ($2 --version </dev/null)
  202. fi
  203. else
  204. ($1 --version </dev/null) >/dev/null 2>&1
  205. fi
  206. test $? -lt 126
  207. }
  208. # Note this deviates from the version comparison in automake
  209. # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
  210. # but this should suffice as we won't be specifying old
  211. # version formats or redundant trailing .0 in bootstrap.conf.
  212. # If we did want full compatibility then we should probably
  213. # use m4_version_compare from autoconf.
  214. sort_ver() { # sort -V is not generally available
  215. ver1="$1"
  216. ver2="$2"
  217. # split on '.' and compare each component
  218. i=1
  219. while : ; do
  220. p1=$(echo "$ver1" | cut -d. -f$i)
  221. p2=$(echo "$ver2" | cut -d. -f$i)
  222. if [ ! "$p1" ]; then
  223. echo "$1 $2"
  224. break
  225. elif [ ! "$p2" ]; then
  226. echo "$2 $1"
  227. break
  228. elif [ ! "$p1" = "$p2" ]; then
  229. if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
  230. echo "$2 $1"
  231. elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
  232. echo "$1 $2"
  233. else # numeric, then lexicographic comparison
  234. lp=$(printf "%s\n%s\n" "$p1" "$p2" | LANG=C sort -n | tail -n1)
  235. if [ "$lp" = "$p2" ]; then
  236. echo "$1 $2"
  237. else
  238. echo "$2 $1"
  239. fi
  240. fi
  241. break
  242. fi
  243. i=$(($i+1))
  244. done
  245. }
  246. get_version_sed='
  247. # Move version to start of line.
  248. s/.*[v ]\([0-9]\)/\1/
  249. # Skip lines that do not start with version.
  250. /^[0-9]/!d
  251. # Remove characters after the version.
  252. s/[^.a-z0-9-].*//
  253. # The first component must be digits only.
  254. s/^\([0-9]*\)[a-z-].*/\1/
  255. #the following essentially does s/5.005/5.5/
  256. s/\.0*\([1-9]\)/.\1/g
  257. p
  258. q'
  259. get_version() {
  260. app=$1
  261. $app --version >/dev/null 2>&1 || { $app --version; return 1; }
  262. $app --version 2>&1 | sed -n "$get_version_sed"
  263. }
  264. check_versions() {
  265. ret=0
  266. while read app req_ver; do
  267. # We only need libtoolize from the libtool package.
  268. if test "$app" = libtool; then
  269. app=libtoolize
  270. fi
  271. # Exempt git if git is not needed.
  272. if test "$app" = git; then
  273. $check_git || continue
  274. fi
  275. # Honor $APP variables ($TAR, $AUTOCONF, etc.)
  276. appvar=$(echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_')
  277. test "$appvar" = TAR && appvar=AMTAR
  278. case $appvar in
  279. GZIP) ;; # Do not use $GZIP: it contains gzip options.
  280. PERL::*) ;; # Keep perl modules as-is
  281. *) eval "app=\${$appvar-$app}" ;;
  282. esac
  283. # Handle the still-experimental Automake-NG programs specially.
  284. # They remain named as the mainstream Automake programs ("automake",
  285. # and "aclocal") to avoid gratuitous incompatibilities with
  286. # preexisting usages (by, say, autoreconf, or custom autogen.sh
  287. # scripts), but correctly identify themselves (as being part of
  288. # "GNU automake-ng") when asked their version.
  289. case $app in
  290. automake-ng|aclocal-ng)
  291. app=${app%-ng}
  292. ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
  293. warn_ "Error: '$app' not found or not from Automake-NG"
  294. ret=1
  295. continue
  296. } ;;
  297. # Another check is for perl modules. These can be written as
  298. # e.g. perl::XML::XPath in case of XML::XPath module, etc.
  299. perl::*)
  300. # Extract module name
  301. app="${app#perl::}"
  302. if ! $PERL -m"$app" -e 'exit 0' >/dev/null 2>&1; then
  303. warn_ "Error: perl module '$app' not found"
  304. ret=1
  305. fi
  306. continue
  307. ;;
  308. esac
  309. if [ "$req_ver" = "-" ]; then
  310. # Merely require app to exist; not all prereq apps are well-behaved
  311. # so we have to rely on $? rather than get_version.
  312. if ! check_exists --verbose $app; then
  313. warn_ "Error: '$app' not found"
  314. ret=1
  315. fi
  316. else
  317. # Require app to produce a new enough version string.
  318. inst_ver=$(get_version $app)
  319. if [ ! "$inst_ver" ]; then
  320. warn_ "Error: '$app' not found"
  321. ret=1
  322. else
  323. latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
  324. if [ ! "$latest_ver" = "$inst_ver" ]; then
  325. warnf_ '%s\n' \
  326. "Error: '$app' version == $inst_ver is too old" \
  327. " '$app' version >= $req_ver is required"
  328. ret=1
  329. fi
  330. fi
  331. fi
  332. done
  333. return $ret
  334. }
  335. print_versions() {
  336. echo "Program Min_version"
  337. echo "----------------------"
  338. printf %s "$buildreq"
  339. echo "----------------------"
  340. # can't depend on column -t
  341. }
  342. # check_build_prerequisites check_git
  343. check_build_prerequisites()
  344. {
  345. check_git="$1"
  346. # gnulib-tool requires at least automake and autoconf.
  347. # If either is not listed, add it (with minimum version) as a prerequisite.
  348. case $buildreq in
  349. *automake*) ;;
  350. *) buildreq="automake 1.9
  351. $buildreq" ;;
  352. esac
  353. case $buildreq in
  354. *autoconf*) ;;
  355. *) buildreq="autoconf 2.59
  356. $buildreq" ;;
  357. esac
  358. # When we can deduce that gnulib-tool will require patch,
  359. # and when patch is not already listed as a prerequisite, add it, too.
  360. if test -d "$local_gl_dir" \
  361. && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then
  362. case $buildreq in
  363. *patch*) ;;
  364. *) buildreq="patch -
  365. $buildreq" ;;
  366. esac
  367. fi
  368. if ! printf '%s' "$buildreq" | check_versions; then
  369. echo >&2
  370. if test -f README-prereq; then
  371. die "See README-prereq for how to get the prerequisite programs"
  372. else
  373. die "Please install the prerequisite programs"
  374. fi
  375. fi
  376. # Warn the user if autom4te appears to be broken; this causes known
  377. # issues with at least gettext 0.18.3.
  378. probe=$(echo 'm4_quote([hi])' | autom4te -l M4sugar -t 'm4_quote:$%' -)
  379. if test "x$probe" != xhi; then
  380. warn_ "WARNING: your autom4te wrapper eats stdin;"
  381. warn_ "if bootstrap fails, consider upgrading your autotools"
  382. fi
  383. }
  384. # find_tool ENVVAR NAMES...
  385. # -------------------------
  386. # Search for a required program. Use the value of ENVVAR, if set,
  387. # otherwise find the first of the NAMES that can be run.
  388. # If found, set ENVVAR to the program name, die otherwise.
  389. #
  390. # FIXME: code duplication, see also gnu-web-doc-update.
  391. find_tool ()
  392. {
  393. find_tool_envvar=$1
  394. shift
  395. find_tool_names=$@
  396. eval "find_tool_res=\$$find_tool_envvar"
  397. if test x"$find_tool_res" = x; then
  398. for i; do
  399. if check_exists $i; then
  400. find_tool_res=$i
  401. break
  402. fi
  403. done
  404. fi
  405. if test x"$find_tool_res" = x; then
  406. warn_ "one of these is required: $find_tool_names;"
  407. die "alternatively set $find_tool_envvar to a compatible tool"
  408. fi
  409. eval "$find_tool_envvar=\$find_tool_res"
  410. eval "export $find_tool_envvar"
  411. }
  412. # --------------------- Preparing GNULIB_SRCDIR for use. ---------------------
  413. # This is part of autopull.sh, but bootstrap needs it too, for self-upgrading.
  414. cleanup_gnulib() {
  415. status=$?
  416. # XXX It's a bad idea to erase the submodule directory if it contains local
  417. # modifications.
  418. rm -fr "$gnulib_path"
  419. exit $status
  420. }
  421. git_modules_config () {
  422. test -f .gitmodules && git config --file .gitmodules "$@"
  423. }
  424. prepare_GNULIB_SRCDIR ()
  425. {
  426. if test -n "$GNULIB_SRCDIR"; then
  427. # Use GNULIB_SRCDIR directly.
  428. # We already checked that $GNULIB_SRCDIR references a directory.
  429. # Verify that it contains a gnulib checkout.
  430. test -f "$GNULIB_SRCDIR/gnulib-tool" \
  431. || die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified, but does not contain gnulib-tool"
  432. elif $use_git; then
  433. gnulib_path=$(git_modules_config submodule.gnulib.path)
  434. test -z "$gnulib_path" && gnulib_path=gnulib
  435. # Get gnulib files. Populate $gnulib_path, possibly updating a
  436. # submodule, for use in the rest of the script.
  437. if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git \
  438. && git_modules_config submodule.gnulib.url >/dev/null; then
  439. # Use GNULIB_REFDIR as a reference.
  440. echo "$0: getting gnulib files..."
  441. if git submodule -h|grep -- --reference > /dev/null; then
  442. # Prefer the one-liner available in git 1.6.4 or newer.
  443. git submodule update --init --reference "$GNULIB_REFDIR" \
  444. "$gnulib_path" || exit $?
  445. else
  446. # This fallback allows at least git 1.5.5.
  447. if test -f "$gnulib_path"/gnulib-tool; then
  448. # Since file already exists, assume submodule init already complete.
  449. git submodule update -- "$gnulib_path" || exit $?
  450. else
  451. # Older git can't clone into an empty directory.
  452. rmdir "$gnulib_path" 2>/dev/null
  453. git clone --reference "$GNULIB_REFDIR" \
  454. "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
  455. && git submodule init -- "$gnulib_path" \
  456. && git submodule update -- "$gnulib_path" \
  457. || exit $?
  458. fi
  459. fi
  460. else
  461. # GNULIB_REFDIR is not set or not usable. Ignore it.
  462. if git_modules_config submodule.gnulib.url >/dev/null; then
  463. echo "$0: getting gnulib files..."
  464. git submodule init -- "$gnulib_path" || exit $?
  465. git submodule update -- "$gnulib_path" || exit $?
  466. elif [ ! -d "$gnulib_path" ]; then
  467. echo "$0: getting gnulib files..."
  468. trap cleanup_gnulib HUP INT PIPE TERM
  469. shallow=
  470. if test -z "$GNULIB_REVISION"; then
  471. if git clone -h 2>&1 | grep -- --depth > /dev/null; then
  472. shallow='--depth 2'
  473. fi
  474. git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \
  475. || cleanup_gnulib
  476. else
  477. if git fetch -h 2>&1 | grep -- --depth > /dev/null; then
  478. shallow='--depth 2'
  479. fi
  480. mkdir -p "$gnulib_path"
  481. # Only want a shallow checkout of $GNULIB_REVISION, but git does not
  482. # support cloning by commit hash. So attempt a shallow fetch by commit
  483. # hash to minimize the amount of data downloaded and changes needed to
  484. # be processed, which can drastically reduce download and processing
  485. # time for checkout. If the fetch by commit fails, a shallow fetch can
  486. # not be performed because we do not know what the depth of the commit
  487. # is without fetching all commits. So fallback to fetching all commits.
  488. git -C "$gnulib_path" init
  489. git -C "$gnulib_path" remote add origin \
  490. ${GNULIB_URL:-$default_gnulib_url}
  491. git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
  492. || git -C "$gnulib_path" fetch origin \
  493. || cleanup_gnulib
  494. git -C "$gnulib_path" reset --hard FETCH_HEAD
  495. fi
  496. trap - HUP INT PIPE TERM
  497. fi
  498. fi
  499. GNULIB_SRCDIR=$gnulib_path
  500. # Verify that the submodule contains a gnulib checkout.
  501. test -f "$gnulib_path/gnulib-tool" \
  502. || die "Error: $gnulib_path is supposed to contain a gnulib checkout, but does not contain gnulib-tool"
  503. fi
  504. # XXX Should this be done if $use_git is false?
  505. if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \
  506. && ! git_modules_config submodule.gnulib.url >/dev/null; then
  507. (cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || cleanup_gnulib
  508. fi
  509. # $GNULIB_SRCDIR now points to the version of gnulib to use, and
  510. # we no longer need to use git or $gnulib_path below here.
  511. }
  512. # -------- Upgrading bootstrap to the version found in GNULIB_SRCDIR. --------
  513. upgrade_bootstrap ()
  514. {
  515. if test -f "$medir"/bootstrap-funclib.sh; then
  516. update_lib=true
  517. { cmp -s "$medir"/bootstrap "$GNULIB_SRCDIR/top/bootstrap" \
  518. && cmp -s "$medir"/bootstrap-funclib.sh "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" \
  519. && cmp -s "$medir"/autopull.sh "$GNULIB_SRCDIR/top/autopull.sh" \
  520. && cmp -s "$medir"/autogen.sh "$GNULIB_SRCDIR/top/autogen.sh"; \
  521. }
  522. else
  523. update_lib=false
  524. cmp -s "$medir"/bootstrap "$GNULIB_SRCDIR/build-aux/bootstrap"
  525. fi || {
  526. if $update_lib; then
  527. echo "$0: updating bootstrap & companions and restarting..."
  528. else
  529. echo "$0: updating bootstrap and restarting..."
  530. fi
  531. case $(sh -c 'echo "$1"' -- a) in
  532. a) ignored=--;;
  533. *) ignored=ignored;;
  534. esac
  535. exec sh -c \
  536. '{ if '$update_lib' && test -f "$1"; then cp "$1" "$3"; else cp "$2" "$3"; fi; } && { if '$update_lib' && test -f "$4"; then cp "$4" "$5"; else rm -f "$5"; fi; } && { if '$update_lib' && test -f "$6"; then cp "$6" "$7"; else rm -f "$7"; fi; } && { if '$update_lib' && 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}" "$@"' \
  537. $ignored \
  538. "$GNULIB_SRCDIR/top/bootstrap" "$GNULIB_SRCDIR/build-aux/bootstrap" "$medir/bootstrap" \
  539. "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" "$medir/bootstrap-funclib.sh" \
  540. "$GNULIB_SRCDIR/top/autopull.sh" "$medir/autopull.sh" \
  541. "$GNULIB_SRCDIR/top/autogen.sh" "$medir/autogen.sh" \
  542. "$0" "$@" --no-bootstrap-sync
  543. }
  544. }
  545. # ----------------------------------------------------------------------------
  546. if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then
  547. use_gnulib=false
  548. else
  549. use_gnulib=true
  550. fi
  551. # -------- Fetch auxiliary files from the network. --------------------------
  552. autopull_usage() {
  553. cat <<EOF
  554. Usage: $me [OPTION]...
  555. Bootstrap this package from the checked-out sources.
  556. Optional environment variables:
  557. GNULIB_SRCDIR Specifies the local directory where gnulib
  558. sources reside. Use this if you already
  559. have gnulib sources on your machine, and
  560. you want to use these sources.
  561. GNULIB_REFDIR Specifies the local directory where a gnulib
  562. repository (with a .git subdirectory) resides.
  563. Use this if you already have gnulib sources
  564. and history on your machine, and do not want
  565. to waste your bandwidth downloading them again.
  566. GNULIB_URL Cloneable URL of the gnulib repository.
  567. Options:
  568. --bootstrap-sync if this bootstrap script is not identical to
  569. the version in the local gnulib sources,
  570. update this script, and then restart it with
  571. /bin/sh or the shell \$CONFIG_SHELL
  572. --no-bootstrap-sync do not check whether bootstrap is out of sync
  573. --force attempt to bootstrap even if the sources seem
  574. not to have been checked out
  575. --no-git do not use git to update gnulib. Requires that
  576. \$GNULIB_SRCDIR or the --gnulib-srcdir option
  577. points to a gnulib repository with the correct
  578. revision
  579. --skip-po do not download po files
  580. EOF
  581. bootstrap_print_option_usage_hook
  582. cat <<EOF
  583. If the file bootstrap.conf exists in the same directory as this script, its
  584. contents are read as shell variables to configure the bootstrap.
  585. For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
  586. are honored.
  587. Gnulib sources can be fetched in various ways:
  588. * If the environment variable GNULIB_SRCDIR is set (either as an
  589. environment variable or via the --gnulib-srcdir option), then sources
  590. are fetched from that local directory. If it is a git repository and
  591. the configuration variable GNULIB_REVISION is set in bootstrap.conf,
  592. then that revision is checked out.
  593. * Otherwise, if this package is in a git repository with a 'gnulib'
  594. submodule configured, then that submodule is initialized and updated
  595. and sources are fetched from there. If GNULIB_REFDIR is set (either
  596. as an environment variable or via the --gnulib-refdir option) and is
  597. a git repository, then it is used as a reference.
  598. * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
  599. are cloned into that directory using git from \$GNULIB_URL, defaulting
  600. to $default_gnulib_url.
  601. If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
  602. then that revision is checked out.
  603. * Otherwise, the existing Gnulib sources in the 'gnulib' directory are
  604. used. If it is a git repository and the configuration variable
  605. GNULIB_REVISION is set in bootstrap.conf, then that revision is
  606. checked out.
  607. If you maintain a package and want to pin a particular revision of the
  608. Gnulib sources that has been tested with your package, then there are
  609. two possible approaches: either configure a 'gnulib' submodule with the
  610. appropriate revision, or set GNULIB_REVISION (and if necessary
  611. GNULIB_URL) in bootstrap.conf.
  612. Running without arguments will suffice in most cases.
  613. EOF
  614. }
  615. # Fetch auxiliary files that are omitted from the version control
  616. # repository of this package.
  617. autopull()
  618. {
  619. # Ensure that CDPATH is not set. Otherwise, the output from cd
  620. # would cause trouble in at least one use below.
  621. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
  622. # Parse options.
  623. # Use git to update gnulib sources
  624. use_git=true
  625. for option
  626. do
  627. case $option in
  628. --help)
  629. autopull_usage
  630. return;;
  631. --version)
  632. set -e
  633. echo "autopull.sh $scriptlibversion"
  634. echo "$copyright"
  635. return 0
  636. ;;
  637. --skip-po)
  638. SKIP_PO=t;;
  639. --force)
  640. checkout_only_file=;;
  641. --bootstrap-sync)
  642. bootstrap_sync=true;;
  643. --no-bootstrap-sync)
  644. bootstrap_sync=false;;
  645. --no-git)
  646. use_git=false;;
  647. *)
  648. bootstrap_option_hook $option || die "$option: unknown option";;
  649. esac
  650. done
  651. $use_git || test -n "$GNULIB_SRCDIR" \
  652. || die "Error: --no-git requires \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option"
  653. test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
  654. || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option is specified, but does not denote a directory"
  655. if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
  656. die "Running this script from a non-checked-out distribution is risky."
  657. fi
  658. check_build_prerequisites $use_git
  659. if $use_gnulib || $bootstrap_sync; then
  660. prepare_GNULIB_SRCDIR
  661. if $bootstrap_sync; then
  662. upgrade_bootstrap
  663. fi
  664. fi
  665. # Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6.
  666. # Also find the compatible sha1 utility on the BSDs
  667. if test x"$SKIP_PO" = x; then
  668. find_tool SHA1SUM sha1sum gsha1sum shasum sha1
  669. fi
  670. # See if we can use gnulib's git-merge-changelog merge driver.
  671. if $use_git && test -d .git && check_exists git; then
  672. if git config merge.merge-changelog.driver >/dev/null ; then
  673. :
  674. elif check_exists git-merge-changelog; then
  675. echo "$0: initializing git-merge-changelog driver"
  676. git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
  677. git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
  678. else
  679. echo "$0: consider installing git-merge-changelog from gnulib"
  680. fi
  681. fi
  682. case $SKIP_PO in
  683. '')
  684. if test -d po; then
  685. update_po_files po $package || return
  686. fi
  687. if test -d runtime-po; then
  688. update_po_files runtime-po $package-runtime || return
  689. fi;;
  690. esac
  691. # ---------------------------------------------------------------------------
  692. bootstrap_post_pull_hook \
  693. || die "bootstrap_post_pull_hook failed"
  694. # Don't proceed if there are uninitialized submodules. In particular,
  695. # autogen.sh will remove dangling links, which might be links into
  696. # uninitialized submodules.
  697. # But it's OK if the 'gnulib' submodule is uninitialized, as long as
  698. # GNULIB_SRCDIR is set.
  699. if $use_git; then
  700. # Uninitialized submodules are listed with an initial dash.
  701. uninitialized=`git submodule | grep '^-' | awk '{ print $2 }'`
  702. if test -n "$GNULIB_SRCDIR"; then
  703. uninitialized=`echo "$uninitialized" | grep -v '^gnulib$'`
  704. fi
  705. if test -n "$uninitialized"; then
  706. die "Some git submodules are not initialized: "`echo "$uninitialized" | tr '\n' ',' | sed -e 's|,$|.|'`" Either use option '--no-git', or run 'git submodule update --init' and bootstrap again."
  707. fi
  708. fi
  709. if test -f "$medir"/autogen.sh; then
  710. echo "$0: done. Now you can run '$medir/autogen.sh'."
  711. fi
  712. }
  713. # ----------------------------- Get translations. -----------------------------
  714. download_po_files() {
  715. subdir=$1
  716. domain=$2
  717. echo "$me: getting translations into $subdir for $domain..."
  718. cmd=$(printf "$po_download_command_format" "$subdir" "$domain")
  719. eval "$cmd"
  720. }
  721. # Mirror .po files to $po_dir/.reference and copy only the new
  722. # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
  723. # Note po files that exist locally only are left in $po_dir but will
  724. # not be included in LINGUAS and hence will not be distributed.
  725. update_po_files() {
  726. # Directory containing primary .po files.
  727. # Overwrite them only when we're sure a .po file is new.
  728. po_dir=$1
  729. domain=$2
  730. # Mirror *.po files into this dir.
  731. # Usually contains *.s1 checksum files.
  732. ref_po_dir="$po_dir/.reference"
  733. test -d $ref_po_dir || mkdir $ref_po_dir || return
  734. download_po_files $ref_po_dir $domain \
  735. && ls "$ref_po_dir"/*.po 2>/dev/null |
  736. sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
  737. langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g')
  738. test "$langs" = '*' && langs=x
  739. for po in $langs; do
  740. case $po in x) continue;; esac
  741. new_po="$ref_po_dir/$po.po"
  742. cksum_file="$ref_po_dir/$po.s1"
  743. if ! test -f "$cksum_file" ||
  744. ! test -f "$po_dir/$po.po" ||
  745. ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then
  746. echo "$me: updated $po_dir/$po.po..."
  747. cp "$new_po" "$po_dir/$po.po" \
  748. && $SHA1SUM < "$new_po" > "$cksum_file" || return
  749. fi
  750. done
  751. }
  752. # -------- Generate files automatically from existing sources. --------------
  753. autogen_usage() {
  754. cat <<EOF
  755. Usage: $me [OPTION]...
  756. Bootstrap this package from the checked-out sources.
  757. Optional environment variables:
  758. GNULIB_SRCDIR Specifies the local directory where gnulib
  759. sources reside. Use this if you already
  760. have gnulib sources on your machine, and
  761. you want to use these sources.
  762. Options:
  763. --copy copy files instead of creating symbolic links
  764. --force attempt to bootstrap even if the sources seem
  765. not to have been checked out
  766. EOF
  767. bootstrap_print_option_usage_hook
  768. cat <<EOF
  769. If the file bootstrap.conf exists in the same directory as this script, its
  770. contents are read as shell variables to configure the bootstrap.
  771. For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
  772. are honored.
  773. Gnulib sources are assumed to be present:
  774. * in \$GNULIB_SRCDIR, if that environment variable is set,
  775. * otherwise, in the 'gnulib' submodule, if such a submodule is configured,
  776. * otherwise, in the 'gnulib' subdirectory.
  777. Running without arguments will suffice in most cases.
  778. EOF
  779. }
  780. version_controlled_file() {
  781. parent=$1
  782. file=$2
  783. if test -d .git; then
  784. git rm -n "$file" > /dev/null 2>&1
  785. elif test -d .svn; then
  786. svn log -r HEAD "$file" > /dev/null 2>&1
  787. elif test -d CVS; then
  788. grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
  789. grep '^/[^/]*/[0-9]' > /dev/null
  790. else
  791. warn_ "no version control for $file?"
  792. false
  793. fi
  794. }
  795. # Strip blank and comment lines to leave significant entries.
  796. gitignore_entries() {
  797. sed '/^#/d; /^$/d' "$@"
  798. }
  799. # If $STR is not already on a line by itself in $FILE, insert it at the start.
  800. # Entries are inserted at the start of the ignore list to ensure existing
  801. # entries starting with ! are not overridden. Such entries support
  802. # whitelisting exceptions after a more generic blacklist pattern.
  803. insert_if_absent() {
  804. file=$1
  805. str=$2
  806. test -f $file || touch $file
  807. test -r $file || die "Error: failed to read ignore file: $file"
  808. duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
  809. if [ "$duplicate_entries" ] ; then
  810. die "Error: Duplicate entries in $file: " $duplicate_entries
  811. fi
  812. linesold=$(gitignore_entries $file | wc -l)
  813. linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l)
  814. if [ $linesold != $linesnew ] ; then
  815. { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
  816. || die "insert_if_absent $file $str: failed"
  817. fi
  818. }
  819. # Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
  820. # insert_if_absent.
  821. insert_vc_ignore() {
  822. vc_ignore_file="$1"
  823. pattern="$2"
  824. case $vc_ignore_file in
  825. *.gitignore)
  826. # A .gitignore entry that does not start with '/' applies
  827. # recursively to subdirectories, so prepend '/' to every
  828. # .gitignore entry.
  829. pattern=$(echo "$pattern" | sed s,^,/,);;
  830. esac
  831. insert_if_absent "$vc_ignore_file" "$pattern"
  832. }
  833. symlink_to_dir()
  834. {
  835. src=$1/$2
  836. dst=${3-$2}
  837. test -f "$src" && {
  838. # If the destination directory doesn't exist, create it.
  839. # This is required at least for "lib/uniwidth/cjk.h".
  840. dst_dir=$(dirname "$dst")
  841. if ! test -d "$dst_dir"; then
  842. mkdir -p "$dst_dir"
  843. # If we've just created a directory like lib/uniwidth,
  844. # tell version control system(s) it's ignorable.
  845. # FIXME: for now, this does only one level
  846. parent=$(dirname "$dst_dir")
  847. for dot_ig in x $vc_ignore; do
  848. test $dot_ig = x && continue
  849. ig=$parent/$dot_ig
  850. insert_vc_ignore $ig "${dst_dir##*/}/"
  851. done
  852. fi
  853. if $copy; then
  854. {
  855. test ! -h "$dst" || {
  856. echo "$me: rm -f $dst" &&
  857. rm -f "$dst"
  858. }
  859. } &&
  860. test -f "$dst" &&
  861. cmp -s "$src" "$dst" || {
  862. echo "$me: cp -fp $src $dst" &&
  863. cp -fp "$src" "$dst"
  864. }
  865. else
  866. # Leave any existing symlink alone, if it already points to the source,
  867. # so that broken build tools that care about symlink times
  868. # aren't confused into doing unnecessary builds. Conversely, if the
  869. # existing symlink's timestamp is older than the source, make it afresh,
  870. # so that broken tools aren't confused into skipping needed builds. See
  871. # <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00326.html>.
  872. test -h "$dst" &&
  873. src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
  874. dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
  875. test "$src_i" = "$dst_i" &&
  876. both_ls=$(ls -dt "$src" "$dst") &&
  877. test "X$both_ls" = "X$dst$nl$src" || {
  878. dot_dots=
  879. case $src in
  880. /*) ;;
  881. *)
  882. case /$dst/ in
  883. *//* | */../* | */./* | /*/*/*/*/*/)
  884. die "invalid symlink calculation: $src -> $dst";;
  885. /*/*/*/*/) dot_dots=../../../;;
  886. /*/*/*/) dot_dots=../../;;
  887. /*/*/) dot_dots=../;;
  888. esac;;
  889. esac
  890. echo "$me: ln -fs $dot_dots$src $dst" &&
  891. ln -fs "$dot_dots$src" "$dst"
  892. }
  893. fi
  894. }
  895. }
  896. # Regenerate all autogeneratable files that are omitted from the
  897. # version control repository. In particular, regenerate all
  898. # aclocal.m4, config.h.in, Makefile.in, configure files with new
  899. # versions of autoconf or automake.
  900. autogen()
  901. {
  902. # Ensure that CDPATH is not set. Otherwise, the output from cd
  903. # would cause trouble in at least one use below.
  904. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
  905. # Environment variables that may be set by the user.
  906. : "${AUTOPOINT=autopoint}"
  907. : "${AUTORECONF=autoreconf}"
  908. if test "$vc_ignore" = auto; then
  909. vc_ignore=
  910. test -d .git && vc_ignore=.gitignore
  911. test -d CVS && vc_ignore="$vc_ignore .cvsignore"
  912. fi
  913. # Parse options.
  914. # Whether to use copies instead of symlinks.
  915. copy=false
  916. for option
  917. do
  918. case $option in
  919. --help)
  920. autogen_usage
  921. return;;
  922. --version)
  923. set -e
  924. echo "autogen.sh $scriptlibversion"
  925. echo "$copyright"
  926. return 0
  927. ;;
  928. --force)
  929. checkout_only_file=;;
  930. --copy)
  931. copy=true;;
  932. *)
  933. bootstrap_option_hook $option || die "$option: unknown option";;
  934. esac
  935. done
  936. test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
  937. || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option is specified, but does not denote a directory"
  938. if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
  939. die "Running this script from a non-checked-out distribution is risky."
  940. fi
  941. if $use_gnulib; then
  942. if test -z "$GNULIB_SRCDIR"; then
  943. gnulib_path=$(test -f .gitmodules && git config --file .gitmodules submodule.gnulib.path)
  944. test -z "$gnulib_path" && gnulib_path=gnulib
  945. GNULIB_SRCDIR=$gnulib_path
  946. fi
  947. fi
  948. # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
  949. found_aux_dir=no
  950. grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'])' configure.ac \
  951. >/dev/null && found_aux_dir=yes
  952. grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
  953. >/dev/null && found_aux_dir=yes
  954. test $found_aux_dir = yes \
  955. || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
  956. # If $build_aux doesn't exist, create it now, otherwise some bits
  957. # below will malfunction. If creating it, also mark it as ignored.
  958. if test ! -d $build_aux; then
  959. mkdir $build_aux
  960. for dot_ig in x $vc_ignore; do
  961. test $dot_ig = x && continue
  962. insert_vc_ignore $dot_ig $build_aux/
  963. done
  964. fi
  965. check_build_prerequisites false
  966. use_libtool=0
  967. # We'd like to use grep -E, to see if any of LT_INIT,
  968. # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
  969. # but that's not portable enough (e.g., for Solaris).
  970. grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
  971. && use_libtool=1
  972. grep '^[ ]*LT_INIT' configure.ac >/dev/null \
  973. && use_libtool=1
  974. if test $use_libtool = 1; then
  975. find_tool LIBTOOLIZE glibtoolize libtoolize
  976. fi
  977. if $use_gnulib; then
  978. gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
  979. <$gnulib_tool || return
  980. fi
  981. # NOTE: we have to be careful to run both autopoint and libtoolize
  982. # before gnulib-tool, since gnulib-tool is likely to provide newer
  983. # versions of files "installed" by these two programs.
  984. # Then, *after* gnulib-tool (see below), we have to be careful to
  985. # run autoreconf in such a way that it does not run either of these
  986. # two just-pre-run programs.
  987. # Import from gettext.
  988. with_gettext=yes
  989. grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
  990. with_gettext=no
  991. if test $with_gettext = yes || test $use_libtool = 1; then
  992. tempbase=.bootstrap$$
  993. trap "rm -f $tempbase.0 $tempbase.1" HUP INT PIPE TERM
  994. > $tempbase.0 > $tempbase.1 &&
  995. find . ! -type d -print | sort > $tempbase.0 || return
  996. if test $with_gettext = yes; then
  997. # Released autopoint has the tendency to install macros that have been
  998. # obsoleted in current gnulib, so run this before gnulib-tool.
  999. echo "$0: $AUTOPOINT --force"
  1000. $AUTOPOINT --force || return
  1001. fi
  1002. # Autoreconf runs aclocal before libtoolize, which causes spurious
  1003. # warnings if the initial aclocal is confused by the libtoolized
  1004. # (or worse out-of-date) macro directory.
  1005. # libtoolize 1.9b added the --install option; but we support back
  1006. # to libtoolize 1.5.22, where the install action was default.
  1007. if test $use_libtool = 1; then
  1008. install=
  1009. case $($LIBTOOLIZE --help) in
  1010. *--install*) install=--install ;;
  1011. esac
  1012. echo "running: $LIBTOOLIZE $install --copy"
  1013. $LIBTOOLIZE $install --copy
  1014. fi
  1015. find . ! -type d -print | sort >$tempbase.1
  1016. old_IFS=$IFS
  1017. IFS=$nl
  1018. for file in $(comm -13 $tempbase.0 $tempbase.1); do
  1019. IFS=$old_IFS
  1020. parent=${file%/*}
  1021. version_controlled_file "$parent" "$file" || {
  1022. for dot_ig in x $vc_ignore; do
  1023. test $dot_ig = x && continue
  1024. ig=$parent/$dot_ig
  1025. insert_vc_ignore "$ig" "${file##*/}"
  1026. done
  1027. }
  1028. done
  1029. IFS=$old_IFS
  1030. rm -f $tempbase.0 $tempbase.1
  1031. trap - HUP INT PIPE TERM
  1032. fi
  1033. # Import from gnulib.
  1034. if $use_gnulib; then
  1035. gnulib_tool_options="\
  1036. --no-changelog\
  1037. --aux-dir=$build_aux\
  1038. --doc-base=$doc_base\
  1039. --lib=$gnulib_name\
  1040. --m4-base=$m4_base/\
  1041. --source-base=$source_base/\
  1042. --tests-base=$tests_base\
  1043. --local-dir=$local_gl_dir\
  1044. $gnulib_tool_option_extras\
  1045. "
  1046. if test $use_libtool = 1; then
  1047. case "$gnulib_tool_options " in
  1048. *' --libtool '*) ;;
  1049. *) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
  1050. esac
  1051. fi
  1052. echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
  1053. $gnulib_tool $gnulib_tool_options --import $gnulib_modules \
  1054. || die "gnulib-tool failed"
  1055. for file in $gnulib_files; do
  1056. symlink_to_dir "$GNULIB_SRCDIR" $file \
  1057. || die "failed to symlink $file"
  1058. done
  1059. fi
  1060. bootstrap_post_import_hook \
  1061. || die "bootstrap_post_import_hook failed"
  1062. # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
  1063. # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
  1064. # The following requires GNU find 4.2.3 or newer. Considering the usual
  1065. # portability constraints of this script, that may seem a very demanding
  1066. # requirement, but it should be ok. Ignore any failure, which is fine,
  1067. # since this is only a convenience to help developers avoid the relatively
  1068. # unusual case in which a symlinked-to .m4 file is git-removed from gnulib
  1069. # between successive runs of this script.
  1070. find "$m4_base" "$source_base" \
  1071. -depth \( -name '*.m4' -o -name '*.[ch]' \) \
  1072. -type l -xtype l -delete > /dev/null 2>&1
  1073. # Invoke autoreconf with --force --install to ensure upgrades of tools
  1074. # such as ylwrap.
  1075. AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS"
  1076. AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive"
  1077. # Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
  1078. echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS"
  1079. AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \
  1080. || die "autoreconf failed"
  1081. # Get some extra files from gnulib, overriding existing files.
  1082. for file in $gnulib_extra_files; do
  1083. case $file in
  1084. */INSTALL) dst=INSTALL;;
  1085. build-aux/*) dst=$build_aux/${file#build-aux/};;
  1086. *) dst=$file;;
  1087. esac
  1088. symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
  1089. || die "failed to symlink $file"
  1090. done
  1091. if test $with_gettext = yes; then
  1092. # Create gettext configuration.
  1093. echo "$0: Creating po/Makevars from po/Makevars.template ..."
  1094. rm -f po/Makevars
  1095. sed '
  1096. /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
  1097. /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
  1098. /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
  1099. /^XGETTEXT_OPTIONS *=/{
  1100. s/$/ \\/
  1101. a\
  1102. '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
  1103. }
  1104. ' po/Makevars.template >po/Makevars \
  1105. || die 'cannot generate po/Makevars'
  1106. # If the 'gettext' module is in use, grab the latest Makefile.in.in.
  1107. # If only the 'gettext-h' module is in use, assume autopoint already
  1108. # put the correct version of this file into place.
  1109. case $gnulib_modules in
  1110. *gettext-h*) ;;
  1111. *gettext*)
  1112. cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
  1113. || die "cannot create po/Makefile.in.in"
  1114. ;;
  1115. esac
  1116. if test -d runtime-po; then
  1117. # Similarly for runtime-po/Makevars, but not quite the same.
  1118. rm -f runtime-po/Makevars
  1119. sed '
  1120. /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
  1121. /^subdir *=.*/s/=.*/= runtime-po/
  1122. /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
  1123. /^XGETTEXT_OPTIONS *=/{
  1124. s/$/ \\/
  1125. a\
  1126. '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
  1127. }
  1128. ' po/Makevars.template >runtime-po/Makevars \
  1129. || die 'cannot generate runtime-po/Makevars'
  1130. # Copy identical files from po to runtime-po.
  1131. (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
  1132. fi
  1133. fi
  1134. bootstrap_epilogue
  1135. echo "$0: done. Now you can run './configure'."
  1136. }
  1137. # ----------------------------------------------------------------------------
  1138. # Local Variables:
  1139. # eval: (add-hook 'before-save-hook 'time-stamp)
  1140. # time-stamp-start: "scriptlibversion="
  1141. # time-stamp-format: "%:y-%02m-%02d.%02H"
  1142. # time-stamp-time-zone: "UTC0"
  1143. # time-stamp-end: "; # UTC"
  1144. # End:
  1145. usage() {
  1146. cat <<EOF
  1147. Usage: $me [OPTION]...
  1148. Bootstrap this package from the checked-out sources.
  1149. Optional environment variables:
  1150. GNULIB_SRCDIR Specifies the local directory where gnulib
  1151. sources reside. Use this if you already
  1152. have gnulib sources on your machine, and
  1153. do not want to waste your bandwidth downloading
  1154. them again.
  1155. GNULIB_URL Cloneable URL of the gnulib repository.
  1156. Options:
  1157. --pull Do phase 1: pull files from network
  1158. --gen Do phase 2: generate from local files.
  1159. (The default is to do both phases.)
  1160. --gnulib-srcdir=DIRNAME specify the local directory where gnulib
  1161. sources reside. Use this if you already
  1162. have gnulib sources on your machine, and
  1163. you want to use these sources. Defaults
  1164. to \$GNULIB_SRCDIR
  1165. --gnulib-refdir=DIRNAME specify the local directory where a gnulib
  1166. repository (with a .git subdirectory) resides.
  1167. Use this if you already have gnulib sources
  1168. and history on your machine, and do not want
  1169. to waste your bandwidth downloading them again.
  1170. Defaults to \$GNULIB_REFDIR
  1171. --bootstrap-sync if this bootstrap script is not identical to
  1172. the version in the local gnulib sources,
  1173. update this script, and then restart it with
  1174. /bin/sh or the shell \$CONFIG_SHELL
  1175. --no-bootstrap-sync do not check whether bootstrap is out of sync
  1176. --copy copy files instead of creating symbolic links
  1177. --force attempt to bootstrap even if the sources seem
  1178. not to have been checked out
  1179. --no-git do not use git to update gnulib. Requires that
  1180. \$GNULIB_SRCDIR or the --gnulib-srcdir option
  1181. points to a gnulib repository with the correct
  1182. revision
  1183. --skip-po do not download po files
  1184. EOF
  1185. bootstrap_print_option_usage_hook
  1186. cat <<EOF
  1187. If the file bootstrap.conf exists in the same directory as this script, its
  1188. contents are read as shell variables to configure the bootstrap.
  1189. For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
  1190. are honored.
  1191. Gnulib sources can be fetched in various ways:
  1192. * If the environment variable GNULIB_SRCDIR is set (either as an
  1193. environment variable or via the --gnulib-srcdir option), then sources
  1194. are fetched from that local directory. If it is a git repository and
  1195. the configuration variable GNULIB_REVISION is set in bootstrap.conf,
  1196. then that revision is checked out.
  1197. * Otherwise, if this package is in a git repository with a 'gnulib'
  1198. submodule configured, then that submodule is initialized and updated
  1199. and sources are fetched from there. If GNULIB_REFDIR is set (either
  1200. as an environment variable or via the --gnulib-refdir option) and is
  1201. a git repository, then it is used as a reference.
  1202. * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
  1203. are cloned into that directory using git from \$GNULIB_URL, defaulting
  1204. to $default_gnulib_url.
  1205. If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
  1206. then that revision is checked out.
  1207. * Otherwise, the existing Gnulib sources in the 'gnulib' directory are
  1208. used. If it is a git repository and the configuration variable
  1209. GNULIB_REVISION is set in bootstrap.conf, then that revision is
  1210. checked out.
  1211. If you maintain a package and want to pin a particular revision of the
  1212. Gnulib sources that has been tested with your package, then there are
  1213. two possible approaches: either configure a 'gnulib' submodule with the
  1214. appropriate revision, or set GNULIB_REVISION (and if necessary
  1215. GNULIB_URL) in bootstrap.conf.
  1216. Running without arguments will suffice in most cases.
  1217. EOF
  1218. }
  1219. # Parse options.
  1220. # Whether to pull and generate.
  1221. pull=false
  1222. gen=false
  1223. # Whether to use copies instead of symlinks.
  1224. copy=false
  1225. # Use git to update gnulib sources
  1226. use_git=true
  1227. for option
  1228. do
  1229. case $option in
  1230. --help)
  1231. usage
  1232. exit;;
  1233. --version)
  1234. set -e
  1235. echo "bootstrap $scriptversion lib $scriptlibversion"
  1236. echo "$copyright"
  1237. exit 0
  1238. ;;
  1239. --pull)
  1240. pull=true;;
  1241. --gen)
  1242. gen=true;;
  1243. --gnulib-srcdir=*)
  1244. GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
  1245. --gnulib-refdir=*)
  1246. GNULIB_REFDIR=${option#--gnulib-refdir=};;
  1247. --skip-po)
  1248. SKIP_PO=t;;
  1249. --force)
  1250. checkout_only_file=;;
  1251. --copy)
  1252. copy=true;;
  1253. --bootstrap-sync)
  1254. bootstrap_sync=true;;
  1255. --no-bootstrap-sync)
  1256. bootstrap_sync=false;;
  1257. --no-git)
  1258. use_git=false;;
  1259. *)
  1260. bootstrap_option_hook $option || die "$option: unknown option";;
  1261. esac
  1262. done
  1263. # Default is to do both.
  1264. $pull || $gen || pull=true gen=true
  1265. $use_git || test -n "$GNULIB_SRCDIR" \
  1266. || die "Error: --no-git requires \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option"
  1267. test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
  1268. || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option is specified, but does not denote a directory"
  1269. if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
  1270. die "Bootstrapping from a non-checked-out distribution is risky."
  1271. fi
  1272. check_build_prerequisites $use_git
  1273. if $bootstrap_sync; then
  1274. prepare_GNULIB_SRCDIR
  1275. upgrade_bootstrap
  1276. # Since we have now upgraded if needed, no need to try it a second time below.
  1277. bootstrap_sync=false
  1278. fi
  1279. echo "$0: Bootstrapping from checked-out $package sources..."
  1280. # Pass GNULIB_SRCDIR and GNULIB_REFDIR to any subsidiary commands that care.
  1281. export GNULIB_SRCDIR
  1282. export GNULIB_REFDIR
  1283. if $pull && { $use_git || test -z "$SKIP_PO"; }; then
  1284. autopull \
  1285. `if $bootstrap_sync; then echo ' --bootstrap-sync'; else echo ' --no-bootstrap-sync'; fi` \
  1286. `if test -z "$checkout_only_file"; then echo ' --force'; fi` \
  1287. `if ! $use_git; then echo ' --no-git'; fi` \
  1288. `if test -n "$SKIP_PO"; then echo ' --skip-po'; fi` \
  1289. || die "could not fetch auxiliary files"
  1290. fi
  1291. if $gen; then
  1292. autogen \
  1293. `if $copy; then echo ' --copy'; fi` \
  1294. `if test -z "$checkout_only_file"; then echo ' --force'; fi` \
  1295. || die "could not generate auxiliary files"
  1296. fi
  1297. # ----------------------------------------------------------------------------
  1298. # Local Variables:
  1299. # eval: (add-hook 'before-save-hook 'time-stamp)
  1300. # time-stamp-start: "scriptversion="
  1301. # time-stamp-format: "%:y-%02m-%02d.%02H"
  1302. # time-stamp-time-zone: "UTC0"
  1303. # time-stamp-end: "; # UTC"
  1304. # End: