5 unshift @INC, '../lib';
11 open(my $fh,">embed_test.c") || die "Cannot open embed_test.c:$!";
17 my $cc = $Config{'cc'};
18 my $cl = ($^O eq 'MSWin32' && $cc eq 'cl');
19 my $exe = 'embed_test' . $Config{'exe_ext'};
20 my $obj = 'embed_test' . $Config{'obj_ext'} if $^O eq 'VMS';
21 my $inc = File::Spec->catdir($INC[0],"..");
22 my $lib = File::Spec->catdir($INC[0],"..");
24 my (@cmd2) if $^O eq 'VMS';
27 push(@cmd,$cc,"/Obj=$obj");
30 if ($crazy =~ s#/inc[^=/]*=([\w\$\_\-\.\[\]\:]+)##i) {
33 if ($crazy =~ s/-I([a-zA-Z0-9\$\_\-\.\[\]\:]*)//) {
36 $crazy =~ s#/Obj[^=/]*=[\w\$\_\-\.\[\]\:]+##i;
37 push(@cmd,"/Include=(".join(',',@incs).")");
39 push(@cmd,"embed_test.c");
41 push(@cmd2,$Config{'ld'}, $Config{'ldflags'}, "/exe=$exe");
42 push(@cmd2,"$obj,[-]perlshr.opt/opt,[-]perlshr_attr.opt/opt");
46 push(@cmd,$cc,"-Fe$exe");
49 push(@cmd,$cc,'-o' => $exe);
51 push(@cmd,"-I$inc",ccopts(),'embed_test.c');
52 if ($^O eq 'MSWin32') {
53 $inc = File::Spec->catdir($inc,'win32');
55 $inc = File::Spec->catdir($inc,'include');
58 push(@cmd,'-link',"-libpath:$lib",$Config{'libperl'},$Config{'libc'});
61 push(@cmd,"-L$lib",File::Spec->catfile($lib,$Config{'libperl'}),$Config{'libc'});
65 push(@cmd,"-L$lib",'-lperl');
68 local $SIG{__WARN__} = sub {
69 warn $_[0] unless $_[0] =~ /No library found for -lperl/
74 if ($^O eq 'aix') { # AIX needs an explicit symbol export list.
75 my ($perl_exp) = grep { -f } qw(perl.exp ../perl.exp);
76 die "where is perl.exp?\n" unless defined $perl_exp;
78 s!-bE:(\S+)!-bE:$perl_exp!;
83 my $display_cmd = "@cmd";
84 chomp($display_cmd); # where is the newline coming from? ldopts()?
85 print "# $display_cmd\n";
86 $status = system(join(' ',@cmd));
87 if ($^O eq 'VMS' && !$status) {
89 $status = system(join(' ',@cmd2));
91 print (($status? 'not ': '')."ok 1\n");
93 my $embed_test = File::Spec->catfile(File::Spec->curdir, "embed_test");
94 $embed_test = "run/nodebug $exe" if $^O eq 'VMS';
96 $status = system($embed_test);
97 print (($status? 'not ':'')."ok 9\n");
98 unlink($exe,"embed_test.c");
99 unlink($obj,"embed_test.map","embed_test.lis") if $^O eq 'VMS'
101 # gcc -g -I.. -L../ -o perl_test perl_test.c -lperl `../perl -I../lib -MExtUtils::Embed -I../ -e ccopts -e ldopts`
110 #define my_puts(a) if(puts(a) < 0) exit(666)
112 char *cmds[] = { "perl","-e", "print qq[ok 5\\n]", NULL };
114 int main(int argc, char **argv, char **env)
116 PerlInterpreter *my_perl = perl_alloc();
120 perl_construct(my_perl);
124 perl_parse(my_perl, NULL, (sizeof(cmds)/sizeof(char *))-1, cmds, env);
134 perl_destruct(my_perl);