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.

177 lines
3.8 KiB

  1. # This File keeps the contents of miniperlmain.c.
  2. #
  3. # It was generated automatically by minimod.PL from the contents
  4. # of miniperlmain.c. Don't edit this file!
  5. #
  6. # ANY CHANGES MADE HERE WILL BE LOST!
  7. #
  8. package ExtUtils::Miniperl;
  9. require Exporter;
  10. @ISA = qw(Exporter);
  11. @EXPORT = qw(&writemain);
  12. $head= <<'EOF!HEAD';
  13. /*
  14. * "The Road goes ever on and on, down from the door where it began."
  15. */
  16. #ifdef OEMVS
  17. #pragma runopts(HEAP(1M,32K,ANYWHERE,KEEP,8K,4K))
  18. #endif
  19. #include "EXTERN.h"
  20. #include "perl.h"
  21. static void xs_init _((void));
  22. static PerlInterpreter *my_perl;
  23. #if defined (__MINT__) || defined (atarist)
  24. /* The Atari operating system doesn't have a dynamic stack. The
  25. stack size is determined from this value. */
  26. long _stksize = 64 * 1024;
  27. #endif
  28. int
  29. main(int argc, char **argv, char **env)
  30. {
  31. int exitstatus;
  32. #ifdef PERL_GLOBAL_STRUCT
  33. #define PERLVAR(var,type) /**/
  34. #define PERLVARI(var,type,init) PL_Vars.var = init;
  35. #define PERLVARIC(var,type,init) PL_Vars.var = init;
  36. #include "perlvars.h"
  37. #undef PERLVAR
  38. #undef PERLVARI
  39. #undef PERLVARIC
  40. #endif
  41. PERL_SYS_INIT(&argc,&argv);
  42. perl_init_i18nl10n(1);
  43. if (!PL_do_undump) {
  44. my_perl = perl_alloc();
  45. if (!my_perl)
  46. exit(1);
  47. perl_construct( my_perl );
  48. PL_perl_destruct_level = 0;
  49. }
  50. exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL );
  51. if (!exitstatus) {
  52. exitstatus = perl_run( my_perl );
  53. }
  54. perl_destruct( my_perl );
  55. perl_free( my_perl );
  56. PERL_SYS_TERM();
  57. exit( exitstatus );
  58. return exitstatus;
  59. }
  60. /* Register any extra external extensions */
  61. EOF!HEAD
  62. $tail=<<'EOF!TAIL';
  63. static void
  64. xs_init(void)
  65. {
  66. }
  67. EOF!TAIL
  68. sub writemain{
  69. my(@exts) = @_;
  70. my($pname);
  71. my($dl) = canon('/','DynaLoader');
  72. print $head;
  73. foreach $_ (@exts){
  74. my($pname) = canon('/', $_);
  75. my($mname, $cname);
  76. ($mname = $pname) =~ s!/!::!g;
  77. ($cname = $pname) =~ s!/!__!g;
  78. print "EXTERN_C void boot_${cname} _((CV* cv));\n";
  79. }
  80. my ($tail1,$tail2) = ( $tail =~ /\A(.*\n)(\s*\}.*)\Z/s );
  81. print $tail1;
  82. print "\tchar *file = __FILE__;\n";
  83. print "\tdXSUB_SYS;\n" if $] > 5.002;
  84. foreach $_ (@exts){
  85. my($pname) = canon('/', $_);
  86. my($mname, $cname, $ccode);
  87. ($mname = $pname) =~ s!/!::!g;
  88. ($cname = $pname) =~ s!/!__!g;
  89. print "\t{\n";
  90. if ($pname eq $dl){
  91. # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
  92. # boot_DynaLoader is called directly in DynaLoader.pm
  93. $ccode = "\t/* DynaLoader is a special case */\n
  94. \tnewXS(\"${mname}::boot_${cname}\", boot_${cname}, file);\n";
  95. print $ccode unless $SEEN{$ccode}++;
  96. } else {
  97. $ccode = "\tnewXS(\"${mname}::bootstrap\", boot_${cname}, file);\n";
  98. print $ccode unless $SEEN{$ccode}++;
  99. }
  100. print "\t}\n";
  101. }
  102. print $tail2;
  103. }
  104. sub canon{
  105. my($as, @ext) = @_;
  106. foreach(@ext){
  107. # might be X::Y or lib/auto/X/Y/Y.a
  108. next if s!::!/!g;
  109. s:^(lib|ext)/(auto/)?::;
  110. s:/\w+\.\w+$::;
  111. }
  112. grep(s:/:$as:, @ext) if ($as ne '/');
  113. @ext;
  114. }
  115. 1;
  116. __END__
  117. =head1 NAME
  118. ExtUtils::Miniperl, writemain - write the C code for perlmain.c
  119. =head1 SYNOPSIS
  120. C<use ExtUtils::Miniperl;>
  121. C<writemain(@directories);>
  122. =head1 DESCRIPTION
  123. This whole module is written when perl itself is built from a script
  124. called minimod.PL. In case you want to patch it, please patch
  125. minimod.PL in the perl distribution instead.
  126. writemain() takes an argument list of directories containing archive
  127. libraries that relate to perl modules and should be linked into a new
  128. perl binary. It writes to STDOUT a corresponding perlmain.c file that
  129. is a plain C file containing all the bootstrap code to make the
  130. modules associated with the libraries available from within perl.
  131. The typical usage is from within a Makefile generated by
  132. ExtUtils::MakeMaker. So under normal circumstances you won't have to
  133. deal with this module directly.
  134. =head1 SEE ALSO
  135. L<ExtUtils::MakeMaker>
  136. =cut