bootstrap 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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.
  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][--cvs-auth=AUTH-METHOD][--cvs-user=USERNAME][--no-po]
  26. Options are:
  27. --gnulib-srcdir=DIRNAME Specify the local directory where gnulib
  28. sources reside. Use this if you already
  29. have gnulib sources on your machine, and
  30. do not want to waste your bandwidth dowloading
  31. them again.
  32. --cvs-auth=METHOD Set the CVS access method used for downloading
  33. gnulib files. METHOD is one of the keywords
  34. accepted by cvs -d option (see info cvs
  35. repository).
  36. --cvs-user=USERNAME Set the CVS username to be used when accessing
  37. the gnulib repository.
  38. --no-po Do not download po files.
  39. --update-po[=LANG] Update po file(s) and exit.
  40. Running without arguments will suffice in most cases. It is equivalent
  41. to
  42. ./bootstrap --cvs-auth=ext --cvs-user=anoncvs
  43. EOF
  44. }
  45. update_po() {
  46. if [ $# = 1 ]; then
  47. case $1 in
  48. *.po) POFILE=$1;;
  49. *) POFILE=${1}.po;;
  50. esac
  51. echo "$0: getting translation for $1..."
  52. wget -C off $TP_URL/$POFILE
  53. else
  54. echo "$0: getting translations into po..."
  55. (cd po &&
  56. rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'` &&
  57. wget -nv -nd -r -l 1 -A .po -C off $TP_URL &&
  58. ls *.po | sed 's/\.po$//' >LINGUAS
  59. ) || exit
  60. fi
  61. }
  62. # Parse options.
  63. DOWNLOAD_PO=yes
  64. for option
  65. do
  66. case $option in
  67. --help)
  68. usage
  69. exit;;
  70. --gnulib-srcdir=*)
  71. GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
  72. --cvs-auth=*)
  73. CVS_AUTH=`expr "$option" : '--cvs-auth=\(.*\)'`;;
  74. --cvs-user=*)
  75. CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
  76. --no-po)
  77. DOWNLOAD_PO=no;;
  78. --update-po=*)
  79. DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
  80. --update-po)
  81. DOWNLOAD_PO=only;;
  82. *)
  83. echo >&2 "$0: $option: unknown option"
  84. exit 1;;
  85. esac
  86. done
  87. case $DOWNLOAD_PO in
  88. only) update_po
  89. exit 0
  90. ;;
  91. no|yes) ;;
  92. *) update_po $DOWNLOAD_PO
  93. exit 0
  94. esac
  95. echo "$0: Bootstrapping CVS tar..."
  96. build_cvs_prefix() {
  97. CVS_PREFIX=:${1}:
  98. if [ "${2}" != - ]; then
  99. CVS_PREFIX=${CVS_PREFIX}${2}@
  100. fi
  101. if [ "$1" = "ext" ]; then
  102. if [ -z "${CVS_RSH}" ]; then
  103. CVS_RSH=ssh
  104. export CVS_RSH
  105. fi
  106. fi
  107. }
  108. # Get gnulib files.
  109. case ${GNULIB_SRCDIR--} in
  110. -)
  111. if [ ! -d gnulib ]; then
  112. echo "$0: getting gnulib files..."
  113. trap exit 1 2 13 15
  114. trap 'rm -fr gnulib; exit 1' 0
  115. case "${CVS_AUTH--}" in
  116. -) build_cvs_prefix ext anoncvs;;
  117. pserver) build_cvs_prefix $CVS_AUTH ${CVS_USER:-anoncvs};;
  118. gserver|server)
  119. build_cvs_prefix $CVS_AUTH ${CVS_USER--};;
  120. ext) build_cvs_prefix $CVS_AUTH ${CVS_USER--};;
  121. *) echo "$0: Unknown CVS access method" >&2
  122. exit 1;;
  123. esac
  124. if [ "${CVS_AUTH--}" = "pserver" ]; then
  125. cvs -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/gnulib login || exit
  126. fi
  127. cvs -q -d ${CVS_PREFIX}subversions.gnu.org:/cvsroot/gnulib co gnulib || exit
  128. trap 0
  129. fi
  130. GNULIB_SRCDIR=gnulib
  131. esac
  132. <$GNULIB_SRCDIR/gnulib-tool || exit
  133. gnulib_modules='
  134. alloca
  135. argmatch
  136. argp
  137. backupfile
  138. dirname
  139. error
  140. exclude
  141. fileblocks
  142. fnmatch-gnu
  143. ftruncate
  144. full-write
  145. getdate
  146. getline
  147. getopt
  148. getpagesize
  149. gettext
  150. gettime
  151. hash
  152. human
  153. lchown
  154. memset
  155. modechange
  156. obstack
  157. quote
  158. quotearg
  159. rmdir
  160. safe-read
  161. save-cwd
  162. savedir
  163. stdbool
  164. stpcpy
  165. strtol
  166. strtoul
  167. timespec
  168. unlocked-io
  169. utime
  170. xalloc
  171. xalloc-die
  172. xgetcwd
  173. xstrtoumax
  174. '
  175. previous_gnulib_modules=
  176. while [ "$gnulib_modules" != "$previous_gnulib_modules" ]; do
  177. previous_gnulib_modules=$gnulib_modules
  178. gnulib_modules=`
  179. (echo "$gnulib_modules"
  180. for gnulib_module in $gnulib_modules; do
  181. $GNULIB_SRCDIR/gnulib-tool --extract-dependencies $gnulib_module
  182. done) | sort -u
  183. `
  184. done
  185. gnulib_files=`
  186. (for gnulib_module in $gnulib_modules; do
  187. $GNULIB_SRCDIR/gnulib-tool --extract-filelist $gnulib_module
  188. done) | sort -u
  189. `
  190. gnulib_dirs=`echo "$gnulib_files" | sed 's,/[^/]*$,,' | sort -u`
  191. mkdir -p $gnulib_dirs || exit
  192. for gnulib_file in $gnulib_files; do
  193. dest=$gnulib_file
  194. case $gnulib_file in
  195. m4/codeset.m4) continue;;
  196. m4/intdiv0.m4) continue;;
  197. m4/inttypes-pri.m4) continue;;
  198. m4/isc-posix.m4) continue;;
  199. m4/lcmessage.m4) continue;;
  200. m4/onceonly_2_57.m4) dest=m4/onceonly.m4;;
  201. # These will be overwritten by autopoint, which still uses
  202. # old jm_.* macro names, so we have to keep both copies.
  203. m4/gettext.m4 | m4/glibc21.m4 | m4/inttypes_h.m4 | m4/lib-ld.m4 | \
  204. m4/lib-prefix.m4 | m4/po.m4 | m4/stdint_h.m4 | m4/uintmax_t.m4 | \
  205. m4/ulonglong.m4)
  206. dest=`expr $gnulib_file : '\(.*\).m4'`_gl.m4;;
  207. esac
  208. rm -f $dest &&
  209. echo "$0: Copying file $GNULIB_SRCDIR/$gnulib_file" &&
  210. cp -p $GNULIB_SRCDIR/$gnulib_file $dest || exit
  211. done
  212. echo "$0: Creating m4/gnulib.m4"
  213. (echo "# This file is generated automatically. Please, do not edit."
  214. echo "#"
  215. echo "AC_DEFUN([tar_GNULIB],["
  216. for gnulib_module in $gnulib_modules; do
  217. echo "# $gnulib_module"
  218. $GNULIB_SRCDIR/gnulib-tool --extract-autoconf-snippet $gnulib_module
  219. done | sed '/AM_GNU_GETTEXT/d'
  220. echo "])") > ./m4/gnulib.m4
  221. echo "$0: Creating lib/Makefile.am"
  222. (cat lib/Makefile.tmpl
  223. for gnulib_module in $gnulib_modules; do
  224. echo "# $gnulib_module"
  225. $GNULIB_SRCDIR/gnulib-tool --extract-automake-snippet $gnulib_module
  226. done | sed 's/lib_SOURCES/libtar_a_SOURCES/g' ) > lib/Makefile.am
  227. # Get translations.
  228. if test "$DOWNLOAD_PO" = "yes"; then
  229. update_po
  230. fi
  231. # Reconfigure, getting other files.
  232. echo "$0: autoreconf --verbose --install --force ..."
  233. autoreconf --verbose --install --force
  234. echo "$0: done. Now you can run './configure'."