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 19 if 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 23 fi 24 25 if 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 29 fi 30 31 # Where to find the GNULIB sources. 32 : ${GNULIB="../gnulib"} 33 GNULIB_TOOL=$GNULIB/gnulib-tool 34 35 # Which modules to update. 36 MODULES=`cat maint-aux/gnulib-modules` 37 38 # Are the GNULIB sources really where we expect them? 39 if 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 43 fi 44 45 trap \ 46 'status=$? 47 # Restore lib/Makefile.am. 48 if test -f lib/Makefile.am.save; then 49 mv lib/Makefile.am.save lib/Makefile.am 50 fi 51 # Restore m4/error.m4. 52 if test -f m4/error.m4.save; then 53 mv m4/error.m4.save m4/error.m4 54 fi 55 exit $status' EXIT 56 57 # Prevent lib/Makefile.am from being overwritten. 58 mv lib/Makefile.am lib/Makefile.am.save 59 # Prevent m4/error.m4 from being overwritten unless necessary. 60 mv m4/error.m4 m4/error.m4.save 61 62 # Run the update. 63 if $GNULIB_TOOL --import $MODULES >/dev/null; then :; else 64 exit $? 65 fi 66 67 # Correct this file for our purposes, but try to avoid munging timestamps 68 # unless necessary. 69 sed '/AC_FUNC_ERROR_AT_LINE/d' <m4/error.m4 >tmp 70 if cmp tmp m4/error.m4.save >/dev/null 2>&1; then 71 mv m4/error.m4.save m4/error.m4 72 rm tmp 73 else 74 mv tmp m4/error.m4 75 rm m4/error.m4.save 76 fi 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. 83 if cmp maint-aux/gnulib-filelist.txt maint-aux/gnulib-filelist.new >/dev/null 84 then 85 # Avoid munging timestamps when nothing's changed. 86 rm maint-aux/gnulib-filelist.new 87 else 88 cat >&2 <<\EOF 89 ******************************************************************** 90 The file list has changed. You may need to add or remove files from 91 CVS. Use `cvs diff maint-aux/gnulib-filelist.txt' to view changes. 92 ******************************************************************** 93 EOF 94 # Save the file list for next time. 95 mv maint-aux/gnulib-filelist.new maint-aux/gnulib-filelist.txt 96 fi 97 98 99 # Warn the user if changes have been made to the Makefile.am. 100 if cmp lib/Makefile.am lib/Makefile.gnulib >/dev/null; then 101 # Avoid munging timestamps when nothing's changed. 102 rm lib/Makefile.am 103 else 104 cat >&2 <<\EOF 105 ******************************************************************** 106 Makefile.am needs updating. Use `cvs diff lib/Makefile.gnulib' to 107 view changes. 108 ******************************************************************** 109 EOF 110 # Save the generated lib/Makefile.am for next time. 111 mv lib/Makefile.am lib/Makefile.gnulib 112 fi 113