9 unshift @INC, dirname $0 || '.';
10 do "sanity.pl" or die $@;
12 my $CoreBuild = -d "ext" && -f "perl.h" && -d "symbian" && -f "perl.c";
16 if (exists $ENV{EPOCROOT}) {
17 if ($ENV{EPOCROOT} =~ m!\\Symbian\\UIQ_21\\$!i) {
18 $SymbianVersion = '7.0s'; # TODO: other UIQ versions
19 } elsif ($ENV{EPOCROOT} =~ m!\\Symbian\\(.+?)\\!i) {
24 $SymbianVersion = $ENV{XSBUILD_SYMBIAN_VERSION}
25 if exists $ENV{XSBUILD_SYMBIAN_VERSION};
27 my $PerlVersion = $ENV{XSBUILD_PERL_VERSION};
38 $0: Usage: $0 [--symbian=version] [--perl=version]
40 [--csuffix=csuffix] [--cplusplus|--cpp]
41 [--win=win] [--arm=arm]
42 [--config|--build|--clean|--distclean|--sis] ext
53 my $BUILDROOT = getcwd();
55 if ( !defined $PerlVersion && $0 =~ m:\\symbian\\perl\\(.+)\\bin\\xsbuild.pl:i )
60 if ( !defined $SymbianVersion) {
61 ($SymbianVersion) = ($ENV{PATH} =~ m!\\Symbian\\(.+?)\\!i);
64 my ($SYMBIAN_ROOT, $SYMBIAN_VERSION, $SDK_NAME, $SDK_VARIANT, $SDK_VERSION);
67 do "sanity.pl" or die $@;
68 my %VERSION = %{ do "version.pl" or die $@ };
69 ($SYMBIAN_ROOT, $SYMBIAN_VERSION, $SDK_NAME, $SDK_VARIANT, $SDK_VERSION) =
70 @{ do "sdk.pl" or die $@ };
71 $VERSION = "$VERSION{REVISION}$VERSION{VERSION}$VERSION{SUBVERSION}";
72 $R_V_SV = "$VERSION{REVISION}.$VERSION{VERSION}.$VERSION{SUBVERSION}";
73 $BUILDROOT = do "cwd.pl" or die $@;
74 $PerlVersion = $R_V_SV;
81 'symbian=s' => \$SymbianVersion,
82 'perl=s' => \$PerlVersion,
83 'extversion=s' => \$CONF{EXTVERSION},
84 'csuffix=s' => \$CSuffix,
85 'cplusplus|cpp' => \$CPlusPlus,
91 'distclean' => \$DistClean,
97 $CSuffix = '.cpp' if $CPlusPlus;
98 $Build = !( $Config || $Clean || $DistClean ) || $Sis unless defined $Build;
100 die "$0: Symbian version undefined\n" unless defined $SymbianVersion;
102 $SymbianVersion =~ s:/:\\:g;
104 #die "$0: Symbian version '$SymbianVersion' not found\n"
105 # unless -d "\\Symbian\\$SymbianVersion";
107 die "$0: Perl version undefined\n" unless defined $PerlVersion;
109 $PERLSDK = "$SYMBIAN_ROOT\\Perl\\$PerlVersion";
111 die "$0: Perl version '$PerlVersion' not found\n"
112 if !$CoreBuild && !-d $PERLSDK;
114 print "Configuring with Symbian $SymbianVersion and Perl $PerlVersion...\n";
116 $R_V_SV = $PerlVersion;
118 $VERSION = $PerlVersion unless defined $VERSION;
120 $VERSION =~ tr/.//d if defined $VERSION;
122 $ENV{SDK} = $SYMBIAN_ROOT; # For the Errno extension
123 $ENV{CROSS} = 1; # For the Encode extension (unbuilt now)
126 my $UREL = "$SYMBIAN_ROOT\\epoc32\\release\\-ARM-\\$UARM";
128 if (exists $ENV{UREL}) {
129 $UREL = $ENV{UREL}; # from sdk.pl
130 $UREL =~ s/-ARM-/$ARM/;
131 $UARM = $ENV{UARM}; # from sdk.pl
132 $SRCDBG = $UARM eq 'udeb' ? "SRCDBG" : "";
140 open( BLD_INF, ">bld.inf" ) or die "$0: bld.inf: $!\n";
141 print BLD_INF <<__EOF__;
152 print "xsbuild: ", $cmd, "\n";
157 my ( $PL, $dir, $file ) = @_;
158 if ( defined $file ) {
159 print "\t(Running $dir\\$PL to create $file)\n";
163 print "\t(Running $dir\\$PL)\n";
166 $ENV{PERL_CORE} = 1 if $CoreBuild;
167 system_echo("perl -I$BUILDROOT\\lib -I$BUILDROOT\\xlib\\symbian -I$BUILDROOT\\t\\lib $PL") == 0
168 or warn "$0: $PL failed.\n";
169 if ( defined $file ) { -s $file or die "$0: No $file created.\n" }
173 my ( $conf, $k ) = @_;
174 push @{ $conf->{$k} }, split( ' ', $1 ) if /^$k\s(.+)$/;
177 sub uniquefy_filenames {
180 for my $i (@{$_[0]}) {
182 $i = lc $i if $i =~ m!\\!;
184 push @$b, $i unless $c{$i}++;
190 my ( $conf, $mmp ) = @_;
191 if ( -r $mmp && open( MMP, "<$mmp" ) ) {
192 print "\tReading $mmp...\n";
195 $conf->{TARGET} = $1 if /^TARGET\s+(.+)$/;
196 $conf->{TARGETPATH} = $1 if /^TARGETPATH\s+(.+)$/;
197 $conf->{EXTVERSION} = $1 if /^EXTVERSION\s+(.+)$/;
198 read_old_multi( $conf, "SOURCE" );
199 read_old_multi( $conf, "SOURCEPATH" );
200 read_old_multi( $conf, "USERINCLUDE" );
201 read_old_multi( $conf, "SYSTEMINCLUDE" );
202 read_old_multi( $conf, "LIBRARY" );
203 read_old_multi( $conf, "MACRO" );
210 my ( $ext, $base, $userinclude, @src ) = @_;
212 my $extdash = $ext; $extdash =~ s!\\!-!g;
214 print "\t$base.mmp\n";
215 $CONF{TARGET} = "perl$VERSION-$extdash.dll";
216 $CONF{TARGETPATH} = "\\System\\Libs\\Perl\\$R_V_SV";
217 $CONF{SOURCE} = [@src];
218 $CONF{SOURCEPATH} = [ $CWD, $BUILDROOT ];
219 $CONF{USERINCLUDE} = [ $CWD, $BUILDROOT ];
220 $CONF{SYSTEMINCLUDE} = ["$PERLSDK\\include"] unless $CoreBuild;
221 $CONF{SYSTEMINCLUDE} = [ $BUILDROOT, "$BUILDROOT\\symbian" ] if $CoreBuild;
224 read_mmp( \%CONF, "_init.mmp" );
225 read_mmp( \%CONF, "$base.mmp" );
227 if ($base eq 'Zlib') {
228 push @{$CONF{USERINCLUDE}}, "$CWD\\zlib-src";
231 for my $ui ( @{$userinclude} ) {
233 if ( $ui =~ m!^(?:[CD]:)?\\! ) {
234 push @{ $CONF{USERINCLUDE} }, $ui;
237 push @{ $CONF{USERINCLUDE} }, "$BUILDROOT\\$ui";
240 push @{ $CONF{SYSTEMINCLUDE} }, "\\epoc32\\include";
241 push @{ $CONF{SYSTEMINCLUDE} }, "\\epoc32\\include\\libc";
242 push @{ $CONF{LIBRARY} }, "euser.lib";
243 push @{ $CONF{LIBRARY} }, "estlib.lib";
244 push @{ $CONF{LIBRARY} }, "perl$VERSION.lib";
245 push @{ $CONF{MACRO} }, "SYMBIAN" unless $CoreBuild;
246 push @{ $CONF{MACRO} }, "PERL_EXT" if $CoreBuild;
247 push @{ $CONF{MACRO} }, "MULTIPLICITY";
248 push @{ $CONF{MACRO} }, "PERL_IMPLICIT_CONTEXT";
249 push @{ $CONF{MACRO} }, "PERL_GLOBAL_STRUCT";
250 push @{ $CONF{MACRO} }, "PERL_GLOBAL_STRUCT_PRIVATE";
252 if ($SDK_VARIANT eq 'S60') {
253 push @{ $CONF{MACRO} }, '__SERIES60__'
254 unless grep { $_ eq '__SERIES60__' } @{ $CONF{MACRO} };
256 if ($SDK_VARIANT eq 'S80') {
257 push @{ $CONF{MACRO} }, '__SERIES80__'
258 unless grep { $_ eq '__SERIES80__' } @{ $CONF{MACRO} };
260 if ($SDK_VARIANT eq 'S90') {
261 push @{ $CONF{MACRO} }, '__SERIES90__'
262 unless grep { $_ eq '__SERIES90__' } @{ $CONF{MACRO} };
264 if ($SDK_VARIANT eq 'UIQ') {
265 push @{ $CONF{MACRO} }, '__UIQ__'
266 unless grep { $_ eq '__UIQ__' } @{ $CONF{MACRO} };
269 for my $u (qw(SOURCE SOURCEPATH SYSTEMINCLUDE USERINCLUDE LIBRARY MACRO)) {
270 $CONF{$u} = uniquefy_filenames( $CONF{$u} );
272 open( BASE_MMP, ">$base.mmp" ) or die "$0: $base.mmp: $!\n";
274 print BASE_MMP <<__EOF__;
277 TARGETPATH $CONF{TARGETPATH}
278 SOURCE @{$CONF{SOURCE}}
281 for my $u (qw(SOURCEPATH SYSTEMINCLUDE USERINCLUDE)) {
282 for my $v ( @{ $CONF{$u} } ) {
283 print BASE_MMP "$u\t$v\n";
286 # OPTION does not work in MMPs for pre-2.0 SDKs?
287 print BASE_MMP <<__EOF__;
288 LIBRARY @{$CONF{LIBRARY}}
289 MACRO @{$CONF{MACRO}}
290 // OPTION MSVC /P // Uncomment for creating .i (cpp'ed .cpp)
291 // OPTION GCC -E // Uncomment for creating .i (cpp'ed .cpp)
293 # if (-f "$base.rss") {
294 # print BASE_MMP "RESOURCE\t$base.rss\n";
301 my ( $base, $build ) = @_;
303 print "\tMakefile\n";
305 my $windef1 = "$SYMBIAN_ROOT\\Epoc32\\Build$CWD\\$base\\$WIN\\$base.def";
306 my $windef2 = "..\\BWINS\\${base}u.def";
307 my $armdef1 = "$SYMBIAN_ROOT\\Epoc32\\Build$CWD\\$base\\$ARM\\$base.def";
308 my $armdef2 = "..\\BMARM\\${base}u.def";
310 my $wrap = $SYMBIAN_ROOT && defined $SDK_VARIANT eq 'S60' && $SDK_VERSION eq '1.2' && $SYMBIAN_ROOT !~ /_CW$/;
311 my $ABLD = $wrap ? 'perl b.pl' : 'abld';
313 open( MAKEFILE, ">Makefile" ) or die "$0: Makefile: $!\n";
314 print MAKEFILE <<__EOF__;
321 sis: build_arm freeze_arm
323 build: abld.bat build_win build_arm
330 \$(ABLD) build \$(WIN) udeb
334 \$(ABLD) build \$(ARM) $UARM
336 win: build_win freeze_win
338 arm: build_arm freeze_arm
340 freeze: freeze_win freeze_arm
344 \$(ABLD) freeze \$(WIN) $base
348 \$(ABLD) freeze \$(ARM) $base
350 defrost: defrost_win defrost_arm
360 clean: clean_win clean_arm
363 \$(ABLD) clean \$(WIN)
366 \$(ABLD) clean \$(ARM)
368 realclean: clean realclean_win realclean_arm
370 -del /f $base.c $base.mmp
373 \$(ABLD) reallyclean \$(WIN)
376 \$(ABLD) reallyclean \$(ARM)
378 distclean: defrost realclean
379 -rmdir ..\\BWINS ..\\BMARM
380 -del /f const-c.inc const-xs.inc
381 -del /f Makefile abld.bat bld.inf
385 if(open(B,">b.pl")) {
389 # nmake doesn't like MFLAGS and MAKEFLAGS being set to -w and w.
391 delete $ENV{MAKEFLAGS};
393 print "abld @ARGV\n";
394 system_echo("abld @ARGV");
398 warn "$0: failed to create b.pl: $!\n";
404 print "[chdir from ", getcwd(), " to ";
405 chdir(shift) or return;
407 print getcwd(), "]\n";
411 # Problem: the Config.pm we have in $BUILDROOT\\lib carries the
412 # version number of the Perl we are building, while the Perl
413 # we are running might have some other version. Solution:
414 # temporarily replace the Config.pm with a patched version.
416 # Reverse patch will be done with this special script
417 my $config_restore_script = "$BUILDROOT\\lib\\symbian_config_restore.pl";
418 # make sure the patch script was not left from previous run
419 unlink $config_restore_script;
420 return unless $CoreBuild;
421 my $V = sprintf "%vd", $^V;
422 # create reverse patch script
423 if (open(RSCRIPT, ">$config_restore_script")) {
424 print RSCRIPT <<__EOF__;
430 die "$0: Cannot create $config_restore_script: $!";
433 unlink("$BUILDROOT\\lib\\Config.pm.bak");
434 print "(patching $BUILDROOT\\lib\\Config.pm)\n";
435 system_echo("perl -pi.bak -e \"s:\\Q$R_V_SV:$V:\" $BUILDROOT\\lib\\Config.pm");
439 my $config_restore_script = "$BUILDROOT\\lib\\symbian_config_restore.pl";
440 # this function should always return True
441 # because it's commonly used in error handling blocks as
442 # &restore_config and die
443 return 1 unless -f $config_restore_script;
444 unlink("$BUILDROOT\\lib\\Config.pm.bak");
445 print "(restoring $BUILDROOT\\lib\\Config.pm)\n";
446 system_echo("perl -pi.bak $config_restore_script $BUILDROOT\\lib\\Config.pm");
447 unlink "$BUILDROOT\\lib\\Config.pm.bak", $config_restore_script;
448 # above command should always return 2 already,
449 # but i want to be absolutely sure that return value is True
454 my ( $ext, $dir ) = @_;
455 print "Configuring for $ext, directory '$dir'...\n";
456 my $extu = $CoreBuild ? "$BUILDROOT\\lib\\ExtUtils" : "$PERLSDK\\lib\\ExtUtils";
457 update_dir($dir) or die "$0: chdir '$dir': $!\n";
460 my $build = dirname($ext);
461 my $base = basename($ext);
462 my $basexs = "$base.xs";
463 my $basepm = "$base.pm";
464 my $basec = "$base$CSuffix";
466 if ( $dir =~ m:^ext\\(.+): ) {
469 elsif ( $dir ne "." ) {
472 my $extdirdir = dirname($extdir);
473 my $targetroot = "\\System\\Libs\\Perl\\$R_V_SV";
474 write_bld_inf($base) if -f $basexs;
479 $extdirdir = $extdirdir eq "." ? "" : "$extdirdir\\";
481 my $extdash = $ext; $extdash =~ s!\\!-!g;
484 $lst{"$UREL\\perl$VERSION-$extdash.dll"} =
485 "$targetroot\\$ARM-symbian\\$base.dll"
487 $lst{"$dir\\$base.pm"} = "$targetroot\\$extdirdir$base.pm"
488 if -f $basepm && $base ne 'XSLoader';
495 find( sub { push @found, $File::Find::name if -f $_ }, 'lib' );
496 for my $found (@found) {
497 next if $found =~ /\.bak$/i; # Zlib
498 my ($short) = ( $found =~ m/^lib.(.+)/ );
501 $lst{"$dir\\$found"} = "$targetroot\\$short";
504 if ( my @pm = glob("*.pm */*.pm") ) {
506 next if $pm =~ m:^t/:;
508 $lst{"$dir\\$pm"} = "$targetroot\\$extdirdir$pm";
511 if ( my @c = glob("*.c *.cpp */*.c */*.cpp") ) {
512 map { s:^zlib-src/:: } @c if $ext eq 'ext\Compress\Raw\Zlib';
518 if ( my @h = glob("*.h */*.h") ) {
519 map { s:^zlib-src/:: } @h if $ext eq 'ext\Compress\Raw\Zlib';
523 $incdir{"$dir\\$h"}++ unless $h eq ".";
526 if ( exists $EXTCFG{$ext} ) {
527 for my $cfg ( @{ $EXTCFG{$ext} } ) {
528 if ( $cfg =~ /^([-+])?(.+\.(c|cpp|h))$/ ) {
529 my $o = defined $1 ? $1 : '+';
532 for my $f ( glob($f) ) {
534 warn "$0: no source file $dir\\$f\n" unless -f $f;
535 $src{$f}++ unless $cfg =~ /\.h$/;
536 if ( $f =~ m:^(.+)\\[^\\]+$: ) {
540 elsif ( $o eq '-' ) {
545 if ( $cfg =~ /^([-+])?(.+\.(pm|pl|inc))$/ ) {
546 my $o = defined $1 ? $1 : '+';
549 for my $f ( glob($f) ) {
551 warn "$0: no Perl file $dir\\$f\n" unless -f $f;
552 $lst{"$dir\\$f"} = "$targetroot\\$extdir\\$f";
554 elsif ( $o eq '-' ) {
555 delete $lst{"$dir\\$f"};
559 if ( $cfg eq 'CONST' && !$ran_PL++ ) {
560 run_PL( "Makefile.PL", $dir, "const-xs.inc" );
564 unless ( $ran_PL++ ) {
565 run_PL( "Makefile.PL", $dir ) if -f "Makefile.PL";
567 if ( $dir eq "ext\\Errno" ) {
568 run_PL( "Errno_pm.PL", $dir, "Errno.pm" );
569 $lst{"$dir\\Errno.pm"} = "$targetroot\\Errno.pm";
571 elsif ( $dir eq "ext\\Devel\\PPPort" ) {
572 run_PL( "ppport_h.PL", $dir, "ppport.h" );
574 elsif ( $dir eq "ext\\DynaLoader" ) {
575 run_PL( "XSLoader_pm.PL", $dir, "XSLoader.pm" );
576 $lst{"ext\\DynaLoader\\XSLoader.pm"} = "$targetroot\\XSLoader.pm";
578 elsif ( $dir eq "ext\\Encode" ) {
579 system_echo("perl bin\\enc2xs -Q -O -o def_t.c -f def_t.fnm") == 0
580 or &restore_config and die "$0: running enc2xs failed: $!\n";
583 my @lst = sort keys %lst;
585 read_mmp( \%CONF, "_init.mmp" );
586 read_mmp( \%CONF, "$base.mmp" );
589 my %MM; # MakeMaker results
590 my @MM = qw(VERSION XS_VERSION);
591 if ( -f "Makefile" ) {
592 print "\tReading MakeMaker Makefile...\n";
593 if ( open( MAKEFILE, "Makefile" ) ) {
605 warn "$0: Makefile: $!";
607 print "\tDeleting MakeMaker Makefile.\n";
613 if ( defined $CONF{EXTVERSION} ) {
614 my $EXTVERSION = $CONF{EXTVERSION};
615 print "\tUsing $EXTVERSION for version...\n";
616 $MM{VERSION} = $MM{XS_VERSION} = $EXTVERSION;
618 (&restore_config and die "$0: VERSION or XS_VERSION undefined\n")
619 unless defined $MM{VERSION} && defined $MM{XS_VERSION};
620 if ( open( BASE_C, ">$basec" ) ) {
621 print BASE_C <<__EOF__;
623 #define VERSION "$MM{VERSION}"
626 #define XS_VERSION "$MM{XS_VERSION}"
632 warn "$0: $basec: $!";
636 "perl -I$BUILDROOT\\lib -I$PERLSDK\\lib $extu\\xsubpp -csuffix .cpp -typemap $extu\\typemap -noprototypes $basexs >> $basec"
642 die "$0: perl xsubpp failed: $!\n";
646 open( _INIT_C, ">_init.c" )
647 or &restore_config and die "$!: _init.c: $!\n";
648 print _INIT_C <<__EOF__;
651 EXPORT_C void _init(void *handle) {
656 my @src = ( "_init.c", sort keys %src );
658 if ( $base eq "Encode" ) { # Currently unused.
659 for my $submf ( glob("*/Makefile") ) {
660 my $d = dirname($submf);
661 print "Configuring Encode::$d...\n";
662 if ( open( SUBMF, $submf ) ) {
663 if ( update_dir($d) ) {
666 next if 1 .. /postamble/;
667 if (m!^(\w+_t)\.c : !) {
669 "perl ..\\bin\\enc2xs -Q -o $1.c -f $1.fnm")
671 or warn "$0: enc2xs: $!\n";
672 push @subsrc, "$1.c";
678 $subbase =~ s!/!::!g;
679 write_mmp( $ext, $subbase, ["..\\Encode"], "$subbase.c",
681 write_makefile( $subbase, $build );
682 write_bld_inf($subbase);
686 "perl -I$BUILDROOT\\lib ..\\$extu\\xsubpp -csuffix .cpp -typemap ..\\$extu\\typemap -noprototypes $subbase.xs > $subbase.c"
692 die "$0: perl xsubpp failed: $!\n";
697 warn "$0: chdir $d: $!\n";
701 warn "$0: $submf: $!";
704 print "Configuring Encode...\n";
707 write_mmp( $ext, $base, [ keys %incdir ], @src );
708 write_makefile( $base, $build );
713 $lstname =~ s:^ext\\::;
714 $lstname =~ s:\\:-:g;
715 print "\t$lstname.lst\n";
717 $CoreBuild ? "$BUILDROOT/symbian/$lstname.lst" : "$BUILDROOT/$lstname.lst";
718 if ( open( my $lst, ">$lstout" ) ) {
719 for my $f (@lst) { print $lst qq["$f"-"!:$lst{$f}"\n] }
723 die "$0: $lstout: $!\n";
725 update_dir($BUILDROOT);
730 $CWD =~ s!^[A-Z]:!!i;
734 if (grep /^(Compress::Raw::Zlib|Cwd|Data::Dumper|Digest::SHA|Sys::Syslog|Time::HiRes)$/, @ARGV) {
736 system_echo("perl -I$BUILDROOT\\lib -I$PERLSDK\\lib $BUILDROOT\\mkppport");
740 for my $ext (@ARGV) {
743 my $extdash = $ext =~ /ext\\/ ? $ext : "ext\\$ext"; $extdash =~ s!\\!-!g;
748 $cfg = $2 if $ext =~ s/(.+?),(.+)/$1/;
753 if ( $ext =~ /\.xs$/ && !-f $ext ) {
754 if ( -f "ext\\$ext" ) {
756 $dir = dirname($ext);
760 if ( -d "ext\\$ext" ) {
765 $dir = "." unless defined $dir;
768 if ( $ext =~ /\.xs$/ && -f $ext ) {
769 $ext = dirname($ext);
777 if ( $ext eq "XSLoader" ) {
778 $ext = "ext\\XSLoader";
780 if ( $ext eq "ext\\XSLoader" ) {
781 $dir = "ext\\DynaLoader";
784 $EXTCFG{$ext} = [ split( /,/, $cfg ) ] if defined $cfg;
786 die "$0: no lib\\Config.pm\n"
787 if $CoreBuild && $Build && !-f "lib\\Config.pm";
790 open( my $cfg, "symbian/install.cfg" )
791 or die "$0: symbian/install.cfg: $!\n";
793 $extdir =~ s:^ext\\::;
795 next unless /^ext\s+(.+)/;
798 my @ext = split( ' ', $ext );
799 $EXTCFG{"ext\\$ext[0]"} = [@ext];
804 if ( $Config || $Build ) {
805 xsconfig( $ext, $dir ) or die "$0: xsconfig '$ext' failed\n";
810 warn "$0: No directory for $ext, skipping...\n";
814 my $chdir = $ext eq "ext\\XSLoader" ? "ext\\DynaLoader" : $dir;
815 die "$0: no directory '$chdir'\n" unless -d $chdir;
816 update_dir($chdir) or die "$0: chdir '$chdir' failed: $!\n";
820 my @ext = split( /\\/, $ext );
823 if ( $Clean || $DistClean ) {
824 print "Cleaning $ext...\n";
828 unlink("const-c.inc");
829 unlink("const-xs.inc");
833 if ( $Build && $ext ne "ext\\XSLoader" && $ext ne "ext\\Errno" ) {
835 # We compile the extension three (3) times.
836 # (1) Only the _init.c to get _init() as the ordinal 1 function in the DLL.
837 # (2) With the rest and the _init.c to get ordinals for the rest.
838 # (3) With an updated _init.c that carries the symbols from step (2).
840 system_echo("make clean");
841 system_echo("make defrost") == 0 or warn "$0: make defrost failed\n";
845 push @TARGET, 'sis' if $Sis;
848 # Hide all but the _init.c.
849 print "\n*** $ext - Compile 1 of 3.\n\n";
850 print "(patching $base.mmp)\n";
852 "perl -pi.bak -e \"s:^SOURCE\\s+_init.c:SOURCE\\t_init.c // :\" $base.mmp"
854 system_echo("bldmake bldfiles");
855 system_echo("make @TARGET") == 0 or die "$0: make #1 failed\n";
858 # Reveal the rest again.
859 print "\n*** $ext - Compile 2 of 3.\n\n";
860 print "(patching $base.mmp)\n";
862 "perl -pi.bak -e \"s:^SOURCE\\t_init.c // :SOURCE\\t_init.c :\" $base.mmp"
864 system_echo("make @TARGET") == 0 or die "$0: make #2 failed\n";
865 unlink("$base.mmp.bak");
867 open( _INIT_C, ">_init.c" ) or die "$0: _init.c: $!\n";
868 print _INIT_C <<'__EOF__';
872 /* This is a different but matching definition from in dl_symbian.xs. */
877 } PerlSymbianLibHandle;
879 EXPORT_C void _init(void* handle) {
885 for my $f ("$SYMBIAN_ROOT\\Epoc32\\Build$CWD\\$base\\WINS\\perl$VERSION-$extdash.def",
886 "..\\BMARM\\perl$VERSION-${extdash}u.def") {
888 if ( open( $def, $f ) ) {
896 unless (defined $basef) {
897 die "$0: failed to find .def for $base\n";
900 next while 1 .. /^EXPORTS/;
901 if (/^\s*(\w+) \@ (\d+) /) {
907 my @symbol = sort keys %symbol;
909 print _INIT_C <<'__EOF__';
911 PerlSymbianLibHandle* h = (PerlSymbianLibHandle*)handle;
913 h->symbols = newHV();
916 for my $sym (@symbol) {
917 my $len = length($sym);
918 print _INIT_C <<__EOF__;
919 hv_store(h->symbols, "$sym", $len, newSViv($symbol{$sym}), 0);
924 die "$0: $basef: no exports found\n";
927 print _INIT_C <<'__EOF__';
933 # Compile #3. This is for real.
934 print "\n*** $ext - Compile 3 of 3.\n\n";
935 system_echo("make @TARGET") == 0 or die "$0: make #3 failed\n";
938 elsif ( $Clean || $DistClean ) {
939 if ( $ext eq "ext\\Errno" ) {
940 unlink( "Errno.pm", "Makefile" );
943 if ( -f "Makefile" ) {
945 system_echo("make clean") == 0 or die "$0: make clean failed\n";
948 system_echo("make distclean") == 0
949 or die "$0: make distclean failed\n";
952 if ( $ext eq "ext\\Compress\\Raw\\Zlib" ) {
954 find( sub { push @bak, $File::Find::name if /\.bak$/ }, "." );
955 unlink(@bak) if @bak;
957 find( sub { push @src, $_ if -f $_ }, "zlib-src" );
958 unlink(@src) if @src;
959 unlink("constants.xs");
961 if ( $ext eq "ext\\Devel\\PPPort" ) {
965 my @D = glob("../BMARM/*.def ../BWINS/*.def");
967 my @B = glob("ext/BWINS ext/BMARM ext/*/BWINS ext/*/BMARM Makefile");
971 update_dir($BUILDROOT);