4 use File::Basename qw(&basename &dirname);
8 # List explicitly here the variables you want Configure to
9 # generate. Metaconfig only looks for shell variables, so you
10 # have to mention them as if they were shell variables, not
11 # %Config entries. Thus you write
13 # to ensure Configure will look for $Config{startperl}.
16 # This forces PL files to create target in same directory as PL file.
17 # This is so that make depend always knows where to find PL derivatives.
20 $file = basename($0, '.PL');
21 $file .= '.com' if $^O eq 'VMS';
23 open OUT,">$file" or die "Can't create $file: $!";
25 print "Extracting $file (with variable substitutions)\n";
27 # In this section, perl variables will be expanded during extraction.
28 # You can use $Config{...} to use Configure variables.
30 print OUT <<"!GROK!THIS!";
32 eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
33 if \$running_under_some_shell;
36 # In the following, perl variables are not expanded during extraction.
38 print OUT <<'!NO!SUBS!';
43 use File::Basename qw(&basename &dirname);
48 $Getopt::Long::bundling_override = 1;
49 $Getopt::Long::passthrough = 0;
50 $Getopt::Long::ignore_case = 0;
52 my $pathsep = ($Config{'osname'} eq 'MSWin32')? "\\" : "/"; # MAJOR HACK. SHOULD
57 unshift @ARGV, split ' ', $ENV{PERLCC_OPTS} if $ENV{PERLCC_OPTS};
89 _usage() if (!_checkopts());
90 push(@ARGV, _maketempfile()) if ($options->{'e'});
98 --------------------------------------------------------------------------------
100 --------------------------------------------------------------------------------
110 my ($program_ext, $module_ext) = _getRegexps();
111 my ($obj, $objfile, $so, $type, $backend, $gentype);
113 $backend = $options->{'b'} ? 'Bytecode' : $options->{'opt'} ? 'CC' : 'C';
115 $gentype = $options->{'b'} ? 'Bytecode' : 'C';
118 (($file =~ m"@$program_ext") && ($file !~ m"@$module_ext"))
119 || (defined($options->{'prog'}) || defined($options->{'run'}))
126 $obj = $objfile = $options->{'o'} ? $options->{'o'} : "${file}c";
130 $objfile = $options->{'C'} ? $options->{'C'} : "$file.c";
131 $obj = $options->{'o'} ? $options->{'o'}
132 : _getExecutable( $file,$program_ext);
138 elsif (($file =~ m"@$module_ext") || ($options->{'mod'}))
144 $obj = $objfile = $options->{'o'} ? $options->{'o'} : "${file}c";
148 die "Shared objects are not supported on Win32 yet!!!!\n"
149 if ($Config{'osname'} eq 'MSWin32');
151 $objfile = $options->{'C'} ? $options->{'C'} : "$file.c";
152 $obj = $options->{'o'} ? $options->{'o'}
153 : _getExecutable($file, $module_ext);
154 $so = "$obj.$Config{so}";
161 _error("noextension", $file, $program_ext, $module_ext);
165 if ($type eq 'program')
167 _print("Making $gentype($objfile) for $file!\n", 36 );
169 my $errcode = _createCode($backend, $objfile, $file);
170 (_print( "ERROR: In generating code for $file!\n", -1), return())
173 _print("Compiling C($obj) for $file!\n", 36 ) if (!$options->{'gen'} &&
175 $errcode = _compileCode($file, $objfile, $obj)
176 if (!$options->{'gen'} &&
181 _print( "ERROR: In compiling code for $objfile !\n", -1);
182 my $ofile = File::Basename::basename($objfile);
183 $ofile =~ s"\.c$"\.o"s;
185 _removeCode("$ofile");
189 _runCode($objfile) if ($options->{'run'} && $options->{'b'});
190 _runCode($obj) if ($options->{'run'} && !$options->{'b'});
192 _removeCode($objfile) if (($options->{'b'} &&
193 ($options->{'e'} && !$options->{'o'})) ||
195 (!$options->{'sav'} ||
196 ($options->{'e'} && !$options->{'C'}))));
198 _removeCode($file) if ($options->{'e'});
200 _removeCode($obj) if (!$options->{'b'} &&
202 !$options->{'sav'} && !$options->{'o'}) ||
203 ($options->{'run'} && !$options->{'sav'})));
207 _print( "Making $gentype($objfile) for $file!\n", 36 );
208 my $errcode = _createCode($backend, $objfile, $file, $obj);
209 (_print( "ERROR: In generating code for $file!\n", -1), return())
212 _print( "Compiling C($so) for $file!\n", 36 ) if (!$options->{'gen'} &&
216 _compileCode($file, $objfile, $obj, $so ) if (!$options->{'gen'} &&
219 (_print( "ERROR: In compiling code for $objfile!\n", -1), return())
226 my ($sourceprog, $ext) = @_;
229 if (defined($options->{'regex'}))
231 eval("(\$obj = \$sourceprog) =~ $options->{'regex'}");
232 return(0) if (_error('badeval', $@));
233 return(0) if (_error('equal', $obj, $sourceprog));
235 elsif (defined ($options->{'ext'}))
237 ($obj = $sourceprog) =~ s"@$ext"$options->{ext}"g;
238 return(0) if (_error('equal', $obj, $sourceprog));
240 elsif (defined ($options->{'run'}))
246 ($obj = $sourceprog) =~ s"@$ext""g;
247 return(0) if (_error('equal', $obj, $sourceprog));
254 my ( $backend, $generated_file, $file, $final_output ) = @_;
256 my $output_switch = "o";
257 my $max_line_len = '';
261 if ($^O eq 'MSWin32' && $backend =~ /^CC?$/ && $Config{cc} =~ /^cl/i) {
262 $max_line_len = '-l2000,';
265 if ($backend eq "Bytecode")
269 open(GENFILE, "> $generated_file") || die "Can't open $generated_file: $!";
271 print GENFILE "#!$^X\n" if @_ == 3;
272 print GENFILE "use ByteLoader $ByteLoader::VERSION;\n";
278 if (@_ == 3) # compiling a program
280 chmod $generated_file, 0777 & ~umask if $backend eq "Bytecode";
281 my $null=File::Spec->devnull;
282 _print( "$^X -I@INC -MB::Stash -c $file\n", 36);
283 my @stash=`$^X -I@INC -MB::Stash -c $file 2>$null`;
284 my $stash=$stash[-1];
287 _print( "$^X -I@INC -MO=$backend,$max_line_len$stash $file\n", 36);
288 $return = _run("$^X -I@INC -MO=$backend,$max_line_len$stash,-$output_switch$generated_file $file", 9);
291 else # compiling a shared object
294 "$^X -I@INC -MO=$backend,$max_line_len-m$final_output $file\n", 36);
296 _run("$^X -I@INC -MO=$backend,$max_line_len-m$final_output,-$output_switch$generated_file $file ", 9);
303 my ($sourceprog, $generated_cfile, $output_executable, $shared_object) = @_;
306 if (@_ == 3) # just compiling a program
309 _ccharness('static', $sourceprog, "-o", $output_executable,
315 my $object_file = $generated_cfile;
316 $object_file =~ s"\.c$"$Config{_o}";
318 $return[0] = _ccharness('compile', $sourceprog, "-c", $generated_cfile);
319 $return[1] = _ccharness
323 $shared_object, $object_file
325 return(1) if (grep ($_, @return));
332 my ($executable) = @_;
333 _print("$executable $options->{'argv'}\n", 36);
334 _run("$executable $options->{'argv'}", -1 );
340 unlink($file) if (-e $file);
349 my $sourceprog = shift(@args);
350 my ($libdir, $incdir);
353 $L = '-libpath:' if $^O eq 'MSWin32' && $Config{cc} =~ /^cl/i;
355 if (-d "$Config{installarchlib}/CORE")
357 $libdir = "$L$Config{installarchlib}/CORE";
358 $incdir = "-I$Config{installarchlib}/CORE";
362 $libdir = "$L.. $L.";
363 $incdir = "-I.. -I.";
366 $libdir .= " $L$options->{L}" if (defined($options->{L}));
367 $incdir .= " -I$options->{L}" if (defined($options->{L}));
374 if (!grep(/^-[cS]$/, @args))
376 my $lperl = $^O eq 'os2' ? '-llibperl'
377 : $^O eq 'MSWin32' ? "$Config{archlibexp}\\CORE\\$Config{libperl}"
379 ($lperl = $Config{libperl}) =~ s/lib(.*)\Q$Config{_a}\E/-l$1/
382 $optimize = $Config{'optimize'} =~ /-O\d/ ? '' : $Config{'optimize'};
384 $flags = $type eq 'dynamic' ? $Config{lddlflags} : $Config{ldflags};
385 $linkargs = "$flags $libdir $lperl @Config{libs}";
386 $linkargs = "/link $linkargs" if $^O eq 'MSWin32' && $Config{cc} =~ /^cl/i;
389 my $libs = _getSharedObjects($sourceprog);
390 @$libs = grep { !(/DynaLoader\.a$/ && ($dynaloader = $_)) } @$libs
394 if ($^O eq 'MSWin32' && $Config{cc} =~ /^bcc/i) {
395 # BC++ cmd line syntax does not allow space between -[oexz...] and arg
396 $args =~ s/(^|\s+)-([oe])\s+/$1-$2/g;
399 my $ccflags = $Config{ccflags};
400 $ccflags .= ' -DUSEIMPORTLIB' if $^O eq 'cygwin';
401 my $cccmd = "$Config{cc} $ccflags $optimize $incdir "
402 ."$args $dynaloader $linkargs @$libs";
404 _print ("$cccmd\n", 36);
408 sub _getSharedObjects
410 my ($sourceprog) = @_;
411 my ($tmpfile, $incfile);
412 my (@sharedobjects, @libraries);
416 ($tmpprog = $sourceprog) =~ s"(.*)[\\/](.*)"$2";
418 my $tempdir= File::Spec->tmpdir;
420 $tmpfile = "$tempdir/$tmpprog.tst";
421 $incfile = "$tempdir/$tmpprog.val";
423 my $fd = new FileHandle("> $tmpfile") || die "Couldn't open $tmpfile!\n";
425 new FileHandle("$sourceprog") || die "Couldn't open $sourceprog!\n";
429 my \$fh3 = new FileHandle("> $incfile")
430 || die "Couldn't open $incfile\\n";
433 foreach \$key (keys(\%INC)) { print \$fh3 "\$key:\$INC{\$key}\\n"; }
438 print $fd ( <$fd2> );
441 _print("$^X -I@INC $tmpfile\n", 36);
442 _run("$^X -I@INC $tmpfile", 9 );
444 $fd = new FileHandle ("$incfile");
455 foreach $line (@lines)
459 my ($modname, $modpath) = split(':', $line);
460 my ($dir, $file) = ($modpath=~ m"(.*)[\\/]($modname)");
462 if ($autolib = _lookforAuto($dir, $file)) { push(@return, $autolib); }
471 # if ($Config{'osname'} eq 'MSWin32')
472 # { $return = "C:\\TEMP\\comp$$.p"; }
474 # { $return = "/tmp/comp$$.p"; }
476 $return = "comp$$.p";
478 my $fd = new FileHandle( "> $return") || die "Couldn't open $return!\n";
479 print $fd $options->{'e'};
488 my ($dir, $file) = @_;
490 my ($relabs, $relshared);
493 my $sharedextension = $^O =~ /MSWin32|cygwin|os2/i
494 ? $Config{_a} : ".$Config{so}";
495 ($prefix = $file) =~ s"(.*)\.pm"$1";
497 my ($tmp, $modname) = ($prefix =~ m"(?:(.*)[\\/]){0,1}(.*)"s);
499 $relshared = "$pathsep$prefix$pathsep$modname$sharedextension";
500 $relabs = "$pathsep$prefix$pathsep$modname$Config{_a}";
501 # HACK . WHY DOES _a HAVE A '.'
504 my @searchpaths = map("$_${pathsep}auto", @INC);
507 foreach $path (@searchpaths)
509 if (-e ($return = "$path$relshared")) { return($return); }
510 if (-e ($return = "$path$relabs")) { return($return); }
515 sub _getRegexps # make the appropriate regexps for making executables,
518 my ($program_ext, $module_ext) = ([],[]);
521 @$program_ext = ($ENV{PERL_SCRIPT_EXT})? split(':', $ENV{PERL_SCRIPT_EXT}) :
522 ('.p$', '.pl$', '.bat$');
525 @$module_ext = ($ENV{PERL_MODULE_EXT})? split(':', $ENV{PERL_MODULE_EXT}) :
528 _mungeRegexp( $program_ext );
529 _mungeRegexp( $module_ext );
531 return($program_ext, $module_ext);
538 grep(s:(^|[^\\])\.:$1\x00\\.:g, @$regexp);
539 grep(s:(^|[^\x00])\\\.:$1\.:g, @$regexp);
540 grep(s:\x00::g, @$regexp);
545 my ($type, @args) = @_;
547 if ($type eq 'equal')
550 if ($args[0] eq $args[1])
552 _print ("ERROR: The object file '$args[0]' does not generate a legitimate executable file! Skipping!\n", -1);
556 elsif ($type eq 'badeval')
560 _print ("ERROR: $args[0]\n", -1);
564 elsif ($type eq 'noextension')
566 my $progext = join(',', @{$args[1]});
567 my $modext = join(',', @{$args[2]});
578 ERROR: '$args[0]' does not have a proper extension! Proper extensions are:
581 SHARED OBJECT: $modext
583 Use the '-prog' flag to force your files to be interpreted as programs.
584 Use the '-mod' flag to force your files to be interpreted as modules.
598 if ($options->{'log'})
600 $_fh = new FileHandle(">> $options->{'log'}") || push(@errors, "ERROR: Couldn't open $options->{'log'}\n");
603 if ($options->{'b'} && $options->{'c'})
606 "ERROR: The '-b' and '-c' options are incompatible. The '-c' option specifies
607 a name for the intermediate C code but '-b' generates byte code
610 if ($options->{'b'} && ($options->{'sav'} || $options->{'gen'}))
613 "ERROR: The '-sav' and '-gen' options are incompatible with the '-b' option.
614 They ask for intermediate C code to be saved by '-b' generates byte
618 if (($options->{'c'}) && (@ARGV > 1) && ($options->{'sav'} ))
621 "ERROR: The '-sav' and '-C' options are incompatible when you have more than
622 one input file! ('-C' explicitly names resulting C code, '-sav' saves it,
623 and hence, with more than one file, the c code will be overwritten for
624 each file that you compile)\n");
626 if (($options->{'o'}) && (@ARGV > 1))
629 "ERROR: The '-o' option is incompatible when you have more than one input
630 file! (-o explicitly names the resulting file, hence, with more than
631 one file the names clash)\n");
634 if ($options->{'e'} && ($options->{'sav'} || $options->{'gen'}) &&
638 "ERROR: You need to specify where you are going to save the resulting
639 C code when using '-sav' and '-e'. Use '-C'.\n");
642 if (($options->{'regex'} || $options->{'run'} || $options->{'o'})
643 && $options->{'gen'})
646 "ERROR: The options '-regex', '-run', and '-o' are incompatible with '-gen'.
647 '-gen' says to stop at C generation, and the other three modify the
648 compilation and/or running process!\n");
651 if ($options->{'run'} && $options->{'mod'})
654 "ERROR: Can't run modules that you are compiling! '-run' and '-mod' are
658 if ($options->{'e'} && @ARGV)
661 "ERROR: The option '-e' needs to be all by itself without any other
664 if ($options->{'e'} && !($options->{'o'} || $options->{'run'}))
666 $options->{'run'} = 1;
669 if (!defined($options->{'verbose'}))
671 $options->{'verbose'} = ($options->{'log'})? 64 : 7;
676 if ($options->{'verbose'} =~ m"[^tagfcd]" &&
677 !( $options->{'verbose'} eq '0' ||
678 ($options->{'verbose'} < 64 && $options->{'verbose'} > 0)))
682 "ERROR: Illegal verbosity level. Needs to have either the letters
683 't','a','g','f','c', or 'd' in it or be between 0 and 63, inclusive.\n");
686 $options->{'verbose'} = ($options->{'verbose'} =~ m"[tagfcd]")?
687 ($options->{'verbose'} =~ m"d") * 32 +
688 ($options->{'verbose'} =~ m"c") * 16 +
689 ($options->{'verbose'} =~ m"f") * 8 +
690 ($options->{'verbose'} =~ m"t") * 4 +
691 ($options->{'verbose'} =~ m"a") * 2 +
692 ($options->{'verbose'} =~ m"g") * 1
693 : $options->{'verbose'};
695 if (!$verbose_error && ( $options->{'log'} &&
697 ($options->{'verbose'} & 8) ||
698 ($options->{'verbose'} & 16) ||
699 ($options->{'verbose'} & 32 )
705 "ERROR: The verbosity level '$options->{'verbose'}' does not output anything
706 to a logfile, and you specified '-log'!\n");
709 if (!$verbose_error && ( !$options->{'log'} &&
711 ($options->{'verbose'} & 8) ||
712 ($options->{'verbose'} & 16) ||
713 ($options->{'verbose'} & 32) ||
714 ($options->{'verbose'} & 64)
720 "ERROR: The verbosity level '$options->{'verbose'}' requires that you also
721 specify a logfile via '-log'\n");
725 (_print( "\n". join("\n", @errors), -1), return(0)) if (@errors);
731 my ($text, $flag ) = @_;
733 my $logflag = int($flag/8) * 8;
734 my $regflag = $flag % 8;
736 if ($flag == -1 || ($flag & $options->{'verbose'}))
738 my $dolog = ((($logflag & $options->{'verbose'}) || $flag == -1)
739 && $options->{'log'});
741 my $doreg = (($regflag & $options->{'verbose'}) || $flag == -1);
743 if ($doreg) { print( STDERR $text ); }
744 if ($dolog) { print $_fh $text; }
750 my ($command, $flag) = @_;
752 my $logflag = ($flag != -1)? int($flag/8) * 8 : 0;
753 my $regflag = $flag % 8;
755 if ($flag == -1 || ($flag & $options->{'verbose'}))
757 my $dolog = ($logflag & $options->{'verbose'} && $options->{'log'});
758 my $doreg = (($regflag & $options->{'verbose'}) || $flag == -1);
760 if ($doreg && !$dolog)
762 print _interruptrun("$command");
764 elsif ($doreg && $dolog)
766 my $text = _interruptrun($command);
772 my $text = _interruptrun($command);
778 _interruptrun($command);
786 my $pid = open (FD, "$command |");
788 local($SIG{HUP}) = sub {
790 # HACK... 2>&1 doesn't propogate
791 # kill, comment out for quick and dirty
792 # process killing of child.
797 local($SIG{INT}) = sub {
799 # HACK... 2>&1 doesn't propogate
800 # kill, comment out for quick and dirty
801 # process killing of child.
807 ($ENV{'PERLCC_TIMEOUT'} &&
808 $Config{'osname'} ne 'MSWin32' && $command =~ m"^perlc");
813 local($SIG{ALRM}) = sub { die "INFINITE LOOP"; };
814 alarm($ENV{'PERLCC_TIMEOUT'}) if ($needalarm);
815 $text = join('', <FD>);
816 alarm(0) if ($needalarm);
821 eval { kill 'HUP', $pid; };
822 _print("SYSTEM TIMEOUT (infinite loop?)\n", 36);
835 Usage: $0 <file_list>
837 WARNING: The whole compiler suite ('perlcc' included) is considered VERY
838 experimental. Use for production purposes is strongly discouraged.
841 -L < extra library dirs for installation (form of 'dir1:dir2') >
842 -I < extra include dirs for installation (form of 'dir1:dir2') >
843 -C < explicit name of resulting C code >
844 -o < explicit name of resulting executable >
845 -e < to compile 'one liners'. Need executable name (-o) or '-run'>
846 -regex < rename regex, -regex 's/\.p/\.exe/' compiles a.p to a.exe >
847 -verbose < verbose level < 1-63, or following letters 'gatfcd' >
848 -argv < arguments for the executables to be run via '-run' or '-e' >
851 -b ( to generate byte code )
852 -opt ( to generated optimised C code. May not work in some cases. )
853 -gen ( to just generate the C code. Implies '-sav' )
854 -sav ( to save intermediate C code, (and executables with '-run'))
855 -run ( to run the compiled program on the fly, as were interpreted.)
856 -prog ( to indicate that the files on command line are programs )
857 -mod ( to indicate that the files on command line are modules )
871 perlcc - frontend for perl compiler
875 %prompt perlcc a.p # compiles into executable 'a'
877 %prompt perlcc A.pm # compile into 'A.so'
879 %prompt perlcc a.p -o execute # compiles 'a.p' into 'execute'.
881 %prompt perlcc a.p -o execute -run # compiles 'a.p' into execute, runs on
884 %prompt perlcc a.p -o execute -run -argv 'arg1 arg2 arg3'
885 # compiles into execute, runs with
886 # arg1 arg2 arg3 as @ARGV
888 %prompt perlcc a.p b.p c.p -regex 's/\.p/\.exe'
889 # compiles into 'a.exe','b.exe','c.exe'.
891 %prompt perlcc a.p -log compilelog # compiles into 'a', saves compilation
892 # info into compilelog, as well
893 # as mirroring to screen
895 %prompt perlcc a.p -log compilelog -verbose cdf
896 # compiles into 'a', saves compilation
897 # info into compilelog, being silent
900 %prompt perlcc a.p -C a.c -gen # generates C code (into a.c) and
901 # stops without compile.
903 %prompt perlcc a.p -L ../lib a.c
904 # Compiles with the perl libraries
905 # inside ../lib included.
909 'perlcc' is the frontend into the perl compiler. Typing 'perlcc a.p'
910 compiles the code inside a.p into a standalone executable, and
911 perlcc A.pm will compile into a shared object, A.so, suitable for inclusion
912 into a perl program via "use A".
914 There are quite a few flags to perlcc which help with such issues as compiling
915 programs in bulk, testing compiled programs for compatibility with the
916 interpreter, and controlling.
922 =item -L < library_directories >
924 Adds directories in B<library_directories> to the compilation command.
926 =item -I < include_directories >
928 Adds directories inside B<include_directories> to the compilation command.
930 =item -C < c_code_name >
932 Explicitly gives the name B<c_code_name> to the generated file containing
933 the C code which is to be compiled. Can only be used if compiling one file
936 =item -o < executable_name >
938 Explicitly gives the name B<executable_name> to the executable which is to be
939 compiled. Can only be used if compiling one file on the command line.
941 =item -e < perl_line_to_execute>
943 Compiles 'one liners', in the same way that B<perl -e> runs text strings at
944 the command line. Default is to have the 'one liner' be compiled, and run all
945 in one go (see B<-run>); giving the B<-o> flag saves the resultant executable,
946 rather than throwing it away. Use '-argv' to pass arguments to the executable
951 Generates bytecode instead of C code.
955 Uses the optimized C backend (C<B::CC>)rather than the simple C backend
956 (C<B::C>). Beware that the optimized C backend creates very large
957 switch structures and structure initializations. Many C compilers
958 find it a challenge to compile the resulting output in finite amounts
959 of time. Many Perl features such as C<goto LABEL> are also not
960 supported by the optimized C backend. The simple C backend should
961 work in more instances, but can only offer modest speed increases.
963 =item -regex <rename_regex>
965 Gives a rule B<rename_regex> - which is a legal perl regular expression - to
966 create executable file names.
968 =item -verbose <verbose_level>
970 Show exactly what steps perlcc is taking to compile your code. You can
971 change the verbosity level B<verbose_level> much in the same way that
972 the C<-D> switch changes perl's debugging level, by giving either a
973 number which is the sum of bits you want or a list of letters
974 representing what you wish to see. Here are the verbosity levels so
977 Bit 1(g): Code Generation Errors to STDERR
978 Bit 2(a): Compilation Errors to STDERR
979 Bit 4(t): Descriptive text to STDERR
980 Bit 8(f): Code Generation Errors to file (B<-log> flag needed)
981 Bit 16(c): Compilation Errors to file (B<-log> flag needed)
982 Bit 32(d): Descriptive text to file (B<-log> flag needed)
984 If the B<-log> tag is given, the default verbose level is 63 (ie: mirroring
985 all of perlcc's output to both the screen and to a log file). If no B<-log>
986 tag is given, then the default verbose level is 7 (ie: outputting all of
987 perlcc's output to STDERR).
989 NOTE: Because of buffering concerns, you CANNOT shadow the output of '-run' to
990 both a file, and to the screen! Suggestions are welcome on how to overcome this
991 difficulty, but for now it simply does not work properly, and hence will only go
996 Opens, for append, a logfile to save some or all of the text for a given
997 compile command. No rewrite version is available, so this needs to be done
1000 =item -argv <arguments>
1002 In combination with C<-run> or C<-e>, tells perlcc to run the resulting
1003 executable with the string B<arguments> as @ARGV.
1007 Tells perl to save the intermediate C code. Usually, this C code is the name
1008 of the perl code, plus '.c'; 'perlcode.p' gets generated in 'perlcode.p.c',
1009 for example. If used with the C<-e> operator, you need to tell perlcc where to
1010 save resulting executables.
1014 Tells perlcc to only create the intermediate C code, and not compile the
1015 results. Does an implicit B<-sav>, saving the C code rather than deleting it.
1019 Immediately run the perl code that has been generated. NOTE: IF YOU GIVE THE
1020 B<-run> FLAG TO B<perlcc>, THEN THE REST OF @ARGV WILL BE INTERPRETED AS
1021 ARGUMENTS TO THE PROGRAM THAT YOU ARE COMPILING.
1025 Indicate that the programs at the command line are programs, and should be
1026 compiled as such. B<perlcc> will automatically determine files to be
1027 programs if they have B<.p>, B<.pl>, B<.bat> extensions.
1031 Indicate that the programs at the command line are modules, and should be
1032 compiled as such. B<perlcc> will automatically determine files to be
1033 modules if they have the extension B<.pm>.
1039 Most of the work of B<perlcc> is done at the command line. However, you can
1040 change the heuristic which determines what is a module and what is a program.
1041 As indicated above, B<perlcc> assumes that the extensions:
1043 .p$, .pl$, and .bat$
1045 indicate a perl program, and:
1049 indicate a library, for the purposes of creating executables. And furthermore,
1050 by default, these extensions will be replaced (and dropped) in the process of
1051 creating an executable.
1053 To change the extensions which are programs, and which are modules, set the
1054 environmental variables:
1059 These two environmental variables take colon-separated, legal perl regular
1060 expressions, and are used by perlcc to decide which objects are which.
1063 setenv PERL_SCRIPT_EXT '.prl$:.perl$'
1064 prompt% perlcc sample.perl
1066 will compile the script 'sample.perl' into the executable 'sample', and
1068 setenv PERL_MODULE_EXT '.perlmod$:.perlmodule$'
1070 prompt% perlcc sample.perlmod
1072 will compile the module 'sample.perlmod' into the shared object
1075 NOTE: the '.' in the regular expressions for PERL_SCRIPT_EXT and PERL_MODULE_EXT
1076 is a literal '.', and not a wild-card. To get a true wild-card, you need to
1077 backslash the '.'; as in:
1079 setenv PERL_SCRIPT_EXT '\.\.\.\.\.'
1081 which would have the effect of compiling ANYTHING (except what is in
1082 PERL_MODULE_EXT) into an executable with 5 less characters in its name.
1084 The PERLCC_OPTS environment variable can be set to the default flags
1085 that must be used by the compiler.
1087 The PERLCC_TIMEOUT environment variable can be set to the number of
1088 seconds to wait for the backends before giving up. This is sometimes
1089 necessary to avoid some compilers taking forever to compile the
1090 generated output. May not work on Windows and similar platforms.
1094 'perlcc' uses a temporary file when you use the B<-e> option to evaluate
1095 text and compile it. This temporary file is 'perlc$$.p'. The temporary C code is
1096 perlc$$.p.c, and the temporary executable is perlc$$.
1098 When you use '-run' and don't save your executable, the temporary executable is
1103 The whole compiler suite (C<perlcc> included) should be considered very
1104 experimental. Use for production purposes is strongly discouraged.
1106 perlcc currently cannot compile shared objects on Win32. This should be fixed
1109 Bugs in the various compiler backends still exist, and are perhaps too
1110 numerous to list here.
1116 close OUT or die "Can't close $file: $!";
1117 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
1118 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';