bootstrap 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  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. [email protected]
  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. *//* | */../* | */./* | /*/*/*/*/*/)
  351. echo >&2 "$0: invalid symlink calculation: $src -> $dst"
  352. exit 1;;
  353. /*/*/*/*/) dot_dots=../../../;;
  354. /*/*/*/) dot_dots=../../;;
  355. /*/*/) dot_dots=../;;
  356. esac;;
  357. esac
  358. echo "$0: ln -fs $dot_dots$src $dst" &&
  359. ln -fs "$dot_dots$src" "$dst"
  360. }
  361. fi
  362. }
  363. }
  364. cp_mark_as_generated()
  365. {
  366. cp_src=$1
  367. cp_dst=$2
  368. if cmp -s "$cp_src" "$GNULIB_SRCDIR/$cp_dst"; then
  369. symlink_to_dir "$GNULIB_SRCDIR" "$cp_dst"
  370. elif cmp -s "$cp_src" "$local_gl_dir/$cp_dst"; then
  371. symlink_to_dir $local_gl_dir "$cp_dst"
  372. else
  373. case $cp_dst in
  374. *.[ch]) c1='/* '; c2=' */';;
  375. *.texi) c1='@c '; c2= ;;
  376. *.m4|*/Make*|Make*) c1='# ' ; c2= ;;
  377. *) c1= ; c2= ;;
  378. esac
  379. # If the destination directory doesn't exist, create it.
  380. # This is required at least for "lib/uniwidth/cjk.h".
  381. dst_dir=`dirname "$cp_dst"`
  382. test -d "$dst_dir" || mkdir -p "$dst_dir"
  383. if test -z "$c1"; then
  384. cmp -s "$cp_src" "$cp_dst" || {
  385. # Copy the file first to get proper permissions if it
  386. # doesn't already exist. Then overwrite the copy.
  387. echo "$0: cp -f $cp_src $cp_dst" &&
  388. rm -f "$cp_dst" &&
  389. cp "$cp_src" "$cp_dst-t" &&
  390. sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst-t" &&
  391. mv -f "$cp_dst-t" "$cp_dst"
  392. }
  393. else
  394. # Copy the file first to get proper permissions if it
  395. # doesn't already exist. Then overwrite the copy.
  396. cp "$cp_src" "$cp_dst-t" &&
  397. (
  398. echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" &&
  399. echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" &&
  400. sed "s!$bt_regex/!!g" "$cp_src"
  401. ) > $cp_dst-t &&
  402. if cmp -s "$cp_dst-t" "$cp_dst"; then
  403. rm -f "$cp_dst-t"
  404. else
  405. echo "$0: cp $cp_src $cp_dst # with edits" &&
  406. mv -f "$cp_dst-t" "$cp_dst"
  407. fi
  408. fi
  409. fi
  410. }
  411. version_controlled_file() {
  412. dir=$1
  413. file=$2
  414. found=no
  415. if test -d CVS; then
  416. grep -F "/$file/" $dir/CVS/Entries 2>/dev/null |
  417. grep '^/[^/]*/[0-9]' > /dev/null && found=yes
  418. elif test -d .git; then
  419. git rm -n "$dir/$file" > /dev/null 2>&1 && found=yes
  420. elif test -d .svn; then
  421. svn log -r HEAD "$dir/$file" > /dev/null 2>&1 && found=yes
  422. else
  423. echo "$0: no version control for $dir/$file?" >&2
  424. fi
  425. test $found = yes
  426. }
  427. slurp() {
  428. for dir in . `(cd $1 && find * -type d -print)`; do
  429. copied=
  430. sep=
  431. for file in `ls -a $1/$dir`; do
  432. case $file in
  433. .|..) continue;;
  434. .*) continue;; # FIXME: should all file names starting with "." be ignored?
  435. esac
  436. test -d $1/$dir/$file && continue
  437. for excluded_file in $excluded_files; do
  438. test "$dir/$file" = "$excluded_file" && continue 2
  439. done
  440. if test $file = Makefile.am; then
  441. copied=$copied${sep}$gnulib_mk; sep=$nl
  442. remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
  443. sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
  444. echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
  445. rm -f $dir/$gnulib_mk &&
  446. sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
  447. }
  448. elif { test "${2+set}" = set && test -r $2/$dir/$file; } ||
  449. version_controlled_file $dir $file; then
  450. echo "$0: $dir/$file overrides $1/$dir/$file"
  451. else
  452. copied=$copied$sep$file; sep=$nl
  453. if test $file = gettext.m4; then
  454. echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
  455. rm -f $dir/$file
  456. sed '
  457. /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
  458. AC_DEFUN([AM_INTL_SUBDIR], [
  459. /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
  460. AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
  461. $a\
  462. AC_DEFUN([gl_LOCK_EARLY], [])
  463. ' $1/$dir/$file >$dir/$file
  464. else
  465. cp_mark_as_generated $1/$dir/$file $dir/$file
  466. fi
  467. fi || exit
  468. done
  469. for dot_ig in x $vc_ignore; do
  470. test $dot_ig = x && continue
  471. ig=$dir/$dot_ig
  472. if test -n "$copied"; then
  473. insert_sorted_if_absent $ig "$copied"
  474. # If an ignored file name ends with .in.h, then also add
  475. # the name with just ".h". Many gnulib headers are generated,
  476. # e.g., stdint.in.h -> stdint.h, dirent.in.h ->..., etc.
  477. # Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
  478. f=`echo "$copied"|sed 's/\.in\.h$/.h/;s/\.sin$/.sed/;s/\.y$/.c/;s/\.gperf$/.h/'`
  479. insert_sorted_if_absent $ig "$f"
  480. # For files like sys_stat.in.h and sys_time.in.h, record as
  481. # ignorable the directory we might eventually create: sys/.
  482. f=`echo "$copied"|sed 's/sys_.*\.in\.h$/sys/'`
  483. insert_sorted_if_absent $ig "$f"
  484. fi
  485. done
  486. done
  487. }
  488. # Create boot temporary directories to import from gnulib and gettext.
  489. rm -fr $bt $bt2 &&
  490. mkdir $bt $bt2 || exit
  491. # Import from gnulib.
  492. gnulib_tool_options="\
  493. --import\
  494. --no-changelog\
  495. --aux-dir $bt/$build_aux\
  496. --doc-base $bt/$doc_base\
  497. --lib $gnulib_name\
  498. --m4-base $bt/$m4_base/\
  499. --source-base $bt/$source_base/\
  500. --tests-base $bt/$tests_base\
  501. --local-dir $local_gl_dir\
  502. $gnulib_tool_option_extras\
  503. "
  504. echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
  505. $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&
  506. slurp $bt || exit
  507. for file in $gnulib_files; do
  508. symlink_to_dir "$GNULIB_SRCDIR" $file || exit
  509. done
  510. # Import from gettext.
  511. with_gettext=yes
  512. grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
  513. with_gettext=no
  514. if test $with_gettext = yes; then
  515. echo "$0: (cd $bt2; autopoint) ..."
  516. cp configure.ac $bt2 &&
  517. (cd $bt2 && autopoint && rm configure.ac) &&
  518. slurp $bt2 $bt || exit
  519. fi
  520. rm -fr $bt $bt2 || exit
  521. # Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
  522. # gnulib-populated directories. Such .m4 files would cause aclocal to fail.
  523. # The following requires GNU find 4.2.3 or newer. Considering the usual
  524. # portability constraints of this script, that may seem a very demanding
  525. # requirement, but it should be ok. Ignore any failure, which is fine,
  526. # since this is only a convenience to help developers avoid the relatively
  527. # unusual case in which a symlinked-to .m4 file is git-removed from gnulib
  528. # between successive runs of this script.
  529. find "$m4_base" "$source_base" \
  530. -depth \( -name '*.m4' -o -name '*.[ch]' \) \
  531. -type l -xtype l -delete > /dev/null 2>&1
  532. # copy_files srcdir dstdir
  533. copy_files() {
  534. for file in `cat $1/DISTFILES`
  535. do
  536. case $file in
  537. "#*") continue;;
  538. esac
  539. dst=`echo $file | sed 's^.*/^^'`
  540. if [ $# -eq 3 ]; then
  541. case $dst in
  542. ${3}*) ;;
  543. *) dst=${3}$dst;;
  544. esac
  545. fi
  546. symlink_to_dir "$1" "$file" "$2/$dst" || exit
  547. # FIXME ignorefile $2 $dst
  548. done
  549. }
  550. # Import from paxutils
  551. copy_files ${PAXUTILS_SRCDIR} .
  552. copy_files ${PAXUTILS_SRCDIR}/am m4
  553. echo "$0: Creating m4/paxutils.m4"
  554. (echo "# This file is generated automatically. Please, do not edit."
  555. echo "#"
  556. echo "AC_DEFUN([${package}_PAXUTILS],["
  557. cat ${PAXUTILS_SRCDIR}/am/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
  558. echo "])") > ./m4/paxutils.m4
  559. #FIXME ignorefile m4 paxutils.m4
  560. if [ -d rmt ]; then
  561. :
  562. else
  563. mkdir rmt
  564. fi
  565. for dir in doc rmt lib tests
  566. do
  567. copy_files ${PAXUTILS_SRCDIR}/$dir $dir
  568. done
  569. copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
  570. # Reconfigure, getting other files.
  571. for command in \
  572. libtool \
  573. 'aclocal --force -I m4' \
  574. 'autoconf --force' \
  575. 'autoheader --force' \
  576. 'automake --add-missing --copy --force-missing';
  577. do
  578. if test "$command" = libtool; then
  579. use_libtool=0
  580. # We'd like to use grep -E, to see if any of LT_INIT,
  581. # AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
  582. # but that's not portable enough (e.g., for Solaris).
  583. grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
  584. && use_libtool=1
  585. grep '^[ ]*LT_INIT' configure.ac >/dev/null \
  586. && use_libtool=1
  587. test $use_libtool = 0 \
  588. && continue
  589. command='libtoolize -c -f'
  590. fi
  591. echo "$0: $command ..."
  592. $command || exit
  593. done
  594. # Get some extra files from gnulib, overriding existing files.
  595. for file in $gnulib_extra_files; do
  596. case $file in
  597. */INSTALL) dst=INSTALL;;
  598. build-aux/*) dst=$build_aux/`expr "$file" : 'build-aux/\(.*\)'`;;
  599. *) dst=$file;;
  600. esac
  601. symlink_to_dir "$GNULIB_SRCDIR" $file $dst || exit
  602. done
  603. if test $with_gettext = yes; then
  604. # Create gettext configuration.
  605. echo "$0: Creating po/Makevars from po/Makevars.template ..."
  606. rm -f po/Makevars
  607. sed '
  608. /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
  609. /^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/
  610. /^XGETTEXT_OPTIONS *=/{
  611. s/$/ \\/
  612. a\
  613. '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
  614. }
  615. ' po/Makevars.template >po/Makevars
  616. if test -d runtime-po; then
  617. # Similarly for runtime-po/Makevars, but not quite the same.
  618. rm -f runtime-po/Makevars
  619. sed '
  620. /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
  621. /^subdir *=.*/s/=.*/= runtime-po/
  622. /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
  623. /^XGETTEXT_OPTIONS *=/{
  624. s/$/ \\/
  625. a\
  626. '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
  627. }
  628. ' <po/Makevars.template >runtime-po/Makevars
  629. # Copy identical files from po to runtime-po.
  630. (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
  631. fi
  632. fi
  633. echo "$0: done. Now you can run './configure'."