home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-05 | 1.8 KB | 82 lines | [TEXT/MPS ] |
- #!perl
- # This script takes the plain miniperlmain.c and writes out perlmain.c
- # which includes all the extensions.
- # The command line arguments name extensions to be used.
- # E.g.: miniperl writemain SDBM_File POSIX > perlmain.c
- #
-
- if ($ARGV[0] eq "-runperl") {
- $runperl = shift @ARGV;
- }
-
- foreach (@ARGV) {
- s/\.o$//; s/\.o\.PPC$//; s/\.o\.68K$//; s/\.xcoff$//;
- s/ext:(.*):[^:]*/$1/ && next;
- s/.*:(.*)/$1/;
- }
-
- open(MAIN, "miniperlmain.c") || die "Couldn't open miniperlmain.c: $!";
-
- while (<MAIN>) {
- s/(perl_destruct_level\s+=\s+)0/${1}2/ if $runperl;
- s/^main\(/run_perl\(/ if $runperl;
- last if /Do not delete this line--writemain depends on it/;
- print;
- }
-
- if ($#ARGV > -1) {
- print " char *file = __FILE__;\n";
- $ai = "";
-
- foreach $ext (@ARGV) {
- ($mname = $ext) =~ s!/!::!g;
- ($cname = $mname) =~ s!:!_!g;
-
- print " { extern void boot_${cname} _((CV* cv));\n";
-
- if ($ext eq "DynaLoader") {
- # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
- # boot_DynaLoader is called directly in DynaLoader.pm
- print " newXS(\"${mname}::boot_${ext}\", boot_${cname}, file);\n";
- } else {
- print " newXS(\"${mname}::bootstrap\", boot_${cname}, file);\n";
- }
-
- if (opendir(AUTOINIT, ":ext:$ext:")) {
- while ($auto = readdir(AUTOINIT)) {
- next unless ($auto =~ /^AutoInit\./i);
- open(AI, ":ext:$ext:$auto");
- if ($auto =~ /\.c$/) {
- print " /* autoinit code from $aifile follows: */\n";
- print " {\n";
- while (<AI>) {
- print;
- }
- print " }\n";
- } elsif ($auto =~ /\.pl$/) {
- while (<AI>) {
- chop;
- $ai .= $_ . " ";
- }
- }
- }
- }
- print " }\n";
- }
- if ($ai ne "") {
- print " autoboot_preamble = \"BEGIN { $ai }\";\n"
- }
- }
- print "}\n";
-
- if ($runperl) {
- print <<END_EXIT;
-
- #undef exit
-
- void (exit)(int status)
- {
- my_exit(status);
- }
- END_EXIT
- }