4
0

bootstrap 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. #! /bin/sh
  2. # Bootstrap 'tar' 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. # URL of our text domain page in Translation Project
  18. TP_URL="http://www.iro.umontreal.ca/translation/maint/tar/"
  19. # Ensure file names are sorted consistently across platforms;
  20. # e.g., m4/ulonglong_gl.m4 should follow m4/ulonglong.m4.
  21. LC_ALL=C
  22. export LC_ALL
  23. usage() {
  24. cat <<EOF
  25. usage: $0 [--gnulib-srcdir=DIR][--paxutils-srcdir=DIR][--cvs-auth=AUTH-METHOD][--cvs-user=USERNAME][--no-po]
  26. Options are:
  27. --paxutils-srcdir=DIRNAME Specify the local directory where paxutils
  28. sources reside. Use this if you already
  29. have paxutils sources on your machine, and
  30. do not want to waste your bandwidth dowloading
  31. them again.
  32. --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
  33. sources reside. Use this if you already
  34. have gnulib sources on your machine, and
  35. do not want to waste your bandwidth dowloading
  36. them again.
  37. --cvs-auth=METHOD Set the CVS access method used for downloading
  38. gnulib files. METHOD is one of the keywords
  39. accepted by cvs -d option (see info cvs
  40. repository).
  41. --cvs-user=USERNAME Set the CVS username to be used when accessing
  42. the gnulib repository.
  43. --no-po Do not download po files.
  44. --update-po[=LANG] Update po file(s) and exit.
  45. If the file \`.bootstrap' exists in the current working directory, its
  46. contents is read, comments and empty lines removed, shell variables expanded
  47. and the result is prepended to the command line options.
  48. Running without arguments will suffice in most cases. It is equivalent
  49. to
  50. ./bootstrap --cvs-auth=pserver
  51. EOF
  52. }
  53. update_po() {
  54. if [ $# = 1 ]; then
  55. case $1 in
  56. *.po) POFILE=$1;;
  57. *) POFILE=${1}.po;;
  58. esac
  59. echo "$0: getting translation for $1..."
  60. (cd po;
  61. wget -r --cache=off -O $POFILE $TP_URL/$POFILE || exit
  62. LANG=`expr $POFILE : '\(.*\)\.po'`
  63. if ! grep -q $LANG LINGUAS; then
  64. mv LINGUAS LINGUAS.$$
  65. (echo $LANG; cat LINGUAS.$$) | sort > LINGUAS
  66. fi)
  67. else
  68. echo "$0: getting translations into po..."
  69. (cd po &&
  70. rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` &&
  71. wget -nv -nd -r -l 1 -A .po --cache off $TP_URL &&
  72. rm -f index.html index.html.[0-9]*
  73. ls *.po | sed 's/\.po$//' >LINGUAS
  74. ) || exit
  75. fi
  76. }
  77. # Read configuration file
  78. if [ -r .bootstrap ]; then
  79. echo "$0: Reading configuration file .bootstrap"
  80. eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
  81. fi
  82. # Parse options.
  83. DOWNLOAD_PO=yes
  84. for option
  85. do
  86. case $option in
  87. --help)
  88. usage
  89. exit;;
  90. --gnulib-srcdir=*)
  91. GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
  92. --paxutils-srcdir=*)
  93. PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
  94. --cvs-auth=*)
  95. CVS_AUTH=`expr "$option" : '--cvs-auth=\(.*\)'`;;
  96. --cvs-user=*)
  97. CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
  98. --no-po)
  99. DOWNLOAD_PO=no;;
  100. --update-po=*)
  101. DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
  102. --update-po)
  103. DOWNLOAD_PO=only;;
  104. *)
  105. echo >&2 "$0: $option: unknown option"
  106. exit 1;;
  107. esac
  108. done
  109. case $DOWNLOAD_PO in
  110. only) update_po
  111. exit 0
  112. ;;
  113. no|yes) ;;
  114. *) update_po $DOWNLOAD_PO
  115. exit 0
  116. esac
  117. echo "$0: Bootstrapping CVS tar..."
  118. build_cvs_prefix() {
  119. CVS_PREFIX=:${1}:
  120. if [ "${2}" != - ]; then
  121. CVS_PREFIX=${CVS_PREFIX}${2}@
  122. fi
  123. if [ "$1" = "ext" ]; then
  124. if [ -z "${CVS_RSH}" ]; then
  125. CVS_RSH=ssh
  126. export CVS_RSH
  127. fi
  128. fi
  129. }
  130. # checkout package
  131. checkout() {
  132. if [ ! -d $1 ]; then
  133. echo "$0: getting $1 files..."
  134. trap exit 1 2 13 15
  135. trap 'rm -fr $1; exit 1' 0
  136. case "${CVS_AUTH-pserver}" in
  137. pserver) build_cvs_prefix pserver ${CVS_USER:-anonymous}
  138. ;;
  139. gserver|server)
  140. build_cvs_prefix $CVS_AUTH ${CVS_USER--}
  141. ;;
  142. ext) build_cvs_prefix $CVS_AUTH ${CVS_USER--}
  143. ;;
  144. *) echo "$0: Unknown CVS access method" >&2
  145. exit 1;;
  146. esac
  147. cvs -q -d ${CVS_PREFIX}cvs.sv.gnu.org:/cvsroot/$1 co $1 || exit
  148. trap - 0
  149. fi
  150. }
  151. gnulib_modules=
  152. newline='
  153. '
  154. get_modules() {
  155. new_gnulib_modules=`sed '/^[ ]*#/d; /^[ ]*$/d' $*`
  156. case $gnulib_modules,$new_gnulib_modules in
  157. ?*,?*) new_gnulib_modules=$newline$new_gnulib_modules;;
  158. esac
  159. gnulib_modules=$gnulib_modules$new_gnulib_modules
  160. }
  161. # Get paxutils files
  162. case ${PAXUTILS_SRCDIR--} in
  163. -) checkout paxutils
  164. PAXUTILS_SRCDIR=paxutils
  165. esac
  166. if [ -r $PAXUTILS_SRCDIR/gnulib.modules ]; then
  167. get_modules $PAXUTILS_SRCDIR/gnulib.modules
  168. fi
  169. # copy_files srcdir dstdir
  170. copy_files() {
  171. for file in `cat $1/DISTFILES`
  172. do
  173. case $file in
  174. "#*") continue;;
  175. esac
  176. dst=`echo $file | sed 's^.*/^^'`
  177. if [ $# -eq 3 ]; then
  178. case $dst in
  179. ${3}*) ;;
  180. *) dst=${3}$dst;;
  181. esac
  182. fi
  183. echo "$0: Copying file $1/$file to $2/$dst"
  184. cp -p $1/$file $2/$dst
  185. done
  186. }
  187. copy_files ${PAXUTILS_SRCDIR}/m4 m4
  188. echo "$0: Creating m4/paxutils.m4"
  189. (echo "# This file is generated automatically. Please, do not edit."
  190. echo "#"
  191. echo "AC_DEFUN([tar_PAXUTILS],["
  192. cat ${PAXUTILS_SRCDIR}/m4/DISTFILES | sed '/^#/d;s/\(.*\)\.m4/pu_\1/' | tr a-z A-Z
  193. echo "])") > ./m4/paxutils.m4
  194. if [ -d rmt ]; then
  195. :
  196. else
  197. mkdir rmt
  198. fi
  199. for dir in doc rmt lib tests
  200. do
  201. copy_files ${PAXUTILS_SRCDIR}/$dir $dir
  202. done
  203. copy_files ${PAXUTILS_SRCDIR}/paxlib lib pax
  204. # Get gnulib files.
  205. case ${GNULIB_SRCDIR--} in
  206. -) checkout gnulib
  207. GNULIB_SRCDIR=gnulib
  208. esac
  209. <$GNULIB_SRCDIR/gnulib-tool || exit
  210. get_modules gnulib.modules
  211. gnulib_modules=`echo "$gnulib_modules" | sort -u`
  212. previous_gnulib_modules=
  213. while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
  214. previous_gnulib_modules=$gnulib_modules
  215. gnulib_modules=`
  216. (echo "$gnulib_modules"
  217. for gnulib_module in $gnulib_modules; do
  218. $GNULIB_SRCDIR/gnulib-tool --extract-dependencies $gnulib_module
  219. done) | sort -u
  220. `
  221. done
  222. gnulib_files=`
  223. (for gnulib_module in $gnulib_modules; do
  224. $GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module
  225. done) | sort -u
  226. `
  227. gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
  228. mkdir -p $gnulib_dirs || exit
  229. for gnulib_file in $gnulib_files; do
  230. dest=$gnulib_file
  231. case $gnulib_file in
  232. m4/codeset.m4) continue;;
  233. m4/intdiv0.m4) continue;;
  234. m4/inttypes-pri.m4) continue;;
  235. m4/isc-posix.m4) continue;;
  236. m4/lcmessage.m4) continue;;
  237. m4/onceonly_2_57.m4) dest=m4/onceonly.m4;;
  238. # These will be overwritten by autopoint, which still uses
  239. # old jm_.* macro names, so we have to keep both copies.
  240. m4/gettext.m4 | m4/glibc21.m4 | m4/inttypes_h.m4 | m4/lib-ld.m4 | \
  241. m4/lib-prefix.m4 | m4/po.m4 | m4/stdint_h.m4 | m4/uintmax_t.m4 | \
  242. m4/ulonglong.m4)
  243. dest=`expr $gnulib_file : '\(.*\).m4'`_gl.m4;;
  244. esac
  245. rm -f $dest &&
  246. echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
  247. cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
  248. done
  249. echo "$0: Creating m4/gnulib.m4"
  250. (echo "# This file is generated automatically. Please, do not edit."
  251. echo "#"
  252. echo "AC_DEFUN([tar_GNULIB],["
  253. for gnulib_module in $gnulib_modules; do
  254. echo "# $gnulib_module"
  255. $GNULIB_SRCDIR/gnulib-tool --extract-autoconf-snippet $gnulib_module
  256. done | sed '/AM_GNU_GETTEXT/d'
  257. echo "])") > ./m4/gnulib.m4
  258. echo "$0: Creating lib/Makefile.am"
  259. (echo "# This file is generated automatically. Do not edit!"
  260. cat lib/Makefile.tmpl
  261. for gnulib_module in $gnulib_modules; do
  262. echo "# $gnulib_module"
  263. $GNULIB_SRCDIR/gnulib-tool --extract-automake-snippet $gnulib_module
  264. done | sed 's/lib_SOURCES/libtar_a_SOURCES/g' ) > lib/Makefile.am
  265. # Get translations.
  266. if test "$DOWNLOAD_PO" = "yes"; then
  267. update_po
  268. fi
  269. # Reconfigure, getting other files.
  270. echo "$0: autoreconf --verbose --install --force ..."
  271. autoreconf --verbose --install --force || exit 1
  272. echo "$0: done. Now you can run './configure'."