12 use ExtUtils::MakeMaker;
13 use ExtUtils::Constant qw (constant_types C_constant XS_constant autoload);
17 my $tobitbucket = ">/dev/null";
22 mkdir $dir, 0777 or die $!;
25 system "$Config{rm} -rf $dir";
28 # push @cleanup, $dir;
30 my @names = ("THREE", {name=>"OK4", type=>"PV",},
31 {name=>"OK5", type=>"PVN",
32 value=>['"not ok 5\\n\\0ok 5\\n"', 15]},
33 {name => "FARTHING", type=>"NV"},
34 {name => "NOT_ZERO", type=>"UV", value=>~0 . "u"});
36 my @names_only = map {(ref $_) ? $_->{name} : $_} @names;
38 my $package = "ExtTest";
39 ################ Header
40 my $header = "$dir/test.h";
41 open FH, ">$header" or die $!;
50 # push @cleanup, $header;
53 my $xs = "$dir/$package.xs";
54 open FH, ">$xs" or die $!;
62 print FH "#include \"test.h\"\n\n";
63 print FH constant_types(); # macro defs
65 foreach (C_constant (undef, "IV", $types, undef, undef, @names) ) {
66 print FH $_, "\n"; # C constant subs
68 print FH "MODULE = $package PACKAGE = $package\n";
69 print FH "PROTOTYPES: ENABLE\n";
70 print FH XS_constant ($package, $types); # XS for ExtTest::constant
75 my $pm = "$dir/$package.pm";
76 open FH, ">$pm" or die $!;
77 print FH "package $package;\n";
89 use vars qw ($VERSION @ISA @EXPORT_OK);
92 @ISA = qw(Exporter DynaLoader);
96 print FH "\t$_\n" foreach (@names_only);
98 print FH autoload ($package, $]);
99 print FH "bootstrap $package \$VERSION;\n1;\n__END__\n";
101 # push @cleanup, $pm;
103 ################ test.pl
104 my $testpl = "$dir/test.pl";
105 open FH, ">$testpl" or die $!;
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";
141 # push @cleanup, $testpl;
143 ################ dummy Makefile.PL
144 # Keep the dependancy in the Makefile happy
145 my $makefilePL = "$dir/Makefile.PL";
146 open FH, ">$makefilePL" or die $!;
148 # push @cleanup, $makefilePL;
150 chdir $dir or die $!; push @INC, '../../lib';
151 END {chdir ".." or warn $!};
153 print "# "; # Grr. MakeMaker hardwired to write its message to STDOUT
156 'VERSION_FROM' => "$package.pm", # finds $VERSION
158 (#ABSTRACT_FROM => "$package.pm", # XXX add this
167 my $make = $Config{make};
168 $make = $ENV{MAKE} if exists $ENV{MAKE};
169 print "# make = '$make'\n";
170 if (system "$make $tobitbucket") {
171 print "not ok 2 # $make failed\n";
178 # This hack to get a # in front of "PERL_DL_NONLAZY=1 ..." isn't going to work
180 print "# make = '$make'\n# ";
182 print "not ok 8 # $make failed\n";