| 1 | // $Header: /cvsroot/swig/SWIG/Lib/perl5/perlmain.i,v 1.2 2003/09/01 18:13:33 beazley Exp $ |
| 2 | // Code to statically rebuild perl5. |
| 3 | // |
| 4 | |
| 5 | #ifdef AUTODOC |
| 6 | %subsection "perlmain.i" |
| 7 | %text %{ |
| 8 | This module provides support for building a new version of the |
| 9 | Perl executable. This will be necessary on systems that do |
| 10 | not support shared libraries and may be necessary with C++ |
| 11 | extensions. |
| 12 | |
| 13 | This module may only build a stripped down version of the |
| 14 | Perl executable. Thus, it may be necessary (or desirable) |
| 15 | to hand-edit this file for your particular application. To |
| 16 | do this, simply copy this file from swig_lib/perl5/perlmain.i |
| 17 | to your working directory and make the appropriate modifications. |
| 18 | |
| 19 | This library file works with Perl 5.003. It may work with earlier |
| 20 | versions, but it hasn't been tested. As far as I know, this |
| 21 | library is C++ safe. |
| 22 | %} |
| 23 | #endif |
| 24 | |
| 25 | %{ |
| 26 | |
| 27 | static void xs_init _((pTHX)); |
| 28 | static PerlInterpreter *my_perl; |
| 29 | |
| 30 | int perl_eval(char *string) { |
| 31 | char *argv[2]; |
| 32 | argv[0] = string; |
| 33 | argv[1] = (char *) 0; |
| 34 | return perl_call_argv("eval",0,argv); |
| 35 | } |
| 36 | |
| 37 | int |
| 38 | main(int argc, char **argv, char **env) |
| 39 | { |
| 40 | int exitstatus; |
| 41 | |
| 42 | my_perl = perl_alloc(); |
| 43 | if (!my_perl) |
| 44 | exit(1); |
| 45 | perl_construct( my_perl ); |
| 46 | |
| 47 | exitstatus = perl_parse( my_perl, xs_init, argc, argv, (char **) NULL ); |
| 48 | if (exitstatus) |
| 49 | exit( exitstatus ); |
| 50 | |
| 51 | /* Initialize all of the module variables */ |
| 52 | |
| 53 | exitstatus = perl_run( my_perl ); |
| 54 | |
| 55 | perl_destruct( my_perl ); |
| 56 | perl_free( my_perl ); |
| 57 | |
| 58 | exit( exitstatus ); |
| 59 | } |
| 60 | |
| 61 | /* Register any extra external extensions */ |
| 62 | |
| 63 | /* Do not delete this line--writemain depends on it */ |
| 64 | /* EXTERN_C void boot_DynaLoader _((CV* cv)); */ |
| 65 | |
| 66 | static void |
| 67 | xs_init(pTHX) |
| 68 | { |
| 69 | /* dXSUB_SYS; */ |
| 70 | char *file = __FILE__; |
| 71 | { |
| 72 | /* newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); */ |
| 73 | newXS(SWIG_name, SWIG_init, file); |
| 74 | #ifdef SWIGMODINIT |
| 75 | SWIGMODINIT |
| 76 | #endif |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | %} |