#! /bin/sh # bootstrap (GNU M4) version 2007-03-24 # Written by Gary V. Vaughan # Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, a copy can be downloaded from # http://www.gnu.org/copyleft/gpl.html, or by writing to the Free # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. # Usage: $progname [options] # -f --force bootstrap even when sources are not from CVS # -p ARG --download-po=ARG whether to download pofiles [yes] # -v --version print version information # -h,-? --help print short or long help message # For --download-po, ARG can also be `no' to skip pofile downloads, # `only' to just update pofiles, or a set of locales to add or update. # You can also set the following variables to help $progname # locate the right tools: # AUTOPOINT, AUTORECONF, AWK, GNULIB_TOOL, M4, RM, SED, WGET # This script bootstraps a CVS checkout of GNU M4 by correctly calling # out to parts of the GNU Build Platform. Currently this requires GNU # Gettext 0.16 or better, Autoconf 2.60 or better, GNU M4 1.4.x or # better, a CVS snapshot of Automake 1.10a or better, a CVS snapshot # of Libtool 2.1a or better, and the latest CVS checkout of Gnulib. # Libtool must be installed; either with the same --prefix as # automake, or made accessible to aclocal's search path via # $AUTOMAKE_prefix/share/aclocal/dirlist. # Report bugs to : ${AUTOPOINT=autopoint} : ${AUTORECONF=autoreconf} : ${AWK=awk} : ${GNULIB_TOOL=gnulib-tool} : ${M4=m4} : ${RM=rm -f} : ${SED=sed} : ${WGET=wget} export WGET : ${DOWNLOAD_PO=yes} # Translation Project URL, for the registry of all projects. TP_URL="http://www.iro.umontreal.ca/translation/registry.cgi?domain=" # Ensure file names are sorted consistently across platforms. # Also, ensure diagnostics are in English, e.g., "wget --help" below. LC_ALL=C export LC_ALL package=m4 ltdldir=ltdl config_aux_dir=$ltdldir/config config_macro_dir=$ltdldir/m4 bailout_cb=: # List dependencies here too; we don't extract them, otherwise dependent # modules could end up being imported to src/ *and* gnu/! src_modules='getopt version-etc-fsf version-etc' dirname="s,/[^/]*$,," basename="s,^.*/,,g" # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" # The name of this program: progname=`echo "$progpath" | $SED "$basename"` PROGRAM=bootstrap # Detect whether this is a CVS checkout or a tarball CVS_only_file=HACKING # func_echo arg... # Echo program name prefixed message. func_echo () { echo $progname: ${1+"$@"} } # func_error arg... # Echo program name prefixed message to standard error. func_error () { echo $progname: ${1+"$@"} >&2 } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_error ${1+"$@"} } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { func_error "missing argument for $1" exit_cmd=exit } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "Try \`$progname --help' for more information." } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { func_error "missing argument for $1" exit_cmd=exit } # func_usage # Echo short help message to standard output and exit. func_usage () { $SED '/^# Usage:/,/# -h/ { s/^# //; s/^# *$//; s/\$progname/'$progname'/; p; }; d' < "$progpath" echo echo "run \`$progname --help | more' for full usage" exit $EXIT_SUCCESS } # func_help # Echo long help message to standard output and exit. func_help () { $SED '/^# Usage:/,/# Report bugs to/ { s/^# //; s/^# *$//; s/\$progname/'$progname'/; p; }; d' < "$progpath" exit $EXIT_SUCCESS } # func_version # Echo version message to standard output and exit. func_version () { $SED '/^# '$PROGRAM' (GNU /,/# warranty; / { s/^# //; s/^# *$//; s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/; p; }; d' < "$progpath" exit $EXIT_SUCCESS } # Parse options once, thoroughly. This comes as soon as possible in # the script to make things like `commit --version' happen quickly. { # sed scripts: my_sed_single_opt='1s/^\(..\).*$/\1/;q' my_sed_single_rest='1s/^..\(.*\)$/\1/;q' my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in -f|--force) CVS_only_file= ;; -p|--download-po) test $# = 0 && func_missing_arg $opt && break case $1 in 0|[Nn]*|[Ff]*) DOWNLOAD_PO=no ;; [Oo]*) DOWNLOAD_PO=only ;; esac ;; # Separate optargs to long options: --download-po=*) arg=`echo "$opt" | $SED "$my_sed_long_arg"` opt=`echo "$opt" | $SED "$my_sed_long_opt"` set -- "$opt" "$arg" ${1+"$@"} ;; # Separate optargs to short options: -p*) arg=`echo "$opt" |$SED "$my_sed_single_rest"` opt=`echo "$opt" |$SED "$my_sed_single_opt"` set -- "$opt" "$arg" ${1+"$@"} ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set -- "$opt" ${1+"$@"}; break ;; esac done # Bail if the options were screwed $exit_cmd $EXIT_FAILURE if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then func_fatal_error "Bootstrapping from a non-CVS distribution is risky." fi } ## ------------------------------ ## ## Fetch translations. ## ## (taken from GNU tar bootstrap) ## ## ------------------------------ ## func_get_translations() { subdir=$1 domain=$2 po_file=$3 func_echo "getting translations into $subdir for $domain..." case $po_file in '') (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`);; esac && $WGET -nv --cache=off -O "$subdir/$domain.html" "$TP_URL$domain" && $SED -n 's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p' <"$subdir/$domain.html" | sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 | $AWK -F. ' { if (lang && $1 != lang) print lang, ver } { lang = $1; ver = substr($0, index($0, ".") + 1) } END { if (lang) print lang, ver } ' | $AWK -v domain="$domain" -v po_file="$po_file" -v subdir="$subdir" ' { lang = $1 if (po_file == (lang ".po")) next ver = $2 urlfmt = "" printf "$WGET -nv --cache=off -O %s/%s.po 'http://www.iro.umontreal.ca/translation/teams/PO/%s/%s-%s.%s.po' &&\n", subdir, lang, lang, domain, ver, lang } END { print ":" } ' | sh && ls "$subdir"/*.po | sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" && rm "$subdir/$domain.html" } ## ------------------------------ ## ## Update translations. ## ## (taken from GNU tar bootstrap) ## ## ------------------------------ ## func_update_po () { if test $# = 1; then case $1 in *.po) POFILE=$1 ;; *) POFILE=$1.po ;; esac func_get_translations ./po $package "$POFILE" && LANG=`expr $POFILE : '\(.*\)\.po'` && { grep -q $LANG po/LINGUAS || (echo $LANG; cat po/LINGUAS) | sort -o po/LINGUAS; } else func_get_translations ./po $package fi } case $DOWNLOAD_PO in no) ;; only) func_update_po; exit 0 ;; yes) func_update_po ;; *) func_update_po $DOWNLOAD_PO ;; esac ## ---------------- ## ## Version control. ## ## ---------------- ## # gnulib-tool updates ltdl/m4/.cvsignore and gnu/.cvsignore, and keeping # generated files under version control does not make sense. Prepopulate # ltdl/m4's version with generated files not tracked by gnulib-tool. if test -f $config_macro_dir/.cvsignore ; then : else func_echo "creating initial $config_macro_dir/.cvsignore" cat > $config_macro_dir/.cvsignore <<\EOF *~ .cvsignore argz.m4 codeset.m4 getopt.m4 gettext.m4 glibc2.m4 glibc21.m4 gnulib-comp.m4 iconv.m4 intdiv0.m4 intl.m4 intldir.m4 intmax.m4 inttypes-pri.m4 inttypes_h.m4 lcmessage.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 libtool.m4 lock.m4 longdouble.m4 longlong.m4 ltdl.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4 nls.m4 po.m4 printf-posix.m4 progtest.m4 size_max.m4 stdint_h.m4 uintmax_t.m4 ulonglong.m4 visibility.m4 wchar_t.m4 wint_t.m4 xsize.m4 EOF fi ## ---------- ## ## Autopoint. ## ## ---------- ## # Released autopoint has the tendency to install macros that have been # obsoleted in current gnulib, so run this before gnulib-tool. func_echo "running: $AUTOPOINT --force" $AUTOPOINT --force ## ---------------------------- ## ## Find the gnulib module tree. ## ## ---------------------------- ## case $GNULIB_TOOL in /* ) gnulibdir=$GNULIB_TOOL ;; # absolute */* ) gnulibdir=`pwd`/$GNULIB_TOOL ;; # relative * ) gnulibdir=`which "$GNULIB_TOOL"` ;; # PATH search esac # Follow symlinks while test -h "$gnulibdir"; do # Resolve symbolic link. sedexpr1='s, -> ,#%%#,' sedexpr2='s,^.*#%%#\(.*\)$,\1,p' linkval=`ls -l "$gnulibdir" | $SED "$sedexpr1" | $SED -n "$sedexpr2"` test -n "$linkval" || break case "$linkval" in /* ) gnulibdir="$linkval" ;; * ) gnulibdir=`echo "$gnulibdir" | sed -e 's,/[^/]*$,,'`/"$linkval" ;; esac done gnulibdir=`echo "$gnulibdir" | $SED "$dirname"` ## ---------------------- ## ## Import Gnulib modules. ## ## ---------------------- ## func_echo "running: ${GNULIB_TOOL} --update" ${GNULIB_TOOL} --update ## --------------------------------- ## ## Copy additional src only modules. ## ## --------------------------------- ## func_echo "fetching modules for src directory" for file in `${GNULIB_TOOL} --extract-filelist $src_modules`; do dest=`echo $file | $SED "$basename"` case $file in lib/*) dest=src/$dest ;; m4/*) dest=$config_macro_dir/$dest ;; *) func_echo "Unknown file: $file" exit 1 ;; esac # Be sure to show all copying errors before bailing out if test -f $gnulibdir/$file; then func_echo "copying file \`$dest'" cp $gnulibdir/$file $dest else func_error "$gnulibdir/$file does not exist" bailout_cb="exit 1" fi done $bailout_cb ## ----------- ## ## Autoreconf. ## ## ----------- ## # Disable autopoint, since it was already done above. func_echo "running: AUTOPOINT=true" \ "$AUTORECONF --force --verbose --install --no-recursive" AUTOPOINT=true $AUTORECONF --force --verbose --install --no-recursive ## ------- ## ## Wrapup. ## ## ------- ## if test x"$DOWNLOAD_PO" != xno; then func_echo "If your pofiles are up-to-date, you can rerun bootstrap" func_echo "as \`DOWNLOAD_PO=no $progname' to avoid redownloading." fi exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "# bootstrap (GNU M4) version " # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "$" # End: