4
0

bootstrap 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888
  1. #! /bin/sh
  2. # Print a version string.
  3. scriptversion=2010-10-08.16; # UTC
  4. # Bootstrap this package from checked-out sources.
  5. # Copyright (C) 2003-2010 Free Software Foundation, Inc.
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  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. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Originally written by Paul Eggert. The canonical version of this
  17. # script is maintained as build-aux/bootstrap in gnulib, however, to
  18. # be useful to your project, you should place a copy of it under
  19. # version control in the top-level directory of your project. The
  20. # intent is that all customization can be done with a bootstrap.conf
  21. # file also maintained in your version control; gnulib comes with a
  22. # template build-aux/bootstrap.conf to get you started.
  23. # Please report bugs or propose patches to bug-gnulib@gnu.org.
  24. nl='
  25. '
  26. # Ensure file names are sorted consistently across platforms.
  27. LC_ALL=C
  28. export LC_ALL
  29. local_gl_dir=gl
  30. # Temporary directory names.
  31. bt='._bootmp'
  32. bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
  33. bt2=${bt}2
  34. usage() {
  35. cat <<EOF
  36. Usage: $0 [OPTION]...
  37. Bootstrap this package from the checked-out sources.
  38. Options:
  39. --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
  40. sources reside. Use this if you already
  41. have gnulib sources on your machine, and
  42. do not want to waste your bandwidth downloading
  43. them again. Defaults to \$GNULIB_SRCDIR.
  44. --copy Copy files instead of creating symbolic links.
  45. --force Attempt to bootstrap even if the sources seem
  46. not to have been checked out.
  47. --skip-po Do not download po files.
  48. If the file $0.conf exists in the same directory as this script, its
  49. contents are read as shell variables to configure the bootstrap.
  50. For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
  51. are honored.
  52. Running without arguments will suffice in most cases.
  53. EOF
  54. }
  55. # Configuration.
  56. # Name of the Makefile.am
  57. gnulib_mk=gnulib.mk
  58. # List of gnulib modules needed.
  59. gnulib_modules=
  60. # Any gnulib files needed that are not in modules.
  61. gnulib_files=
  62. # A function to be called to edit gnulib.mk right after it's created.
  63. # Override it via your own definition in bootstrap.conf.
  64. gnulib_mk_hook() { :; }
  65. # A function to be called after everything else in this script.
  66. # Override it via your own definition in bootstrap.conf.
  67. bootstrap_epilogue() { :; }
  68. # The command to download all .po files for a specified domain into
  69. # a specified directory. Fill in the first %s is the domain name, and
  70. # the second with the destination directory. Use rsync's -L and -r
  71. # options because the latest/%s directory and the .po files within are
  72. # all symlinks.
  73. po_download_command_format=\
  74. "rsync --delete --exclude '*.s1' -Lrtvz \
  75. 'translationproject.org::tp/latest/%s/' '%s'"
  76. extract_package_name='
  77. /^AC_INIT(/{
  78. /.*,.*,.*, */{
  79. s///
  80. s/[][]//g
  81. s/)$//
  82. p
  83. q
  84. }
  85. s/AC_INIT(\[*//
  86. s/]*,.*//
  87. s/^GNU //
  88. y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
  89. s/[^A-Za-z0-9_]/-/g
  90. p
  91. }
  92. '
  93. package=`sed -n "$extract_package_name" configure.ac` || exit
  94. gnulib_name=lib$package
  95. build_aux=build-aux
  96. source_base=lib
  97. m4_base=m4
  98. doc_base=doc
  99. tests_base=tests
  100. # Extra files from gnulib, which override files from other sources.
  101. gnulib_extra_files="
  102. $build_aux/install-sh
  103. $build_aux/missing
  104. $build_aux/mdate-sh
  105. $build_aux/texinfo.tex
  106. $build_aux/depcomp
  107. $build_aux/config.guess
  108. $build_aux/config.sub
  109. doc/INSTALL
  110. "
  111. # Additional gnulib-tool options to use. Use "\newline" to break lines.
  112. gnulib_tool_option_extras=
  113. # Other locale categories that need message catalogs.
  114. EXTRA_LOCALE_CATEGORIES=
  115. # Additional xgettext options to use. Use "\\\newline" to break lines.
  116. XGETTEXT_OPTIONS='\\\
  117. --flag=_:1:pass-c-format\\\
  118. --flag=N_:1:pass-c-format\\\
  119. --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
  120. '
  121. # Package bug report address and copyright holder for gettext files
  122. COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
  123. MSGID_BUGS_ADDRESS=bug-$package@gnu.org
  124. # Files we don't want to import.
  125. excluded_files=
  126. # File that should exist in the top directory of a checked out hierarchy,
  127. # but not in a distribution tarball.
  128. checkout_only_file=README-hacking
  129. # Whether to use copies instead of symlinks.
  130. copy=false
  131. # Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
  132. # those files to be generated in directories like lib/, m4/, and po/.
  133. # Or set it to 'auto' to make this script select which to use based
  134. # on which version control system (if any) is used in the source directory.
  135. vc_ignore=auto
  136. # find_tool ENVVAR NAMES...
  137. # -------------------------
  138. # Search for a required program. Use the value of ENVVAR, if set,
  139. # otherwise find the first of the NAMES that can be run (i.e.,
  140. # supports --version). If found, set ENVVAR to the program name,
  141. # die otherwise.
  142. find_tool ()
  143. {
  144. find_tool_envvar=$1
  145. shift
  146. find_tool_names=$@
  147. eval "find_tool_res=\$$find_tool_envvar"
  148. if test x"$find_tool_res" = x; then
  149. for i
  150. do
  151. if ($i --version </dev/null) >/dev/null 2>&1; then
  152. find_tool_res=$i
  153. break
  154. fi
  155. done
  156. else
  157. find_tool_error_prefix="\$$find_tool_envvar: "
  158. fi
  159. if test x"$find_tool_res" = x; then
  160. echo >&2 "$0: one of these is required: $find_tool_names"
  161. exit 1
  162. fi
  163. ($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
  164. echo >&2 "$0: ${find_tool_error_prefix}cannot run $find_tool_res --version"
  165. exit 1
  166. }
  167. eval "$find_tool_envvar=\$find_tool_res"
  168. eval "export $find_tool_envvar"
  169. }
  170. # Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6.
  171. find_tool SHA1SUM sha1sum gsha1sum shasum
  172. # Override the default configuration, if necessary.
  173. # Make sure that bootstrap.conf is sourced from the current directory
  174. # if we were invoked as "sh bootstrap".
  175. case "$0" in
  176. */*) test -r "$0.conf" && . "$0.conf" ;;
  177. *) test -r "$0.conf" && . ./"$0.conf" ;;
  178. esac
  179. if test "$vc_ignore" = auto; then
  180. vc_ignore=
  181. test -d .git && vc_ignore=.gitignore
  182. test -d CVS && vc_ignore="$vc_ignore .cvsignore"
  183. fi
  184. # Translate configuration into internal form.
  185. # Parse options.
  186. for option
  187. do
  188. case $option in
  189. --help)
  190. usage
  191. exit;;
  192. --gnulib-srcdir=*)
  193. GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;;
  194. --skip-po)
  195. SKIP_PO=t;;
  196. --force)
  197. checkout_only_file=;;
  198. --copy)
  199. copy=true;;
  200. *)
  201. echo >&2 "$0: $option: unknown option"
  202. exit 1;;
  203. esac
  204. done
  205. if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
  206. echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
  207. exit 1
  208. fi
  209. # If $STR is not already on a line by itself in $FILE, insert it,
  210. # sorting the new contents of the file and replacing $FILE with the result.
  211. insert_sorted_if_absent() {
  212. file=$1
  213. str=$2
  214. test -f $file || touch $file
  215. echo "$str" | sort -u - $file | cmp - $file > /dev/null \
  216. || echo "$str" | sort -u - $file -o $file \
  217. || exit 1
  218. }
  219. # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
  220. found_aux_dir=no
  221. grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
  222. >/dev/null && found_aux_dir=yes
  223. grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
  224. >/dev/null && found_aux_dir=yes
  225. if test $found_aux_dir = no; then
  226. echo "$0: expected line not found in configure.ac. Add the following:" >&2
  227. echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
  228. exit 1
  229. fi
  230. # If $build_aux doesn't exist, create it now, otherwise some bits
  231. # below will malfunction. If creating it, also mark it as ignored.
  232. if test ! -d $build_aux; then
  233. mkdir $build_aux
  234. for dot_ig in x $vc_ignore; do
  235. test $dot_ig = x && continue
  236. insert_sorted_if_absent $dot_ig $build_aux
  237. done
  238. fi
  239. # Note this deviates from the version comparison in automake
  240. # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
  241. # but this should suffice as we won't be specifying old
  242. # version formats or redundant trailing .0 in bootstrap.conf.
  243. # If we did want full compatibility then we should probably
  244. # use m4_version_compare from autoconf.
  245. sort_ver() { # sort -V is not generally available
  246. ver1="$1"
  247. ver2="$2"
  248. # split on '.' and compare each component
  249. i=1
  250. while : ; do
  251. p1=$(echo "$ver1" | cut -d. -f$i)
  252. p2=$(echo "$ver2" | cut -d. -f$i)
  253. if [ ! "$p1" ]; then
  254. echo "$1 $2"
  255. break
  256. elif [ ! "$p2" ]; then
  257. echo "$2 $1"
  258. break
  259. elif [ ! "$p1" = "$p2" ]; then
  260. if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
  261. echo "$2 $1"
  262. elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
  263. echo "$1 $2"
  264. else # numeric, then lexicographic comparison
  265. lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
  266. if [ "$lp" = "$p2" ]; then
  267. echo "$1 $2"
  268. else
  269. echo "$2 $1"
  270. fi
  271. fi
  272. break
  273. fi
  274. i=$(($i+1))
  275. done
  276. }
  277. get_version() {
  278. app=$1
  279. $app --version >/dev/null 2>&1 || return 1
  280. $app --version 2>&1 |
  281. sed -n '# extract version within line
  282. s/.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
  283. t done
  284. # extract version at start of line
  285. s/^\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
  286. t done
  287. d
  288. :done
  289. #the following essentially does s/5.005/5.5/
  290. s/\.0*\([1-9]\)/.\1/g
  291. p
  292. q'
  293. }
  294. check_versions() {
  295. ret=0
  296. while read app req_ver; do
  297. # We only need libtoolize from the libtool package.
  298. if test "$app" = libtool; then
  299. app=libtoolize
  300. fi
  301. # Honor $APP variables ($TAR, $AUTOCONF, etc.)
  302. appvar=`echo $app | tr '[a-z]-' '[A-Z]_'`
  303. test "$appvar" = TAR && appvar=AMTAR
  304. eval "app=\${$appvar-$app}"
  305. inst_ver=$(get_version $app)
  306. if [ ! "$inst_ver" ]; then
  307. echo "Error: '$app' not found" >&2
  308. ret=1
  309. elif [ ! "$req_ver" = "-" ]; then
  310. latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
  311. if [ ! "$latest_ver" = "$inst_ver" ]; then
  312. echo "Error: '$app' version == $inst_ver is too old" >&2
  313. echo " '$app' version >= $req_ver is required" >&2
  314. ret=1
  315. fi
  316. fi
  317. done
  318. return $ret
  319. }
  320. print_versions() {
  321. echo "Program Min_version"
  322. echo "----------------------"
  323. printf %s "$buildreq"
  324. echo "----------------------"
  325. # can't depend on column -t
  326. }
  327. use_libtool=0
  328. # We'd like to use grep -E, to see if any of LT_INIT,
  329. # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
  330. # but that's not portable enough (e.g., for Solaris).
  331. grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
  332. && use_libtool=1
  333. grep '^[ ]*LT_INIT' configure.ac >/dev/null \
  334. && use_libtool=1
  335. if test $use_libtool = 1; then
  336. find_tool LIBTOOLIZE glibtoolize libtoolize
  337. fi
  338. if ! printf "$buildreq" | check_versions; then
  339. echo >&2
  340. if test -f README-prereq; then
  341. echo "See README-prereq for how to get the prerequisite programs" >&2
  342. else
  343. echo "Please install the prerequisite programs" >&2
  344. fi
  345. exit 1
  346. fi
  347. echo "$0: Bootstrapping from checked-out $package sources..."
  348. # See if we can use gnulib's git-merge-changelog merge driver.
  349. if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
  350. if git config merge.merge-changelog.driver >/dev/null ; then
  351. :
  352. elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
  353. echo "initializing git-merge-changelog driver"
  354. git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
  355. git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
  356. else
  357. echo "consider installing git-merge-changelog from gnulib"
  358. fi
  359. fi
  360. cleanup_gnulib() {
  361. status=$?
  362. rm -fr "$gnulib_path"
  363. exit $status
  364. }
  365. git_modules_config () {
  366. test -f .gitmodules && git config --file .gitmodules "$@"
  367. }
  368. gnulib_path=`git_modules_config submodule.gnulib.path`
  369. : ${gnulib_path=gnulib}
  370. # Get gnulib files.
  371. case ${GNULIB_SRCDIR--} in
  372. -)
  373. if git_modules_config submodule.gnulib.url >/dev/null; then
  374. echo "$0: getting gnulib files..."
  375. git submodule init || exit $?
  376. git submodule update || exit $?
  377. elif [ ! -d "$gnulib_path" ]; then
  378. echo "$0: getting gnulib files..."
  379. trap cleanup_gnulib 1 2 13 15
  380. shallow=
  381. git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
  382. git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
  383. cleanup_gnulib
  384. trap - 1 2 13 15
  385. fi
  386. GNULIB_SRCDIR=$gnulib_path
  387. ;;
  388. *)
  389. # Use GNULIB_SRCDIR as a reference.
  390. if test -d "$GNULIB_SRCDIR"/.git && \
  391. git_modules_config submodule.gnulib.url >/dev/null; then
  392. echo "$0: getting gnulib files..."
  393. if git submodule -h|grep -- --reference > /dev/null; then
  394. # Prefer the one-liner available in git 1.6.4 or newer.
  395. git submodule update --init --reference "$GNULIB_SRCDIR" \
  396. "$gnulib_path" || exit $?
  397. else
  398. # This fallback allows at least git 1.5.5.
  399. if test -f "$gnulib_path"/gnulib-tool; then
  400. # Since file already exists, assume submodule init already complete.
  401. git submodule update || exit $?
  402. else
  403. # Older git can't clone into an empty directory.
  404. rmdir "$gnulib_path" 2>/dev/null
  405. git clone --reference "$GNULIB_SRCDIR" \
  406. "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
  407. && git submodule init && git submodule update \
  408. || exit $?
  409. fi
  410. fi
  411. GNULIB_SRCDIR=$gnulib_path
  412. fi
  413. ;;
  414. esac
  415. gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
  416. <$gnulib_tool || exit
  417. # Get translations.
  418. download_po_files() {
  419. subdir=$1
  420. domain=$2
  421. echo "$0: getting translations into $subdir for $domain..."
  422. cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
  423. eval "$cmd"
  424. }
  425. # Mirror .po files to $po_dir/.reference and copy only the new
  426. # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
  427. # Note po files that exist locally only are left in $po_dir but will
  428. # not be included in LINGUAS and hence will not be distributed.
  429. update_po_files() {
  430. # Directory containing primary .po files.
  431. # Overwrite them only when we're sure a .po file is new.
  432. po_dir=$1
  433. domain=$2
  434. # Mirror *.po files into this dir.
  435. # Usually contains *.s1 checksum files.
  436. ref_po_dir="$po_dir/.reference"
  437. test -d $ref_po_dir || mkdir $ref_po_dir || return
  438. download_po_files $ref_po_dir $domain \
  439. && ls "$ref_po_dir"/*.po 2>/dev/null |
  440. sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
  441. langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
  442. test "$langs" = '*' && langs=x
  443. for po in $langs; do
  444. case $po in x) continue;; esac
  445. new_po="$ref_po_dir/$po.po"
  446. cksum_file="$ref_po_dir/$po.s1"
  447. if ! test -f "$cksum_file" ||
  448. ! test -f "$po_dir/$po.po" ||
  449. ! $SHA1SUM -c --status "$cksum_file" \
  450. < "$new_po" > /dev/null; then
  451. echo "updated $po_dir/$po.po..."
  452. cp "$new_po" "$po_dir/$po.po" \
  453. && $SHA1SUM < "$new_po" > "$cksum_file"
  454. fi
  455. done
  456. }
  457. case $SKIP_PO in
  458. '')
  459. if test -d po; then
  460. update_po_files po $package || exit
  461. fi
  462. if test -d runtime-po; then
  463. update_po_files runtime-po $package-runtime || exit
  464. fi;;
  465. esac
  466. symlink_to_dir()
  467. {
  468. src=$1/$2
  469. dst=${3-$2}
  470. test -f "$src" && {
  471. # If the destination directory doesn't exist, create it.
  472. # This is required at least for "lib/uniwidth/cjk.h".
  473. dst_dir=`dirname "$dst"`
  474. if ! test -d "$dst_dir"; then
  475. mkdir -p "$dst_dir"
  476. # If we've just created a directory like lib/uniwidth,
  477. # tell version control system(s) it's ignorable.
  478. # FIXME: for now, this does only one level
  479. parent=`dirname "$dst_dir"`
  480. for dot_ig in x $vc_ignore; do
  481. test $dot_ig = x && continue
  482. ig=$parent/$dot_ig
  483. insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'`
  484. done
  485. fi
  486. if $copy; then
  487. {
  488. test ! -h "$dst" || {
  489. echo "$0: rm -f $dst" &&
  490. rm -f "$dst"
  491. }
  492. } &&
  493. test -f "$dst" &&
  494. cmp -s "$src" "$dst" || {
  495. echo "$0: cp -fp $src $dst" &&
  496. cp -fp "$src" "$dst"
  497. }
  498. else
  499. test -h "$dst" &&
  500. src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
  501. dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
  502. test "$src_i" = "$dst_i" || {
  503. dot_dots=
  504. case $src in
  505. /*) ;;
  506. *)
  507. case /$dst/ in
  508. *//* | */../* | */./* | /*/*/*/*/*/)
  509. echo >&2 "$0: invalid symlink calculation: $src -> $dst"
  510. exit 1;;
  511. /*/*/*/*/) dot_dots=../../../;;
  512. /*/*/*/) dot_dots=../../;;
  513. /*/*/) dot_dots=../;;
  514. esac;;
  515. esac
  516. echo "$0: ln -fs $dot_dots$src $dst" &&
  517. ln -fs "$dot_dots$src" "$dst"
  518. }
  519. fi
  520. }
  521. }
  522. cp_mark_as_generated()
  523. {
  524. cp_src=$1
  525. cp_dst=$2
  526. if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
  527. symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
  528. elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
  529. symlink_to_dir $local_gl_dir "$cp_dst"
  530. else
  531. case $cp_dst in
  532. *.[ch]) c1='/* '; c2=' */';;
  533. *.texi) c1='@c '; c2= ;;
  534. *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
  535. *) c1= ; c2= ;;
  536. esac
  537. # If the destination directory doesn't exist, create it.
  538. # This is required at least for "lib/uniwidth/cjk.h".
  539. dst_dir=`dirname "$cp_dst"`
  540. test -d "$dst_dir" || mkdir -p "$dst_dir"
  541. if test -z "$c1"; then
  542. cmp -s "$cp_src" "$cp_dst" || {
  543. # Copy the file first to get proper permissions if it
  544. # doesn't already exist. Then overwrite the copy.
  545. echo "$0: cp -f $cp_src $cp_dst" &&
  546. rm -f "$cp_dst" &&
  547. cp "$cp_src" "$cp_dst-t" &&
  548. sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" &&
  549. mv -f "$cp_dst-t" "$cp_dst"
  550. }
  551. else
  552. # Copy the file first to get proper permissions if it
  553. # doesn't already exist. Then overwrite the copy.
  554. cp "$cp_src" "$cp_dst-t" &&
  555. (
  556. echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
  557. echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
  558. sed "s!$bt_regex/!!g" "$cp_src"
  559. ) > $cp_dst-t &&
  560. if cmp -s "$cp_dst-t" "$cp_dst"; then
  561. rm -f "$cp_dst-t"
  562. else
  563. echo "$0: cp $cp_src $cp_dst # with edits" &&
  564. mv -f "$cp_dst-t" "$cp_dst"
  565. fi
  566. fi
  567. fi
  568. }
  569. version_controlled_file() {
  570. dir=$1
  571. file=$2
  572. found=no
  573. if test -d CVS; then
  574. grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
  575. grep '^/[^/]*/[0-9]' > /dev/null && found=yes
  576. elif test -d .git; then
  577. git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
  578. elif test -d .svn; then
  579. svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
  580. else
  581. echo "$0: no version control for $dir/$file?" >&2
  582. fi
  583. test $found = yes
  584. }
  585. slurp() {
  586. for dir in . `(cd $1 && find * -type d -print)`; do
  587. copied=
  588. sep=
  589. for file in `ls -a $1/$dir`; do
  590. case $file in
  591. .|..) continue;;
  592. # FIXME: should all file names starting with "." be ignored?
  593. .*) continue;;
  594. esac
  595. test -d $1/$dir/$file && continue
  596. for excluded_file in $excluded_files; do
  597. test "$dir/$file" = "$excluded_file" && continue 2
  598. done
  599. if test $file = Makefile.am && test "X$gnulib_mk" != XMakefile.am; then
  600. copied=$copied${sep}$gnulib_mk; sep=$nl
  601. remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
  602. sed "$remove_intl" $1/$dir/$file |
  603. cmp - $dir/$gnulib_mk > /dev/null || {
  604. echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
  605. rm -f $dir/$gnulib_mk &&
  606. sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk &&
  607. gnulib_mk_hook $dir/$gnulib_mk
  608. }
  609. elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
  610. version_controlled_file $dir $file; then
  611. echo "$0: $dir/$file overrides $1/$dir/$file"
  612. else
  613. copied=$copied$sep$file; sep=$nl
  614. if test $file = gettext.m4; then
  615. echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
  616. rm -f $dir/$file
  617. sed '
  618. /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
  619. AC_DEFUN([AM_INTL_SUBDIR], [])
  620. /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
  621. AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
  622. $a\
  623. AC_DEFUN([gl_LOCK_EARLY], [])
  624. ' $1/$dir/$file >$dir/$file
  625. else
  626. cp_mark_as_generated $1/$dir/$file $dir/$file
  627. fi
  628. fi || exit
  629. done
  630. for dot_ig in x $vc_ignore; do
  631. test $dot_ig = x && continue
  632. ig=$dir/$dot_ig
  633. if test -n "$copied"; then
  634. insert_sorted_if_absent $ig "$copied"
  635. # If an ignored file name ends with .in.h, then also add
  636. # the name with just ".h". Many gnulib headers are generated,
  637. # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
  638. # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
  639. f=`echo "$copied" |
  640. sed '
  641. s/\.in\.h$/.h/
  642. s/\.sin$/.sed/
  643. s/\.y$/.c/
  644. s/\.gperf$/.h/
  645. '
  646. `
  647. insert_sorted_if_absent $ig "$f"
  648. # For files like sys_stat.in.h and sys_time.in.h, record as
  649. # ignorable the directory we might eventually create: sys/.
  650. f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
  651. insert_sorted_if_absent $ig "$f"
  652. fi
  653. done
  654. done
  655. }
  656. # Create boot temporary directories to import from gnulib and gettext.
  657. rm -fr $bt $bt2 &&
  658. mkdir $bt $bt2 || exit
  659. # Import from gnulib.
  660. gnulib_tool_options="\
  661. --import\
  662. --no-changelog\
  663. --aux-dir $bt/$build_aux\
  664. --doc-base $bt/$doc_base\
  665. --lib $gnulib_name\
  666. --m4-base $bt/$m4_base/\
  667. --source-base $bt/$source_base/\
  668. --tests-base $bt/$tests_base\
  669. --local-dir $local_gl_dir\
  670. $gnulib_tool_option_extras\
  671. "
  672. if test $use_libtool = 1; then
  673. case "$gnulib_tool_options " in
  674. *' --libtool '*) ;;
  675. *) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
  676. esac
  677. fi
  678. echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
  679. $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
  680. slurp $bt || exit
  681. for file in $gnulib_files; do
  682. symlink_to_dir "$GNULIB_SRCDIR" $file || exit
  683. done
  684. # Import from gettext.
  685. with_gettext=yes
  686. grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
  687. with_gettext=no
  688. if test $with_gettext = yes; then
  689. echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..."
  690. cp configure.ac $bt2 &&
  691. (cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) &&
  692. slurp $bt2 $bt || exit
  693. fi
  694. rm -fr $bt $bt2 || exit
  695. # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
  696. # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
  697. # The following requires GNU find 4.2.3 or newer. Considering the usual
  698. # portability constraints of this script, that may seem a very demanding
  699. # requirement, but it should be ok. Ignore any failure, which is fine,
  700. # since this is only a convenience to help developers avoid the relatively
  701. # unusual case in which a symlinked-to .m4 file is git-removed from gnulib
  702. # between successive runs of this script.
  703. find "$m4_base" "$source_base" \
  704. -depth \( -name '*.m4' -o -name '*.[ch]' \) \
  705. -type l -xtype l -delete > /dev/null 2>&1
  706. # Reconfigure, getting other files.
  707. # Skip autoheader if it's not needed.
  708. grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null ||
  709. AUTOHEADER=true
  710. for command in \
  711. libtool \
  712. "${ACLOCAL-aclocal} --force -I m4 $ACLOCAL_FLAGS" \
  713. "${AUTOCONF-autoconf} --force" \
  714. "${AUTOHEADER-autoheader} --force" \
  715. "${AUTOMAKE-automake} --add-missing --copy --force-missing"
  716. do
  717. if test "$command" = libtool; then
  718. test $use_libtool = 0 \
  719. && continue
  720. command="${LIBTOOLIZE-libtoolize} -c -f"
  721. fi
  722. echo "$0: $command ..."
  723. $command || exit
  724. done
  725. # Get some extra files from gnulib, overriding existing files.
  726. for file in $gnulib_extra_files; do
  727. case $file in
  728. */INSTALL) dst=INSTALL;;
  729. build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
  730. *) dst=$file;;
  731. esac
  732. symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
  733. done
  734. if test $with_gettext = yes; then
  735. # Create gettext configuration.
  736. echo "$0: Creating po/Makevars from po/Makevars.template ..."
  737. rm -f po/Makevars
  738. sed '
  739. /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
  740. /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
  741. /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
  742. /^XGETTEXT_OPTIONS *=/{
  743. s/$/ \\/
  744. a\
  745. '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
  746. }
  747. ' po/Makevars.template >po/Makevars || exit 1
  748. if test -d runtime-po; then
  749. # Similarly for runtime-po/Makevars, but not quite the same.
  750. rm -f runtime-po/Makevars
  751. sed '
  752. /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
  753. /^subdir *=.*/s/=.*/= runtime-po/
  754. /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
  755. /^XGETTEXT_OPTIONS *=/{
  756. s/$/ \\/
  757. a\
  758. '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
  759. }
  760. ' po/Makevars.template >runtime-po/Makevars || exit 1
  761. # Copy identical files from po to runtime-po.
  762. (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
  763. fi
  764. fi
  765. bootstrap_epilogue
  766. echo "$0: done. Now you can run './configure'."
  767. # Local variables:
  768. # eval: (add-hook 'write-file-hooks 'time-stamp)
  769. # time-stamp-start: "scriptversion="
  770. # time-stamp-format: "%:y-%02m-%02d.%02H"
  771. # time-stamp-time-zone: "UTC"
  772. # time-stamp-end: "; # UTC"
  773. # End: