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. *//* | */../* | */./* | /*/*/*/*/*/)
  537. echo >&2 "$0: invalid symlink calculation: $src -> $dst"
  538. exit 1;;
  539. /*/*/*/*/) dot_dots=../../../;;
  540. /*/*/*/) dot_dots=../../;;
  541. /*/*/) dot_dots=../;;
  542. esac;;
  543. esac
  544. echo "$0: ln -fs $dot_dots$src $dst" &&
  545. ln -fs "$dot_dots$src" "$dst"
  546. }
  547. fi
  548. }
  549. }
  550. cp_mark_as_generated()
  551. {
  552. cp_src=$1
  553. cp_dst=$2
  554. if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
  555. symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
  556. elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
  557. symlink_to_dir $local_gl_dir "$cp_dst"
  558. else
  559. case $cp_dst in
  560. *.[ch]) c1='/* '; c2=' */';;
  561. *.texi) c1='@c '; c2= ;;
  562. *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
  563. *) c1= ; c2= ;;
  564. esac
  565. # If the destination directory doesn't exist, create it.
  566. # This is required at least for "lib/uniwidth/cjk.h".
  567. dst_dir=`dirname "$cp_dst"`
  568. test -d "$dst_dir" || mkdir -p "$dst_dir"
  569. if test -z "$c1"; then
  570. cmp -s "$cp_src" "$cp_dst" || {
  571. # Copy the file first to get proper permissions if it
  572. # doesn't already exist. Then overwrite the copy.
  573. echo "$0: cp -f $cp_src $cp_dst" &&
  574. rm -f "$cp_dst" &&
  575. cp "$cp_src" "$cp_dst-t" &&
  576. sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" &&
  577. mv -f "$cp_dst-t" "$cp_dst"
  578. }
  579. else
  580. # Copy the file first to get proper permissions if it
  581. # doesn't already exist. Then overwrite the copy.
  582. cp "$cp_src" "$cp_dst-t" &&
  583. (
  584. echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
  585. echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
  586. sed "s!$bt_regex/!!g" "$cp_src"
  587. ) > $cp_dst-t &&
  588. if cmp -s "$cp_dst-t" "$cp_dst"; then
  589. rm -f "$cp_dst-t"
  590. else
  591. echo "$0: cp $cp_src $cp_dst # with edits" &&
  592. mv -f "$cp_dst-t" "$cp_dst"
  593. fi
  594. fi
  595. fi
  596. }
  597. version_controlled_file() {
  598. dir=$1
  599. file=$2
  600. found=no
  601. if test -d CVS; then
  602. grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
  603. grep '^/[^/]*/[0-9]' > /dev/null && found=yes
  604. elif test -d .git; then
  605. git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
  606. elif test -d .svn; then
  607. svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
  608. else
  609. echo "$0: no version control for $dir/$file?" >&2
  610. fi
  611. test $found = yes
  612. }
  613. slurp() {
  614. for dir in . `(cd $1 && find * -type d -print)`; do
  615. copied=
  616. sep=
  617. for file in `ls -a $1/$dir`; do
  618. case $file in
  619. .|..) continue;;
  620. # FIXME: should all file names starting with "." be ignored?
  621. .*) continue;;
  622. esac
  623. test -d $1/$dir/$file && continue
  624. for excluded_file in $excluded_files; do
  625. test "$dir/$file" = "$excluded_file" && continue 2
  626. done
  627. if test $file = Makefile.am && test "X$gnulib_mk" != XMakefile.am; then
  628. copied=$copied${sep}$gnulib_mk; sep=$nl
  629. remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
  630. sed "$remove_intl" $1/$dir/$file |
  631. cmp - $dir/$gnulib_mk > /dev/null || {
  632. echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
  633. rm -f $dir/$gnulib_mk &&
  634. sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk &&
  635. gnulib_mk_hook $dir/$gnulib_mk
  636. }
  637. elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
  638. version_controlled_file $dir $file; then
  639. echo "$0: $dir/$file overrides $1/$dir/$file"
  640. else
  641. copied=$copied$sep$file; sep=$nl
  642. if test $file = gettext.m4; then
  643. echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
  644. rm -f $dir/$file
  645. sed '
  646. /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
  647. AC_DEFUN([AM_INTL_SUBDIR], [])
  648. /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
  649. AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
  650. $a\
  651. AC_DEFUN([gl_LOCK_EARLY], [])
  652. ' $1/$dir/$file >$dir/$file
  653. else
  654. cp_mark_as_generated $1/$dir/$file $dir/$file
  655. fi
  656. fi || exit
  657. done
  658. for dot_ig in x $vc_ignore; do
  659. test $dot_ig = x && continue
  660. ig=$dir/$dot_ig
  661. if test -n "$copied"; then
  662. insert_sorted_if_absent $ig "$copied"
  663. # If an ignored file name ends with .in.h, then also add
  664. # the name with just ".h". Many gnulib headers are generated,
  665. # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
  666. # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
  667. f=`echo "$copied" |
  668. sed '
  669. s/\.in\.h$/.h/
  670. s/\.sin$/.sed/
  671. s/\.y$/.c/
  672. s/\.gperf$/.h/
  673. '
  674. `
  675. insert_sorted_if_absent $ig "$f"
  676. # For files like sys_stat.in.h and sys_time.in.h, record as
  677. # ignorable the directory we might eventually create: sys/.
  678. f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
  679. insert_sorted_if_absent $ig "$f"
  680. fi
  681. done
  682. done
  683. }
  684. # Create boot temporary directories to import from gnulib and gettext.
  685. rm -fr $bt $bt2 &&
  686. mkdir $bt $bt2 || exit
  687. # Import from gnulib.
  688. gnulib_tool_options="\
  689. --import\
  690. --no-changelog\
  691. --aux-dir $bt/$build_aux\
  692. --doc-base $bt/$doc_base\
  693. --lib $gnulib_name\
  694. --m4-base $bt/$m4_base/\
  695. --source-base $bt/$source_base/\
  696. --tests-base $bt/$tests_base\
  697. --local-dir $local_gl_dir\
  698. $gnulib_tool_option_extras\
  699. "
  700. if test $use_libtool = 1; then
  701. case "$gnulib_tool_options " in
  702. *' --libtool '*) ;;
  703. *) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
  704. esac
  705. fi
  706. echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
  707. $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
  708. slurp $bt || exit
  709. for file in $gnulib_files; do
  710. symlink_to_dir "$GNULIB_SRCDIR" $file || exit
  711. done
  712. # Import from gettext.
  713. with_gettext=yes
  714. grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
  715. with_gettext=no
  716. if test $with_gettext = yes; then
  717. echo "$0: (cd $bt2; ${AUTOPOINT-autopoint}) ..."
  718. cp configure.ac $bt2 &&
  719. (cd $bt2 && ${AUTOPOINT-autopoint} && rm configure.ac) &&
  720. slurp $bt2 $bt || exit
  721. fi
  722. rm -fr $bt $bt2 || exit
  723. # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
  724. # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
  725. # The following requires GNU find 4.2.3 or newer. Considering the usual
  726. # portability constraints of this script, that may seem a very demanding
  727. # requirement, but it should be ok. Ignore any failure, which is fine,
  728. # since this is only a convenience to help developers avoid the relatively
  729. # unusual case in which a symlinked-to .m4 file is git-removed from gnulib
  730. # between successive runs of this script.
  731. find "$m4_base" "$source_base" \
  732. -depth \( -name '*.m4' -o -name '*.[ch]' \) \
  733. -type l -xtype l -delete > /dev/null 2>&1
  734. # Reconfigure, getting other files.
  735. # copy_files srcdir dstdir
  736. copy_files() {
  737. for file in `cat $1/DISTFILES`
  738. do
  739. case $file in
  740. "#*") continue;;
  741. esac
  742. dst=`echo $file | sed 's^.*/^^'`
  743. if [ $# -eq 3 ]; then
  744. case $dst in
  745. ${3}*) ;;
  746. *) dst=${3}$dst;;
  747. esac
  748. fi
  749. symlink_to_dir "$1" "$file" "$2/$dst" || exit
  750. # FIXME ignorefile $2 $dst
  751. done
  752. }
  753. # Import from paxutils
  754. copy_files ${PAXUTILS_SRCDIR} .
  755. copy_files ${PAXUTILS_SRCDIR}/am m4
  756. echo "$0: Creating m4/paxutils.m4"
  757. (echo "# This file is generated automatically. Please, do not edit."
  758. echo "#"
  759. echo "AC_DEFUN([${package}_PAXUTILS],["
  760. cat ${PAXUTILS_SRCDIR}/am/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
  761. echo "])") > ./m4/paxutils.m4
  762. #FIXME ignorefile m4 paxutils.m4
  763. if [ -d rmt ]; then
  764. :
  765. else
  766. mkdir rmt
  767. fi
  768. for dir in doc rmt lib tests
  769. do
  770. copy_files ${PAXUTILS_SRCDIR}/$dir $dir
  771. done
  772. copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
  773. # Skip autoheader if it's not needed.
  774. grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null ||
  775. AUTOHEADER=true
  776. for command in \
  777. libtool \
  778. "${ACLOCAL-aclocal} --force -I m4 $ACLOCAL_FLAGS" \
  779. "${AUTOCONF-autoconf} --force" \
  780. "${AUTOHEADER-autoheader} --force" \
  781. "${AUTOMAKE-automake} --add-missing --copy --force-missing"
  782. do
  783. if test "$command" = libtool; then
  784. test $use_libtool = 0 \
  785. && continue
  786. command="${LIBTOOLIZE-libtoolize} -c -f"
  787. fi
  788. echo "$0: $command ..."
  789. $command || exit
  790. done
  791. # Get some extra files from gnulib, overriding existing files.
  792. for file in $gnulib_extra_files; do
  793. case $file in
  794. */INSTALL) dst=INSTALL;;
  795. build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
  796. *) dst=$file;;
  797. esac
  798. symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
  799. done
  800. if test $with_gettext = yes; then
  801. # Create gettext configuration.
  802. echo "$0: Creating po/Makevars from po/Makevars.template ..."
  803. rm -f po/Makevars
  804. sed '
  805. /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
  806. /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
  807. /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
  808. /^XGETTEXT_OPTIONS *=/{
  809. s/$/ \\/
  810. a\
  811. '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
  812. }
  813. ' po/Makevars.template >po/Makevars || exit 1
  814. if test -d runtime-po; then
  815. # Similarly for runtime-po/Makevars, but not quite the same.
  816. rm -f runtime-po/Makevars
  817. sed '
  818. /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
  819. /^subdir *=.*/s/=.*/= runtime-po/
  820. /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
  821. /^XGETTEXT_OPTIONS *=/{
  822. s/$/ \\/
  823. a\
  824. '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
  825. }
  826. ' po/Makevars.template >runtime-po/Makevars || exit 1
  827. # Copy identical files from po to runtime-po.
  828. (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
  829. fi
  830. fi
  831. bootstrap_epilogue
  832. echo "$0: done. Now you can run './configure'."
  833. # Local variables:
  834. # eval: (add-hook 'write-file-hooks 'time-stamp)
  835. # time-stamp-start: "scriptversion="
  836. # time-stamp-format: "%:y-%02m-%02d.%02H"
  837. # time-stamp-time-zone: "UTC"
  838. # time-stamp-end: "; # UTC"
  839. # End: