home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 March / PCWorld_2003-03_cd.bin / Software / Topware / activeperl / ActivePerl / Perl / bin / perlcc.bat < prev    next >
Encoding:
DOS Batch File  |  2002-12-01  |  19.7 KB  |  701 lines

  1. @rem = '--*-Perl-*--
  2. @echo off
  3. if "%OS%" == "Windows_NT" goto WinNT
  4. perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
  5. goto endofperl
  6. :WinNT
  7. perl -x -S %0 %*
  8. if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
  9. if %errorlevel% == 9009 echo You do not have Perl in your PATH.
  10. if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
  11. goto endofperl
  12. @rem ';
  13. #!perl
  14. #line 15
  15.     eval 'exec D:\p4\Apps\Gecko\MSI\data\ActivePerl\Perl\bin\perl.exe -S $0 ${1+"$@"}'
  16.     if $running_under_some_shell;
  17. --$running_under_some_shell;
  18.  
  19. # Version 2.0, Simon Cozens, Thu Mar 30 17:52:45 JST 2000 
  20. # Version 2.01, Tom Christiansen, Thu Mar 30 08:25:14 MST 2000
  21. # Version 2.02, Simon Cozens, Sun Apr 16 01:53:36 JST 2000
  22. # Version 2.03, Edward Peschko, Mon Feb 26 12:04:17 PST 2001
  23.  
  24. use strict;
  25. use warnings;
  26. use 5.006_000;
  27.  
  28. use FileHandle;
  29. use Config;
  30. use Fcntl qw(:DEFAULT :flock);
  31. use File::Temp qw(tempfile);
  32. use Cwd;
  33. our $VERSION = 2.03;
  34. $| = 1;
  35.  
  36. $SIG{INT} = sub { exit(); }; # exit gracefully and clean up after ourselves.
  37.  
  38. use subs qw{
  39.     cc_harness check_read check_write checkopts_byte choose_backend
  40.     compile_byte compile_cstyle compile_module generate_code
  41.     grab_stash parse_argv sanity_check vprint yclept spawnit
  42. };
  43. sub opt(*); # imal quoting
  44. sub is_win32();
  45. sub is_msvc();
  46.  
  47. our ($Options, $BinPerl, $Backend);
  48. our ($Input => $Output);
  49. our ($logfh);
  50. our ($cfile);
  51. our (@begin_output); # output from BEGIN {}, for testsuite
  52.  
  53. # eval { main(); 1 } or die;
  54.  
  55. main();
  56.  
  57. sub main {
  58.     parse_argv();
  59.     check_write($Output);
  60.     choose_backend();
  61.     generate_code();
  62.     run_code();
  63.     _die("XXX: Not reached?");
  64. }
  65.  
  66. #######################################################################
  67.  
  68. sub choose_backend {
  69.     # Choose the backend.
  70.     $Backend = 'C';
  71.     if (opt(B)) {
  72.         checkopts_byte();
  73.         $Backend = 'Bytecode';
  74.     }
  75.     if (opt(S) && opt(c)) {
  76.         # die "$0: Do you want me to compile this or not?\n";
  77.         delete $Options->{S};
  78.     }
  79.     $Backend = 'CC' if opt(O);
  80. }
  81.  
  82.  
  83. sub generate_code { 
  84.  
  85.     vprint 0, "Compiling $Input";
  86.  
  87.     $BinPerl  = yclept();  # Calling convention for perl.
  88.  
  89.     if (opt(shared)) {
  90.         compile_module();
  91.     } else {
  92.         if ($Backend eq 'Bytecode') {
  93.             compile_byte();
  94.         } else {
  95.             compile_cstyle();
  96.         }
  97.     }
  98.     exit(0) if (!opt('r'));
  99. }
  100.  
  101. sub run_code {
  102.     vprint 0, "Running code";
  103.     run("$Output @ARGV");
  104.     exit(0);
  105. }
  106.  
  107. # usage: vprint [level] msg args
  108. sub vprint {
  109.     my $level;
  110.     if (@_ == 1) {
  111.         $level = 1;
  112.     } elsif ($_[0] =~ /^\d$/) {
  113.         $level = shift;
  114.     } else {
  115.         # well, they forgot to use a number; means >0
  116.         $level = 0;
  117.     } 
  118.     my $msg = "@_";
  119.     $msg .= "\n" unless substr($msg, -1) eq "\n";
  120.     if (opt(v) > $level)
  121.     {
  122.          print        "$0: $msg" if !opt('log');
  123.      print $logfh "$0: $msg" if  opt('log');
  124.     }
  125. }
  126.  
  127. sub parse_argv {
  128.  
  129.     use Getopt::Long; 
  130.  
  131.     # disallows using long arguments
  132.     # Getopt::Long::Configure("bundling");
  133.  
  134.     Getopt::Long::Configure("no_ignore_case");
  135.  
  136.     # no difference in exists and defined for %ENV; also, a "0"
  137.     # argument or a "" would not help cc, so skip
  138.     unshift @ARGV, split ' ', $ENV{PERLCC_OPTS} if $ENV{PERLCC_OPTS};
  139.  
  140.     $Options = {};
  141.     Getopt::Long::GetOptions( $Options,
  142.         'L:s',          # lib directory
  143.         'I:s',          # include directories (FOR C, NOT FOR PERL)
  144.         'o:s',          # Output executable
  145.         'v:i',          # Verbosity level
  146.         'e:s',          # One-liner
  147.     'r',            # run resulting executable
  148.         'B',            # Byte compiler backend
  149.         'O',            # Optimised C backend
  150.         'c',            # Compile only
  151.         'h',            # Help me
  152.         'S',            # Dump C files
  153.     'r',            # run the resulting executable
  154.         'T',            # run the backend using perl -T
  155.         't',            # run the backend using perl -t
  156.         'static',       # Dirty hack to enable -shared/-static
  157.         'shared',       # Create a shared library (--shared for compat.)
  158.     'log:s',        # where to log compilation process information
  159.         'Wb:s',         # pass (comma-sepearated) options to backend
  160.         'testsuite',    # try to be nice to testsuite
  161.     );
  162.  
  163.     $Options->{v} += 0;
  164.  
  165.     if( opt(t) && opt(T) ) {
  166.         warn "Can't specify both -T and -t, -t ignored";
  167.         $Options->{t} = 0;
  168.     }
  169.  
  170.     helpme() if opt(h); # And exit
  171.  
  172.     $Output = opt(o) || ( is_win32 ? 'a.exe' : 'a.out' );
  173.     $Output = is_win32() ? $Output : relativize($Output);
  174.     $logfh  = new FileHandle(">> " . opt('log')) if (opt('log'));
  175.  
  176.     if (opt(e)) {
  177.         warn "$0: using -e 'code' as input file, ignoring @ARGV\n" if @ARGV;
  178.         # We don't use a temporary file here; why bother?
  179.         # XXX: this is not bullet proof -- spaces or quotes in name!
  180.         $Input = is_win32() ? # Quotes eaten by shell
  181.             '-e "'.opt(e).'"' :
  182.             "-e '".opt(e)."'";
  183.     } else {
  184.         $Input = shift @ARGV;  # XXX: more files?
  185.         _usage_and_die("$0: No input file specified\n") unless $Input;
  186.         # DWIM modules. This is bad but necessary.
  187.         $Options->{shared}++ if $Input =~ /\.pm\z/;
  188.         warn "$0: using $Input as input file, ignoring @ARGV\n" if @ARGV;
  189.         check_read($Input);
  190.         check_perl($Input);
  191.         sanity_check();
  192.     }
  193.  
  194. }
  195.  
  196. sub opt(*) {
  197.     my $opt = shift;
  198.     return exists($Options->{$opt}) && ($Options->{$opt} || 0);
  199.  
  200. sub compile_module { 
  201.     die "$0: Compiling to shared libraries is currently disabled\n";
  202. }
  203.  
  204. sub compile_byte {
  205.     require ByteLoader;
  206.     my $stash = grab_stash();
  207.     my $command = "$BinPerl -MO=Bytecode,$stash $Input";
  208.     # The -a option means we'd have to close the file and lose the
  209.     # lock, which would create the tiniest of races. Instead, append
  210.     # the output ourselves. 
  211.     vprint 1, "Writing on $Output";
  212.  
  213.     my $openflags = O_WRONLY | O_CREAT;
  214.     $openflags |= O_BINARY if eval { O_BINARY; 1 };
  215.     $openflags |= O_EXLOCK if eval { O_EXLOCK; 1 };
  216.  
  217.     # these dies are not "$0: .... \n" because they "can't happen"
  218.  
  219.     sysopen(OUT, $Output, $openflags)
  220.         or die "can't write to $Output: $!";
  221.  
  222.     # this is blocking; hold on; why are we doing this??
  223.     # flock OUT, LOCK_EX or die "can't lock $Output: $!"
  224.     #    unless eval { O_EXLOCK; 1 };
  225.  
  226.     truncate(OUT, 0)
  227.         or die "couldn't trunc $Output: $!";
  228.  
  229.     print OUT <<EOF;
  230. #!$^X
  231. use ByteLoader $ByteLoader::VERSION;
  232. EOF
  233.  
  234.     # Now the compile:
  235.     vprint 1, "Compiling...";
  236.     vprint 3, "Calling $command";
  237.  
  238.     my ($output_r, $error_r) = spawnit($command);
  239.  
  240.     if (@$error_r && $? != 0) {
  241.     _die("$0: $Input did not compile, which can't happen:\n@$error_r\n");
  242.     } else {
  243.     my @error = grep { !/^$Input syntax OK$/o } @$error_r;
  244.     warn "$0: Unexpected compiler output:\n@error" if @error;
  245.     }
  246.  
  247.     # Write it and leave.
  248.     print OUT @$output_r               or _die("can't write $Output: $!");
  249.     close OUT                          or _die("can't close $Output: $!");
  250.  
  251.     # wait, how could it be anything but what you see next?
  252.     chmod 0777 & ~umask, $Output    or _die("can't chmod $Output: $!");
  253.     exit 0;
  254. }
  255.  
  256. sub compile_cstyle {
  257.     my $stash = grab_stash();
  258.     my $taint = opt(T) ? '-T' :
  259.                 opt(t) ? '-t' : '';
  260.  
  261.     # What are we going to call our output C file?
  262.     my $lose = 0;
  263.     my ($cfh);
  264.     my $testsuite = '';
  265.     my $addoptions = opt(Wb);
  266.  
  267.     if( $addoptions ) {
  268.         $addoptions .= ',' if $addoptions !~ m/,$/;
  269.     }
  270.  
  271.     if (opt(testsuite)) {
  272.         my $bo = join '', @begin_output;
  273.         $bo =~ s/\\/\\\\\\\\/gs;
  274.         $bo =~ s/\n/\\n/gs;
  275.         $bo =~ s/,/\\054/gs;
  276.         # don't look at that: it hurts
  277.         $testsuite = q{-fuse-script-name,-fsave-data,-fsave-sig-hash,}.
  278.             qq[-e"print q{$bo}",] .
  279.             q{-e"open(Test::Builder::TESTOUT\054 '>&STDOUT') or die $!",} .
  280.             q{-e"open(Test::Builder::TESTERR\054 '>&STDERR') or die $!",};
  281.     }
  282.     if (opt(S) || opt(c)) {
  283.         # We need to keep it.
  284.         if (opt(e)) {
  285.             $cfile = "a.out.c";
  286.         } else {
  287.             $cfile = $Input;
  288.             # File off extension if present
  289.             # hold on: plx is executable; also, careful of ordering!
  290.             $cfile =~ s/\.(?:p(?:lx|l|h)|m)\z//i;
  291.             $cfile .= ".c";
  292.             $cfile = $Output if opt(c) && $Output =~ /\.c\z/i;
  293.         }
  294.         check_write($cfile);
  295.     } else {
  296.         # Don't need to keep it, be safe with a tempfile.
  297.         $lose = 1;
  298.         ($cfh, $cfile) = tempfile("pccXXXXX", SUFFIX => ".c"); 
  299.         close $cfh; # See comment just below
  300.     }
  301.     vprint 1, "Writing C on $cfile";
  302.  
  303.     my $max_line_len = '';
  304.     if ($^O eq 'MSWin32' && $Config{cc} =~ /^cl/i) {
  305.         $max_line_len = '-l2000,';
  306.     }
  307.  
  308.     # This has to do the write itself, so we can't keep a lock. Life
  309.     # sucks.
  310.     my $command = "$BinPerl $taint -MO=$Backend,$addoptions$testsuite$max_line_len$stash,-o$cfile $Input";
  311.     vprint 1, "Compiling...";
  312.     vprint 1, "Calling $command";
  313.  
  314.     my ($output_r, $error_r) = spawnit($command);
  315.     my @output = @$output_r;
  316.     my @error = @$error_r;
  317.  
  318.     if (@error && $? != 0) {
  319.         _die("$0: $Input did not compile, which can't happen:\n@error\n");
  320.     }
  321.  
  322.     is_msvc ?
  323.         cc_harness_msvc($cfile,$stash) :
  324.         cc_harness($cfile,$stash) unless opt(c);
  325.  
  326.     if ($lose) {
  327.         vprint 2, "unlinking $cfile";
  328.         unlink $cfile or _die("can't unlink $cfile: $!"); 
  329.     }
  330. }
  331.  
  332. sub cc_harness_msvc {
  333.     my ($cfile,$stash)=@_;
  334.     use ExtUtils::Embed ();
  335.     my $obj = "${Output}.obj";
  336.     my $compile = ExtUtils::Embed::ccopts." -c -Fo$obj $cfile ";
  337.     my $link = "-out:$Output $obj";
  338.     $compile .= " -I".$_ for split /\s+/, opt(I);
  339.     $link .= " -libpath:".$_ for split /\s+/, opt(L);
  340.     my @mods = split /-?u /, $stash;
  341.     $link .= " ".ExtUtils::Embed::ldopts("-std", \@mods);
  342.     $link .= " perl57.lib kernel32.lib msvcrt.lib";
  343.     vprint 3, "running $Config{cc} $compile";
  344.     system("$Config{cc} $compile");
  345.     vprint 3, "running $Config{ld} $link";
  346.     system("$Config{ld} $link");
  347. }
  348.  
  349. sub cc_harness {
  350.     my ($cfile,$stash)=@_;
  351.     use ExtUtils::Embed ();
  352.     my $command = ExtUtils::Embed::ccopts." -o $Output $cfile ";
  353.     $command .= " -I".$_ for split /\s+/, opt(I);
  354.     $command .= " -L".$_ for split /\s+/, opt(L);
  355.     my @mods = split /-?u /, $stash;
  356.     $command .= " ".ExtUtils::Embed::ldopts("-std", \@mods);
  357.         $command .= " -lperl";
  358.     vprint 3, "running $Config{cc} $command";
  359.     system("$Config{cc} $command");
  360. }
  361.  
  362. # Where Perl is, and which include path to give it.
  363. sub yclept {
  364.     my $command = "$^X ";
  365.  
  366.     # DWIM the -I to be Perl, not C, include directories.
  367.     if (opt(I) && $Backend eq "Bytecode") {
  368.         for (split /\s+/, opt(I)) {
  369.             if (-d $_) {
  370.                 push @INC, $_;
  371.             } else {
  372.                 warn "$0: Include directory $_ not found, skipping\n";
  373.             }
  374.         }
  375.     }
  376.             
  377.     $command .= "-I$_ " for @INC;
  378.     return $command;
  379. }
  380.  
  381. # Use B::Stash to find additional modules and stuff.
  382. {
  383.     my $_stash;
  384.     sub grab_stash {
  385.  
  386.         warn "already called get_stash once" if $_stash;
  387.  
  388.         my $taint = opt(T) ? '-T' :
  389.                     opt(t) ? '-t' : '';
  390.         my $command = "$BinPerl $taint -MB::Stash -c $Input";
  391.         # Filename here is perfectly sanitised.
  392.         vprint 3, "Calling $command\n";
  393.  
  394.         my ($stash_r, $error_r) = spawnit($command);
  395.         my @stash = @$stash_r;
  396.         my @error = @$error_r;
  397.  
  398.         if (@error && $? != 0) {
  399.             _die("$0: $Input did not compile:\n@error\n");
  400.         }
  401.  
  402.         # band-aid for modules with noisy BEGIN {}
  403.         foreach my $i ( @stash ) {
  404.             $i =~ m/-u(?:[\w:]+|\<none\>)$/ and $stash[0] = $i and next;
  405.             push @begin_output, $i;
  406.         }
  407.         chomp $stash[0];
  408.         $stash[0] =~ s/,-u\<none\>//;
  409.         $stash[0] =~ s/^.*?-u/-u/s;
  410.         vprint 2, "Stash: ", join " ", split /,?-u/, $stash[0];
  411.         chomp $stash[0];
  412.         return $_stash = $stash[0];
  413.     }
  414.  
  415. }
  416.  
  417. # Check the consistency of options if -B is selected.
  418. # To wit, (-B|-O) ==> no -shared, no -S, no -c
  419. sub checkopts_byte {
  420.  
  421.     _die("$0: Please choose one of either -B and -O.\n") if opt(O);
  422.  
  423.     if (opt(shared)) {
  424.         warn "$0: Will not create a shared library for bytecode\n";
  425.         delete $Options->{shared};
  426.     }
  427.  
  428.     for my $o ( qw[c S] ) { 
  429.         if (opt($o)) { 
  430.             warn "$0: Compiling to bytecode is a one-pass process--",
  431.                   "-$o ignored\n";
  432.             delete $Options->{$o};
  433.         }
  434.     }
  435.  
  436. }
  437.  
  438. # Check the input and output files make sense, are read/writeable.
  439. sub sanity_check {
  440.     if ($Input eq $Output) {
  441.         if ($Input eq 'a.out') {
  442.             _die("$0: Compiling a.out is probably not what you want to do.\n");
  443.             # You fully deserve what you get now. No you *don't*. typos happen.
  444.         } else {
  445.             warn "$0: Will not write output on top of input file, ",
  446.                 "compiling to a.out instead\n";
  447.             $Output = "a.out";
  448.         }
  449.     }
  450. }
  451.  
  452. sub check_read { 
  453.     my $file = shift;
  454.     unless (-r $file) {
  455.         _die("$0: Input file $file is a directory, not a file\n") if -d _;
  456.         unless (-e _) {
  457.             _die("$0: Input file $file was not found\n");
  458.         } else {
  459.             _die("$0: Cannot read input file $file: $!\n");
  460.         }
  461.     }
  462.     unless (-f _) {
  463.         # XXX: die?  don't try this on /dev/tty
  464.         warn "$0: WARNING: input $file is not a plain file\n";
  465.     } 
  466. }
  467.  
  468. sub check_write {
  469.     my $file = shift;
  470.     if (-d $file) {
  471.         _die("$0: Cannot write on $file, is a directory\n");
  472.     }
  473.     if (-e _) {
  474.         _die("$0: Cannot write on $file: $!\n") unless -w _;
  475.     } 
  476.     unless (-w cwd()) { 
  477.         _die("$0: Cannot write in this directory: $!\n");
  478.     }
  479. }
  480.  
  481. sub check_perl {
  482.     my $file = shift;
  483.     unless (-T $file) {
  484.         warn "$0: Binary `$file' sure doesn't smell like perl source!\n";
  485.         print "Checking file type... ";
  486.         system("file", $file);  
  487.         _die("Please try a perlier file!\n");
  488.     } 
  489.  
  490.     open(my $handle, "<", $file)    or _die("XXX: can't open $file: $!");
  491.     local $_ = <$handle>;
  492.     if (/^#!/ && !/perl/) {
  493.         _die("$0: $file is a ", /^#!\s*(\S+)/, " script, not perl\n");
  494.     } 
  495.  
  496.  
  497. # File spawning and error collecting
  498. sub spawnit {
  499.     my ($command) = shift;
  500.     my (@error,@output);
  501.     my $errname;
  502.     (undef, $errname) = tempfile("pccXXXXX");
  503.     { 
  504.     open (S_OUT, "$command 2>$errname |")
  505.         or _die("$0: Couldn't spawn the compiler.\n");
  506.     @output = <S_OUT>;
  507.     }
  508.     open (S_ERROR, $errname) or _die("$0: Couldn't read the error file.\n");
  509.     @error = <S_ERROR>;
  510.     close S_ERROR;
  511.     close S_OUT;
  512.     unlink $errname or _die("$0: Can't unlink error file $errname");
  513.     return (\@output, \@error);
  514. }
  515.  
  516. sub helpme {
  517.        print "perlcc compiler frontend, version $VERSION\n\n";
  518.        { no warnings;
  519.        exec "pod2usage $0";
  520.        exec "perldoc $0";
  521.        exec "pod2text $0";
  522.        }
  523. }
  524.  
  525. sub relativize {
  526.     my ($args) = @_;
  527.  
  528.     return() if ($args =~ m"^[/\\]");
  529.     return("./$args");
  530. }
  531.  
  532. sub _die {
  533.     $logfh->print(@_) if opt('log');
  534.     print STDERR @_;
  535.     exit(); # should die eventually. However, needed so that a 'make compile'
  536.             # can compile all the way through to the end for standard dist.
  537. }
  538.  
  539. sub _usage_and_die {
  540.     _die(<<EOU);
  541. $0: Usage:
  542. $0 [-o executable] [-r] [-O|-B|-c|-S] [-log log] [source[.pl] | -e oneliner]
  543. EOU
  544. }
  545.  
  546. sub run {
  547.     my (@commands) = @_;
  548.  
  549.     print interruptrun(@commands) if (!opt('log'));
  550.     $logfh->print(interruptrun(@commands)) if (opt('log'));
  551. }
  552.  
  553. sub interruptrun
  554. {
  555.     my (@commands) = @_;
  556.  
  557.     my $command = join('', @commands);
  558.     local(*FD);
  559.     my $pid = open(FD, "$command |");
  560.     my $text;
  561.     
  562.     local($SIG{HUP}) = sub { kill 9, $pid; exit };
  563.     local($SIG{INT}) = sub { kill 9, $pid; exit };
  564.  
  565.     my $needalarm = 
  566.           ($ENV{PERLCC_TIMEOUT} && 
  567.       $Config{'osname'} ne 'MSWin32' && 
  568.       $command =~ m"(^|\s)perlcc\s");
  569.  
  570.     eval 
  571.     {
  572.          local($SIG{ALRM}) = sub { die "INFINITE LOOP"; };
  573.          alarm($ENV{PERLCC_TIMEOUT}) if ($needalarm);
  574.      $text = join('', <FD>);
  575.      alarm(0) if ($needalarm);
  576.     };
  577.  
  578.     if ($@)
  579.     {
  580.         eval { kill 'HUP', $pid };
  581.         vprint 0, "SYSTEM TIMEOUT (infinite loop?)\n";
  582.     }
  583.  
  584.     close(FD);
  585.     return($text);
  586. }
  587.  
  588. sub is_win32() { $^O =~ m/^MSWin/ }
  589. sub is_msvc() { is_win32 && $Config{cc} =~ m/^cl/i }
  590.  
  591. END {
  592.     unlink $cfile if ($cfile && !opt(S) && !opt(c));
  593. }
  594.  
  595. __END__
  596.  
  597. =head1 NAME
  598.  
  599. perlcc - generate executables from Perl programs
  600.  
  601. =head1 SYNOPSIS
  602.  
  603.     $ perlcc hello              # Compiles into executable 'a.out'
  604.     $ perlcc -o hello hello.pl  # Compiles into executable 'hello'
  605.  
  606.     $ perlcc -O file            # Compiles using the optimised C backend
  607.     $ perlcc -B file            # Compiles using the bytecode backend
  608.  
  609.     $ perlcc -c file            # Creates a C file, 'file.c'
  610.     $ perlcc -S -o hello file   # Creates a C file, 'file.c',
  611.                                 # then compiles it to executable 'hello'
  612.     $ perlcc -c out.c file      # Creates a C file, 'out.c' from 'file'
  613.  
  614.     $ perlcc -e 'print q//'     # Compiles a one-liner into 'a.out'
  615.     $ perlcc -c -e 'print q//'  # Creates a C file 'a.out.c'
  616.  
  617.     $ perlcc -I /foo hello    # extra headers (notice the space after -I)
  618.     $ perlcc -L /foo hello    # extra libraries (notice the space after -L)
  619.  
  620.     $ perlcc -r hello           # compiles 'hello' into 'a.out', runs 'a.out'.
  621.     $ perlcc -r hello a b c     # compiles 'hello' into 'a.out', runs 'a.out'.
  622.                                 # with arguments 'a b c' 
  623.  
  624.     $ perlcc hello -log c       # compiles 'hello' into 'a.out' logs compile
  625.                                 # log into 'c'. 
  626.  
  627. =head1 DESCRIPTION
  628.  
  629. F<perlcc> creates standalone executables from Perl programs, using the
  630. code generators provided by the L<B> module. At present, you may
  631. either create executable Perl bytecode, using the C<-B> option, or 
  632. generate and compile C files using the standard and 'optimised' C
  633. backends.
  634.  
  635. The code generated in this way is not guaranteed to work. The whole
  636. codegen suite (C<perlcc> included) should be considered B<very>
  637. experimental. Use for production purposes is strongly discouraged.
  638.  
  639. =head1 OPTIONS
  640.  
  641. =over 4
  642.  
  643. =item -LI<library directories>
  644.  
  645. Adds the given directories to the library search path when C code is
  646. passed to your C compiler.
  647.  
  648. =item -II<include directories>
  649.  
  650. Adds the given directories to the include file search path when C code is
  651. passed to your C compiler; when using the Perl bytecode option, adds the
  652. given directories to Perl's include path.
  653.  
  654. =item -o I<output file name>
  655.  
  656. Specifies the file name for the final compiled executable.
  657.  
  658. =item -c I<C file name>
  659.  
  660. Create C code only; do not compile to a standalone binary.
  661.  
  662. =item -e I<perl code>
  663.  
  664. Compile a one-liner, much the same as C<perl -e '...'>
  665.  
  666. =item -S
  667.  
  668. Do not delete generated C code after compilation.
  669.  
  670. =item -B
  671.  
  672. Use the Perl bytecode code generator.
  673.  
  674. =item -O
  675.  
  676. Use the 'optimised' C code generator. This is more experimental than
  677. everything else put together, and the code created is not guaranteed to
  678. compile in finite time and memory, or indeed, at all.
  679.  
  680. =item -v
  681.  
  682. Increase verbosity of output; can be repeated for more verbose output.
  683.  
  684. =item -r 
  685.  
  686. Run the resulting compiled script after compiling it.
  687.  
  688. =item -log
  689.  
  690. Log the output of compiling to a file rather than to stdout.
  691.  
  692. =back
  693.  
  694. =cut
  695.  
  696.  
  697. __END__
  698. :endofperl
  699.