bootstrap 27 KB

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