#!/usr/bin/perl

#+
#  - - - - - - -
#   m a n u a l
#  - - - - - - -
#
#  Extract a manual (manual.lis) constructed from certain text files
#  plus material extracted from all the .c files in the current
#  directory.
#
#  Last revision:   2008 October 8
#
#  Copyright International Astronomical Union.  All rights reserved.
#-

open ( M, ">".($m = "manual.lis") ) || die "Can't open $m!\n";
while ( < title.lis contents.lis intro.lis sofa_lib.lis sofa_vml.lis > ) {
   open ( C, $_ );
   while ( <C> ) {
      print M;
   }
   print M "\f\n";
   close ( C );
}

while ( <*.c> ) {
   if ( /t_/ ) { next; }
   open ( C, $_ );
   if ( $begun || $begun++ ) { print M "\f\n" }
      print M "\n";
      while ( <C> ) {
         if ( /\*  This revision:  / ) { print M "*/\n"; last; }
         print M unless ( /#include/ );
      }
   close ( C );
}
print M "\f\n";

while ( < copyr.lis consts.lis sofa.h sofam.h board.lis > ) {
   open ( C, $_ );
   while ( <C> ) {
      print M;
   }
   print M "\f\n";
   close ( C );
}

close ( M );