This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add a test.taintwarn makefile target,
[perl5.git] / win32 / buildext.pl
CommitLineData
7e050124
PK
1=head1 NAME
2
3buildext.pl - build extensions
4
5=head1 SYNOPSIS
6
fefd7080 7 buildext.pl make [-make_opts] dep directory [target] !ext1 !ext2
7e050124
PK
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
fefd7080
VK
19Will skip building extensions which are marked with an '!' char.
20Mostly because they still not ported to specified platform.
21
7e050124
PK
22=cut
23
17af6fb0
NIS
24use File::Basename;
25use Cwd;
8e232993 26use FindExt;
fefd7080
VK
27
28# @ARGV with '!' at first position are exclusions
29my %excl = map {$_=>1} map {/^!(.*)$/} @ARGV;
30@ARGV = grep {!/^!/} @ARGV;
31
17af6fb0
NIS
32my $here = getcwd();
33my $perl = $^X;
34$here =~ s,/,\\,g;
35if ($perl =~ m#^\.\.#)
36 {
37 $perl = "$here\\$perl";
38 }
200dcf2d 39(my $topdir = $perl) =~ s/\\[^\\]+$//;
3a7016a8
GS
40# miniperl needs to find perlglob and pl2bat
41$ENV{PATH} = "$topdir;$topdir\\win32\\bin;$ENV{PATH}";
200dcf2d 42#print "PATH=$ENV{PATH}\n";
3a7016a8
GS
43my $pl2bat = "$topdir\\win32\\bin\\pl2bat";
44unless (-f "$pl2bat.bat") {
45 my @args = ($perl, ("$pl2bat.pl") x 2);
46 print "@args\n";
fefd7080 47 system(@args) unless defined $::Cross::platform;
3a7016a8 48}
17af6fb0 49my $make = shift;
f76dcffd 50$make .= " ".shift while $ARGV[0]=~/^-/;
17af6fb0
NIS
51my $dep = shift;
52my $dmod = -M $dep;
53my $dir = shift;
54chdir($dir) || die "Cannot cd to $dir\n";
7e050124 55my $targ = shift;
17af6fb0 56(my $ext = getcwd()) =~ s,/,\\,g;
fefd7080 57my $code;
8e232993 58FindExt::scan_ext($ext);
17af6fb0 59
8e232993
NIS
60my @ext = FindExt::extensions();
61
62foreach my $dir (sort @ext)
17af6fb0 63 {
fefd7080
VK
64 if (exists $excl{$dir}) {
65 warn "Skipping extension $ext\\$dir, not ported to current platform";
66 next;
67 }
17af6fb0
NIS
68 if (chdir("$ext\\$dir"))
69 {
70 my $mmod = -M 'Makefile';
71 if (!(-f 'Makefile') || $mmod > $dmod)
72 {
0026721a 73 print "\nRunning Makefile.PL in $dir\n";
e7d8b26b
MS
74 my @perl = ($perl, "-I$here\\..\\lib", 'Makefile.PL',
75 'INSTALLDIRS=perl', 'PERL_CORE=1');
fefd7080
VK
76 if (defined $::Cross::platform) {
77 @perl = (@perl[0,1],"-MCross=$::Cross::platform",@perl[2..$#perl]);
78 }
e7d8b26b 79 print join(' ', @perl), "\n";
fefd7080 80 $code = system(@perl);
17af6fb0
NIS
81 warn "$code from $dir's Makefile.PL" if $code;
82 $mmod = -M 'Makefile';
83 if ($mmod > $dmod)
84 {
85 warn "Makefile $mmod > $dmod ($dep)\n";
86 }
87 }
7e050124
PK
88 if ($targ)
89 {
90 print "Making $targ in $dir\n$make $targ\n";
fefd7080
VK
91 $code = system("$make $targ");
92 die "Unsuccessful make($dir): code=$code" if $code!=0;
7e050124
PK
93 }
94 else
95 {
96 print "Making $dir\n$make\n";
fefd7080
VK
97 $code = system($make);
98 die "Unsuccessful make($dir): code=$code" if $code!=0;
7e050124 99 }
17af6fb0
NIS
100 chdir($here) || die "Cannot cd to $here:$!";
101 }
102 else
103 {
104 warn "Cannot cd to $ext\\$dir:$!";
105 }
106 }
107