bootstrap 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  1. #! /bin/sh
  2. # Bootstrap this package from checked-out sources.
  3. # Copyright (C) 2003-2008, 2009 Free Software Foundation, Inc.
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. # Written by Paul Eggert and Sergey Poznyakoff.
  15. nl='
  16. '
  17. # Ensure file names are sorted consistently across platforms.
  18. LC_ALL=C
  19. export LC_ALL
  20. local_gl_dir=gl
  21. # Temporary directory names.
  22. bt='._bootmp'
  23. bt_regex=`echo "$bt"| sed 's/\./[.]/g'`
  24. bt2=${bt}2
  25. usage() {
  26. echo >&2 "\
  27. Usage: $0 [OPTION]...
  28. Bootstrap this package from the checked-out sources.
  29. Options:
  30. --paxutils-srcdir=DIRNAME Specify the local directory where paxutils
  31. sources reside. Use this if you already
  32. have paxutils sources on your machine, and
  33. do not want to waste your bandwidth dowloading
  34. them again.
  35. --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
  36. sources reside. Use this if you already
  37. have gnulib sources on your machine, and
  38. do not want to waste your bandwidth downloading
  39. them again.
  40. --copy Copy files instead of creating symbolic links.
  41. --force Attempt to bootstrap even if the sources seem
  42. not to have been checked out.
  43. --skip-po Do not download po files.
  44. If the file $0.conf exists in the same directory as this script, its
  45. contents are read as shell variables to configure the bootstrap.
  46. Running without arguments will suffice in most cases.
  47. "
  48. }
  49. # Configuration.
  50. # Name of the Makefile.am
  51. gnulib_mk=gnulib.mk
  52. # List of gnulib modules needed.
  53. gnulib_modules=
  54. # Any gnulib files needed that are not in modules.
  55. gnulib_files=
  56. # The command to download all .po files for a specified domain into
  57. # a specified directory. Fill in the first %s is the domain name, and
  58. # the second with the destination directory. Use rsync's -L and -r
  59. # options because the latest/%s directory and the .po files within are
  60. # all symlinks.
  61. po_download_command_format=\
  62. "rsync -Lrtvz 'translationproject.org::tp/latest/%s/' '%s'"
  63. extract_package_name='
  64. /^AC_INIT(/{
  65. /.*,.*,.*, */{
  66. s///
  67. s/[][]//g
  68. s/)$//
  69. p
  70. q
  71. }
  72. s/AC_INIT(\[*//
  73. s/]*,.*//
  74. s/^GNU //
  75. y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
  76. s/[^A-Za-z0-9_]/-/g
  77. p
  78. }
  79. '
  80. package=`sed -n "$extract_package_name" configure.ac` || exit
  81. gnulib_name=lib$package
  82. build_aux=build-aux
  83. source_base=lib
  84. m4_base=m4
  85. doc_base=doc
  86. tests_base=tests
  87. # Extra files from gnulib, which override files from other sources.
  88. gnulib_extra_files="
  89. $build_aux/install-sh
  90. $build_aux/missing
  91. $build_aux/mdate-sh
  92. $build_aux/texinfo.tex
  93. $build_aux/depcomp
  94. $build_aux/config.guess
  95. $build_aux/config.sub
  96. doc/INSTALL
  97. "
  98. # Additional gnulib-tool options to use. Use "\newline" to break lines.
  99. gnulib_tool_option_extras=
  100. # Other locale categories that need message catalogs.
  101. EXTRA_LOCALE_CATEGORIES=
  102. # Additional xgettext options to use. Use "\\\newline" to break lines.
  103. XGETTEXT_OPTIONS='\\\
  104. --flag=_:1:pass-c-format\\\
  105. --flag=N_:1:pass-c-format\\\
  106. --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
  107. '
  108. # Package bug report address for gettext files
  109. MSGID_BUGS_ADDRESS=bug-$package@gnu.org
  110. # Files we don't want to import.
  111. excluded_files=
  112. # File that should exist in the top directory of a checked out hierarchy,
  113. # but not in a distribution tarball.
  114. checkout_only_file=README-hacking
  115. # Whether to use copies instead of symlinks.
  116. copy=false
  117. # Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
  118. # those files to be generated in directories like lib/, m4/, and po/.
  119. # Or set it to 'auto' to make this script select which to use based
  120. # on which version control system (if any) is used in the source directory.
  121. vc_ignore=auto
  122. # Override the default configuration, if necessary.
  123. # Make sure that bootstrap.conf is sourced from the current directory
  124. # if we were invoked as "sh bootstrap".
  125. case "$0" in
  126. */*) test -r "$0.conf" && . "$0.conf" ;;
  127. *) test -r "$0.conf" && . ./"$0.conf" ;;
  128. esac
  129. if test "$vc_ignore" = auto; then
  130. vc_ignore=
  131. test -d .git && vc_ignore=.gitignore
  132. test -d CVS && vc_ignore="$vc_ignore .cvsignore"
  133. fi
  134. # Translate configuration into internal form.
  135. # Parse options.
  136. for option
  137. do
  138. case $option in
  139. --help)
  140. usage
  141. exit;;
  142. --gnulib-srcdir=*)
  143. GNULIB_SRCDIR=`expr "X$option" : 'X--gnulib-srcdir=\(.*\)'`;;
  144. --paxutils-srcdir=*)
  145. PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
  146. --skip-po)
  147. SKIP_PO=t;;
  148. --force)
  149. checkout_only_file=;;
  150. --copy)
  151. copy=true;;
  152. *)
  153. echo >&2 "$0: $option: unknown option"
  154. exit 1;;
  155. esac
  156. done
  157. if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
  158. echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2
  159. exit 1
  160. fi
  161. # If $STR is not already on a line by itself in $FILE, insert it,
  162. # sorting the new contents of the file and replacing $FILE with the result.
  163. insert_sorted_if_absent() {
  164. file=$1
  165. str=$2
  166. test -f $file || touch $file
  167. echo "$str" | sort -u - $file | cmp -s - $file \
  168. || echo "$str" | sort -u - $file -o $file \
  169. || exit 1
  170. }
  171. # Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
  172. found_aux_dir=no
  173. grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
  174. >/dev/null && found_aux_dir=yes
  175. grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
  176. >/dev/null && found_aux_dir=yes
  177. if test $found_aux_dir = no; then
  178. echo "$0: expected line not found in configure.ac. Add the following:" >&2
  179. echo " AC_CONFIG_AUX_DIR([$build_aux])" >&2
  180. exit 1
  181. fi
  182. # If $build_aux doesn't exist, create it now, otherwise some bits
  183. # below will malfunction. If creating it, also mark it as ignored.
  184. if test ! -d $build_aux; then
  185. mkdir $build_aux
  186. for dot_ig in x $vc_ignore; do
  187. test $dot_ig = x && continue
  188. insert_sorted_if_absent $dot_ig $build_aux
  189. done
  190. fi
  191. echo "$0: Bootstrapping from checked-out $package sources..."
  192. # See if we can use gnulib's git-merge-changelog merge driver.
  193. if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
  194. if git config merge.merge-changelog.driver >/dev/null ; then
  195. :
  196. elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
  197. echo "initializing git-merge-changelog driver"
  198. git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
  199. git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
  200. else
  201. echo "consider installing git-merge-changelog from gnulib"
  202. fi
  203. fi
  204. cleanup() {
  205. status=$?
  206. rm -fr $1
  207. exit $status
  208. }
  209. git_modules_config () {
  210. GIT_CONFIG_LOCAL=.gitmodules git config "$@"
  211. }
  212. # Get paxutils files.
  213. case ${PAXUTILS_SRCDIR--} in
  214. -) if [ ! -d paxutils ]; then
  215. echo "$0: getting paxutils files..."
  216. trap "cleanup paxutils" 1 2 13 15
  217. git clone --depth 1 git://git.sv.gnu.org/paxutils || cleanup paxutils
  218. trap - 1 2 13 15
  219. fi
  220. PAXUTILS_SRCDIR=paxutils
  221. ;;
  222. esac
  223. if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
  224. gnulib_modules=`
  225. (echo "$gnulib_modules"; grep '^[^#]' $PAXUTILS_SRCDIR/gnulib.modules) |
  226. sort -u
  227. `
  228. fi
  229. # Get gnulib files.
  230. case ${GNULIB_SRCDIR--} in
  231. -)
  232. if git_modules_config submodule.gnulib.url >/dev/null; then
  233. echo "$0: getting gnulib files..."
  234. git submodule init || exit $?
  235. git submodule update || exit $?
  236. elif [ ! -d gnulib ]; then
  237. echo "$0: getting gnulib files..."
  238. trap cleanup_gnulib 1 2 13 15
  239. git clone --help|grep depth > /dev/null && shallow='--depth 2' || shallow=
  240. git clone $shallow git://git.sv.gnu.org/gnulib ||
  241. "cleanup $1"
  242. trap - 1 2 13 15
  243. fi
  244. GNULIB_SRCDIR=gnulib
  245. ;;
  246. *)
  247. # Redirect the gnulib submodule to the directory on the command line
  248. # if possible.
  249. if test -d "$GNULIB_SRCDIR"/.git && \
  250. git_modules_config submodule.gnulib.url >/dev/null; then
  251. git submodule init
  252. GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
  253. git config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
  254. echo "$0: getting gnulib files..."
  255. git submodule update || exit $?
  256. GNULIB_SRCDIR=gnulib
  257. fi
  258. ;;
  259. esac
  260. gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
  261. <$gnulib_tool || exit
  262. # Get translations.
  263. download_po_files() {
  264. subdir=$1
  265. domain=$2
  266. echo "$0: getting translations into $subdir for $domain..."
  267. cmd=`printf "$po_download_command_format" "$domain" "$subdir"`
  268. eval "$cmd"
  269. }
  270. # Download .po files to $po_dir/.reference and copy only the new
  271. # or modified ones into $po_dir. Also update $po_dir/LINGUAS.
  272. update_po_files() {
  273. # Directory containing primary .po files.
  274. # Overwrite them only when we're sure a .po file is new.
  275. po_dir=$1
  276. domain=$2
  277. # Download *.po files into this dir.
  278. # Usually contains *.s1 checksum files.
  279. ref_po_dir="$po_dir/.reference"
  280. test -d $ref_po_dir || mkdir $ref_po_dir || return
  281. download_po_files $ref_po_dir $domain \
  282. && ls "$ref_po_dir"/*.po 2>/dev/null |
  283. sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS"
  284. langs=`cd $ref_po_dir && echo *.po|sed 's/\.po//g'`
  285. test "$langs" = '*' && langs=x
  286. for po in $langs; do
  287. case $po in x) continue;; esac
  288. new_po="$ref_po_dir/$po.po"
  289. cksum_file="$ref_po_dir/$po.s1"
  290. if ! test -f "$cksum_file" ||
  291. ! test -f "$po_dir/$po.po" ||
  292. ! sha1sum -c --status "$cksum_file" < "$new_po" > /dev/null; then
  293. echo "updated $po_dir/$po.po..."
  294. cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file"
  295. fi
  296. done
  297. }
  298. case $SKIP_PO in
  299. '')
  300. if test -d po; then
  301. update_po_files po $package || exit
  302. fi
  303. if test -d runtime-po; then
  304. update_po_files runtime-po $package-runtime || exit
  305. fi;;
  306. esac
  307. symlink_to_dir()
  308. {
  309. src=$1/$2
  310. dst=${3-$2}
  311. test -f "$src" && {
  312. # If the destination directory doesn't exist, create it.
  313. # This is required at least for "lib/uniwidth/cjk.h".
  314. dst_dir=`dirname "$dst"`
  315. if ! test -d "$dst_dir"; then
  316. mkdir -p "$dst_dir"
  317. # If we've just created a directory like lib/uniwidth,
  318. # tell version control system(s) it's ignorable.
  319. # FIXME: for now, this does only one level
  320. parent=`dirname "$dst_dir"`
  321. for dot_ig in x $vc_ignore; do
  322. test $dot_ig = x && continue
  323. ig=$parent/$dot_ig
  324. insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'`
  325. done
  326. fi
  327. if $copy; then
  328. {
  329. test ! -h "$dst" || {
  330. echo "$0: rm -f $dst" &&
  331. rm -f "$dst"
  332. }
  333. } &&
  334. test -f "$dst" &&
  335. cmp -s "$src" "$dst" || {
  336. echo "$0: cp -fp $src $dst" &&
  337. cp -fp "$src" "$dst"
  338. }
  339. else
  340. test -h "$dst" &&
  341. src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 &&
  342. dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 &&
  343. test "$src_i" = "$dst_i" || {
  344. dot_dots=
  345. case $src in
  346. /*) ;;
  347. *)
  348. case /$dst/ in
  349. *//* | */../* | */./* | /*/*/*/*/*/)
  350. echo >&2 "$0: invalid symlink calculation: $src -> $dst"
  351. exit 1;;
  352. /*/*/*/*/) dot_dots=../../../;;
  353. /*/*/*/) dot_dots=../../;;
  354. /*/*/) dot_dots=../;;
  355. esac;;
  356. esac
  357. echo "$0: ln -fs $dot_dots$src $dst" &&
  358. ln -fs "$dot_dots$src" "$dst"
  359. }
  360. fi
  361. }
  362. }
  363. cp_mark_as_generated()
  364. {
  365. cp_src=$1
  366. cp_dst=$2
  367. if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
  368. symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
  369. elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
  370. symlink_to_dir $local_gl_dir "$cp_dst"
  371. else
  372. case $cp_dst in
  373. *.[ch]) c1='/* '; c2=' */';;
  374. *.texi) c1='@c '; c2= ;;
  375. *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
  376. *) c1= ; c2= ;;
  377. esac
  378. # If the destination directory doesn't exist, create it.
  379. # This is required at least for "lib/uniwidth/cjk.h".
  380. dst_dir=`dirname "$cp_dst"`
  381. test -d "$dst_dir" || mkdir -p "$dst_dir"
  382. if test -z "$c1"; then
  383. cmp -s "$cp_src" "$cp_dst" || {
  384. # Copy the file first to get proper permissions if it
  385. # doesn't already exist. Then overwrite the copy.
  386. echo "$0: cp -f $cp_src $cp_dst" &&
  387. rm -f "$cp_dst" &&
  388. cp "$cp_src" "$cp_dst-t" &&
  389. sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" &&
  390. mv -f "$cp_dst-t" "$cp_dst"
  391. }
  392. else
  393. # Copy the file first to get proper permissions if it
  394. # doesn't already exist. Then overwrite the copy.
  395. cp "$cp_src" "$cp_dst-t" &&
  396. (
  397. echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
  398. echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
  399. sed "s!$bt_regex/!!g" "$cp_src"
  400. ) > $cp_dst-t &&
  401. if cmp -s "$cp_dst-t" "$cp_dst"; then
  402. rm -f "$cp_dst-t"
  403. else
  404. echo "$0: cp $cp_src $cp_dst # with edits" &&
  405. mv -f "$cp_dst-t" "$cp_dst"
  406. fi
  407. fi
  408. fi
  409. }
  410. version_controlled_file() {
  411. dir=$1
  412. file=$2
  413. found=no
  414. if test -d CVS; then
  415. grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
  416. grep '^/[^/]*/[0-9]' > /dev/null && found=yes
  417. elif test -d .git; then
  418. git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
  419. elif test -d .svn; then
  420. svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
  421. else
  422. echo "$0: no version control for $dir/$file?" >&2
  423. fi
  424. test $found = yes
  425. }
  426. slurp() {
  427. for dir in . `(cd $1 && find * -type d -print)`; do
  428. copied=
  429. sep=
  430. for file in `ls -a $1/$dir`; do
  431. case $file in
  432. .|..) continue;;
  433. .*) continue;; # FIXME: should all file names starting with "." be ignored?
  434. esac
  435. test -d $1/$dir/$file && continue
  436. for excluded_file in $excluded_files; do
  437. test "$dir/$file" = "$excluded_file" && continue 2
  438. done
  439. if test $file = Makefile.am; then
  440. copied=$copied${sep}$gnulib_mk; sep=$nl
  441. remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
  442. sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
  443. echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
  444. rm -f $dir/$gnulib_mk &&
  445. sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
  446. }
  447. elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
  448. version_controlled_file $dir $file; then
  449. echo "$0: $dir/$file overrides $1/$dir/$file"
  450. else
  451. copied=$copied$sep$file; sep=$nl
  452. if test $file = gettext.m4; then
  453. echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
  454. rm -f $dir/$file
  455. sed '
  456. /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
  457. AC_DEFUN([AM_INTL_SUBDIR], [
  458. /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
  459. AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
  460. $a\
  461. AC_DEFUN([gl_LOCK_EARLY], [])
  462. ' $1/$dir/$file >$dir/$file
  463. else
  464. cp_mark_as_generated $1/$dir/$file $dir/$file
  465. fi
  466. fi || exit
  467. done
  468. for dot_ig in x $vc_ignore; do
  469. test $dot_ig = x && continue
  470. ig=$dir/$dot_ig
  471. if test -n "$copied"; then
  472. insert_sorted_if_absent $ig "$copied"
  473. # If an ignored file name ends with .in.h, then also add
  474. # the name with just ".h". Many gnulib headers are generated,
  475. # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
  476. # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
  477. f=`echo "$copied"|sed 's/\.in\.h$/.h/;s/\.sin$/.sed/;s/\.y$/.c/;s/\.gperf$/.h/'`
  478. insert_sorted_if_absent $ig "$f"
  479. # For files like sys_stat.in.h and sys_time.in.h, record as
  480. # ignorable the directory we might eventually create: sys/.
  481. f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
  482. insert_sorted_if_absent $ig "$f"
  483. fi
  484. done
  485. done
  486. }
  487. # Create boot temporary directories to import from gnulib and gettext.
  488. rm -fr $bt $bt2 &&
  489. mkdir $bt $bt2 || exit
  490. # Import from gnulib.
  491. gnulib_tool_options="\
  492. --import\
  493. --no-changelog\
  494. --aux-dir $bt/$build_aux\
  495. --doc-base $bt/$doc_base\
  496. --lib $gnulib_name\
  497. --m4-base $bt/$m4_base/\
  498. --source-base $bt/$source_base/\
  499. --tests-base $bt/$tests_base\
  500. --local-dir $local_gl_dir\
  501. $gnulib_tool_option_extras\
  502. "
  503. echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
  504. $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
  505. slurp $bt || exit
  506. for file in $gnulib_files; do
  507. symlink_to_dir "$GNULIB_SRCDIR" $file || exit
  508. done
  509. # Import from gettext.
  510. with_gettext=yes
  511. grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
  512. with_gettext=no
  513. if test $with_gettext = yes; then
  514. echo "$0: (cd $bt2; autopoint) ..."
  515. cp configure.ac $bt2 &&
  516. (cd $bt2 && autopoint && rm configure.ac) &&
  517. slurp $bt2 $bt || exit
  518. fi
  519. rm -fr $bt $bt2 || exit
  520. # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
  521. # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
  522. # The following requires GNU find 4.2.3 or newer. Considering the usual
  523. # portability constraints of this script, that may seem a very demanding
  524. # requirement, but it should be ok. Ignore any failure, which is fine,
  525. # since this is only a convenience to help developers avoid the relatively
  526. # unusual case in which a symlinked-to .m4 file is git-removed from gnulib
  527. # between successive runs of this script.
  528. find "$m4_base" "$source_base" \
  529. -depth \( -name '*.m4' -o -name '*.[ch]' \) \
  530. -type l -xtype l -delete > /dev/null 2>&1
  531. # copy_files srcdir dstdir
  532. copy_files() {
  533. for file in `cat $1/DISTFILES`
  534. do
  535. case $file in
  536. "#*") continue;;
  537. esac
  538. dst=`echo $file | sed 's^.*/^^'`
  539. if [ $# -eq 3 ]; then
  540. case $dst in
  541. ${3}*) ;;
  542. *) dst=${3}$dst;;
  543. esac
  544. fi
  545. symlink_to_dir "$1" "$file" "$2/$dst" || exit
  546. # FIXME ignorefile $2 $dst
  547. done
  548. }
  549. # Import from paxutils
  550. copy_files ${PAXUTILS_SRCDIR} .
  551. copy_files ${PAXUTILS_SRCDIR}/am m4
  552. echo "$0: Creating m4/paxutils.m4"
  553. (echo "# This file is generated automatically. Please, do not edit."
  554. echo "#"
  555. echo "AC_DEFUN([${package}_PAXUTILS],["
  556. cat ${PAXUTILS_SRCDIR}/am/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
  557. echo "])") > ./m4/paxutils.m4
  558. #FIXME ignorefile m4 paxutils.m4
  559. if [ -d rmt ]; then
  560. :
  561. else
  562. mkdir rmt
  563. fi
  564. for dir in doc rmt lib tests
  565. do
  566. copy_files ${PAXUTILS_SRCDIR}/$dir $dir
  567. done
  568. copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
  569. # Reconfigure, getting other files.
  570. for command in \
  571. libtool \
  572. 'aclocal --force -I m4' \
  573. 'autoconf --force' \
  574. 'autoheader --force' \
  575. 'automake --add-missing --copy --force-missing';
  576. do
  577. if test "$command" = libtool; then
  578. use_libtool=0
  579. # We'd like to use grep -E, to see if any of LT_INIT,
  580. # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
  581. # but that's not portable enough (e.g., for Solaris).
  582. grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
  583. && use_libtool=1
  584. grep '^[ ]*LT_INIT' configure.ac >/dev/null \
  585. && use_libtool=1
  586. test $use_libtool = 0 \
  587. && continue
  588. command='libtoolize -c -f'
  589. fi
  590. echo "$0: $command ..."
  591. $command || exit
  592. done
  593. # Get some extra files from gnulib, overriding existing files.
  594. for file in $gnulib_extra_files; do
  595. case $file in
  596. */INSTALL) dst=INSTALL;;
  597. build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
  598. *) dst=$file;;
  599. esac
  600. symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
  601. done
  602. if test $with_gettext = yes; then
  603. # Create gettext configuration.
  604. echo "$0: Creating po/Makevars from po/Makevars.template ..."
  605. rm -f po/Makevars
  606. sed '
  607. /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
  608. /^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/
  609. /^XGETTEXT_OPTIONS *=/{
  610. s/$/ \\/
  611. a\
  612. '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
  613. }
  614. ' po/Makevars.template >po/Makevars
  615. if test -d runtime-po; then
  616. # Similarly for runtime-po/Makevars, but not quite the same.
  617. rm -f runtime-po/Makevars
  618. sed '
  619. /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
  620. /^subdir *=.*/s/=.*/= runtime-po/
  621. /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
  622. /^XGETTEXT_OPTIONS *=/{
  623. s/$/ \\/
  624. a\
  625. '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
  626. }
  627. ' <po/Makevars.template >runtime-po/Makevars
  628. # Copy identical files from po to runtime-po.
  629. (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
  630. fi
  631. fi
  632. echo "$0: done. Now you can run './configure'."