#!/bin/sh

# small shell script to generate our API docs
# it'll copy over qt

#
# create directory structure
echo "Creating directory structure"
rm -rf $OPIEDIR/apidocs
mkdir $OPIEDIR/apidocs
mkdir $OPIEDIR/apidocs/api
mkdir $OPIEDIR/apidocs/common
mkdir $OPIEDIR/apidocs/qt
mkdir $OPIEDIR/apidocs/libqpe
mkdir $OPIEDIR/apidocs/libopie
mkdir $OPIEDIR/apidocs/pim
mkdir $OPIEDIR/apidocs/network
mkdir $OPIEDIR/apidocs/net2
mkdir $OPIEDIR/apidocs/core2
mkdir $OPIEDIR/apidocs/pim2
mkdir $OPIEDIR/apidocs/ui2
mkdir $OPIEDIR/apidocs/db2

# now copy qt doc
echo "Scanning and copying QT docu"
cp -R $QTDIR/doc/html/* $OPIEDIR/apidocs/qt
doxytag -t $OPIEDIR/apidocs/qt/qt.tag $OPIEDIR/apidocs/qt

cp -r $OPIEDIR/doc/common/* $OPIEDIR/apidocs/common
# now start with libqpe
echo "Creating docu for qpe"
cp $OPIEDIR/doc/Doxyfile_libqpe $OPIEDIR/library/Doxyfile
cd $OPIEDIR/library
doxygen Doxyfile
rm -f Doxyfile

# now do libopie
echo "Creating docu for libopie"
cp $OPIEDIR/doc/Doxyfile_libopie $OPIEDIR/libopie/Doxyfile
cd $OPIEDIR/libopie
doxygen Doxyfile
rm -f Doxyfile

echo "Creating docu for PIM"
# now it's time for libopie/pim
cp $OPIEDIR/doc/Doxyfile_pim $OPIEDIR/libopie/pim/Doxyfile
cd $OPIEDIR/libopie/pim
doxygen Doxyfile
rm -f Doxyfile

echo "Creating docu for NetworkSettings"
# now do networksettings
cp $OPIEDIR/doc/Doxyfile_net $OPIEDIR/noncore/settings/networksettings/Doxyfile
cd $OPIEDIR/noncore/settings/networksettings
doxygen Doxyfile
rm -f Doxyfile

echo "Creating docu for Opie2 Core"
# now do networksettings
cp $OPIEDIR/doc/Doxyfile_core2 $OPIEDIR/libopie2/opiecore/Doxyfile
cd $OPIEDIR/libopie2/opiecore
doxygen Doxyfile
rm -f Doxyfile

echo "Creating docu for Opie2 DB"
# now do networksettings
cp $OPIEDIR/doc/Doxyfile_db2 $OPIEDIR/libopie2/opiedb/Doxyfile
cd $OPIEDIR/libopie2/opiedb
doxygen Doxyfile
rm -f Doxyfile

echo "Creating docu for Opie2 mm"
# now do networksettings
cp $OPIEDIR/doc/Doxyfile_mm2 $OPIEDIR/libopie2/opiemm/Doxyfile
cd $OPIEDIR/libopie2/opiemm
doxygen Doxyfile
rm -f Doxyfile

echo "Creating docu for Opie2 net"
# now do networksettings
cp $OPIEDIR/doc/Doxyfile_net2 $OPIEDIR/libopie2/opienet/Doxyfile
cd $OPIEDIR/libopie2/opienet
doxygen Doxyfile
rm -f Doxyfile

echo "Creating docu for Opie2 ui"
# now do networksettings
cp $OPIEDIR/doc/Doxyfile_ui2 $OPIEDIR/libopie2/opieui/Doxyfile
cd $OPIEDIR/libopie2/opieui
doxygen Doxyfile
rm -f Doxyfile

echo "Creating docu for Opie2 pim"
# now do networksettings
cp $OPIEDIR/doc/Doxyfile_pim2 $OPIEDIR/libopie2/opiepim/Doxyfile
cd $OPIEDIR/libopie2/opiepim
doxygen Doxyfile
rm -f Doxyfile

echo "Making mainpage"
# now generate the mainpage
cp $OPIEDIR/doc/Doxyfile_main $OPIEDIR/Doxyfile
cp $OPIEDIR/doc/Mainpage.dox $OPIEDIR/
cd $OPIEDIR
doxygen Doxyfile
rm -f Doxyfile
rm -f Mainpage.dox

echo "Done with generation!!! hopefully grin"