home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C / Applications / MacPerl 5.0.3 / MacPerl Source ƒ / Perl5 / writemain.test < prev    next >
Encoding:
Text File  |  1995-10-13  |  1.4 KB  |  58 lines  |  [TEXT/MPS ]

  1. #!perl
  2. # This script takes the plain miniperlmain.c and writes out perlmain.c
  3. # which includes all the extensions.
  4. # The command line arguments name extensions to be used.
  5. #  E.g.:  miniperl writemain SDBM_File POSIX > perlmain.c
  6. #
  7.  
  8. foreach (@ARGV) {
  9.     s/\.o$//; s/\.o\.PPC$//; s/\.o\.68K$//; s/\.xcoff$//;
  10.     s/ext:(.*):[^:]*/$1/ && next;
  11.     s/.*:(.*)/$1/;
  12. }
  13.  
  14. if ($#ARGV > -1) {
  15.     print "    char *file = __FILE__;\n";
  16.     $ai = "";
  17.     
  18.     foreach $ext (@ARGV) {
  19.         ($mname = $ext) =~ s!/!::!g;
  20.         ($cname = $mname) =~ s!:!_!g;
  21.         
  22.         print "    {   extern void boot_${cname} _((CV* cv));\n";
  23.         
  24.         if ($ext eq "DynaLoader") {
  25.              # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
  26.              # boot_DynaLoader is called directly in DynaLoader.pm
  27.              print "        newXS(\"${mname}::boot_${ext}\", boot_${cname}, file);\n";
  28.         } else {
  29.              print "        newXS(\"${mname}::bootstrap\", boot_${cname}, file);\n";
  30.         }
  31.         
  32.         if (opendir(AUTOINIT, ":ext:$ext:")) {
  33.             while ($auto = readdir(AUTOINIT)) {
  34.                 next unless ($auto =~ /^AutoInit\./i);
  35.                 open(AI, ":ext:$ext:$auto");
  36.                 if ($auto =~ /\.c$/) {
  37.                     print "    /* autoinit code from $aifile follows: */\n";
  38.                     print "    {\n";
  39.                     while (<AI>) {
  40.                         print;
  41.                     }
  42.                     print "    }\n";
  43.                 } elsif ($auto =~ /\.pl$/) {
  44.                     while (<AI>) {
  45.                         chop;
  46.                         $ai .= $_ . " ";
  47.                     }
  48.                 }
  49.             }
  50.         }
  51.         print "    }\n";
  52.     }
  53.     if ($ai ne "") {
  54.         print "    autoboot_preamble = \"BEGIN { $ai }\";\n"
  55.     }
  56. }
  57. print "}\n";
  58.