X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/e70f46d132433f71c48f0467d4833f2d79f3d53a..592d0b1eb5a6e8041df3d1461dc9fca60e3e0a54:/bootstrap diff --git a/bootstrap b/bootstrap index 8828a7e5..33825b7a 100755 --- a/bootstrap +++ b/bootstrap @@ -2,7 +2,7 @@ # Bootstrap this package from CVS. -# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. # 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 @@ -29,6 +29,30 @@ nl=' LC_ALL=C export LC_ALL +usage() { + echo >&2 "\ +Usage: $0 [OPTION]... +Bootstrap this package from the checked-out sources. + +Options: + --gnulib-srcdir=DIRNAME Specify the local directory where gnulib + sources reside. Use this if you already + have gnulib sources on your machine, and + do not want to waste your bandwidth dowloading + them again. + --copy Copy files instead of creating symbolic links. + --force Attempt to bootstrap even if the sources seem + not to have been checked out. + --skip-po Do not download po files. + --cvs-user=USERNAME Set the CVS username to be used when accessing + the gnulib repository. + +If the file .bootstrap.conf exists in the current working directory, its +contents are read as shell variables to configure the bootstrap. + +Running without arguments will suffice in most cases. +" +} # Configuration. @@ -63,6 +87,7 @@ package=`sed -n "$extract_package_name" configure.ac` || exit # Extra files from gnulib, which override files from other sources. gnulib_extra_files=' + build-aux/announce-gen build-aux/install-sh build-aux/missing build-aux/mdate-sh @@ -86,6 +111,13 @@ XGETTEXT_OPTIONS='\\\ # Files we don't want to import. excluded_files= +# File that should exist in the top directory of a checked out hierarchy, +# but not in a distribution tarball. +CVS_only_file=README-cvs + +# Whether to use copies instead of symlinks. +copy=false + # Override the default configuration, if necessary. test -r bootstrap.conf && . ./bootstrap.conf @@ -97,7 +129,7 @@ for option do case $option in --help) - echo "$0: usage: $0 [--gnulib-srcdir=DIR] [--cvs-user=USERNAME] [--skip-po]" + usage exit;; --gnulib-srcdir=*) GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;; @@ -105,12 +137,21 @@ do CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;; --skip-po) SKIP_PO=t;; + --force) + CVS_only_file=;; + --copy) + copy=true;; *) echo >&2 "$0: $option: unknown option" exit 1;; esac done +if test -n "$CVS_only_file" && test ! -r "$CVS_only_file"; then + echo "$0: Bootstrapping from a non-checked-out distribution is risky." >&2 + exit 1 +fi + echo "$0: Bootstrapping CVS $package..." cleanup_gnulib() { @@ -216,29 +257,43 @@ symlink_to_gnulib() { src=$GNULIB_SRCDIR/$1 dst=${2-$1} - dot_dots= - - case $src in - /*) ;; - *) - case /$dst/ in - *//* | */../* | */./* | /*/*/*/*/*/) - echo >&2 "$0: invalid symlink calculation: $src -> $dst" - exit 1;; - /*/*/*/*/) dot_dots=../../../;; - /*/*/*/) dot_dots=../../;; - /*/*/) dot_dots=../;; - esac;; - esac test -f "$src" && { - test -h "$dst" && - src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 && - dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 && - test "$src_i" = "$dst_i" || { - echo "$0: ln -fs $dot_dots$src $dst" && - ln -fs "$dot_dots$src" "$dst" - } + if $copy; then + { + test ! -h "$dst" || { + echo "$0: rm -f $dst" && + rm -f "$dst" + } + } && + test -f "$dst" && + cmp -s "$src" "$dst" || { + echo "$0: cp -fp $src $dst" && + cp -fp "$src" "$dst" + } + else + test -h "$dst" && + src_ls=`ls -diL "$src" 2>/dev/null` && set $src_ls && src_i=$1 && + dst_ls=`ls -diL "$dst" 2>/dev/null` && set $dst_ls && dst_i=$1 && + test "$src_i" = "$dst_i" || { + dot_dots= + case $src in + /*) ;; + *) + case /$dst/ in + *//* | */../* | */./* | /*/*/*/*/*/) + echo >&2 "$0: invalid symlink calculation: $src -> $dst" + exit 1;; + /*/*/*/*/) dot_dots=../../../;; + /*/*/*/) dot_dots=../../;; + /*/*/) dot_dots=../;; + esac;; + esac + + echo "$0: ln -fs $dot_dots$src $dst" && + ln -fs "$dot_dots$src" "$dst" + } + fi } } @@ -260,7 +315,7 @@ cp_mark_as_generated() if test -z "$c1"; then cmp -s "$cp_src" "$cp_dst" || { echo "$0: cp -f $cp_src $cp_dst" && - cp -f "$cp_src" "$cp_dst" + sed 's/\.#bootmp\///g' "$cp_src" > "$cp_dst" } else # Copy the file first to get proper permissions if it @@ -269,7 +324,7 @@ cp_mark_as_generated() ( echo "$c1-*- buffer-read-only: t -*- vi: set ro:$c2" && echo "${c1}DO NOT EDIT! GENERATED AUTOMATICALLY!$c2" && - cat "$cp_src" + sed 's/\.#bootmp\///g' "$cp_src" ) > $cp_dst-t && if cmp -s "$cp_dst-t" "$cp_dst"; then rm -f "$cp_dst-t" @@ -281,6 +336,21 @@ cp_mark_as_generated() fi } +version_controlled_file() { + dir=$1 + file=$2 + found=no + if test -d CVS; then + grep -F "/$file/" $dir/CVS/Entries 2>/dev/null | + grep '^/[^/]*/[0-9]' > /dev/null && found=yes + elif test -d .git; then + git-rm -n "$dir/$file" > /dev/null 2>&1 && found=yes + else + echo "$0: no version control for $dir/$file?" >&2 + fi + test $found = yes +} + slurp() { for dir in . `(cd $1 && find * -type d -print)`; do copied= @@ -299,8 +369,7 @@ slurp() { sed "$remove_intl" $1/$dir/$file >$dir/gnulib.mk } elif { test "${2+set}" = set && test -r $2/$dir/$file; } || - grep -F "/$file/" $dir/CVS/Entries 2>/dev/null | - grep -q '^/[^/]*/[0-9]'; then + version_controlled_file $dir $file; then echo "$0: $dir/$file overrides $1/$dir/$file" else copied=$copied$sep$file; sep=$nl @@ -321,11 +390,13 @@ slurp() { fi || exit done - ig=$dir/.cvsignore - if test -n "$copied" && test -f $ig; then - echo "$copied" | sort -u - $ig | cmp -s - $ig || - echo "$copied" | sort -u - $ig -o $ig || exit - fi + for dot_ig in .cvsignore .gitignore; do + ig=$dir/$dot_ig + if test -n "$copied" && test -f $ig; then + echo "$copied" | sort -u - $ig | cmp -s - $ig || + echo "$copied" | sort -u - $ig -o $ig || exit + fi + done done } @@ -348,6 +419,7 @@ gnulib_tool_options="\ --m4-base $bt/m4/\ --source-base $bt/lib/\ --tests-base $bt/tests\ + --local-dir gl\ " echo "$0: $gnulib_tool $gnulib_tool_options --import ..." $gnulib_tool $gnulib_tool_options --import $gnulib_modules &&