bootstrap 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. #! /bin/sh
  2. # Print a version string.
  3. scriptversion=2010-10-24.18; # 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 [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/missing
  109. $build_aux/mdate-sh
  110. $build_aux/texinfo.tex
  111. $build_aux/depcomp
  112. $build_aux/config.guess
  113. $build_aux/config.sub
  114. doc/INSTALL
  115. "
  116. # Additional gnulib-tool options to use. Use "\newline" to break lines.
  117. gnulib_tool_option_extras=
  118. # Other locale categories that need message catalogs.
  119. EXTRA_LOCALE_CATEGORIES=
  120. # Additional xgettext options to use. Use "\\\newline" to break lines.
  121. XGETTEXT_OPTIONS='\\\
  122. --flag=_:1:pass-c-format\\\
  123. --flag=N_:1:pass-c-format\\\
  124. --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
  125. '
  126. # Package bug report address and copyright holder for gettext files
  127. COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
  128. [email protected]
  129. # Files we don't want to import.
  130. excluded_files=
  131. # File that should exist in the top directory of a checked out hierarchy,
  132. # but not in a distribution tarball.
  133. checkout_only_file=README-hacking
  134. # Whether to use copies instead of symlinks.
  135. copy=false
  136. # Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
  137. # those files to be generated in directories like lib/, m4/, and po/.
  138. # Or set it to 'auto' to make this script select which to use based
  139. # on which version control system (if any) is used in the source directory.
  140. vc_ignore=auto
  141. # find_tool ENVVAR NAMES...
  142. # -------------------------
  143. # Search for a required program. Use the value of ENVVAR, if set,
  144. # otherwise find the first of the NAMES that can be run (i.e.,
  145. # supports --version). If found, set ENVVAR to the program name,
  146. # die otherwise.
  147. find_tool ()
  148. {
  149. find_tool_envvar=$1
  150. shift
  151. find_tool_names=$@
  152. eval "find_tool_res=\$$find_tool_envvar"
  153. if test x"$find_tool_res" = x; then
  154. for i
  155. do
  156. if ($i --version </dev/null) >/dev/null 2>&1; then
  157. find_tool_res=$i
  158. break
  159. fi
  160. done
  161. else
  162. find_tool_error_prefix="\$$find_tool_envvar: "
  163. fi
  164. if test x"$find_tool_res" = x; then
  165. echo >&2 "$0: one of these is required: $find_tool_names"
  166. exit 1
  167. fi
  168. ($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
  169. echo >&2 "$0: ${find_tool_error_prefix}cannot run $find_tool_res --version"
  170. exit 1
  171. }
  172. eval "$find_tool_envvar=\$find_tool_res"
  173. eval "export $find_tool_envvar"
  174. }
  175. # Find sha1sum, named gsha1sum on MacPorts, and shasum on MacOS 10.6.
  176. find_tool SHA1SUM sha1sum gsha1sum shasum
  177. # Override the default configuration, if necessary.
  178. # Make sure that bootstrap.conf is sourced from the current directory
  179. # if we were invoked as "sh bootstrap".
  180. case "$0" in
  181. */*) test -r "$0.conf" && . "$0.conf" ;;
  182. *) test -r "$0.conf" && . ./"$0.conf" ;;
  183. esac
  184. if test "$vc_ignore" = auto; then
  185. vc_ignore=
  186. test -d .git && vc_ignore=.gitignore
  187. test -d CVS && vc_ignore="$vc_ignore .cvsignore"
  188. fi
  189. # Translate configuration into internal form.
  190. # Parse options.
  191. for option
  192. do
  193. case $option in
  194. --help)
  195. usage
  196. exit;;
  197. --gnulib-srcdir=*)
  198. GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;;
  199. --paxutils-srcdir=*)
  200. PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
  201. --skip-po)
  202. SKIP_PO=t;;
  203. --force)
  204. checkout_only_file=;;
  205. --copy)
  206. copy=true;;
  207. *)
  208. echo >&2 "$0: $option: unknown option"
  209. exit 1;;
  210. esac
  211. done
  212. if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
  213. echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
  214. exit 1
  215. fi
  216. # If $STR is not already on a line by itself in $FILE, insert it,
  217. # sorting the new contents of the file and replacing $FILE with the result.
  218. insert_sorted_if_absent() {
  219. file=$1
  220. str=$2
  221. test -f $file || touch $file
  222. echo "$str" | sort -u - $file | cmp - $file > /dev/null \
  223. || echo "$str" | sort -u - $file -o $file \
  224. || exit 1
  225. }
  226. # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
  227. found_aux_dir=no
  228. grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
  229. >/dev/null && found_aux_dir=yes
  230. grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
  231. >/dev/null && found_aux_dir=yes
  232. if test $found_aux_dir = no; then
  233. echo "$0: expected line not found in configure.ac. Add the following:" >&2
  234. echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
  235. exit 1
  236. fi
  237. # If $build_aux doesn't exist, create it now, otherwise some bits
  238. # below will malfunction. If creating it, also mark it as ignored.
  239. if test ! -d $build_aux; then
  240. mkdir $build_aux
  241. for dot_ig in x $vc_ignore; do
  242. test $dot_ig = x && continue
  243. insert_sorted_if_absent $dot_ig $build_aux
  244. done
  245. fi
  246. # Note this deviates from the version comparison in automake
  247. # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
  248. # but this should suffice as we won't be specifying old
  249. # version formats or redundant trailing .0 in bootstrap.conf.
  250. # If we did want full compatibility then we should probably
  251. # use m4_version_compare from autoconf.
  252. sort_ver() { # sort -V is not generally available
  253. ver1="$1"
  254. ver2="$2"
  255. # split on '.' and compare each component
  256. i=1
  257. while : ; do
  258. p1=$(echo "$ver1" | cut -d. -f$i)
  259. p2=$(echo "$ver2" | cut -d. -f$i)
  260. if [ ! "$p1" ]; then
  261. echo "$1 $2"
  262. break
  263. elif [ ! "$p2" ]; then
  264. echo "$2 $1"
  265. break
  266. elif [ ! "$p1" = "$p2" ]; then
  267. if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
  268. echo "$2 $1"
  269. elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
  270. echo "$1 $2"
  271. else # numeric, then lexicographic comparison
  272. lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
  273. if [ "$lp" = "$p2" ]; then
  274. echo "$1 $2"
  275. else
  276. echo "$2 $1"
  277. fi
  278. fi
  279. break
  280. fi
  281. i=$(($i+1))
  282. done
  283. }
  284. get_version() {
  285. app=$1
  286. $app --version >/dev/null 2>&1 || return 1
  287. $app --version 2>&1 |
  288. sed -n '# extract version within line
  289. s/.*[v ]\{1,\}\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
  290. t done
  291. # extract version at start of line
  292. s/^\([0-9]\{1,\}\.[.a-z0-9-]*\).*/\1/
  293. t done
  294. d
  295. :done
  296. #the following essentially does s/5.005/5.5/
  297. s/\.0*\([1-9]\)/.\1/g
  298. p
  299. q'
  300. }
  301. check_versions() {
  302. ret=0
  303. while read app req_ver; do
  304. # We only need libtoolize from the libtool package.
  305. if test "$app" = libtool; then
  306. app=libtoolize
  307. fi
  308. # Honor $APP variables ($TAR, $AUTOCONF, etc.)
  309. appvar=`echo $app | tr '[a-z]-' '[A-Z]_'`
  310. test "$appvar" = TAR && appvar=AMTAR
  311. eval "app=\${$appvar-$app}"
  312. inst_ver=$(get_version $app)
  313. if [ ! "$inst_ver" ]; then
  314. echo "Error: '$app' not found" >&2
  315. ret=1
  316. elif [ ! "$req_ver" = "-" ]; then
  317. latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
  318. if [ ! "$latest_ver" = "$inst_ver" ]; then
  319. echo "Error: '$app' version == $inst_ver is too old" >&2
  320. echo " '$app' version >= $req_ver is required" >&2
  321. ret=1
  322. fi
  323. fi
  324. done
  325. return $ret
  326. }
  327. print_versions() {
  328. echo "Program Min_version"
  329. echo "----------------------"
  330. printf %s "$buildreq"
  331. echo "----------------------"
  332. # can't depend on column -t
  333. }
  334. use_libtool=0
  335. # We'd like to use grep -E, to see if any of LT_INIT,
  336. # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
  337. # but that's not portable enough (e.g., for Solaris).
  338. grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
  339. && use_libtool=1
  340. grep '^[ ]*LT_INIT' configure.ac >/dev/null \
  341. && use_libtool=1
  342. if test $use_libtool = 1; then
  343. find_tool LIBTOOLIZE glibtoolize libtoolize
  344. fi
  345. if ! printf "$buildreq" | check_versions; then
  346. echo >&2
  347. if test -f README-prereq; then
  348. echo "See README-prereq for how to get the prerequisite programs" >&2
  349. else
  350. echo "Please install the prerequisite programs" >&2
  351. fi
  352. exit 1
  353. fi
  354. echo "$0: Bootstrapping from checked-out $package sources..."
  355. # See if we can use gnulib's git-merge-changelog merge driver.
  356. if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
  357. if git config merge.merge-changelog.driver >/dev/null ; then
  358. :
  359. elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
  360. echo "initializing git-merge-changelog driver"
  361. git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
  362. git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
  363. else
  364. echo "consider installing git-merge-changelog from gnulib"
  365. fi
  366. fi
  367. cleanup() {
  368. status=$?
  369. rm -fr $1
  370. exit $status
  371. }
  372. cleanup_gnulib() {
  373. cleanup "$gnulib_path"
  374. }
  375. # Get paxutils files.
  376. case ${PAXUTILS_SRCDIR--} in
  377. -) if [ ! -d paxutils ]; then
  378. echo "$0: getting paxutils files..."
  379. trap "cleanup paxutils" 1 2 13 15
  380. git clone --depth 1 git://git.sv.gnu.org/paxutils || cleanup paxutils
  381. trap - 1 2 13 15
  382. fi
  383. PAXUTILS_SRCDIR=paxutils
  384. ;;
  385. esac
  386. if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
  387. gnulib_modules=`
  388. (echo "$gnulib_modules"; grep '^[^#]' $PAXUTILS_SRCDIR/gnulib.modules) |
  389. sort -u
  390. `
  391. fi
  392. git_modules_config () {
  393. test -f .gitmodules && git config --file .gitmodules "$@"
  394. }
  395. gnulib_path=`git_modules_config submodule.gnulib.path`
  396. : ${gnulib_path=gnulib}
  397. # Get gnulib files.
  398. case ${GNULIB_SRCDIR--} in
  399. -)
  400. if git_modules_config submodule.gnulib.url >/dev/null; then
  401. echo "$0: getting gnulib files..."
  402. git submodule init || exit $?
  403. git submodule update || exit $?
  404. elif [ ! -d "$gnulib_path" ]; then
  405. echo "$0: getting gnulib files..."
  406. trap cleanup_gnulib 1 2 13 15
  407. shallow=
  408. git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
  409. git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
  410. cleanup_gnulib
  411. trap - 1 2 13 15
  412. fi
  413. GNULIB_SRCDIR=$gnulib_path
  414. ;;
  415. *)
  416. # Use GNULIB_SRCDIR as a reference.
  417. if test -d "$GNULIB_SRCDIR"/.git && \
  418. git_modules_config submodule.gnulib.url >/dev/null; then
  419. echo "$0: getting gnulib files..."
  420. if git submodule -h|grep -- --reference > /dev/null; then
  421. # Prefer the one-liner available in git 1.6.4 or newer.
  422. git submodule update --init --reference "$GNULIB_SRCDIR" \
  423. "$gnulib_path" || exit $?
  424. else
  425. # This fallback allows at least git 1.5.5.
  426. if test -f "$gnulib_path"/gnulib-tool; then
  427. # Since file already exists, assume submodule init already complete.
  428. git submodule update || exit $?
  429. else
  430. # Older git can't clone into an empty directory.
  431. rmdir "$gnulib_path" 2>/dev/null
  432. git clone --reference "$GNULIB_SRCDIR" \
  433. "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
  434. && git submodule init && git submodule update \
  435. || exit $?
  436. fi
  437. fi
  438. GNULIB_SRCDIR=$gnulib_path
  439. fi
  440. ;;
  441. esac
  442. gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
  443. <$gnulib_tool || exit
  444. # Get translations.
  445. download_po_files() {
  446. subdir=$1
  447. domain=$2
  448. echo "$0: getting translations into $subdir for $domain..."
  449. cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
  450. eval "$cmd"
  451. }
  452. # Mirror .po files to $po_dir/.reference and copy only the new
  453. # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
  454. # Note po files that exist locally only are left in $po_dir but will
  455. # not be included in LINGUAS and hence will not be distributed.
  456. update_po_files() {
  457. # Directory containing primary .po files.
  458. # Overwrite them only when we're sure a .po file is new.
  459. po_dir=$1
  460. domain=$2
  461. # Mirror *.po files into this dir.
  462. # Usually contains *.s1 checksum files.
  463. ref_po_dir="$po_dir/.reference"
  464. test -d $ref_po_dir || mkdir $ref_po_dir || return
  465. download_po_files $ref_po_dir $domain \
  466. && ls "$ref_po_dir"/*.po 2>/dev/null |
  467. sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
  468. langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
  469. test "$langs" = '*' && langs=x
  470. for po in $langs; do
  471. case $po in x) continue;; esac
  472. new_po="$ref_po_dir/$po.po"
  473. cksum_file="$ref_po_dir/$po.s1"
  474. if ! test -f "$cksum_file" ||
  475. ! test -f "$po_dir/$po.po" ||
  476. ! $SHA1SUM -c --status "$cksum_file" \
  477. < "$new_po" > /dev/null; then
  478. echo "updated $po_dir/$po.po..."
  479. cp "$new_po" "$po_dir/$po.po" \
  480. && $SHA1SUM < "$new_po" > "$cksum_file"
  481. fi
  482. done
  483. }
  484. case $SKIP_PO in
  485. '')
  486. if test -d po; then
  487. update_po_files po $package || exit
  488. fi
  489. if test -d runtime-po; then
  490. update_po_files runtime-po $package-runtime || exit
  491. fi;;
  492. esac
  493. symlink_to_dir()
  494. {
  495. src=$1/$2
  496. dst=${3-$2}
  497. test -f "$src" && {
  498. # If the destination directory doesn't exist, create it.
  499. # This is required at least for "lib/uniwidth/cjk.h".
  500. dst_dir=`dirname "$dst"`
  501. if ! test -d "$dst_dir"; then
  502. mkdir -p "$dst_dir"
  503. # If we've just created a directory like lib/uniwidth,
  504. # tell version control system(s) it's ignorable.
  505. # FIXME: for now, this does only one level
  506. parent=`dirname "$dst_dir"`
  507. for dot_ig in x $vc_ignore; do
  508. test $dot_ig = x && continue
  509. ig=$parent/$dot_ig
  510. insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'`
  511. done
  512. fi
  513. if $copy; then
  514. {
  515. test ! -h "$dst" || {
  516. echo "$0: rm -f $dst" &&
  517. rm -f "$dst"
  518. }
  519. } &&
  520. test -f "$dst" &&
  521. cmp -s "$src" "$dst" || {
  522. echo "$0: cp -fp $src $dst" &&
  523. cp -fp "$src" "$dst"
  524. }
  525. else
  526. test -h "$dst" &&
  527. src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
  528. dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
  529. test "$src_i" = "$dst_i" || {
  530. dot_dots=
  531. case $src in
  532. /*) ;;
  533. *)
  534. case /$dst/ in
  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: