#!/bin/sh

# make sure we do this in the right dir
cd /usr/src/AfterStep

# remove the old devel version, and copy the new one
rm -rf AfterStep-current2
cp -r AfterStep-devel AfterStep-current2

# clean out the directories we'll be making the patch from
cd AfterStep-current
makeasclean
cd ..
cd AfterStep-current2
makeasclean
cd ..

# make the patch
diff -N -u -r AfterStep-current AfterStep-current2 > /tmp/patch

# check for c++-style comments
if grep -q "//" /tmp/patch; then
  echo "Warning!  Possible C++ comment(s) detected."
  fi

# try to make sure there's a ChangeLog entry
if ! grep -q "ChangeLog" /tmp/patch; then
  echo "Warning!  No ChangeLog entry detected."
  fi

# check the patch for files with no newline at the end; such files confuse 
# the various versions of patch
if grep -q "\\ No newline at end of file" /tmp/patch; then
  echo "Warning!  Files with no newline at the end detected in patch."
  echo "Please be sure all files have newlines at the end, otherwise some"
  echo "versions of patch will be confused."
  fi

# try to make sure "make config" was run if configure.in was changed
if grep -q "configure.in" /tmp/patch && ! grep -q "configure " /tmp/patch; then
  echo "Warning!  Changes to configure.in detected, but configure does"
  echo "not appear to be changed.  Please be sure to run:"
  echo "make config"
  echo "to update the configure script."
elif test AfterStep-devel/configure -ot AfterStep-devel/autoconf/configure.in; then
  echo "Warning!  configure appears to be older than configure.in.  Please"
  echo "be sure to run:"
  echo "make config"
  echo "to update the configure script."
fi
