12 use ExtUtils::MakeMaker;
13 use ExtUtils::Constant qw (constant_types C_constant XS_constant autoload);
22 print "# $dir being created...\n";
23 mkdir $dir, 0777 or die "mkdir: $!\n";
25 use File::Spec::Functions;
29 print "# $dir being removed...\n";
33 my @names = ("THREE", {name=>"OK4", type=>"PV",},
34 {name=>"OK5", type=>"PVN",
35 value=>['"not ok 5\\n\\0ok 5\\n"', 15]},
36 {name => "FARTHING", type=>"NV"},
37 {name => "NOT_ZERO", type=>"UV", value=>~0 . "u"});
39 my @names_only = map {(ref $_) ? $_->{name} : $_} @names;
41 my $package = "ExtTest";
42 ################ Header
43 my $header = catfile($dir, "test.h");
44 open FH, ">$header" or die "open >$header: $!\n";
52 close FH or die "close $header: $!\n";
55 my $xs = catfile($dir, "$package.xs");
56 open FH, ">$xs" or die "open >$xs: $!\n";
64 print FH "#include \"test.h\"\n\n";
65 print FH constant_types(); # macro defs
67 foreach (C_constant (undef, "IV", $types, undef, undef, @names) ) {
68 print FH $_, "\n"; # C constant subs
70 print FH "MODULE = $package PACKAGE = $package\n";
71 print FH "PROTOTYPES: ENABLE\n";
72 print FH XS_constant ($package, $types); # XS for ExtTest::constant
73 close FH or die "close $xs: $!\n";
76 my $pm = catfile($dir, "$package.pm");
77 open FH, ">$pm" or die "open >$pm: $!\n";
78 print FH "package $package;\n";
90 use vars qw ($VERSION @ISA @EXPORT_OK);
93 @ISA = qw(Exporter DynaLoader);
97 print FH "\t$_\n" foreach (@names_only);
99 print FH autoload ($package, $]);
100 print FH "bootstrap $package \$VERSION;\n1;\n__END__\n";
101 close FH or die "close $pm: $!\n";
103 ################ test.pl
104 my $testpl = catfile($dir, "test.pl");
105 open FH, ">$testpl" or die "open >$testpl: $!\n";
107 print FH "use $package qw(@names_only);\n";
114 print "not ok 3 # $three\n";
123 my $farthing = FARTHING;
124 if ($farthing == 0.25) {
127 print "not ok 6 # $farthing\n";
130 my $not_zero = NOT_ZERO;
131 if ($not_zero > 0 && $not_zero == ~0) {
134 print "not ok 7 # \$not_zero=$not_zero ~0=" . (~0) . "\n";
140 close FH or die "close $testpl: $!\n";
142 ################ dummy Makefile.PL
143 # Keep the dependancy in the Makefile happy
144 my $makefilePL = catfile($dir, "Makefile.PL");
145 open FH, ">$makefilePL" or die "open >$makefilePL: $!\n";
146 close FH or die "close $makefilePL: $!\n";
148 chdir $dir or die $!; push @INC, '../../lib';
149 END {chdir ".." or warn $!};
151 # Grr. MakeMaker hardwired to write its message to STDOUT.
155 'VERSION_FROM' => "$package.pm", # finds $VERSION
157 (#ABSTRACT_FROM => "$package.pm", # XXX add this
166 my $make = $Config{make};
168 $make = $ENV{MAKE} if exists $ENV{MAKE};
172 print "# make = '$make'\n";
175 print "not ok 2 # $make failed: $?\n";
182 print "# make = '$make'\n";
185 print "not ok 8 # $make failed: $?\n";
188 $makeout =~ s/^\s*PERL_DL_NONLAZY=.+?\n//m;
191 $makeout =~ s/^\w*?make.+?(?:entering|leaving) directory.+?\n//mig;