home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _e4cff1b4b426f9df5debbb95da7fa21c < prev    next >
Text File  |  2004-06-01  |  6KB  |  213 lines

  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.  
  9.  
  10. package ExtUtils::Miniperl;
  11. require Exporter;
  12. @ISA = qw(Exporter);
  13. @EXPORT = qw(&writemain);
  14.  
  15. $head= <<'EOF!HEAD';
  16. /*    miniperlmain.c
  17.  *
  18.  *    Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002,
  19.  *    by Larry Wall and others
  20.  *
  21.  *    You may distribute under the terms of either the GNU General Public
  22.  *    License or the Artistic License, as specified in the README file.
  23.  *
  24.  */
  25.  
  26. /*
  27.  * "The Road goes ever on and on, down from the door where it began."
  28.  */
  29.  
  30. #ifdef OEMVS
  31. #ifdef MYMALLOC
  32. /* sbrk is limited to first heap segement so make it big */
  33. #pragma runopts(HEAP(8M,500K,ANYWHERE,KEEP,8K,4K) STACK(,,ANY,) ALL31(ON))
  34. #else
  35. #pragma runopts(HEAP(2M,500K,ANYWHERE,KEEP,8K,4K) STACK(,,ANY,) ALL31(ON))
  36. #endif
  37. #endif
  38.  
  39.  
  40. #include "EXTERN.h"
  41. #define PERL_IN_MINIPERLMAIN_C
  42. #include "perl.h"
  43.  
  44. static void xs_init (pTHX);
  45. static PerlInterpreter *my_perl;
  46.  
  47. #if defined (__MINT__) || defined (atarist)
  48. /* The Atari operating system doesn't have a dynamic stack.  The
  49.    stack size is determined from this value.  */
  50. long _stksize = 64 * 1024;
  51. #endif
  52.  
  53. int
  54. main(int argc, char **argv, char **env)
  55. {
  56.     int exitstatus;
  57.  
  58. #ifdef PERL_GLOBAL_STRUCT
  59. #define PERLVAR(var,type) /**/
  60. #define PERLVARA(var,type) /**/
  61. #define PERLVARI(var,type,init) PL_Vars.var = init;
  62. #define PERLVARIC(var,type,init) PL_Vars.var = init;
  63. #include "perlvars.h"
  64. #undef PERLVAR
  65. #undef PERLVARA
  66. #undef PERLVARI
  67. #undef PERLVARIC
  68. #endif
  69.  
  70.     /* if user wants control of gprof profiling off by default */
  71.     /* noop unless Configure is given -Accflags=-DPERL_GPROF_CONTROL */
  72.     PERL_GPROF_MONCONTROL(0);
  73.  
  74.     PERL_SYS_INIT3(&argc,&argv,&env);
  75.  
  76. #if defined(USE_5005THREADS) || defined(USE_ITHREADS)
  77.     /* XXX Ideally, this should really be happening in perl_alloc() or
  78.      * perl_construct() to keep libperl.a transparently fork()-safe.
  79.      * It is currently done here only because Apache/mod_perl have
  80.      * problems due to lack of a call to cancel pthread_atfork()
  81.      * handlers when shared objects that contain the handlers may
  82.      * be dlclose()d.  This forces applications that embed perl to
  83.      * call PTHREAD_ATFORK() explicitly, but if and only if it hasn't
  84.      * been called at least once before in the current process.
  85.      * --GSAR 2001-07-20 */
  86.     PTHREAD_ATFORK(Perl_atfork_lock,
  87.                    Perl_atfork_unlock,
  88.                    Perl_atfork_unlock);
  89. #endif
  90.  
  91.     if (!PL_do_undump) {
  92.     my_perl = perl_alloc();
  93.     if (!my_perl)
  94.         exit(1);
  95.     perl_construct(my_perl);
  96.     PL_perl_destruct_level = 0;
  97.     }
  98.     PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
  99.     exitstatus = perl_parse(my_perl, xs_init, argc, argv, (char **)NULL);
  100.     if (!exitstatus)
  101.         perl_run(my_perl);
  102.       
  103.     exitstatus = perl_destruct(my_perl);
  104.  
  105.     perl_free(my_perl);
  106.  
  107.     PERL_SYS_TERM();
  108.  
  109.     exit(exitstatus);
  110.     return exitstatus;
  111. }
  112.  
  113. /* Register any extra external extensions */
  114.  
  115. EOF!HEAD
  116. $tail=<<'EOF!TAIL';
  117.  
  118. static void
  119. xs_init(pTHX)
  120. {
  121. }
  122. EOF!TAIL
  123.  
  124. sub writemain{
  125.     my(@exts) = @_;
  126.  
  127.     my($pname);
  128.     my($dl) = canon('/','DynaLoader');
  129.     print $head;
  130.  
  131.     foreach $_ (@exts){
  132.     my($pname) = canon('/', $_);
  133.     my($mname, $cname);
  134.     ($mname = $pname) =~ s!/!::!g;
  135.     ($cname = $pname) =~ s!/!__!g;
  136.         print "EXTERN_C void boot_${cname} (pTHX_ CV* cv);\n";
  137.     }
  138.  
  139.     my ($tail1,$tail2) = ( $tail =~ /\A(.*\n)(\s*\}.*)\Z/s );
  140.     print $tail1;
  141.  
  142.     print "\tchar *file = __FILE__;\n";
  143.     print "\tdXSUB_SYS;\n" if $] > 5.002;
  144.  
  145.     foreach $_ (@exts){
  146.     my($pname) = canon('/', $_);
  147.     my($mname, $cname, $ccode);
  148.     ($mname = $pname) =~ s!/!::!g;
  149.     ($cname = $pname) =~ s!/!__!g;
  150.     print "\t{\n";
  151.     if ($pname eq $dl){
  152.         # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
  153.         # boot_DynaLoader is called directly in DynaLoader.pm
  154.         $ccode = "\t/* DynaLoader is a special case */\n
  155. \tnewXS(\"${mname}::boot_${cname}\", boot_${cname}, file);\n";
  156.         print $ccode unless $SEEN{$ccode}++;
  157.     } else {
  158.         $ccode = "\tnewXS(\"${mname}::bootstrap\", boot_${cname}, file);\n";
  159.         print $ccode unless $SEEN{$ccode}++;
  160.     }
  161.     print "\t}\n";
  162.     }
  163.     print $tail2;
  164. }
  165.  
  166. sub canon{
  167.     my($as, @ext) = @_;
  168.     foreach(@ext){
  169.         # might be X::Y or lib/auto/X/Y/Y.a
  170.         next if s!::!/!g;
  171.         s:^(lib|ext)/(auto/)?::;
  172.         s:/\w+\.\w+$::;
  173.     }
  174.     grep(s:/:$as:, @ext) if ($as ne '/');
  175.     @ext;
  176. }
  177.  
  178. 1;
  179. __END__
  180.  
  181. =head1 NAME
  182.  
  183. ExtUtils::Miniperl, writemain - write the C code for perlmain.c
  184.  
  185. =head1 SYNOPSIS
  186.  
  187. C<use ExtUtils::Miniperl;>
  188.  
  189. C<writemain(@directories);>
  190.  
  191. =head1 DESCRIPTION
  192.  
  193. This whole module is written when perl itself is built from a script
  194. called minimod.PL. In case you want to patch it, please patch
  195. minimod.PL in the perl distribution instead.
  196.  
  197. writemain() takes an argument list of directories containing archive
  198. libraries that relate to perl modules and should be linked into a new
  199. perl binary. It writes to STDOUT a corresponding perlmain.c file that
  200. is a plain C file containing all the bootstrap code to make the
  201. modules associated with the libraries available from within perl.
  202.  
  203. The typical usage is from within a Makefile generated by
  204. ExtUtils::MakeMaker. So under normal circumstances you won't have to
  205. deal with this module directly.
  206.  
  207. =head1 SEE ALSO
  208.  
  209. L<ExtUtils::MakeMaker>
  210.  
  211. =cut
  212.  
  213.