+ # func_add_or_update handles a file that ought to be present afterwards.
+ # Uses parameters f, g, already_present.
+ func_add_or_update ()
+ {
+ cp "$gnulib_dir/$f" "$destdir/$g.tmp" || func_fatal_error "failed"
+ if test -n "$lgpl"; then
+ # Update license.
+ case "$f" in
+ lib/*)
+ sed -e 's/GNU General/GNU Lesser General/g' \
+ -e 's/version 2\([ ,]\)/version 2.1\1/g' \
+ < "$gnulib_dir/$f" > "$destdir/$g.tmp" || func_fatal_error "failed"
+ ;;
+ esac
+ fi
+ if test -f "$destdir/$g"; then
+ # The file already exists.
+ if cmp "$destdir/$g" "$destdir/$g.tmp" > /dev/null; then
+ : # The file has not changed.
+ else
+ # Replace the file.
+ if $doit; then
+ if test -n "$already_present"; then
+ echo "Updating file $g (backup in ${g}~)"
+ else
+ echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
+ fi
+ mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
+ if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
+ func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
+ else
+ mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
+ fi
+ else
+ if test -n "$already_present"; then
+ echo "Update file $g (backup in ${g}~)"
+ else
+ echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
+ fi
+ fi
+ fi
+ else
+ # Install the file.
+ # Don't protest if the file should be there but isn't: it happens
+ # frequently that developers don't put autogenerated files into CVS.
+ if $doit; then
+ echo "Copying file $g"
+ if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
+ func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
+ else
+ mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
+ fi
+ else
+ echo "Copy file $g"
+ fi
+ fi
+ rm -f "$destdir/$g.tmp"
+ }
+ # Then the files that are in new-files, but not in old-files:
+ sed_take_last_column='s,^.*'"$delimiter"',,'
+ already_present=
+ for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
+ case "$f" in
+ build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
+ lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
+ m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
+ tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
+ *) g="$f" ;;
+ esac
+ func_add_or_update
+ done
+ # Then the files that are in new-files and in old-files:
+ already_present=true
+ for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
+ case "$f" in
+ build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
+ lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
+ m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
+ tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
+ *) g="$f" ;;
+ esac
+ func_add_or_update
+ done
+ rm -rf "$tmp"
+ # Undo the effect of the previous 'trap' command. Some shellology:
+ # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
+ # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
+ # exit); for the others we need to call 'exit' explicitly. The value of $? is
+ # 128 + signal number and is set before the trap-registered command is run.
+ trap '' 0
+ trap 'exit $?' 1 2 3 15
+
+ # Command-line invocation printed in a comment in generated gnulib-cache.m4.
+ actioncmd="gnulib-tool --import"
+ actioncmd="$actioncmd --dir=$destdir"
+ actioncmd="$actioncmd --lib=$libname"
+ actioncmd="$actioncmd --source-base=$sourcebase"
+ actioncmd="$actioncmd --m4-base=$m4base"
+ actioncmd="$actioncmd --aux-dir=$auxdir"
+ for module in $avoidlist; do
+ actioncmd="$actioncmd --avoid=$module"
+ done