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