[3090] | 1 | #! /bin/sh
|
---|
| 2 |
|
---|
| 3 | # bootstrap (GNU M4) version 2006-09-21
|
---|
| 4 | # Written by Gary V. Vaughan <gary@gnu.org>
|
---|
| 5 |
|
---|
| 6 | # Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
---|
| 7 | # This is free software; see the source for copying conditions. There is NO
|
---|
| 8 | # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
| 9 |
|
---|
| 10 | # This program is free software; you can redistribute it and/or modify
|
---|
| 11 | # it under the terms of the GNU General Public License as published by
|
---|
| 12 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | # (at your option) any later version.
|
---|
| 14 | #
|
---|
| 15 | # This program is distributed in the hope that it will be useful, but
|
---|
| 16 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 18 | # General Public License for more details.
|
---|
| 19 | #
|
---|
| 20 | # You should have received a copy of the GNU General Public License
|
---|
| 21 | # along with this program; if not, a copy can be downloaded from
|
---|
| 22 | # http://www.gnu.org/copyleft/gpl.html, or by writing to the Free
|
---|
| 23 | # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
---|
| 24 | # MA 02110-1301, USA.
|
---|
| 25 |
|
---|
| 26 | # Usage: $progname [options]
|
---|
| 27 |
|
---|
| 28 | # -f --force bootstrap even when sources are not from CVS
|
---|
| 29 | # -v --version print version information
|
---|
| 30 | # -h,-? --help print short or long help message
|
---|
| 31 |
|
---|
| 32 | # You can also set the following variables to help $progname
|
---|
| 33 | # locate the right tools:
|
---|
| 34 | # AUTORECONF, GNULIB_TOOL, RM, SED
|
---|
| 35 |
|
---|
| 36 | # This script bootstraps a CVS checkout of GNU M4 by correctly
|
---|
| 37 | # calling out to parts of the GNU Build Platform. Currently this
|
---|
| 38 | # requires GNU Autoconf 2.60, GNU Automake 1.9.6, and bleeding edge
|
---|
| 39 | # CVS snapshots of GNU Gnulib.
|
---|
| 40 |
|
---|
| 41 | # Report bugs to <bug-m4@gnu.org>
|
---|
| 42 |
|
---|
| 43 | : ${AUTORECONF=autoreconf}
|
---|
| 44 | : ${GNULIB_TOOL=gnulib-tool}
|
---|
| 45 | : ${RM=rm -f}
|
---|
| 46 | : ${SED=sed}
|
---|
| 47 |
|
---|
| 48 | dirname="s,/[^/]*$,,"
|
---|
| 49 | basename="s,^.*/,,g"
|
---|
| 50 |
|
---|
| 51 | # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
|
---|
| 52 | # is ksh but when the shell is invoked as "sh" and the current value of
|
---|
| 53 | # the _XPG environment variable is not equal to 1 (one), the special
|
---|
| 54 | # positional parameter $0, within a function call, is the name of the
|
---|
| 55 | # function.
|
---|
| 56 | progpath="$0"
|
---|
| 57 |
|
---|
| 58 | # The name of this program:
|
---|
| 59 | progname=`echo "$progpath" | $SED "$basename"`
|
---|
| 60 | PROGRAM=bootstrap
|
---|
| 61 |
|
---|
| 62 | # Detect whether this is a CVS checkout or a tarball
|
---|
| 63 | CVS_only_file=HACKING
|
---|
| 64 |
|
---|
| 65 | # func_echo arg...
|
---|
| 66 | # Echo program name prefixed message.
|
---|
| 67 | func_echo ()
|
---|
| 68 | {
|
---|
| 69 | echo $progname: ${1+"$@"}
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | # func_error arg...
|
---|
| 74 | # Echo program name prefixed message to standard error.
|
---|
| 75 | func_error ()
|
---|
| 76 | {
|
---|
| 77 | echo $progname: ${1+"$@"} >&2
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | # func_fatal_error arg...
|
---|
| 81 | # Echo program name prefixed message to standard error, and exit.
|
---|
| 82 | func_fatal_error ()
|
---|
| 83 | {
|
---|
| 84 | func_error ${1+"$@"}
|
---|
| 85 | exit $EXIT_FAILURE
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | # func_verbose arg...
|
---|
| 89 | # Echo program name prefixed message in verbose mode only.
|
---|
| 90 | func_verbose ()
|
---|
| 91 | {
|
---|
| 92 | $opt_verbose && func_error ${1+"$@"}
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | # func_missing_arg argname
|
---|
| 96 | # Echo program name prefixed message to standard error and set global
|
---|
| 97 | # exit_cmd.
|
---|
| 98 | func_missing_arg ()
|
---|
| 99 | {
|
---|
| 100 | func_error "missing argument for $1"
|
---|
| 101 | exit_cmd=exit
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | # func_fatal_help arg...
|
---|
| 105 | # Echo program name prefixed message to standard error, followed by
|
---|
| 106 | # a help hint, and exit.
|
---|
| 107 | func_fatal_help ()
|
---|
| 108 | {
|
---|
| 109 | func_error ${1+"$@"}
|
---|
| 110 | func_fatal_error "Try \`$progname --help' for more information."
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | # func_missing_arg argname
|
---|
| 114 | # Echo program name prefixed message to standard error and set global
|
---|
| 115 | # exit_cmd.
|
---|
| 116 | func_missing_arg ()
|
---|
| 117 | {
|
---|
| 118 | func_error "missing argument for $1"
|
---|
| 119 | exit_cmd=exit
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | # func_usage
|
---|
| 123 | # Echo short help message to standard output and exit.
|
---|
| 124 | func_usage ()
|
---|
| 125 | {
|
---|
| 126 | $SED '/^# Usage:/,/# -h/ {
|
---|
| 127 | s/^# //; s/^# *$//;
|
---|
| 128 | s/\$progname/'$progname'/;
|
---|
| 129 | p;
|
---|
| 130 | }; d' < "$progpath"
|
---|
| 131 | echo
|
---|
| 132 | echo "run \`$progname --help | more' for full usage"
|
---|
| 133 | exit $EXIT_SUCCESS
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | # func_help
|
---|
| 137 | # Echo long help message to standard output and exit.
|
---|
| 138 | func_help ()
|
---|
| 139 | {
|
---|
| 140 | $SED '/^# Usage:/,/# Report bugs to/ {
|
---|
| 141 | s/^# //; s/^# *$//;
|
---|
| 142 | s/\$progname/'$progname'/;
|
---|
| 143 | p;
|
---|
| 144 | }; d' < "$progpath"
|
---|
| 145 | exit $EXIT_SUCCESS
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | # func_version
|
---|
| 149 | # Echo version message to standard output and exit.
|
---|
| 150 | func_version ()
|
---|
| 151 | {
|
---|
| 152 | $SED '/^# '$PROGRAM' (GNU /,/# warranty; / {
|
---|
| 153 | s/^# //; s/^# *$//;
|
---|
| 154 | s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/;
|
---|
| 155 | p;
|
---|
| 156 | }; d' < "$progpath"
|
---|
| 157 | exit $EXIT_SUCCESS
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | # func_update
|
---|
| 161 | # Copy $1 to $2 if it is newer.
|
---|
| 162 | func_update ()
|
---|
| 163 | {
|
---|
| 164 | if test -f "$2" && cmp -s "$1" "$2" ; then
|
---|
| 165 | func_verbose "$2 is up-to-date"
|
---|
| 166 | else
|
---|
| 167 | func_echo "copying $1 -> $2"
|
---|
| 168 | cp "$1" "$2"
|
---|
| 169 | fi
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | # Parse options once, thoroughly. This comes as soon as possible in
|
---|
| 173 | # the script to make things like `bootstrap --version' happen quickly.
|
---|
| 174 | {
|
---|
| 175 | # sed scripts:
|
---|
| 176 | my_sed_single_opt='1s/^\(..\).*$/\1/;q'
|
---|
| 177 | my_sed_single_rest='1s/^..\(.*\)$/\1/;q'
|
---|
| 178 | my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
|
---|
| 179 | my_sed_long_arg='1s/^--[^=]*=//'
|
---|
| 180 |
|
---|
| 181 | # this just eases exit handling
|
---|
| 182 | while test $# -gt 0; do
|
---|
| 183 | opt="$1"
|
---|
| 184 | shift
|
---|
| 185 | case $opt in
|
---|
| 186 | # Separate optargs to short options:
|
---|
| 187 | -f|--force) CVS_only_file= ;;
|
---|
| 188 | -\?|-h) func_usage ;;
|
---|
| 189 | --help) func_help ;;
|
---|
| 190 | --version) func_version ;;
|
---|
| 191 | --) break ;;
|
---|
| 192 | -*) func_fatal_help "unrecognized option \`$opt'" ;;
|
---|
| 193 | *) set -- "$opt" ${1+"$@"}; break ;;
|
---|
| 194 | esac
|
---|
| 195 | done
|
---|
| 196 |
|
---|
| 197 | # Bail if the options were screwed
|
---|
| 198 | $exit_cmd $EXIT_FAILURE
|
---|
| 199 |
|
---|
| 200 | if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then
|
---|
| 201 | func_fatal_error "Bootstrapping from a non-CVS distribution is risky."
|
---|
| 202 | fi
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | ## ---------------------------- ##
|
---|
| 206 | ## Find the gnulib module tree. ##
|
---|
| 207 | ## ---------------------------- ##
|
---|
| 208 |
|
---|
| 209 | case $GNULIB_TOOL in
|
---|
| 210 | /* ) gnulibdir=$GNULIB_TOOL ;; # absolute
|
---|
| 211 | */* ) gnulibdir=`pwd`/$GNULIB_TOOL ;; # relative
|
---|
| 212 | * ) gnulibdir=`which "$GNULIB_TOOL"` ;; # PATH search
|
---|
| 213 | esac
|
---|
| 214 |
|
---|
| 215 | # Follow symlinks
|
---|
| 216 | while test -h "$gnulibdir"; do
|
---|
| 217 |
|
---|
| 218 | # Resolve symbolic link.
|
---|
| 219 | sedexpr1='s, -> ,#%%#,'
|
---|
| 220 | sedexpr2='s,^.*#%%#\(.*\)$,\1,p'
|
---|
| 221 | linkval=`LC_ALL=C ls -l "$gnulibdir" | $SED "$sedexpr1" | $SED -n "$sedexpr2"`
|
---|
| 222 | test -n "$linkval" || break
|
---|
| 223 |
|
---|
| 224 | case "$linkval" in
|
---|
| 225 | /* ) gnulibdir="$linkval" ;;
|
---|
| 226 | * ) gnulibdir=`echo "$gnulibdir" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
|
---|
| 227 | esac
|
---|
| 228 |
|
---|
| 229 | done
|
---|
| 230 |
|
---|
| 231 | gnulibdir=`echo "$gnulibdir" | $SED "$dirname"`
|
---|
| 232 |
|
---|
| 233 | ## ---------------------- ##
|
---|
| 234 | ## Import Gnulib modules. ##
|
---|
| 235 | ## ---------------------- ##
|
---|
| 236 |
|
---|
| 237 | func_echo "running: $GNULIB_TOOL --update"
|
---|
| 238 | $GNULIB_TOOL --update || func_fatal_error "gnulib-tool failed"
|
---|
| 239 |
|
---|
| 240 | ## ----------- ##
|
---|
| 241 | ## Autoreconf. ##
|
---|
| 242 | ## ----------- ##
|
---|
| 243 |
|
---|
| 244 | func_echo "running: $AUTORECONF --force --verbose --install"
|
---|
| 245 | $AUTORECONF --force --verbose --install || func_fatal_error "autoreconf failed"
|
---|
| 246 |
|
---|
| 247 | ## ---------------------------------------- ##
|
---|
| 248 | ## Gnulib is more up-to-date than automake. ##
|
---|
| 249 | ## ---------------------------------------- ##
|
---|
| 250 |
|
---|
| 251 | func_update "$gnulibdir"/build-aux/config.guess config.guess
|
---|
| 252 | func_update "$gnulibdir"/build-aux/config.sub config.sub
|
---|
| 253 | func_update "$gnulibdir"/build-aux/depcomp depcomp
|
---|
| 254 | func_update "$gnulibdir"/build-aux/install-sh install-sh
|
---|
| 255 | func_update "$gnulibdir"/build-aux/mdate-sh doc/mdate-sh
|
---|
| 256 | func_update "$gnulibdir"/build-aux/missing missing
|
---|
| 257 | func_update "$gnulibdir"/build-aux/texinfo.tex doc/texinfo.tex
|
---|
| 258 | func_update "$gnulibdir"/doc/COPYING COPYING
|
---|
| 259 | func_update "$gnulibdir"/doc/INSTALL INSTALL
|
---|
| 260 |
|
---|
| 261 | exit 0
|
---|
| 262 |
|
---|
| 263 | # Local variables:
|
---|
| 264 | # eval: (add-hook 'write-file-hooks 'time-stamp)
|
---|
| 265 | # time-stamp-start: "# bootstrap (GNU M4) version "
|
---|
| 266 | # time-stamp-format: "%:y-%02m-%02d"
|
---|
| 267 | # time-stamp-end: "$"
|
---|
| 268 | # End:
|
---|