# Bootstrap this package from checked-out sources.
-# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009
+# 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
bt2=${bt}2
usage() {
- echo >&2 "\
+ cat <<EOF
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 downloading
- them again.
+ sources reside. Use this if you already
+ have gnulib sources on your machine, and
+ do not want to waste your bandwidth downloading
+ 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.
+ not to have been checked out.
--skip-po Do not download po files.
--cvs-user=USERNAME Set the username to use when checking out
- sources from the gnulib repository.
+ sources from 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.
-"
+EOF
}
# Configuration.
# File that should exist in the top directory of a checked out hierarchy,
# but not in a distribution tarball.
-checkout_only_file=README-hacking
+checkout_only_file=HACKING
# Whether to use copies instead of symlinks.
copy=false
# on which version control system (if any) is used in the source directory.
vc_ignore=auto
+# find_tool ENVVAR NAMES...
+# -------------------------
+find_tool ()
+{
+ # Find sha1sum, named gsha1sum on MacPorts.
+ find_tool_envvar=$1
+ shift
+ if eval test x"\$$find_tool_envvar" = x; then
+ for i
+ do
+ if ($i --version </dev/null) >/dev/null 2>&1; then
+ find_tool_res=$i
+ break
+ fi
+ done
+ fi
+ if test x"$find_tool_res" = x; then
+ echo >&2 "$0: $find_tool_name is required"
+ exit 1
+ fi
+ ($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
+ echo >&2 "$0: cannot run $find_tool_res --version"
+ exit 1
+ }
+ eval "$find_tool_envvar=\"$find_tool_res\""
+ eval "export $find_tool_envvar"
+}
+
+# Find sha1sum, named gsha1sum on MacPorts.
+find_tool SHA1SUM sha1sum gsha1sum
+
# Override the default configuration, if necessary.
test -r bootstrap.conf && . ./bootstrap.conf
exit 1
fi
-# If $STR is not already on a line by itself in $FILE, insert it,
+# If each line in $STR is not already on a line by itself in $FILE, insert it,
# sorting the new contents of the file and replacing $FILE with the result.
insert_sorted_if_absent() {
file=$1
|| exit 1
}
+# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
+# insert_sorted_if_absent.
+insert_vc_ignore() {
+ vc_ignore_file="$1"
+ case $vc_ignore_file in
+ *.gitignore)
+ # A .gitignore entry that does not start with `/' applies recursively to
+ # subdirectories, so prepend `/' to every .gitignore entry.
+ pattern=`echo "$2" | sed s,^,/,`;;
+ *)
+ pattern="$2";;
+ esac
+ insert_sorted_if_absent "$vc_ignore_file" "$pattern"
+}
+
# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
found_aux_dir=no
grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
mkdir $build_aux
for dot_ig in x $vc_ignore; do
test $dot_ig = x && continue
- insert_sorted_if_absent $dot_ig $build_aux
+ insert_vc_ignore $dot_ig $build_aux
done
fi
exit $status
}
+# See if we can use gnulib's git-merge-changelog merge driver.
+
+if test -d .git && (git --version) >/dev/null 2>/dev/null ; then
+ if git config merge.merge-changelog.driver >/dev/null ; then
+ :
+ elif (git-merge-changelog --version) >/dev/null 2>/dev/null ; then
+ echo "initializing git-merge-changelog driver"
+ git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
+ git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
+ else
+ echo "consider installing git-merge-changelog from gnulib"
+ fi
+fi
+
# Get gnulib files.
case ${GNULIB_SRCDIR--} in
trap cleanup_gnulib 1 2 13 15
- cvs -z3 -q -d ${CVS_PREFIX}cvs.savannah.gnu.org:/cvsroot/gnulib co gnulib ||
+ cvs -z3 -q -d ${CVS_PREFIX}pserver.git.sv.gnu.org:/gnulib.git co -d gnulib HEAD ||
cleanup_gnulib
trap - 1 2 13 15
for po in `cd $ref_po_dir && echo *.po|sed 's/\.po//g'`; do
new_po="$ref_po_dir/$po.po"
cksum_file="$ref_po_dir/$po.s1"
- if ! sha1sum -c --status "$cksum_file" < "$new_po" > /dev/null; then
+ if ! "$SHA1SUM" -c --status "$cksum_file" < "$new_po" > /dev/null; then
echo "updated $po_dir/$po.po..."
- cp "$new_po" "$po_dir/$po.po" && sha1sum < "$new_po" > "$cksum_file"
+ cp "$new_po" "$po_dir/$po.po" && "$SHA1SUM" < "$new_po" > "$cksum_file"
fi
done
}
fi;;
esac
+check_dst_dir()
+{
+ dst=$1
+ # If the destination directory doesn't exist, create it.
+ # This is required at least for "lib/uniwidth/cjk.h".
+ dst_dir=`dirname "$dst"`
+ if ! test -d "$dst_dir"; then
+ mkdir -p "$dst_dir"
+
+ # If we've just created a directory like lib/uniwidth,
+ # tell version control system(s) it's ignorable.
+ # FIXME: for now, this does only one level
+ parent=`dirname "$dst_dir"`
+ for dot_ig in x $vc_ignore; do
+ test $dot_ig = x && continue
+ ig=$parent/$dot_ig
+ insert_vc_ignore $ig `echo "$dst_dir"|sed 's,.*/,,'`
+ done
+ fi
+}
+
symlink_to_dir()
{
src=$1/$2
test -f "$src" && {
- # If the destination directory doesn't exist, create it.
- # This is required at least for "lib/uniwidth/cjk.h".
- dst_dir=`dirname "$dst"`
- if ! test -d "$dst_dir"; then
- mkdir -p "$dst_dir"
-
- # If we've just created a directory like lib/uniwidth,
- # tell version control system(s) it's ignorable.
- # FIXME: for now, this does only one level
- parent=`dirname "$dst_dir"`
- for dot_ig in x $vc_ignore; do
- test $dot_ig = x && continue
- ig=$parent/$dot_ig
- insert_sorted_if_absent $ig `echo "$dst_dir"|sed 's,.*/,,'`
- done
- fi
+ check_dst_dir "$dst"
if $copy; then
{
sed "s!$bt_regex/!!g" "$cp_src" > "$cp_dst"
}
else
+ check_dst_dir "$cp_dst"
# Copy the file first to get proper permissions if it
# doesn't already exist. Then overwrite the copy.
cp "$cp_src" "$cp_dst-t" &&
test "$dir/$file" = "$excluded_file" && continue 2
done
if test $file = Makefile.am; then
- copied=$copied${sep}$gnulib_mk; sep=$nl
+ copied=$copied${sep}$gnulib_mk; sep=$nl
remove_intl='/^[^#].*\/intl/s/^/#/;'"s!$bt_regex/!!g"
- sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
+ sed "$remove_intl" $1/$dir/$file | cmp -s - $dir/$gnulib_mk || {
echo "$0: Copying $1/$dir/$file to $dir/$gnulib_mk ..." &&
rm -f $dir/$gnulib_mk &&
sed "$remove_intl" $1/$dir/$file >$dir/$gnulib_mk
test $dot_ig = x && continue
ig=$dir/$dot_ig
if test -n "$copied"; then
- insert_sorted_if_absent $ig "$copied"
+ insert_vc_ignore $ig "$copied"
# If an ignored file name ends with _.h, then also add
# the name with just ".h". Many gnulib headers are generated,
# e.g., stdint_.h -> stdint.h, dirent_.h ->..., etc.
# Likewise for .gperf -> .h, .y -> .c, and .sin -> .sed
f=`echo "$copied"|sed 's/_\.h$/.h/;s/\.sin$/.sed/;s/\.y$/.c/;s/\.gperf$/.h/'`
- insert_sorted_if_absent $ig "$f"
+ insert_vc_ignore $ig "$f"
# For files like sys_stat_.h and sys_time_.h, record as
# ignorable the directory we might eventually create: sys/.
f=`echo "$copied"|sed 's/sys_.*_\.h$/sys/'`
- insert_sorted_if_absent $ig "$f"
+ insert_vc_ignore $ig "$f"
fi
done
done