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