Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

919 lines
26 KiB

  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. goto endofperl
  11. @rem ';
  12. #!perl
  13. #line 14
  14. eval 'exec P:\Apps\ActivePerl\temp\bin\MSWin32-x86-object\perl.exe -S $0 ${1+"$@"}'
  15. if $running_under_some_shell;
  16. use Config;
  17. use strict;
  18. use FileHandle;
  19. use File::Basename qw(&basename &dirname);
  20. use Cwd;
  21. use Getopt::Long;
  22. $Getopt::Long::bundling_override = 1;
  23. $Getopt::Long::passthrough = 0;
  24. $Getopt::Long::ignore_case = 0;
  25. my $options = {};
  26. my $_fh;
  27. main();
  28. sub main
  29. {
  30. GetOptions
  31. (
  32. $options, "L:s",
  33. "I:s",
  34. "C:s",
  35. "o:s",
  36. "e:s",
  37. "regex:s",
  38. "verbose:s",
  39. "log:s",
  40. "argv:s",
  41. "gen",
  42. "sav",
  43. "run",
  44. "prog",
  45. "mod"
  46. );
  47. my $key;
  48. local($") = "|";
  49. _usage() if (!_checkopts());
  50. push(@ARGV, _maketempfile()) if ($options->{'e'});
  51. _usage() if (!@ARGV);
  52. my $file;
  53. foreach $file (@ARGV)
  54. {
  55. _print("
  56. --------------------------------------------------------------------------------
  57. Compiling $file:
  58. --------------------------------------------------------------------------------
  59. ", 36 );
  60. _doit($file);
  61. }
  62. }
  63. sub _doit
  64. {
  65. my ($file) = @_;
  66. my ($program_ext, $module_ext) = _getRegexps();
  67. my ($obj, $objfile, $so, $type);
  68. if (
  69. (($file =~ m"@$program_ext") && ($file !~ m"@$module_ext"))
  70. || (defined($options->{'prog'}) || defined($options->{'run'}))
  71. )
  72. {
  73. $objfile = ($options->{'C'}) ? $options->{'C'} : "$file.c";
  74. $type = 'program';
  75. $obj = ($options->{'o'})? $options->{'o'} :
  76. _getExecutable( $file,$program_ext);
  77. return() if (!$obj);
  78. }
  79. elsif (($file =~ m"@$module_ext") || ($options->{'mod'}))
  80. {
  81. die "Shared objects are not supported on Win32 yet!!!!\n"
  82. if ($Config{'osname'} eq 'MSWin32');
  83. $obj = ($options->{'o'})? $options->{'o'} :
  84. _getExecutable($file, $module_ext);
  85. $so = "$obj.$Config{so}";
  86. $type = 'sharedlib';
  87. return() if (!$obj);
  88. $objfile = ($options->{'C'}) ? $options->{'C'} : "$file.c";
  89. }
  90. else
  91. {
  92. _error("noextension", $file, $program_ext, $module_ext);
  93. return();
  94. }
  95. if ($type eq 'program')
  96. {
  97. _print("Making C($objfile) for $file!\n", 36 );
  98. my $errcode = _createCode($objfile, $file);
  99. (_print( "ERROR: In generating code for $file!\n", -1), return())
  100. if ($errcode);
  101. _print("Compiling C($obj) for $file!\n", 36 ) if (!$options->{'gen'});
  102. $errcode = _compileCode($file, $objfile, $obj)
  103. if (!$options->{'gen'});
  104. if ($errcode)
  105. {
  106. _print( "ERROR: In compiling code for $objfile !\n", -1);
  107. my $ofile = File::Basename::basename($objfile);
  108. $ofile =~ s"\.c$"\.o"s;
  109. _removeCode("$ofile");
  110. return()
  111. }
  112. _runCode($obj) if ($options->{'run'});
  113. _removeCode($objfile) if (!$options->{'sav'} ||
  114. ($options->{'e'} && !$options->{'C'}));
  115. _removeCode($file) if ($options->{'e'});
  116. _removeCode($obj) if (($options->{'e'}
  117. && !$options->{'sav'}
  118. && !$options->{'o'})
  119. || ($options->{'run'} && !$options->{'sav'}));
  120. }
  121. else
  122. {
  123. _print( "Making C($objfile) for $file!\n", 36 );
  124. my $errcode = _createCode($objfile, $file, $obj);
  125. (_print( "ERROR: In generating code for $file!\n", -1), return())
  126. if ($errcode);
  127. _print( "Compiling C($so) for $file!\n", 36 ) if (!$options->{'gen'});
  128. my $errorcode =
  129. _compileCode($file, $objfile, $obj, $so ) if (!$options->{'gen'});
  130. (_print( "ERROR: In compiling code for $objfile!\n", -1), return())
  131. if ($errcode);
  132. }
  133. }
  134. sub _getExecutable
  135. {
  136. my ($sourceprog, $ext) = @_;
  137. my ($obj);
  138. if (defined($options->{'regex'}))
  139. {
  140. eval("(\$obj = \$sourceprog) =~ $options->{'regex'}");
  141. return(0) if (_error('badeval', $@));
  142. return(0) if (_error('equal', $obj, $sourceprog));
  143. }
  144. elsif (defined ($options->{'ext'}))
  145. {
  146. ($obj = $sourceprog) =~ s"@$ext"$options->{ext}"g;
  147. return(0) if (_error('equal', $obj, $sourceprog));
  148. }
  149. elsif (defined ($options->{'run'}))
  150. {
  151. $obj = "perlc$$";
  152. }
  153. else
  154. {
  155. ($obj = $sourceprog) =~ s"@$ext""g;
  156. return(0) if (_error('equal', $obj, $sourceprog));
  157. }
  158. return($obj);
  159. }
  160. sub _createCode
  161. {
  162. my ( $generated_cfile, $file, $final_output ) = @_;
  163. my $return;
  164. local($") = " -I";
  165. if (@_ == 2) # compiling a program
  166. {
  167. _print( "$^X -I@INC -MO=CC,-o$generated_cfile $file\n", 36);
  168. $return = _run("$ -I@INC -MO=CC,-o$generated_cfile $file", 9);
  169. $return;
  170. }
  171. else # compiling a shared object
  172. {
  173. _print(
  174. "$ -I@INC -MO=CC,-m$final_output,-o$generated_cfile $file\n", 36);
  175. $return =
  176. _run("$ -I@INC -MO=CC,-m$final_output,-o$generated_cfile $file", 9);
  177. $return;
  178. }
  179. }
  180. sub _compileCode
  181. {
  182. my ($sourceprog, $generated_cfile, $output_executable, $shared_object) = @_;
  183. my @return;
  184. if (@_ == 3) # just compiling a program
  185. {
  186. $return[0] =
  187. _ccharness('static', $sourceprog, "-o", $output_executable, $generated_cfile);
  188. $return[0];
  189. }
  190. else
  191. {
  192. my $object_file = $generated_cfile;
  193. $object_file =~ s"\.c$"$Config{_o}";
  194. $return[0] = _ccharness('compile', $sourceprog, "-c", $generated_cfile);
  195. $return[1] = _ccharness
  196. (
  197. 'dynamic',
  198. $sourceprog, "-o",
  199. $shared_object, $object_file
  200. );
  201. return(1) if (grep ($_, @return));
  202. return(0);
  203. }
  204. }
  205. sub _runCode
  206. {
  207. my ($executable) = @_;
  208. _print("$executable $options->{'argv'}\n", 36);
  209. _run("$executable $options->{'argv'}", -1 );
  210. }
  211. sub _removeCode
  212. {
  213. my ($file) = @_;
  214. unlink($file) if (-e $file);
  215. }
  216. sub _ccharness
  217. {
  218. my $type = shift;
  219. my (@args) = @_;
  220. local($") = " ";
  221. my $sourceprog = shift(@args);
  222. my ($libdir, $incdir);
  223. if (-d "$Config{installarchlib}/CORE")
  224. {
  225. $libdir = "-L$Config{installarchlib}/CORE";
  226. $incdir = "-I$Config{installarchlib}/CORE";
  227. }
  228. else
  229. {
  230. $libdir = "-L.. -L.";
  231. $incdir = "-I.. -I.";
  232. }
  233. $libdir .= " -L$options->{L}" if (defined($options->{L}));
  234. $incdir .= " -I$options->{L}" if (defined($options->{L}));
  235. my $linkargs = '';
  236. if (!grep(/^-[cS]$/, @args))
  237. {
  238. my $lperl = $^O eq 'os2' ? '-llibperl' : '-lperl';
  239. my $flags = $type eq 'dynamic' ? $Config{lddlflags} : $Config{ldflags};
  240. $linkargs = "$flags $libdir $lperl @Config{libs}";
  241. }
  242. my @sharedobjects = _getSharedObjects($sourceprog);
  243. my $cccmd =
  244. "$Config{cc} @Config{qw(ccflags optimize)} $incdir @sharedobjects @args $linkargs";
  245. _print ("$cccmd\n", 36);
  246. _run("$cccmd", 18 );
  247. }
  248. sub _getSharedObjects
  249. {
  250. my ($sourceprog) = @_;
  251. my ($tmpfile, $incfile);
  252. my (@return);
  253. local($") = " -I";
  254. if ($Config{'osname'} eq 'MSWin32')
  255. {
  256. # _addstuff;
  257. }
  258. else
  259. {
  260. my ($tmpprog);
  261. ($tmpprog = $sourceprog) =~ s"(.*)[\/\\](.*)"$2";
  262. $tmpfile = "/tmp/$tmpprog.tst";
  263. $incfile = "/tmp/$tmpprog.val";
  264. }
  265. my $fd = new FileHandle("> $tmpfile") || die "Couldn't open $tmpfile!\n";
  266. my $fd2 =
  267. new FileHandle("$sourceprog") || die "Couldn't open $sourceprog!\n";
  268. my $perl = <$fd2>; # strip off header;
  269. print $fd
  270. <<"EOF";
  271. use FileHandle;
  272. my \$fh3 = new FileHandle("> $incfile")
  273. || die "Couldn't open $incfile\\n";
  274. my \$key;
  275. foreach \$key (keys(\%INC)) { print \$fh3 "\$key:\$INC{\$key}\\n"; }
  276. close(\$fh3);
  277. exit();
  278. EOF
  279. print $fd ( <$fd2> );
  280. close($fd);
  281. _print("$ -I@INC $tmpfile\n", 36);
  282. _run("$ -I@INC $tmpfile", 9 );
  283. $fd = new FileHandle ("$incfile");
  284. my @lines = <$fd>;
  285. unlink($tmpfile);
  286. unlink($incfile);
  287. my $line;
  288. my $autolib;
  289. foreach $line (@lines)
  290. {
  291. chomp($line);
  292. my ($modname, $modpath) = split(':', $line);
  293. my ($dir, $file) = ($modpath=~ m"(.*)[\\/]($modname)");
  294. if ($autolib = _lookforAuto($dir, $file))
  295. {
  296. push(@return, $autolib);
  297. }
  298. }
  299. return(@return);
  300. }
  301. sub _maketempfile
  302. {
  303. my $return;
  304. # if ($Config{'osname'} eq 'MSWin32')
  305. # { $return = "C:\\TEMP\\comp$$.p"; }
  306. # else
  307. # { $return = "/tmp/comp$$.p"; }
  308. $return = "comp$$.p";
  309. my $fd = new FileHandle( "> $return") || die "Couldn't open $return!\n";
  310. print $fd $options->{'e'};
  311. close($fd);
  312. return($return);
  313. }
  314. sub _lookforAuto
  315. {
  316. my ($dir, $file) = @_;
  317. my $relshared;
  318. my $return;
  319. ($relshared = $file) =~ s"(.*)\.pm"$1";
  320. my ($tmp, $modname) = ($relshared =~ m"(?:(.*)[\\/]){0,1}(.*)"s);
  321. $relshared .=
  322. ($Config{'osname'} eq 'MSWin32')? "\\$modname.dll" : "/$modname.so";
  323. if (-e ($return = "$Config{'installarchlib'}/auto/$relshared") )
  324. {
  325. return($return);
  326. }
  327. elsif (-e ($return = "$Config{'installsitearch'}/auto/$relshared"))
  328. {
  329. return($return);
  330. }
  331. elsif (-e ($return = "$dir/arch/auto/$relshared"))
  332. {
  333. return($return);
  334. }
  335. else
  336. {
  337. return(undef);
  338. }
  339. }
  340. sub _getRegexps # make the appropriate regexps for making executables,
  341. { # shared libs
  342. my ($program_ext, $module_ext) = ([],[]);
  343. @$program_ext = ($ENV{PERL_SCRIPT_EXT})? split(':', $ENV{PERL_SCRIPT_EXT}) :
  344. ('.p$', '.pl$', '.bat$');
  345. @$module_ext = ($ENV{PERL_MODULE_EXT})? split(':', $ENV{PERL_MODULE_EXT}) :
  346. ('.pm$');
  347. _mungeRegexp( $program_ext );
  348. _mungeRegexp( $module_ext );
  349. return($program_ext, $module_ext);
  350. }
  351. sub _mungeRegexp
  352. {
  353. my ($regexp) = @_;
  354. grep(s:(^|[^\\])\.:$1\x00\\.:g, @$regexp);
  355. grep(s:(^|[^\x00])\\\.:$1\.:g, @$regexp);
  356. grep(s:\x00::g, @$regexp);
  357. }
  358. sub _error
  359. {
  360. my ($type, @args) = @_;
  361. if ($type eq 'equal')
  362. {
  363. if ($args[0] eq $args[1])
  364. {
  365. _print ("ERROR: The object file '$args[0]' does not generate a legitimate executable file! Skipping!\n", -1);
  366. return(1);
  367. }
  368. }
  369. elsif ($type eq 'badeval')
  370. {
  371. if ($args[0])
  372. {
  373. _print ("ERROR: $args[0]\n", -1);
  374. return(1);
  375. }
  376. }
  377. elsif ($type eq 'noextension')
  378. {
  379. my $progext = join(',', @{$args[1]});
  380. my $modext = join(',', @{$args[2]});
  381. $progext =~ s"\\""g;
  382. $modext =~ s"\\""g;
  383. $progext =~ s"\$""g;
  384. $modext =~ s"\$""g;
  385. _print
  386. (
  387. "
  388. ERROR: '$args[0]' does not have a proper extension! Proper extensions are:
  389. PROGRAM: $progext
  390. SHARED OBJECT: $modext
  391. Use the '-prog' flag to force your files to be interpreted as programs.
  392. Use the '-mod' flag to force your files to be interpreted as modules.
  393. ", -1
  394. );
  395. return(1);
  396. }
  397. return(0);
  398. }
  399. sub _checkopts
  400. {
  401. my @errors;
  402. local($") = "\n";
  403. if ($options->{'log'})
  404. {
  405. $_fh = new FileHandle(">> $options->{'log'}") || push(@errors, "ERROR: Couldn't open $options->{'log'}\n");
  406. }
  407. if (($options->{'c'}) && (@ARGV > 1) && ($options->{'sav'} ))
  408. {
  409. push(@errors,
  410. "ERROR: The '-sav' and '-C' options are incompatible when you have more than
  411. one input file! ('-C' explicitly names resulting C code, '-sav' saves it,
  412. and hence, with more than one file, the c code will be overwritten for
  413. each file that you compile)\n");
  414. }
  415. if (($options->{'o'}) && (@ARGV > 1))
  416. {
  417. push(@errors,
  418. "ERROR: The '-o' option is incompatible when you have more than one input file!
  419. (-o explicitly names the resulting executable, hence, with more than
  420. one file the names clash)\n");
  421. }
  422. if ($options->{'e'} && $options->{'sav'} && !$options->{'o'} &&
  423. !$options->{'C'})
  424. {
  425. push(@errors,
  426. "ERROR: You need to specify where you are going to save the resulting
  427. executable or C code, when using '-sav' and '-e'. Use '-o' or '-C'.\n");
  428. }
  429. if (($options->{'regex'} || $options->{'run'} || $options->{'o'})
  430. && $options->{'gen'})
  431. {
  432. push(@errors,
  433. "ERROR: The options '-regex', '-run', and '-o' are incompatible with '-gen'.
  434. '-gen' says to stop at C generation, and the other three modify the
  435. compilation and/or running process!\n");
  436. }
  437. if ($options->{'run'} && $options->{'mod'})
  438. {
  439. push(@errors,
  440. "ERROR: Can't run modules that you are compiling! '-run' and '-mod' are
  441. incompatible!\n");
  442. }
  443. if ($options->{'e'} && @ARGV)
  444. {
  445. push (@errors,
  446. "ERROR: The option '-e' needs to be all by itself without any other
  447. file arguments!\n");
  448. }
  449. if ($options->{'e'} && !($options->{'o'} || $options->{'run'}))
  450. {
  451. $options->{'run'} = 1;
  452. }
  453. if (!defined($options->{'verbose'}))
  454. {
  455. $options->{'verbose'} = ($options->{'log'})? 64 : 7;
  456. }
  457. my $verbose_error;
  458. if ($options->{'verbose'} =~ m"[^tagfcd]" &&
  459. !( $options->{'verbose'} eq '0' ||
  460. ($options->{'verbose'} < 64 && $options->{'verbose'} > 0)))
  461. {
  462. $verbose_error = 1;
  463. push(@errors,
  464. "ERROR: Illegal verbosity level. Needs to have either the letters
  465. 't','a','g','f','c', or 'd' in it or be between 0 and 63, inclusive.\n");
  466. }
  467. $options->{'verbose'} = ($options->{'verbose'} =~ m"[tagfcd]")?
  468. ($options->{'verbose'} =~ m"d") * 32 +
  469. ($options->{'verbose'} =~ m"c") * 16 +
  470. ($options->{'verbose'} =~ m"f") * 8 +
  471. ($options->{'verbose'} =~ m"t") * 4 +
  472. ($options->{'verbose'} =~ m"a") * 2 +
  473. ($options->{'verbose'} =~ m"g") * 1
  474. : $options->{'verbose'};
  475. if (!$verbose_error && ( $options->{'log'} &&
  476. !(
  477. ($options->{'verbose'} & 8) ||
  478. ($options->{'verbose'} & 16) ||
  479. ($options->{'verbose'} & 32 )
  480. )
  481. )
  482. )
  483. {
  484. push(@errors,
  485. "ERROR: The verbosity level '$options->{'verbose'}' does not output anything
  486. to a logfile, and you specified '-log'!\n");
  487. } # }
  488. if (!$verbose_error && ( !$options->{'log'} &&
  489. (
  490. ($options->{'verbose'} & 8) ||
  491. ($options->{'verbose'} & 16) ||
  492. ($options->{'verbose'} & 32) ||
  493. ($options->{'verbose'} & 64)
  494. )
  495. )
  496. )
  497. {
  498. push(@errors,
  499. "ERROR: The verbosity level '$options->{'verbose'}' requires that you also
  500. specify a logfile via '-log'\n");
  501. } # }
  502. (_print( "\n". join("\n", @errors), -1), return(0)) if (@errors);
  503. return(1);
  504. }
  505. sub _print
  506. {
  507. my ($text, $flag ) = @_;
  508. my $logflag = int($flag/8) * 8;
  509. my $regflag = $flag % 8;
  510. if ($flag == -1 || ($flag & $options->{'verbose'}))
  511. {
  512. my $dolog = ((($logflag & $options->{'verbose'}) || $flag == -1)
  513. && $options->{'log'});
  514. my $doreg = (($regflag & $options->{'verbose'}) || $flag == -1);
  515. if ($doreg) { print( STDERR $text ); }
  516. if ($dolog) { print $_fh $text; }
  517. }
  518. }
  519. sub _run
  520. {
  521. my ($command, $flag) = @_;
  522. my $logflag = ($flag != -1)? int($flag/8) * 8 : 0;
  523. my $regflag = $flag % 8;
  524. if ($flag == -1 || ($flag & $options->{'verbose'}))
  525. {
  526. my $dolog = ($logflag & $options->{'verbose'} && $options->{'log'});
  527. my $doreg = (($regflag & $options->{'verbose'}) || $flag == -1);
  528. if ($doreg && !$dolog)
  529. { system("$command"); }
  530. elsif ($doreg && $dolog)
  531. { my $text = `$command 2>&1`; print $_fh $text; print STDERR $text;}
  532. else
  533. { my $text = `$command 2>&1`; print $_fh $text; }
  534. }
  535. else
  536. {
  537. `$command 2>&1`;
  538. }
  539. return($?);
  540. }
  541. sub _usage
  542. {
  543. _print
  544. (
  545. <<"EOF"
  546. Usage: $0 <file_list>
  547. Flags with arguments
  548. -L < extra library dirs for installation (form of 'dir1:dir2') >
  549. -I < extra include dirs for installation (form of 'dir1:dir2') >
  550. -C < explicit name of resulting C code >
  551. -o < explicit name of resulting executable >
  552. -e < to compile 'one liners'. Need executable name (-o) or '-run'>
  553. -regex < rename regex, -regex 's/\.p/\.exe/' compiles a.p to a.exe >
  554. -verbose < verbose level (1-63, or following letters 'gatfcd' >
  555. -argv < arguments for the executables to be run via '-run' or '-e' >
  556. Boolean flags
  557. -gen ( to just generate the c code. Implies '-sav' )
  558. -sav ( to save intermediate c code, (and executables with '-run'))
  559. -run ( to run the compiled program on the fly, as were interpreted.)
  560. -prog ( to indicate that the files on command line are programs )
  561. -mod ( to indicate that the files on command line are modules )
  562. EOF
  563. , -1
  564. );
  565. exit(255);
  566. }
  567. __END__
  568. =head1 NAME
  569. perlcc - frontend for perl compiler
  570. =head1 SYNOPSIS
  571. %prompt perlcc a.p # compiles into executable 'a'
  572. %prompt perlcc A.pm # compile into 'A.so'
  573. %prompt perlcc a.p -o execute # compiles 'a.p' into 'execute'.
  574. %prompt perlcc a.p -o execute -run # compiles 'a.p' into execute, runs on
  575. # the fly
  576. %prompt perlcc a.p -o execute -run -argv 'arg1 arg2 arg3'
  577. # compiles into execute, runs with
  578. # arg1 arg2 arg3 as @ARGV
  579. %prompt perlcc a.p b.p c.p -regex 's/\.p/\.exe'
  580. # compiles into 'a.exe','b.exe','c.exe'.
  581. %prompt perlcc a.p -log compilelog # compiles into 'a', saves compilation
  582. # info into compilelog, as well
  583. # as mirroring to screen
  584. %prompt perlcc a.p -log compilelog -verbose cdf
  585. # compiles into 'a', saves compilation
  586. # info into compilelog, being silent
  587. # on screen.
  588. %prompt perlcc a.p -C a.c -gen # generates C code (into a.c) and
  589. # stops without compile.
  590. %prompt perlcc a.p -L ../lib a.c
  591. # Compiles with the perl libraries
  592. # inside ../lib included.
  593. =head1 DESCRIPTION
  594. 'perlcc' is the frontend into the perl compiler. Typing 'perlcc a.p'
  595. compiles the code inside a.p into a standalone executable, and
  596. perlcc A.pm will compile into a shared object, A.so, suitable for inclusion
  597. into a perl program via "use A".
  598. There are quite a few flags to perlcc which help with such issues as compiling
  599. programs in bulk, testing compiled programs for compatibility with the
  600. interpreter, and controlling.
  601. =head1 OPTIONS
  602. =over 4
  603. =item -L < library_directories >
  604. Adds directories in B<library_directories> to the compilation command.
  605. =item -I < include_directories >
  606. Adds directories inside B<include_directories> to the compilation command.
  607. =item -C < c_code_name >
  608. Explicitly gives the name B<c_code_name> to the generated c code which is to
  609. be compiled. Can only be used if compiling one file on the command line.
  610. =item -o < executable_name >
  611. Explicitly gives the name B<executable_name> to the executable which is to be
  612. compiled. Can only be used if compiling one file on the command line.
  613. =item -e < perl_line_to_execute>
  614. Compiles 'one liners', in the same way that B<perl -e> runs text strings at
  615. the command line. Default is to have the 'one liner' be compiled, and run all
  616. in one go (see B<-run>); giving the B<-o> flag saves the resultant executable,
  617. rather than throwing it away. Use '-argv' to pass arguments to the executable
  618. created.
  619. =item -regex <rename_regex>
  620. Gives a rule B<rename_regex> - which is a legal perl regular expression - to
  621. create executable file names.
  622. =item -verbose <verbose_level>
  623. Show exactly what steps perlcc is taking to compile your code. You can change
  624. the verbosity level B<verbose_level> much in the same way that the '-D' switch
  625. changes perl's debugging level, by giving either a number which is the sum of
  626. bits you want or a list of letters representing what you wish to see. Here are
  627. the verbosity levels so far :
  628. Bit 1(g): Code Generation Errors to STDERR
  629. Bit 2(a): Compilation Errors to STDERR
  630. Bit 4(t): Descriptive text to STDERR
  631. Bit 8(f): Code Generation Errors to file (B<-log> flag needed)
  632. Bit 16(c): Compilation Errors to file (B<-log> flag needed)
  633. Bit 32(d): Descriptive text to file (B<-log> flag needed)
  634. If the B<-log> tag is given, the default verbose level is 63 (ie: mirroring
  635. all of perlcc's output to both the screen and to a log file). If no B<-log>
  636. tag is given, then the default verbose level is 7 (ie: outputting all of
  637. perlcc's output to STDERR).
  638. NOTE: Because of buffering concerns, you CANNOT shadow the output of '-run' to
  639. both a file, and to the screen! Suggestions are welcome on how to overcome this
  640. difficulty, but for now it simply does not work properly, and hence will only go
  641. to the screen.
  642. =item -log <logname>
  643. Opens, for append, a logfile to save some or all of the text for a given
  644. compile command. No rewrite version is available, so this needs to be done
  645. manually.
  646. =item -argv <arguments>
  647. In combination with '-run' or '-e', tells perlcc to run the resulting
  648. executable with the string B<arguments> as @ARGV.
  649. =item -sav
  650. Tells perl to save the intermediate C code. Usually, this C code is the name
  651. of the perl code, plus '.c'; 'perlcode.p' gets generated in 'perlcode.p.c',
  652. for example. If used with the '-e' operator, you need to tell perlcc where to
  653. save resulting executables.
  654. =item -gen
  655. Tells perlcc to only create the intermediate C code, and not compile the
  656. results. Does an implicit B<-sav>, saving the C code rather than deleting it.
  657. =item -run
  658. Immediately run the perl code that has been generated. NOTE: IF YOU GIVE THE
  659. B<-run> FLAG TO B<perlcc>, THEN THE REST OF @ARGV WILL BE INTERPRETED AS
  660. ARGUMENTS TO THE PROGRAM THAT YOU ARE COMPILING.
  661. =item -prog
  662. Indicate that the programs at the command line are programs, and should be
  663. compiled as such. B<perlcc> will automatically determine files to be
  664. programs if they have B<.p>, B<.pl>, B<.bat> extensions.
  665. =item -mod
  666. Indicate that the programs at the command line are modules, and should be
  667. compiled as such. B<perlcc> will automatically determine files to be
  668. modules if they have the extension B<.pm>.
  669. =back
  670. =head1 ENVIRONMENT
  671. Most of the work of B<perlcc> is done at the command line. However, you can
  672. change the heuristic which determines what is a module and what is a program.
  673. As indicated above, B<perlcc> assumes that the extensions:
  674. .p$, .pl$, and .bat$
  675. indicate a perl program, and:
  676. .pm$
  677. indicate a library, for the purposes of creating executables. And furthermore,
  678. by default, these extensions will be replaced (and dropped ) in the process of
  679. creating an executable.
  680. To change the extensions which are programs, and which are modules, set the
  681. environmental variables:
  682. PERL_SCRIPT_EXT
  683. PERL_MODULE_EXT
  684. These two environmental variables take colon-separated, legal perl regular
  685. expressions, and are used by perlcc to decide which objects are which.
  686. For example:
  687. setenv PERL_SCRIPT_EXT '.prl$:.perl$'
  688. prompt% perlcc sample.perl
  689. will compile the script 'sample.perl' into the executable 'sample', and
  690. setenv PERL_MODULE_EXT '.perlmod$:.perlmodule$'
  691. prompt% perlcc sample.perlmod
  692. will compile the module 'sample.perlmod' into the shared object
  693. 'sample.so'
  694. NOTE: the '.' in the regular expressions for PERL_SCRIPT_EXT and PERL_MODULE_EXT
  695. is a literal '.', and not a wild-card. To get a true wild-card, you need to
  696. backslash the '.'; as in:
  697. setenv PERL_SCRIPT_EXT '\.\.\.\.\.'
  698. which would have the effect of compiling ANYTHING (except what is in
  699. PERL_MODULE_EXT) into an executable with 5 less characters in its name.
  700. =head1 FILES
  701. 'perlcc' uses a temporary file when you use the B<-e> option to evaluate
  702. text and compile it. This temporary file is 'perlc$$.p'. The temporary C code is
  703. perlc$$.p.c, and the temporary executable is perlc$$.
  704. When you use '-run' and don't save your executable, the temporary executable is
  705. perlc$$
  706. =head1 BUGS
  707. perlcc currently cannot compile shared objects on Win32. This should be fixed
  708. by perl5.005.
  709. =cut
  710. __END__
  711. :endofperl