windows build fails if there is no perlglob.exe in the PATH
[p5sagit/p5-mst-13.2.git] / win32 / buildext.pl
CommitLineData
7e050124 1=head1 NAME
2
3buildext.pl - build extensions
4
5=head1 SYNOPSIS
6
7 buildext.pl make [-make_opts] dep directory [target]
8
9E.g.
10
11 buildext.pl nmake -nologo perldll.def ..\ext
12
13 buildext.pl nmake -nologo perldll.def ..\ext clean
14
15 buildext.pl dmake perldll.def ..\ext
16
17 buildext.pl dmake perldll.def ..\ext clean
18
19=cut
20
17af6fb0 21use File::Basename;
22use Cwd;
8e232993 23use FindExt;
17af6fb0 24my $here = getcwd();
25my $perl = $^X;
26$here =~ s,/,\\,g;
27if ($perl =~ m#^\.\.#)
28 {
29 $perl = "$here\\$perl";
30 }
200dcf2d 31(my $topdir = $perl) =~ s/\\[^\\]+$//;
32$ENV{PATH} = "$topdir;$ENV{PATH}"; # so miniperl can find perlglob.exe
33#print "PATH=$ENV{PATH}\n";
17af6fb0 34my $make = shift;
f76dcffd 35$make .= " ".shift while $ARGV[0]=~/^-/;
17af6fb0 36my $dep = shift;
37my $dmod = -M $dep;
38my $dir = shift;
39chdir($dir) || die "Cannot cd to $dir\n";
7e050124 40my $targ = shift;
17af6fb0 41(my $ext = getcwd()) =~ s,/,\\,g;
8e232993 42FindExt::scan_ext($ext);
17af6fb0 43
8e232993 44my @ext = FindExt::extensions();
45
46foreach my $dir (sort @ext)
17af6fb0 47 {
48 if (chdir("$ext\\$dir"))
49 {
50 my $mmod = -M 'Makefile';
51 if (!(-f 'Makefile') || $mmod > $dmod)
52 {
0026721a 53 print "\nRunning Makefile.PL in $dir\n";
e7d8b26b 54 my @perl = ($perl, "-I$here\\..\\lib", 'Makefile.PL',
55 'INSTALLDIRS=perl', 'PERL_CORE=1');
56 print join(' ', @perl), "\n";
57 my $code = system(@perl);
17af6fb0 58 warn "$code from $dir's Makefile.PL" if $code;
59 $mmod = -M 'Makefile';
60 if ($mmod > $dmod)
61 {
62 warn "Makefile $mmod > $dmod ($dep)\n";
63 }
64 }
7e050124 65 if ($targ)
66 {
67 print "Making $targ in $dir\n$make $targ\n";
e79607b0 68 system("$make $targ");
7e050124 69 }
70 else
71 {
72 print "Making $dir\n$make\n";
73 system($make);
74 }
17af6fb0 75 chdir($here) || die "Cannot cd to $here:$!";
76 }
77 else
78 {
79 warn "Cannot cd to $ext\\$dir:$!";
80 }
81 }
82