# Copyright (C) 1999, 2000, 2002, 2005, 2006 by the deal.II group
# $Id: makefile2html 13367 2006-07-13 12:15:48Z bangerth $

print <<'EOT'
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                 "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <link href="../screen.css" rel="StyleSheet" title="deal.II Homepage" media="screen">
    <title>Makefile fro deal.II</title>
    <meta name="author" content="the deal.II authors <authors@dealii.org>">
    <meta name="keywords" content="deal.II Makefile"></head>
  <body>
EOT
;

# ignore the first few lines
$_ = <>;
while ( m!^#\s*\$Id!) {
    $_ = <>;
}

# have two states, in which the program can be:
# comment-mode and program-mode
$comment_mode = 0;
$program_mode = 1;
$state =  $comment_mode;

print "<p>\n";

while (<>) {
    # ignore subversion tag
    next if m!^#\*\s*\$Id:!;

    # substitute special characters
    s/&/&amp;/g;
    s/</&lt;/g;
    s/>/&gt;/g;
    s/\t/        /g;

    if (($state == $program_mode) && m!^\s*#!)
    {     
	$state = $comment_mode;
	print "</code></pre>\n";
	print "\n";
	print "<p>\n";
    }
    # if in comment mode and no comment line: toggle state.
    # don't do so, if only a blank line
    elsif (($state == $comment_mode) && !m!^\s*#! && !m!^\s*$!)
    {     
	$state = $program_mode;
	print "</p>\n";
	print "\n";
	print "<pre><code>\n";
    }
    
    if ($state == $comment_mode) 
    {
	m!\s*#\s*(.*)!;
	print $1, "\n";
	print "</p>\n\n<p>" if  $1 =~ m!^\s*$!;
    }
    else
    {
	print "        $_";
    }
}

if ($state == $program_mode) {
   print "</code></pre>\n";
}

print "</body>\n</html>\n";
