Use config.arch in OS/390 where the combination of
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / Embed.t
CommitLineData
f1feeb72 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 unshift @INC, '../lib';
6}
7use Config;
8use ExtUtils::Embed;
1091dea4 9use File::Spec;
f1feeb72 10
11open(my $fh,">embed_test.c") || die "Cannot open embed_test.c:$!";
12print $fh <DATA>;
13close($fh);
14
15$| = 1;
16print "1..9\n";
1091dea4 17my $cc = $Config{'cc'};
18my $cl = ($^O eq 'MSWin32' && $cc eq 'cl');
b1b2427f 19my $exe = 'embed_test' . $Config{'exe_ext'};
1091dea4 20my $inc = File::Spec->catdir($INC[0],"..");
21my $lib = File::Spec->catdir($INC[0],"..");
22my @cmd;
23if ($cl) {
24 push(@cmd,$cc,"-Fe$exe");
25}
26else {
27 push(@cmd,$cc,'-o' => $exe);
28}
29push(@cmd,"-I$inc",ccopts(),'embed_test.c');
30if ($^O eq 'MSWin32') {
b1b2427f 31 $inc = File::Spec->catdir($inc,'win32');
1091dea4 32 push(@cmd,"-I$inc");
b1b2427f 33 $inc = File::Spec->catdir($inc,'include');
1091dea4 34 push(@cmd,"-I$inc");
35 if ($cc eq 'cl') {
b1b2427f 36 push(@cmd,'-link',"-libpath:$lib",$Config{'libperl'},$Config{'libc'});
1091dea4 37 }
38 else {
67bfc918 39 push(@cmd,"-L$lib",File::Spec->catfile($lib,$Config{'libperl'}),$Config{'libc'});
1091dea4 40 }
41}
42else {
43 push(@cmd,"-L$lib",'-lperl');
44}
fee3faea 45{
46 local $SIG{__WARN__} = sub {
47 warn $_[0] unless $_[0] =~ /No library found for -lperl/
48 };
49 push(@cmd,ldopts());
50}
1091dea4 51
f490490f 52if ($^O eq 'aix') { # AIX needs an explicit symbol export list.
53 my ($perl_exp) = grep { -f } qw(perl.exp ../perl.exp);
54 die "where is perl.exp?\n" unless defined $perl_exp;
55 for (@cmd) {
56 s!-bE:(\S+)!-bE:$perl_exp!;
57 }
58}
59
94597104 60print "# @cmd"; # where is the newline coming from? ldopts()?
f1feeb72 61print "not " if system(join(' ',@cmd));
62print "ok 1\n";
3be77bcf 63
64my $embed_test = File::Spec->catfile(File::Spec->curdir, "embed_test");
65
66print "not " if system($embed_test);
f1feeb72 67print "ok 9\n";
94597104 68
b1b2427f 69unlink($exe,"embed_test.c");
f1feeb72 70
94597104 71# gcc -g -I.. -L../ -o perl_test perl_test.c -lperl `../perl -I../lib -MExtUtils::Embed -I../ -e ccopts -e ldopts`
f1feeb72 72
73__END__
74
75/* perl_test.c */
76
77#include <EXTERN.h>
78#include <perl.h>
79
80#define my_puts(a) if(puts(a) < 0) exit(666)
81
82char *cmds[] = { "perl","-e", "print qq[ok 5\\n]", NULL };
83
84int main(int argc, char **argv, char **env)
85{
86 PerlInterpreter *my_perl = perl_alloc();
87
88 my_puts("ok 2");
89
90 perl_construct(my_perl);
91
92 my_puts("ok 3");
93
94 perl_parse(my_perl, NULL, (sizeof(cmds)/sizeof(char *))-1, cmds, env);
95
96 my_puts("ok 4");
97
98 fflush(stdout);
99
100 perl_run(my_perl);
101
102 my_puts("ok 6");
103
104 perl_destruct(my_perl);
105
106 my_puts("ok 7");
107
108 perl_free(my_perl);
109
110 my_puts("ok 8");
111
112 return 0;
113}
114
115
116
117