#!/usr/bin/perl -w

#Iterate through ipp src dir to find Doxygen configuration files
#Run Doxygen and copy the html files produced to alala web server
#Called daily by cron

use strict;
use warnings;
use File::Find;
use File::Copy;

my $srcDir = "/data/ipp002.0/ippDoxygen/ipp";
system `rm -rf /data/ipp002.0/ippDoxygen/ipp`;
system `svn co http://svn.pan-starrs.ifa.hawaii.edu/repo/ipp/trunk/ /data/ipp002.0/ippDoxygen/ipp`;
my $destDir = "/data/alala.0/ippDocs";
system `rm -rf $destDir/*`;

finddepth(\&wanted, $srcDir);
chdir $srcDir;
system `/usr/bin/doxygen`;
system ("cp -r $srcDir/docs/html/* $destDir");

sub wanted {
  #don't want the archive or DB src
  return if ($File::Find::name =~ /archive$/); 
  return if ($File::Find::name =~ /ippdb\.src/); 

  if ($File::Find::name =~ /Doxyfile\.in$/) {
    my $file = $File::Find::name;
    my $subDir = $1 if ($file =~ /\/([^\/]+)\/Doxyfile/);
    my $currDir = $File::Find::dir;
    system ("$currDir/autogen.sh");
  }
}



