4
0

bootstrap 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. #! /bin/sh
  2. # Bootstrap 'tar' from CVS.
  3. # Copyright (C) 2003, 2004 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., 59 Temple Place - Suite 330, Boston, MA
  15. # 02111-1307, USA.
  16. # Written by Paul Eggert and Sergey Poznyakoff.
  17. # URL of our text domain page in Translation Project
  18. TP_URL="http://www2.iro.umontreal.ca/~gnutra/po/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. Running without arguments will suffice in most cases. It is equivalent
  46. to
  47. ./bootstrap --cvs-auth=ext --cvs-user=anoncvs
  48. EOF
  49. }
  50. update_po() {
  51. if [ $# = 1 ]; then
  52. case $1 in
  53. *.po) POFILE=$1;;
  54. *) POFILE=${1}.po;;
  55. esac
  56. echo "$0: getting translation for $1..."
  57. wget -C off $TP_URL/$POFILE
  58. else
  59. echo "$0: getting translations into po..."
  60. (cd po &&
  61. rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` &&
  62. wget -nv -nd -r -l 1 -A .po -C off $TP_URL &&
  63. ls *.po | sed 's/\.po$//' >LINGUAS
  64. ) || exit
  65. fi
  66. }
  67. # Parse options.
  68. DOWNLOAD_PO=yes
  69. for option
  70. do
  71. case $option in
  72. --help)
  73. usage
  74. exit;;
  75. --gnulib-srcdir=*)
  76. GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
  77. --paxutils-srcdir=*)
  78. PAXUTILS_SRCDIR=`expr "$option" : '--paxutils-srcdir=\(.*\)'`;;
  79. --cvs-auth=*)
  80. CVS_AUTH=`expr "$option" : '--cvs-auth=\(.*\)'`;;
  81. --cvs-user=*)
  82. CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
  83. --no-po)
  84. DOWNLOAD_PO=no;;
  85. --update-po=*)
  86. DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
  87. --update-po)
  88. DOWNLOAD_PO=only;;
  89. *)
  90. echo >&2 "$0: $option: unknown option"
  91. exit 1;;
  92. esac
  93. done
  94. case $DOWNLOAD_PO in
  95. only) update_po
  96. exit 0
  97. ;;
  98. no|yes) ;;
  99. *) update_po $DOWNLOAD_PO
  100. exit 0
  101. esac
  102. echo "$0: Bootstrapping CVS tar..."
  103. build_cvs_prefix() {
  104. CVS_PREFIX=:${1}:
  105. if [ "${2}" != - ]; then
  106. CVS_PREFIX=${CVS_PREFIX}${2}@
  107. fi
  108. if [ "$1" = "ext" ]; then
  109. if [ -z "${CVS_RSH}" ]; then
  110. CVS_RSH=ssh
  111. export CVS_RSH
  112. fi
  113. fi
  114. }
  115. # checkout package
  116. checkout() {
  117. if [ ! -d $1 ]; then
  118. echo "$0: getting $1 files..."
  119. trap exit 1 2 13 15
  120. trap 'rm -fr $1; exit 1' 0
  121. case "${CVS_AUTH--}" in
  122. -) build_cvs_prefix ext anoncvs
  123. ;;
  124. pserver) build_cvs_prefix $CVS_AUTH ${CVS_USER:-anoncvs}
  125. ;;
  126. gserver|server)
  127. build_cvs_prefix $CVS_AUTH ${CVS_USER--}
  128. ;;
  129. ext) build_cvs_prefix $CVS_AUTH ${CVS_USER--}
  130. ;;
  131. *) echo "$0: Unknown CVS access method" >&2
  132. exit 1;;
  133. esac
  134. if [ "${CVS_AUTH--}" = "pserver" ]; then
  135. cvs -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/$1 login || exit
  136. fi
  137. cvs -q -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/$1 co $1 || exit
  138. trap 0
  139. fi
  140. }
  141. # Get gnulib files.
  142. case ${GNULIB_SRCDIR--} in
  143. -) checkout gnulib
  144. GNULIB_SRCDIR=gnulib
  145. esac
  146. <$GNULIB_SRCDIR/gnulib-tool || exit
  147. gnulib_modules='
  148. alloca
  149. argmatch
  150. argp
  151. backupfile
  152. dirname
  153. error
  154. exclude
  155. fileblocks
  156. fnmatch-gnu
  157. ftruncate
  158. full-write
  159. getdate
  160. getline
  161. getopt
  162. getpagesize
  163. gettext
  164. gettime
  165. hash
  166. human
  167. lchown
  168. memset
  169. modechange
  170. obstack
  171. quote
  172. quotearg
  173. rmdir
  174. safe-read
  175. save-cwd
  176. savedir
  177. stdbool
  178. stpcpy
  179. strtol
  180. strtoul
  181. timespec
  182. unlocked-io
  183. utime
  184. xalloc
  185. xalloc-die
  186. xgetcwd
  187. xstrtoumax
  188. '
  189. previous_gnulib_modules=
  190. while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
  191. previous_gnulib_modules=$gnulib_modules
  192. gnulib_modules=`
  193. (echo "$gnulib_modules"
  194. for gnulib_module in $gnulib_modules; do
  195. $GNULIB_SRCDIR/gnulib-tool --extract-dependencies $gnulib_module
  196. done) | sort -u
  197. `
  198. done
  199. gnulib_files=`
  200. (for gnulib_module in $gnulib_modules; do
  201. $GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module
  202. done) | sort -u
  203. `
  204. gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
  205. mkdir -p $gnulib_dirs || exit
  206. for gnulib_file in $gnulib_files; do
  207. dest=$gnulib_file
  208. case $gnulib_file in
  209. m4/codeset.m4) continue;;
  210. m4/intdiv0.m4) continue;;
  211. m4/inttypes-pri.m4) continue;;
  212. m4/isc-posix.m4) continue;;
  213. m4/lcmessage.m4) continue;;
  214. m4/onceonly_2_57.m4) dest=m4/onceonly.m4;;
  215. # These will be overwritten by autopoint, which still uses
  216. # old jm_.* macro names, so we have to keep both copies.
  217. m4/gettext.m4 | m4/glibc21.m4 | m4/inttypes_h.m4 | m4/lib-ld.m4 | \
  218. m4/lib-prefix.m4 | m4/po.m4 | m4/stdint_h.m4 | m4/uintmax_t.m4 | \
  219. m4/ulonglong.m4)
  220. dest=`expr $gnulib_file : '\(.*\).m4'`_gl.m4;;
  221. esac
  222. rm -f $dest &&
  223. echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
  224. cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
  225. done
  226. echo "$0: Creating m4/gnulib.m4"
  227. (echo "# This file is generated automatically. Please, do not edit."
  228. echo "#"
  229. echo "AC_DEFUN([tar_GNULIB],["
  230. for gnulib_module in $gnulib_modules; do
  231. echo "# $gnulib_module"
  232. $GNULIB_SRCDIR/gnulib-tool --extract-autoconf-snippet $gnulib_module
  233. done | sed '/AM_GNU_GETTEXT/d'
  234. echo "])") > ./m4/gnulib.m4
  235. echo "$0: Creating lib/Makefile.am"
  236. (cat lib/Makefile.tmpl
  237. for gnulib_module in $gnulib_modules; do
  238. echo "# $gnulib_module"
  239. $GNULIB_SRCDIR/gnulib-tool --extract-automake-snippet $gnulib_module
  240. done | sed 's/lib_SOURCES/libtar_a_SOURCES/g' ) > lib/Makefile.am
  241. # Get paxutils files
  242. case ${PAXUTILS_SRCDIR--} in
  243. -) checkout paxutils
  244. PAXUTILS_SRCDIR=paxutils
  245. esac
  246. # copy_files srcdir dstdir
  247. copy_files() {
  248. for file in `cat $1/DISTFILES`
  249. do
  250. case $file in
  251. "#*") continue;;
  252. esac
  253. echo "$0: Copying file $1/$file"
  254. cp -p $1/$file $2/`expr $file : '.*/\(.*\)'`
  255. done
  256. }
  257. copy_files ${PAXUTILS_SRCDIR}/m4 m4
  258. if [ -d rmt ]; then
  259. :
  260. else
  261. mkdir rmt
  262. fi
  263. copy_files ${PAXUTILS_SRCDIR}/rmt rmt
  264. copy_files ${PAXUTILS_SRCDIR}/lib lib
  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
  272. echo "$0: done. Now you can run './configure'."