#!/usr/bin/perl -w
#$Id: sp_includer 21533 2006-06-08 14:57:34Z wsnyder $
######################################################################
#
# Copyright 2001-2006 by Wilson Snyder.  This program is free software;
# you can redistribute it and/or modify it under the terms of either the GNU
# General Public License or the Perl Artistic License.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#                                                                           
######################################################################

require 5.005;
use Getopt::Long;
use IO::File;
use Pod::Text;
use strict;

use vars qw ($Debug);

#======================================================================
# main

$Debug = 0;
my @params;
if (! GetOptions (
		  "help"	=> \&usage,
		  "debug"	=> \&debug,
		  "<>"		=> \&parameter,
		  )) {
    usage();
}

foreach my $param (@params) {
    print "#include \"$param\"\n"
}

#----------------------------------------------------------------------

sub usage {
    print '$Id: sp_includer 21533 2006-06-08 14:57:34Z wsnyder $ ', "\n";
    $SIG{__WARN__} = sub{};	#pod2text isn't clean.
    pod2text($0);
    exit (1);
}

sub debug {
    $Debug = 1;
}

sub parameter {
    my $param = shift;
    push @params, $param;
}
 
#######################################################################
__END__

=pod

=head1 NAME

sp_includer - Form include statements

=head1 SYNOPSIS

  sp_includer <file1.cpp>...

=head1 DESCRIPTION

sp_includer simply takes all of the arguments on the command line and
prints #include statements for each argument.

This allows multiple files to be compiled in one pass; rather then using

    gcc file1.cpp
    gcc file2.cpp
    gcc file3.cpp

or the equivalently slow

    gcc file1.cpp file2.cpp file3.cpp

this program allows

    sp_includer file1.cpp file2.cpp file3.cpp > file_CONCAT.cpp
    gcc file_CONCAT.cpp

where any headers all files require will be read only once.  With the
SystemC headers, this saves ~5 seconds per file, many minutes across an
entire large project.

=head1 ARGUMENTS

=over 4

=item --help

Displays this message and program version and exits.

=back

=head1 DISTRIBUTION

SystemPerl is part of the L<http://www.veripool.com/> free SystemC software
tool suite.  The latest version is available from CPAN and from
L<http://www.veripool.com/systemperl.html>.

Copyright 2001-2006 by Wilson Snyder.  This package is free software; you
can redistribute it and/or modify it under the terms of either the GNU
Lesser General Public License or the Perl Artistic License.

=head1 AUTHORS

Wilson Snyder <wsnyder@wsnyder.org>

=head1 SEE ALSO

L<SystemC::SystemPerl>

=cut

######################################################################
### Local Variables:
### compile-command: "./sp_includer a.cpp b.cpp c.cpp"
### End:
