#! @SH@
# @configure_input@

echo "Adding java source files from srcdir '@top_srcdir@'."
@FIND@ @top_srcdir@/java @top_srcdir@/javax @top_srcdir@/gnu \
       @top_srcdir@/org @top_srcdir@/vm/reference \
       @top_srcdir@/external/w3c_dom @top_srcdir@/external/sax \
       -follow -type f -print | grep '\.java$' > ${top_builddir}/lib/classes.1

# Only include generated files once.
if test ! "${top_builddir}" -ef "@top_srcdir@"; then
  echo "Adding generated files in builddir '${top_builddir}'."
  @FIND@ ${top_builddir}/gnu ${top_builddir}/java -follow -type f -print \
  | grep '\.java$' >> ${top_builddir}/lib/classes.1
fi

for filexp in `cat @top_srcdir@/lib/$1.omit` ; do { grep -v ${filexp} < ${top_builddir}/lib/classes.1 > ${top_builddir}/lib/classes.2 ; mv ${top_builddir}/lib/classes.2 ${top_builddir}/lib/classes.1 ; } ; done

new=
if test -e ${top_builddir}/lib/classes; then
  p=`diff ${top_builddir}/lib/classes ${top_builddir}/lib/classes.1`
  if test "$p" != ""; then
    new="true"
    cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes
  fi
else
  new="true"
  cp ${top_builddir}/lib/classes.1 ${top_builddir}/lib/classes
fi

if test "$new" = "true"; then
  echo "JAVA_SRCS = \\" > ${top_builddir}/lib/java.dep
  for i in `cat ${top_builddir}/lib/classes` ; do
    echo $i "\\" >> ${top_builddir}/lib/java.dep
  done
fi

# Split in multiple parts for gcj
grep -v /javax/ classes | grep -v /awt/ \
                        | grep -v /beans/ \
                        | grep -v /locale/ \
			| grep -v /xml/ > classes.standard
grep /awt/ classes > classes.awt
grep /beans/ classes >> classes.awt
grep /locale/ classes > classes.locale
grep /xml/ classes > classes.xml
grep /javax/ classes | grep -v /xml/ > classes.standardx
