#!/bin/sh

PACKAGE=$1
sort <../${PACKAGE}-MANIFEST >../sort.$$
mv ../sort.$$ ../${PACKAGE}-MANIFEST
if diff MANIFEST ../${PACKAGE}-MANIFEST
then
  rm -f ../${PACKAGE}-MANIFEST
  cat <<EOF

The contents of ${PACKAGE} match the MANIFEST -- no errors were detected.
EOF

else
  cat <<EOF

Oops! The MANIFEST does not match the contents of ${PACKAGE}!
The 'diff' output above indicates which file(s) do not match.
There are five possible reasons for this problem:
  1. The package version given in the MANIFEST is out-of-date.  If this is
     the problem, update the package version in MANIFEST (in each line).
  2. A file belonging to the package is missing;  find it!
     Look in previous versions of the package for the missing file.
  3. A file that does not belong to the package is present within this
     directory or one of its subdirectories;  remove it!
  4. A new file in the package is not mentioned in the MANIFEST;  in this
     case, replace MANIFEST with ../${PACKAGE}-MANIFEST.
  5. A file formerly belonging to the package has been removed;  in this
     case, replace MANIFEST with ../${PACKAGE}-MANIFEST.
Read the 'diff' output above to identify which reason(s) apply.  Be careful
not to replace MANIFEST unless all errors related to reasons 1, 2, and 3 have
been corrected.  In any case, rerun 'make tarballs' after correcting the
problem(s).

EOF

fi
