#!/bin/sh

if [ $# -ne 0 ]; then
   DOCDIRS="$*"
elif [ -f wrapper.tex ]; then
   DOCDIRS="."
elif [ -f docdirs ]; then
   DOCDIRS=`cat docdirs`
else
   DOCDIRS=""
fi


for DIR in $DOCDIRS; do
   if [ -f $DIR/docdirs ]; then
   
     DOC_SUBDIRS=`cat $DIR/docdirs`
     
     BIB_FILES=""
     for SUBDIR in ${DOC_SUBDIRS}; do
        if [ -f $DIR/$SUBDIR/cgal.bib ]; then
	   BIB_FILES="$BIB_FILES $DIR/$SUBDIR/cgal.bib"
        fi
     done
     echo "BIB_FILES = $BIB_FILES"
     echo "DIR = $DIR"

     if [ -n "$BIB_FILES" ]; then
       if [ -f cgal-manual.bib ]; then
          rmbibcomments $BIB_FILES cgal-manual.bib | bibmerge > temp_cgal.bib
          \mv temp_cgal.bib cgal-manual.bib
       else
          rmbibcomments $BIB_FILES | bibmerge > cgal-manual.bib
       fi
     fi

   fi
done




syntax highlighted by Code2HTML, v. 0.9.1