source: git/libfac/bin/makeheader @ 9d6bf4

spielwiese
Last change on this file since 9d6bf4 was 18500b, checked in by Martin Lee <martinlee84@…>, 12 years ago
chg: moved libfac back
  • Property mode set to 100755
File size: 1.5 KB
Line 
1#!/usr/local/bin/perl
2
3###
4### makeheader - generate a header file out of several header file (ver 1.1)
5###
6
7if ( ( $#ARGV == 0 ) && ( $ARGV[0] eq '-help' ) ) {
8    die "\nThis is makeheader, a header file generation tool.\n\n" .
9        "   with makeheader it is possible to generate a single header\n" .
10        "   file out of several other header files\n" .
11        "   the parts to be included in the generated header file have\n" .
12        "   to be marked with /*BEGINPUBLIC*/ and /*ENDPUBLIC*/\n" .
13        "   to include a header file into the generated header file use\n" .
14        "   the command .INCLUDE name.h on a single line\n\n" .
15        "usage: makeheader <template> <outfile>\n\n";
16}
17
18if ( $#ARGV < 1 ) {
19    die "usage: makeheader <template> <outfile>\n\n";
20}
21
22$infile = shift( @ARGV );
23$outfile = shift( @ARGV );
24
25open( INFILE, $infile ) || 
26    die "makeheader: can not open template file $infile for reading!\n";
27open( OUTFILE, ">$outfile" ) ||
28    die "makeheader: can not open header file $outfile for writing!\n";
29
30while( $currentline = <INFILE> ) {
31    if ( index( $currentline, ".INCLUDE" ) == 0 ) {
32        $currentline =~ s/.INCLUDE //;
33        open( INCLFILE, $currentline ) ||
34            die "can not open included file '$currentline' for reading!\n";
35        while ( $inclline = <INCLFILE> ) {
36            if ( index( $inclline, "/*BEGINPUBLIC*/" ) >= 0 ) {
37                while (( $inclline = <INCLFILE> ) &&
38                       ( index( $inclline, "/*ENDPUBLIC*/" ) < 0 )) {
39                    print OUTFILE $inclline;
40                }
41            }
42        }
43    }
44    else {
45        print OUTFILE $currentline;
46    }
47}
48
49close OUTFILE;
50close INFILE;
51
Note: See TracBrowser for help on using the repository browser.