Update README.vos and release vos build macros
[p5sagit/p5-mst-13.2.git] / win32 / buildext.pl
1 =head1 NAME
2
3 buildext.pl - build extensions
4
5 =head1 SYNOPSIS
6
7     buildext.pl make [-make_opts] dep directory [target]
8
9 E.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
21 use File::Basename;
22 use Cwd;
23 use FindExt;
24 my $here = getcwd();
25 my $perl = $^X;
26 $here =~ s,/,\\,g;
27 if ($perl =~ m#^\.\.#)
28  {
29   $perl = "$here\\$perl";
30  }
31 (my $topdir = $perl) =~ s/\\[^\\]+$//;
32 # miniperl needs to find perlglob and pl2bat
33 $ENV{PATH} = "$topdir;$topdir\\win32\\bin;$ENV{PATH}";
34 #print "PATH=$ENV{PATH}\n";
35 my $pl2bat = "$topdir\\win32\\bin\\pl2bat";
36 unless (-f "$pl2bat.bat") {
37     my @args = ($perl, ("$pl2bat.pl") x 2);
38     print "@args\n";
39     system(@args);
40 }
41 my $make = shift;
42 $make .= " ".shift while $ARGV[0]=~/^-/;
43 my $dep  = shift;
44 my $dmod = -M $dep;
45 my $dir  = shift;
46 chdir($dir) || die "Cannot cd to $dir\n";
47 my $targ  = shift;
48 (my $ext = getcwd()) =~ s,/,\\,g;
49 FindExt::scan_ext($ext);
50
51 my @ext = FindExt::extensions();
52
53 foreach my $dir (sort @ext)
54  {
55   if (chdir("$ext\\$dir"))
56    {
57     my $mmod = -M 'Makefile';
58     if (!(-f 'Makefile') || $mmod > $dmod)
59      {
60       print "\nRunning Makefile.PL in $dir\n";
61       my @perl = ($perl, "-I$here\\..\\lib", 'Makefile.PL',
62                   'INSTALLDIRS=perl', 'PERL_CORE=1');
63       print join(' ', @perl), "\n";
64       my $code = system(@perl);
65       warn "$code from $dir's Makefile.PL" if $code;
66       $mmod = -M 'Makefile';
67       if ($mmod > $dmod)
68        {
69         warn "Makefile $mmod > $dmod ($dep)\n";
70        }
71      }  
72     if ($targ)
73      {
74       print "Making $targ in $dir\n$make $targ\n";
75       system("$make $targ");
76      }
77     else
78      {
79       print "Making $dir\n$make\n";
80       system($make);
81      }
82     chdir($here) || die "Cannot cd to $here:$!";
83    }
84   else
85    {
86     warn "Cannot cd to $ext\\$dir:$!";
87    }
88  }
89