Re: Cross-compiling as of WinCE
[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/\\[^\\]+$//;
3a7016a8 32# miniperl needs to find perlglob and pl2bat
33$ENV{PATH} = "$topdir;$topdir\\win32\\bin;$ENV{PATH}";
200dcf2d 34#print "PATH=$ENV{PATH}\n";
3a7016a8 35my $pl2bat = "$topdir\\win32\\bin\\pl2bat";
36unless (-f "$pl2bat.bat") {
37 my @args = ($perl, ("$pl2bat.pl") x 2);
38 print "@args\n";
39 system(@args);
40}
17af6fb0 41my $make = shift;
f76dcffd 42$make .= " ".shift while $ARGV[0]=~/^-/;
17af6fb0 43my $dep = shift;
44my $dmod = -M $dep;
45my $dir = shift;
46chdir($dir) || die "Cannot cd to $dir\n";
7e050124 47my $targ = shift;
17af6fb0 48(my $ext = getcwd()) =~ s,/,\\,g;
8e232993 49FindExt::scan_ext($ext);
17af6fb0 50
8e232993 51my @ext = FindExt::extensions();
52
53foreach my $dir (sort @ext)
17af6fb0 54 {
55 if (chdir("$ext\\$dir"))
56 {
57 my $mmod = -M 'Makefile';
58 if (!(-f 'Makefile') || $mmod > $dmod)
59 {
0026721a 60 print "\nRunning Makefile.PL in $dir\n";
e7d8b26b 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);
17af6fb0 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 }
7e050124 72 if ($targ)
73 {
74 print "Making $targ in $dir\n$make $targ\n";
e79607b0 75 system("$make $targ");
7e050124 76 }
77 else
78 {
79 print "Making $dir\n$make\n";
80 system($make);
81 }
17af6fb0 82 chdir($here) || die "Cannot cd to $here:$!";
83 }
84 else
85 {
86 warn "Cannot cd to $ext\\$dir:$!";
87 }
88 }
89