This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[PATCH: perl@11564] introducing perlivp
[perl5.git] / win32 / buildext.pl
CommitLineData
7e050124
PK
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
NIS
21use File::Basename;
22use Cwd;
8e232993 23use FindExt;
17af6fb0
NIS
24my $here = getcwd();
25my $perl = $^X;
26$here =~ s,/,\\,g;
27if ($perl =~ m#^\.\.#)
28 {
29 $perl = "$here\\$perl";
30 }
31my $make = shift;
f76dcffd 32$make .= " ".shift while $ARGV[0]=~/^-/;
17af6fb0
NIS
33my $dep = shift;
34my $dmod = -M $dep;
35my $dir = shift;
36chdir($dir) || die "Cannot cd to $dir\n";
7e050124 37my $targ = shift;
17af6fb0 38(my $ext = getcwd()) =~ s,/,\\,g;
8e232993 39FindExt::scan_ext($ext);
17af6fb0 40
8e232993
NIS
41my @ext = FindExt::extensions();
42
43foreach my $dir (sort @ext)
17af6fb0
NIS
44 {
45 if (chdir("$ext\\$dir"))
46 {
47 my $mmod = -M 'Makefile';
48 if (!(-f 'Makefile') || $mmod > $dmod)
49 {
0026721a 50 print "\nRunning Makefile.PL in $dir\n";
7e050124
PK
51 print "$perl \"-I$here\\..\\lib\" Makefile.PL INSTALLDIRS=perl\n";
52 my $code = system($perl,"-I$here\\..\\lib",'Makefile.PL','INSTALLDIRS=perl');
17af6fb0
NIS
53 warn "$code from $dir's Makefile.PL" if $code;
54 $mmod = -M 'Makefile';
55 if ($mmod > $dmod)
56 {
57 warn "Makefile $mmod > $dmod ($dep)\n";
58 }
59 }
7e050124
PK
60 if ($targ)
61 {
62 print "Making $targ in $dir\n$make $targ\n";
63 system($make,$targ);
64 }
65 else
66 {
67 print "Making $dir\n$make\n";
68 system($make);
69 }
17af6fb0
NIS
70 chdir($here) || die "Cannot cd to $here:$!";
71 }
72 else
73 {
74 warn "Cannot cd to $ext\\$dir:$!";
75 }
76 }
77