12 use ExtUtils::MakeMaker;
13 use ExtUtils::Constant qw (constant_types C_constant XS_constant autoload);
15 use File::Spec::Functions;
17 # Because were are going to be changing directory before running Makefile.PL
18 my $perl = File::Spec->rel2abs( $^X );
20 print "# perl=$perl\n";
21 my $runperl = "$perl \"-I../../lib\"";
28 print "# $dir being created...\n";
29 mkdir $dir, 0777 or die "mkdir: $!\n";
34 print "# $dir being removed...\n";
38 my @names = ("FIVE", {name=>"OK6", type=>"PV",},
39 {name=>"OK7", type=>"PVN",
40 value=>['"not ok 7\\n\\0ok 7\\n"', 15]},
41 {name => "FARTHING", type=>"NV"},
42 {name => "NOT_ZERO", type=>"UV", value=>"~(UV)0"});
44 my @names_only = map {(ref $_) ? $_->{name} : $_} @names;
46 my $package = "ExtTest";
47 ################ Header
48 my $header = catfile($dir, "test.h");
49 push @files, "test.h";
50 open FH, ">$header" or die "open >$header: $!\n";
58 close FH or die "close $header: $!\n";
61 my $xs = catfile($dir, "$package.xs");
62 push @files, "$package.xs";
63 open FH, ">$xs" or die "open >$xs: $!\n";
71 print FH "#include \"test.h\"\n\n";
72 print FH constant_types(); # macro defs
74 foreach (C_constant (undef, "IV", $types, undef, undef, @names) ) {
75 print FH $_, "\n"; # C constant subs
77 print FH "MODULE = $package PACKAGE = $package\n";
78 print FH "PROTOTYPES: ENABLE\n";
79 print FH XS_constant ($package, $types); # XS for ExtTest::constant
80 close FH or die "close $xs: $!\n";
83 my $pm = catfile($dir, "$package.pm");
84 push @files, "$package.pm";
85 open FH, ">$pm" or die "open >$pm: $!\n";
86 print FH "package $package;\n";
98 use vars qw ($VERSION @ISA @EXPORT_OK);
101 @ISA = qw(Exporter DynaLoader);
105 print FH "\t$_\n" foreach (@names_only);
107 print FH autoload ($package, $]);
108 print FH "bootstrap $package \$VERSION;\n1;\n__END__\n";
109 close FH or die "close $pm: $!\n";
111 ################ test.pl
112 my $testpl = catfile($dir, "test.pl");
113 push @files, "test.pl";
114 open FH, ">$testpl" or die "open >$testpl: $!\n";
116 print FH "use $package qw(@names_only);\n";
123 print "not ok 5 # $five\n";
132 my $farthing = FARTHING;
133 if ($farthing == 0.25) {
136 print "not ok 8 # $farthing\n";
139 my $not_zero = NOT_ZERO;
140 if ($not_zero > 0 && $not_zero == ~0) {
143 print "not ok 9 # \$not_zero=$not_zero ~0=" . (~0) . "\n";
149 close FH or die "close $testpl: $!\n";
151 ################ Makefile.PL
152 # Keep the dependancy in the Makefile happy
153 my $makefilePL = catfile($dir, "Makefile.PL");
154 push @files, "Makefile.PL";
155 open FH, ">$makefilePL" or die "open >$makefilePL: $!\n";
157 use ExtUtils::MakeMaker;
159 'NAME' => "$package",
160 'VERSION_FROM' => "$package.pm", # finds \$VERSION
162 (#ABSTRACT_FROM => "$package.pm", # XXX add this
163 AUTHOR => "$0") : ())
167 close FH or die "close $makefilePL: $!\n";
169 chdir $dir or die $!; push @INC, '../../lib';
170 END {chdir ".." or warn $!};
172 my @perlout = `$runperl Makefile.PL`;
174 print "not ok 1 # $runperl Makefile.PL failed: $?\n";
175 print "# $_" foreach @perlout;
182 my $makefile = ($^O eq 'VMS' ? 'descrip' : 'Makefile');
183 my $makefile_ext = ($^O eq 'VMS' ? '.mms' : '');
184 if (-f "$makefile$makefile_ext") {
189 my $makefile_rename = ($^O eq 'VMS' ? '.mms' : '.old');
190 push @files, "$makefile$makefile_rename"; # Renamed by make clean
192 my $make = $Config{make};
194 $make = $ENV{MAKE} if exists $ENV{MAKE};
198 print "# make = '$make'\n";
201 print "not ok 3 # $make failed: $?\n";
207 if ($Config{usedl}) {
210 push @files, "perl$Config{exe_ext}";
211 my $makeperl = "$make perl";
212 print "# make = '$makeperl'\n";
213 $makeout = `$makeperl`;
215 print "not ok 4 # $makeperl failed: $?\n";
222 my $maketest = "$make test";
223 print "# make = '$maketest'\n";
224 $makeout = `$maketest`;
226 print "not ok 10 # $maketest failed: $?\n";
229 $makeout =~ s/^\s*PERL_DL_NONLAZY=.+?\n//m;
232 $makeout =~ s/^\w*?make.+?(?:entering|leaving) directory.+?\n//mig;
234 # Hopefully gets most make's babblings
235 # make -f Makefile.aperl perl
236 $makeout =~ s/^\w*?make.+\sperl[^A-Za-z0-9]*\n//mig;
237 # make[1]: `perl' is up to date.
238 $makeout =~ s/^\w*?make.+perl.+?is up to date.*?\n//mig;
244 my $makeclean = "$make clean";
245 print "# make = '$makeclean'\n";
246 $makeout = `$makeclean`;
248 print "not ok 11 # $make failed: $?\n";
254 unlink $_ or warn "unlink $_: $!";
258 opendir DIR, "." or die "opendir '.': $!";
259 while (defined (my $entry = readdir DIR)) {
260 next if $entry =~ /^\.\.?$/;
261 print "# Extra file '$entry'\n";
264 closedir DIR or warn "closedir '.': $!";