1#! /bin/sh 2# Update the local files from GNULIB. Currently assumes that the current 3# GNULIB sources are in a directory parallel with this one. 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2, or (at your option) 8# any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software Foundation, 17# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19if test -f maint-aux/gnulib-modules; then :; else 20 >&2 echo \ 21"This script expects to be run from the top level of the CVS source tree." 22 exit 2 23fi 24 25if test -f maint-aux/gnulib-modules; then :; else 26 >&2 echo \ 27"Failed to find the modules list (\`maint-aux/gnulib-modules')." 28 exit 2 29fi 30 31# Where to find the GNULIB sources. 32: ${GNULIB="../gnulib"} 33GNULIB_TOOL=$GNULIB/gnulib-tool 34 35# Which modules to update. 36MODULES=`cat maint-aux/gnulib-modules` 37 38# Are the GNULIB sources really where we expect them? 39if test -r $GNULIB && test -d $GNULIB \ 40 && test -r $GNULIB_TOOL && test -f $GNULIB_TOOL; then :; else 41 echo GNULIB sources not found. >&2 42 exit 1 43fi 44 45trap \ 46'status=$? 47# Restore lib/Makefile.am. 48if test -f lib/Makefile.am.save; then 49 mv lib/Makefile.am.save lib/Makefile.am 50fi 51# Restore m4/error.m4. 52if test -f m4/error.m4.save; then 53 mv m4/error.m4.save m4/error.m4 54fi 55exit $status' EXIT 56 57# Prevent lib/Makefile.am from being overwritten. 58mv lib/Makefile.am lib/Makefile.am.save 59# Prevent m4/error.m4 from being overwritten unless necessary. 60mv m4/error.m4 m4/error.m4.save 61 62# Run the update. 63if $GNULIB_TOOL --import $MODULES >/dev/null; then :; else 64 exit $? 65fi 66 67# Correct this file for our purposes, but try to avoid munging timestamps 68# unless necessary. 69sed '/AC_FUNC_ERROR_AT_LINE/d' <m4/error.m4 >tmp 70if cmp tmp m4/error.m4.save >/dev/null 2>&1; then 71 mv m4/error.m4.save m4/error.m4 72 rm tmp 73else 74 mv tmp m4/error.m4 75 rm m4/error.m4.save 76fi 77 78# Extract the names of the files we imported. 79$GNULIB_TOOL --extract-filelist $MODULES |sort |uniq |sed '/^$/d' \ 80 >maint-aux/gnulib-filelist.new 81 82# Warn the user if the filelist has changed. 83if cmp maint-aux/gnulib-filelist.txt maint-aux/gnulib-filelist.new >/dev/null 84then 85 # Avoid munging timestamps when nothing's changed. 86 rm maint-aux/gnulib-filelist.new 87else 88 cat >&2 <<\EOF 89******************************************************************** 90The file list has changed. You may need to add or remove files from 91CVS. Use `cvs diff maint-aux/gnulib-filelist.txt' to view changes. 92******************************************************************** 93EOF 94 # Save the file list for next time. 95 mv maint-aux/gnulib-filelist.new maint-aux/gnulib-filelist.txt 96fi 97 98 99# Warn the user if changes have been made to the Makefile.am. 100if cmp lib/Makefile.am lib/Makefile.gnulib >/dev/null; then 101 # Avoid munging timestamps when nothing's changed. 102 rm lib/Makefile.am 103else 104 cat >&2 <<\EOF 105******************************************************************** 106Makefile.am needs updating. Use `cvs diff lib/Makefile.gnulib' to 107view changes. 108******************************************************************** 109EOF 110 # Save the generated lib/Makefile.am for next time. 111 mv lib/Makefile.am lib/Makefile.gnulib 112fi 113