bootstrap 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. #! /bin/sh
  2. # Bootstrap this package from CVS.
  3. # Copyright (C) 2003, 2004, 2005, 2006 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 2, or (at your option)
  7. # 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, write to the Free Software
  14. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. # 02110-1301, USA.
  16. # Written by Paul Eggert and Sergey Poznyakoff.
  17. package=tar
  18. # Translation Project URL, for the registry of all projects.
  19. TP_URL='http://www.iro.umontreal.ca/translation/registry.cgi?domain='
  20. # Ensure file names are sorted consistently across platforms.
  21. # Also, ensure diagnostics are in English, e.g., "wget --help" below.
  22. LC_ALL=C
  23. export LC_ALL
  24. usage() {
  25. cat <<EOF
  26. usage: $0 [--gnulib-srcdir=DIR][--paxutils-srcdir=DIR][--cvs-auth=AUTH-METHOD][--cvs-user=USERNAME][--no-po]
  27. Options are:
  28. --paxutils-srcdir=DIRNAME Specify the local directory where paxutils
  29. sources reside. Use this if you already
  30. have paxutils sources on your machine, and
  31. do not want to waste your bandwidth dowloading
  32. them again.
  33. --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
  34. sources reside. Use this if you already
  35. have gnulib sources on your machine, and
  36. do not want to waste your bandwidth dowloading
  37. them again.
  38. --cvs-auth=METHOD Set the CVS access method used for downloading
  39. gnulib files. METHOD is one of the keywords
  40. accepted by cvs -d option (see info cvs
  41. repository).
  42. --cvs-user=USERNAME Set the CVS username to be used when accessing
  43. the gnulib repository.
  44. --no-po Do not download po files.
  45. --update-po[=LANG] Update po file(s) and exit.
  46. If the file \`.bootstrap' exists in the current working directory, its
  47. contents is read, comments and empty lines removed, shell variables expanded
  48. and the result is prepended to the command line options.
  49. Running without arguments will suffice in most cases. It is equivalent
  50. to
  51. ./bootstrap --cvs-auth=pserver
  52. EOF
  53. }
  54. # Read configuration file
  55. if [ -r .bootstrap ]; then
  56. echo "$0: Reading configuration file .bootstrap"
  57. eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
  58. fi
  59. # Parse options.
  60. DOWNLOAD_PO=yes
  61. for option
  62. do
  63. case $option in
  64. --help)
  65. usage
  66. exit;;
  67. --gnulib-srcdir=*)
  68. GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
  69. --paxutils-srcdir=*)
  70. PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
  71. --cvs-auth=*)
  72. CVS_AUTH=`expr "$option" : '--cvs-auth=\(.*\)'`;;
  73. --cvs-user=*)
  74. CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
  75. --no-po)
  76. DOWNLOAD_PO=no;;
  77. --update-po=*)
  78. DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
  79. --update-po)
  80. DOWNLOAD_PO=only;;
  81. *)
  82. echo >&2 "$0: $option: unknown option"
  83. exit 1;;
  84. esac
  85. done
  86. # Get translations.
  87. get_translations() {
  88. subdir=$1
  89. domain=$2
  90. po_file=$3
  91. echo "$0: getting translations into $subdir for $domain..."
  92. case $po_file in
  93. '') (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`);;
  94. esac &&
  95. $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" &&
  96. sed -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" |
  97. sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
  98. awk -F. '
  99. { if (lang && $1 != lang) print lang, ver }
  100. { lang = $1; ver = substr($0, index($0, ".") + 1) }
  101. END { if (lang) print lang, ver }
  102. ' |
  103. awk -v domain="$domain" -v po_file="$po_file" -v subdir="$subdir" '
  104. {
  105. lang = $1
  106. if (po_file && po_file != (lang ".po")) next
  107. # Work around bugs in translations uncovered by gettext 0.15.
  108. # This workaround can be removed once the translations are fixed.
  109. if (lang == "hu" || lang == "zh_TW") next
  110. ver = $2
  111. urlfmt = ""
  112. printf "$WGET_COMMAND -O %s/%s.po 'http://www.iro.umontreal.ca/translation/teams/PO/%s/%s-%s.%s.po' &&\n", subdir, lang, lang, domain, ver, lang
  113. }
  114. END { print ":" }
  115. ' |
  116. sh &&
  117. ls "$subdir"/*.po | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
  118. rm "$subdir/$domain.html"
  119. }
  120. update_po() {
  121. if [ $# = 1 ]; then
  122. case $1 in
  123. *.po) POFILE=$1;;
  124. *) POFILE=${1}.po;;
  125. esac
  126. get_translations po $package "$POFILE"
  127. else
  128. get_translations po $package
  129. fi
  130. }
  131. case $DOWNLOAD_PO in
  132. no) ;;
  133. *)
  134. case `wget --help` in
  135. *'--no-cache'*)
  136. no_cache='--no-cache';;
  137. *'--cache=on/off'*)
  138. no_cache='--cache=off';;
  139. *)
  140. no_cache='';;
  141. esac
  142. WGET_COMMAND="wget -nv $no_cache"
  143. export WGET_COMMAND
  144. esac
  145. case $DOWNLOAD_PO in
  146. only) update_po
  147. exit
  148. ;;
  149. no|yes) ;;
  150. *) update_po $DOWNLOAD_PO
  151. exit
  152. esac
  153. echo "$0: Bootstrapping CVS $package..."
  154. build_cvs_prefix() {
  155. CVS_PREFIX=:${1}:
  156. if [ "${2}" != - ]; then
  157. CVS_PREFIX=${CVS_PREFIX}${2}@
  158. fi
  159. if [ "$1" = "ext" ]; then
  160. if [ -z "${CVS_RSH}" ]; then
  161. CVS_RSH=ssh
  162. export CVS_RSH
  163. fi
  164. fi
  165. }
  166. # checkout package
  167. checkout() {
  168. if [ ! -d $1 ]; then
  169. echo "$0: getting $1 files..."
  170. trap exit 1 2 13 15
  171. trap 'rm -fr $1; exit 1' 0
  172. case "${CVS_AUTH-pserver}" in
  173. pserver) build_cvs_prefix pserver ${CVS_USER:-anonymous}
  174. ;;
  175. gserver|server)
  176. build_cvs_prefix $CVS_AUTH ${CVS_USER--}
  177. ;;
  178. ext) build_cvs_prefix $CVS_AUTH ${CVS_USER--}
  179. ;;
  180. *) echo "$0: Unknown CVS access method" >&2
  181. exit 1;;
  182. esac
  183. cvs -q -d ${CVS_PREFIX}cvs.sv.gnu.org:/cvsroot/$1 co $1 || exit
  184. trap - 0
  185. fi
  186. }
  187. gnulib_modules=
  188. newline='
  189. '
  190. get_modules() {
  191. new_gnulib_modules=`sed '/^[ ]*#/d; /^[ ]*$/d' $*`
  192. case $gnulib_modules,$new_gnulib_modules in
  193. ?*,?*) new_gnulib_modules=$newline$new_gnulib_modules;;
  194. esac
  195. gnulib_modules=$gnulib_modules$new_gnulib_modules
  196. }
  197. # Get paxutils files
  198. case ${PAXUTILS_SRCDIR--} in
  199. -) checkout paxutils
  200. PAXUTILS_SRCDIR=paxutils
  201. esac
  202. if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
  203. get_modules $PAXUTILS_SRCDIR/gnulib.modules
  204. fi
  205. # copy_files srcdir dstdir
  206. copy_files() {
  207. for file in `cat $1/DISTFILES`
  208. do
  209. case $file in
  210. "#*") continue;;
  211. esac
  212. dst=`echo $file | sed 's^.*/^^'`
  213. if [ $# -eq 3 ]; then
  214. case $dst in
  215. ${3}*) ;;
  216. *) dst=${3}$dst;;
  217. esac
  218. fi
  219. echo "$0: Copying file $1/$file to $2/$dst"
  220. cp -p $1/$file $2/$dst
  221. done
  222. }
  223. copy_files ${PAXUTILS_SRCDIR}/m4 m4
  224. echo "$0: Creating m4/paxutils.m4"
  225. (echo "# This file is generated automatically. Please, do not edit."
  226. echo "#"
  227. echo "AC_DEFUN([${package}_PAXUTILS],["
  228. cat ${PAXUTILS_SRCDIR}/m4/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
  229. echo "])") > ./m4/paxutils.m4
  230. if [ -d rmt ]; then
  231. :
  232. else
  233. mkdir rmt
  234. fi
  235. for dir in doc rmt lib tests
  236. do
  237. copy_files ${PAXUTILS_SRCDIR}/$dir $dir
  238. done
  239. copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
  240. # Get gnulib files.
  241. case ${GNULIB_SRCDIR--} in
  242. -) checkout gnulib
  243. GNULIB_SRCDIR=gnulib
  244. esac
  245. gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
  246. <$gnulib_tool || exit
  247. get_modules gnulib.modules
  248. gnulib_modules=`echo "$gnulib_modules" | sort -u`
  249. previous_gnulib_modules=
  250. while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
  251. previous_gnulib_modules=$gnulib_modules
  252. gnulib_modules=`
  253. (echo "$gnulib_modules"
  254. for gnulib_module in $gnulib_modules; do
  255. $gnulib_tool --extract-dependencies $gnulib_module
  256. done) | sort -u
  257. `
  258. done
  259. gnulib_files=`
  260. (for gnulib_module in $gnulib_modules; do
  261. $gnulib_tool --extract-filelist $gnulib_module
  262. done) | sort -u
  263. `
  264. gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
  265. mkdir -p $gnulib_dirs || exit
  266. for gnulib_file in $gnulib_files; do
  267. dest=$gnulib_file
  268. rm -f $dest &&
  269. echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
  270. cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
  271. done
  272. # This suppresses a bogus diagnostic
  273. # "warning: macro `AM_LANGINFO_CODESET' not found in library".
  274. echo "$0: patching m4/gettext.m4 to remove need for intl/* ..."
  275. sed '
  276. /^AC_DEFUN(\[AM_INTL_SUBDIR],/,/^]/c\
  277. AC_DEFUN([AM_INTL_SUBDIR], [])
  278. /^AC_DEFUN(\[gt_INTL_SUBDIR_CORE],/,/^]/c\
  279. AC_DEFUN([gt_INTL_SUBDIR_CORE], [])
  280. ' m4/gettext.m4 >m4/gettext_gl.m4 || exit
  281. echo "$0: Creating m4/gnulib.m4"
  282. (echo "# This file is generated automatically. Please, do not edit."
  283. echo "#"
  284. echo "AC_DEFUN([${package}_GNULIB],["
  285. for gnulib_module in $gnulib_modules; do
  286. echo "# $gnulib_module"
  287. $gnulib_tool --extract-autoconf-snippet $gnulib_module
  288. done | sed '/AM_GNU_GETTEXT/d'
  289. echo "])") > ./m4/gnulib.m4
  290. echo "$0: Creating lib/Makefile.am"
  291. (echo "# This file is generated automatically. Do not edit!"
  292. cat lib/Makefile.tmpl
  293. for gnulib_module in $gnulib_modules; do
  294. echo "# $gnulib_module"
  295. $gnulib_tool --extract-automake-snippet $gnulib_module
  296. done | sed "s/lib_SOURCES/lib${package}_a_SOURCES/g" ) > lib/Makefile.am
  297. # Get translations.
  298. if test "$DOWNLOAD_PO" = "yes"; then
  299. update_po
  300. fi
  301. # Reconfigure, getting other files.
  302. echo "$0: autopoint --force ..."
  303. autopoint --force || exit
  304. # We don't need intl, so remove it.
  305. intl_files_to_remove='
  306. intl
  307. m4/gettext.m4
  308. m4/glibc2.m4
  309. m4/intdiv0.m4
  310. m4/intmax.m4
  311. m4/lcmessage.m4
  312. m4/lock.m4
  313. m4/printf-posix.m4
  314. m4/visibility.m4
  315. '
  316. echo $0: rm -fr $intl_files_to_remove ...
  317. rm -fr $intl_files_to_remove || exit
  318. # Undo changes to gnulib files that autoreconf made.
  319. for gnulib_file in $gnulib_files; do
  320. test ! -f $gnulib_file || cmp -s $gnulib_file $GNULIB_SRCDIR/$gnulib_file || {
  321. rm -f $gnulib_file &&
  322. echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file again" &&
  323. cp -p $GNULIB_SRCDIR/$gnulib_file $gnulib_file || exit
  324. }
  325. done
  326. # Make sure aclocal.m4 is not older than input files.
  327. sleep 1
  328. for command in \
  329. 'aclocal --force -I m4' \
  330. 'autoconf --force' \
  331. 'autoheader --force' \
  332. 'automake --add-missing --copy --force-missing';
  333. do
  334. echo "$0: $command ..."
  335. $command || exit
  336. done
  337. # Create gettext configuration.
  338. echo "$0: Creating po/Makevars from po/Makevars.template ..."
  339. sed '
  340. /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
  341. /^XGETTEXT_OPTIONS *=/{
  342. s/$/ \\/
  343. a\
  344. --flag=_:1:pass-c-format \\\
  345. --flag=N_:1:pass-c-format \\\
  346. --flag=error:3:c-format --flag=error_at_line:5:c-format \\\
  347. --flag=asnprintf:3:c-format --flag=vasnprintf:3:c-format \\\
  348. --flag=argp_error:2:c-format \\\
  349. --flag=__argp_error:2:c-format \\\
  350. --flag=argp_failure:4:c-format \\\
  351. --flag=__argp_failure:4:c-format \\\
  352. --flag=argp_fmtstream_printf:2:c-format \\\
  353. --flag=__argp_fmtstream_printf:2:c-format
  354. }
  355. ' po/Makevars.template >po/Makevars
  356. echo "$0: done. Now you can run './configure'."