3 # Copyright (c) 2004-2005 Nokia. All rights reserved.
8 print "Configuring...\n";
9 print "Configuring with: Perl version $] ($^X)\n";
13 my %VERSION = %{ do "version.pl" };
15 printf "Configuring for: Perl version $VERSION{REVISION}.%03d%03d\n",
16 $VERSION{VERSION}, $VERSION{SUBVERSION};
18 my $VERSION = "$VERSION{REVISION}$VERSION{VERSION}$VERSION{SUBVERSION}";
19 my $R_V_SV = "$VERSION{REVISION}.$VERSION{VERSION}.$VERSION{SUBVERSION}";
21 my $SDK = do "sdk.pl";
22 my %PORT = %{ do "port.pl" };
24 my ( $SYMBIAN_VERSION, $SDK_VERSION ) = ( $SDK =~ m!\\Symbian\\(.+?)\\(.+)$! );
26 if ($SDK eq 'C:\Symbian\Series60_1_2_CW') {
27 ( $SYMBIAN_VERSION, $SDK_VERSION ) = qw(6.1 1.2);
30 my $WIN = $ENV{WIN} ; # 'wins', 'winscw' (from sdk.pl)
31 my $ARM = 'thumb'; # 'thumb', 'armi'
32 my $S60SDK = $ENV{S60SDK}; # qw(1.2 2.0 2.1 2.6) (from sdk.pl)
34 my $UREL = $ENV{UREL}; # from sdk.pl
35 $UREL =~ s/-ARM-/$ARM/;
36 my $UARM = $ENV{UARM}; # from sdk.pl
38 die "$0: SDK not recognized\n"
39 if !defined($SYMBIAN_VERSION) || !defined($SDK_VERSION) || !defined($S60SDK);
41 die "$0: does not know which Windows compiler to use\n"
44 print "Symbian $SYMBIAN_VERSION SDK $S60SDK ($WIN) installed at $SDK\n";
46 my $CWD = do "cwd.pl";
47 print "Build directory $CWD\n";
49 die "$0: '+' in cwd does not work with SDK 1.2\n"
50 if $S60SDK eq '1.2' && $CWD =~ /\+/;
56 my ( $target, $type, @x ) = @_;
57 my $miniperl = $target eq 'miniperl';
58 my $perl = $target eq 'perl';
59 my $mmp = "$target.mmp";
60 my $targetpath = $miniperl
61 || $perl ? "TARGETPATH\t\\System\\Apps\\Perl" : "";
62 if ( open( my $fh, ">$mmp" ) ) {
70 EPOCHEAPSIZE 1024 8388608
75 print $fh "MACRO\t__SERIES60_1X__\n" if $S60SDK =~ /^1\./;
76 print $fh "MACRO\t__SERIES60_2X__\n" if $S60SDK =~ /^2\./;
78 @c = map { glob } qw(*.c); # Find the .c files.
79 @c = map { lc } @c; # Lowercase the names.
80 @c = grep { !/malloc\.c/ } @c; # Use the system malloc.
81 @c = grep { !/main\.c/ } @c; # main.c must be explicit.
82 push @c, map { lc } @x;
83 @c = map { s:^\.\./::; $_ } @c; # Remove the leading ../
84 @c = map { $c{$_}++ } @c; # Uniquefy.
85 @c = sort keys %c; # Beautify.
88 print $fh "SOURCE\t\t$_\n";
93 USERINCLUDE $CWD\\ext\\DynaLoader
94 USERINCLUDE $CWD\\symbian
95 SYSTEMINCLUDE \\epoc32\\include\\libc
96 SYSTEMINCLUDE \\epoc32\\include
100 if ( $miniperl || $perl || $type eq 'dll' ) {
103 LIBRARY commonengine.lib
108 if ( $type eq 'exe' ) {
110 STATICLIBRARY ecrt0.lib
126 MACRO PERL_IMPLICIT_CONTEXT
128 unless ( $miniperl || $perl ) {
130 MACRO PERL_GLOBAL_STRUCT
131 MACRO PERL_GLOBAL_STRUCT_PRIVATE
137 warn "$0: failed to open $mmp for writing: $!\n";
142 if ( open( BLD_INF, ">bld.inf" ) ) {
144 push @unclean, "bld.inf";
145 print BLD_INF <<__EOF__;
150 for (@mmp) { print BLD_INF $_, "\n" }
154 warn "$0: failed to open bld.inf for writing: $!\n";
161 if ( open( CONFIG_SH, "symbian/config.sh" ) ) {
162 while (<CONFIG_SH>) {
163 if (/^(\w+)=['"]?(.*?)["']?$/) {
164 my ( $var, $val ) = ( $1, $2 );
165 $val =~ s/x.y.z/$R_V_SV/gi;
166 $val =~ s/thumb/$ARM/gi;
167 $val = "'$SYMBIAN_VERSION'" if $var eq 'osvers';
168 $val = "'$SDK_VERSION'" if $var eq 'sdkvers';
169 $config{$var} = $val;
175 warn "$0: failed to open symbian\\config.sh for reading: $!\n";
179 sub create_config_h {
181 if ( open( CONFIG_H, ">config.h" ) ) {
182 print "\tconfig.h\n";
183 push @unclean, "config.h";
184 if ( open( CONFIG_H_SH, "config_h.SH" ) ) {
185 while (<CONFIG_H_SH>) {
186 last if /\#ifndef _config_h_/;
188 print CONFIG_H <<__EOF__;
190 * Package name : perl
191 * Source directory : .
192 * Configuration time:
194 * Target system : symbian
199 while (<CONFIG_H_SH>) {
200 last if /!GROK!THIS/;
201 s/\$(\w+)/exists $config{$1} ? $config{$1} : ""/eg;
202 s/^#undef\s+(\S+).+/#undef $1/g;
209 warn "$0: failed to open ../config_h.SH for reading: $!\n";
214 warn "$0: failed to open config.h for writing: $!\n";
218 sub create_DynaLoader_cpp {
219 print "\text\\DynaLoader\\DynaLoader.cpp\n";
221 q[perl -Ilib lib\ExtUtils\xsubpp ext\DynaLoader\dl_symbian.xs >ext\DynaLoader\DynaLoader.cpp]
223 or die "$0: creating DynaLoader.cpp failed: $!\n";
224 push @unclean, 'ext\DynaLoader\DynaLoader.cpp';
228 sub create_symbian_port_h {
229 print "\tsymbian\\symbian_port.h\n";
230 if ( open( SYMBIAN_PORT_H, ">symbian/symbian_port.h" ) ) {
231 $S60SDK =~ /^(\d+)\.(\d+)$/;
232 my ($sdkmajor, $sdkminor) = ($1, $2);
233 print SYMBIAN_PORT_H <<__EOF__;
234 /* Copyright (c) 2004-2005, Nokia. All rights reserved. */
236 #ifndef __symbian_port_h__
237 #define __symbian_port_h__
239 #define PERL_SYMBIANPORT_MAJOR $PORT{dll}->{MAJOR}
240 #define PERL_SYMBIANPORT_MINOR $PORT{dll}->{MINOR}
241 #define PERL_SYMBIANPORT_PATCH $PORT{dll}->{PATCH}
243 #define PERL_SYMBIANSDK_FLAVOR L"Series 60"
244 #define PERL_SYMBIANSDK_MAJOR $sdkmajor
245 #define PERL_SYMBIANSDK_MINOR $sdkminor
247 #endif /* #ifndef __symbian_port_h__ */
249 close(SYMBIAN_PORT_H);
250 push @unclean, 'symbian\symbian_port.h';
253 warn "$0: failed to open symbian/symbian_port.h for writing: $!\n";
257 sub create_perlmain_c {
258 print "\tperlmain.c\n";
260 q[perl -ne "print qq[ char *file = __FILE__;\n] if /dXSUB_SYS/;print;print qq[ newXS(\"DynaLoader::boot_DynaLoader\", boot_DynaLoader, file);\n] if /dXSUB_SYS/;print qq[EXTERN_C void boot_DynaLoader (pTHX_ CV* cv);\n] if /Do not delete this line/" miniperlmain.c > perlmain.c]
262 or die "$0: Creating perlmain.c failed: $!\n";
263 push @unclean, 'perlmain.c';
266 sub create_PerlApp_pkg {
267 print "\tsymbian\\PerlApp.pkg\n";
268 if ( open( PERLAPP_PKG, ">symbian\\PerlApp.pkg" ) ) {
270 if ($S60SDK ne '1.2' || $SDK =~ m/_CW$/) { # Do only if not in 1.2 VC.
271 $APPS =~ s!\\epoc32\\release\\(.+)\\$UARM$!\\epoc32\\data\\z\\system\\apps\\PerlApp!i;
273 print PERLAPP_PKG <<__EOF__;
274 ; !!!!!! DO NOT EDIT THIS FILE !!!!!!
275 ; This file is built by symbian\\config.pl.
276 ; Any changes made here will be lost!
280 ; Note that the demo_pl needs to be run to create the demo .pl scripts.
285 ; Standard SIS file header
286 #{"PerlApp"},(0x102015F6),0,1,0
288 ; Supports Series 60 v0.9
289 (0x101F6F88), 0, 0, 0, {"Series60ProductID"}
292 "$UREL\\PerlApp.APP"-"!:\\system\\apps\\PerlApp\\PerlApp.app"
293 "$UREL\\PerlRecog.mdl"-"!:\\system\\recogs\\PerlRecog.mdl"
294 "$APPS\\PerlApp.rsc"-"!:\\system\\apps\\PerlApp\\PerlApp.rsc"
295 "$APPS\\PerlApp.aif"-"!:\\system\\apps\\PerlApp\\PerlApp.aif"
297 if ( open( DEMOS, "perl symbian\\demo_pl list |" ) ) {
300 print PERLAPP_PKG qq["$_"-"!:\\Perl\\$_"\n];
307 die "$0: symbian\\PerlApp.pkg: $!\n";
309 push @unclean, 'symbian\PerlApp.pkg';
312 print "Creating...\n";
315 'miniperlmain.c', 'symbian\symbian_stubs.c',
316 'symbian\PerlBase.cpp', 'symbian\symbian_utils.cpp',
320 'perlmain.c', 'symbian\symbian_stubs.c',
321 'symbian\symbian_utils.cpp', 'symbian\PerlBase.cpp',
322 'ext\DynaLoader\DynaLoader.cpp',
326 "perl$VERSION", 'dll',
327 'symbian\symbian_dll.cpp', 'symbian\symbian_stubs.c',
328 'symbian\symbian_utils.cpp', 'symbian\PerlBase.cpp',
329 'ext\DynaLoader\DynaLoader.cpp',
335 create_symbian_port_h();
336 create_DynaLoader_cpp();
337 create_PerlApp_pkg();
339 if ( open( PERLAPP_MMP, ">symbian/PerlApp.mmp" ) ) {
341 push @MACRO, '__SERIES60_1X__' if $S60SDK =~ /^1\./;
342 push @MACRO, '__SERIES60_2X__' if $S60SDK =~ /^2\./;
343 print PERLAPP_MMP <<__EOF__;
344 // !!!!!! DO NOT EDIT THIS FILE !!!!!!
345 // This file is built by symbian\\config.pl.
346 // Any changes made here will be lost!
349 UID 0x100039CE 0x102015F6
350 TARGETPATH \\system\\apps\\PerlApp
360 USERINCLUDE \\symbian\\perl\\$R_V_SV\\include
362 SYSTEMINCLUDE \\epoc32\\include
363 SYSTEMINCLUDE \\epoc32\\include\\libc
369 LIBRARY commondialogs.lib
375 LIBRARY perl$VERSION.lib
377 AIF PerlApp.aif . PerlAppAif.rss
380 for my $macro (@MACRO) {
381 print PERLAPP_MMP <<__EOF__;
387 push @unclean, 'symbian\PerlApp.mmp';
390 warn "$0: failed to create symbian\\PerlApp.mmp";
393 if ( open( MAKEFILE, ">Makefile" ) ) {
394 my $perl = "perl$VERSION";
395 my $windef1 = "$SDK\\Epoc32\\Build$CWD\\$perl\\$WIN\\$perl.def";
396 my $windef2 = "..\\BWINS\\${perl}u.def";
397 my $armdef1 = "$SDK\\Epoc32\\Build$CWD\\$perl\\$ARM\\$perl.def";
398 my $armdef2 = "..\\BMARM\\${perl}u.def";
399 print "\tMakefile\n";
400 print MAKEFILE <<__EOF__;
402 \@echo === Perl for Symbian ===
403 \@echo Useful targets:
404 \@echo all win arm clean
405 \@echo perldll.sis perlext.sis perlsdk.zip
412 build: rename_makedef build_win build_arm
414 @unclean: symbian\\config.pl
415 perl symbian\\config.pl
417 build_win: abld.bat win_perl.mf win_miniperl.mf win_${VERSION}.mf perldll_win
419 build_vc6: abld.bat win_perl.mf win_miniperl.mf win_${VERSION}.mf vc6.mf perldll_win
421 build_arm: abld.bat perl_arm miniperl_arm arm_${VERSION}.mf perldll_arm
423 miniperl_win: miniperl.mmp abld.bat win_miniperl.mf rename_makedef
424 abld build \$(WIN) udeb miniperl
426 miniperl_arm: miniperl.mmp abld.bat arm_miniperl.mf rename_makedef
427 abld build \$(ARM) $UARM miniperl
429 miniperl: miniperl_win miniperl_arm
431 perl: perl_win perl_arm
433 perl_win: perl.mmp abld.bat win_perl.mf rename_makedef
434 abld build \$(WIN) perl
436 perl_arm: perl.mmp abld.bat arm_perl.mf rename_makedef
437 abld build \$(ARM) $UARM perl
439 perldll_win: perl${VERSION}_win freeze_win perl${VERSION}_win
441 perl${VERSION}_win: perl$VERSION.mmp abld.bat rename_makedef
442 abld build \$(WIN) perl$VERSION
444 perldll_arm: perl${VERSION}_arm freeze_arm perl${VERSION}_arm
446 perl${VERSION}_arm: perl$VERSION.mmp arm_${VERSION}.mf abld.bat rename_makedef
447 abld build \$(ARM) $UARM perl$VERSION
449 perldll perl$VERSION: perldll_win perldll_arm
451 win: miniperl_win perl_win perldll_win
453 arm: miniperl_arm perl_arm perldll_arm
456 -ren makedef.pl nomakedef.pl
458 # Symbian SDK has a makedef.pl of its own,
459 # and we don't need Perl's.
461 -ren nomakedef.pl makedef.pl
463 abld.bat abld: bld.inf
466 makefiles: win.mf arm.mf vc6.mf
468 vc6: win.mf vc6.mf build_vc6
470 win_miniperl.mf: abld.bat symbian\\config.pl
471 abld makefile \$(WIN) miniperl
472 echo > win_miniperl.mf
474 win_perl.mf: abld.bat symbian\\config.pl
475 abld makefile \$(WIN) perl
478 win_${VERSION}.mf: abld.bat symbian\\config.pl
479 abld makefile \$(WIN) perl${VERSION}
480 echo > win_${VERSION}.mf
483 cd symbian; make win.mf
485 win.mf: win_miniperl.mf win_perl.mf win_${VERSION}.mf symbian\\win.mf
487 arm_miniperl.mf: abld.bat symbian\\config.pl
488 abld makefile \$(ARM) miniperl
489 echo > arm_miniperl.mf
491 arm_perl.mf: abld.bat symbian\\config.pl
492 abld makefile \$(ARM) perl
495 arm_${VERSION}.mf: abld.bat symbian\\config.pl
496 abld makefile \$(ARM) perl${VERSION}
497 echo > arm_${VERSION}.mf
499 arm.mf: arm_miniperl.mf arm_perl.mf arm_${VERSION}.mf
501 vc6.mf: abld.bat symbian\\config.pl
505 PM = lib\\Config.pm lib\\Cross.pm lib\\lib.pm ext\\DynaLoader\\DynaLoader.pm ext\\DynaLoader\\XSLoader.pm ext\\Errno\\Errno.pm
506 POD = lib\\Config.pod
510 XLIB = -Ixlib\\symbian
512 XSBOPT = --win=\$(WIN) --arm=\$(ARM)
515 copy symbian\\config.sh config.sh
516 perl -pi.bak -e "s:x\\.y\\.z+:$R_V_SV:g" config.sh
517 perl \$(XLIB) configpm --cross=symbian
518 copy xlib\\symbian\\Config.pm lib\\Config.pm
519 perl -pi.bak -e "s:x\\.y\\.z:$R_V_SV:g" lib\\Config.pm
520 perl -pi.bak -e "s:5\\.\\d+\\.\\d+:$R_V_SV:g" lib\\Config.pm
521 -perl -pi.bak -e "s:x\\.y\\.z:$R_V_SV:g" xlib\\symbian\\Config_heavy.pl
526 ext\\DynaLoader\\DynaLoader.pm:
527 -del /f ext\\DynaLoader\\DynaLoader.pm
528 perl -Ixlib\\symbian ext\\DynaLoader\\DynaLoader_pm.PL
529 perl -pi.bak -e "s/__END__//" DynaLoader.pm
530 copy /y DynaLoader.pm ext\\DynaLoader\\DynaLoader.pm
531 -del /f DynaLoader.pm DynaLoader.pm.bak
533 ext\\DynaLoader\\XSLoader.pm:
534 perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) XSLoader
536 ext\\Errno\\Errno.pm:
537 perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) Errno
539 miniperlexe.sis: miniperl_arm symbian\\makesis.pl
540 perl \$(XLIB) symbian\\makesis.pl miniperl
542 perlexe.sis: perl_arm symbian\\makesis.pl
543 perl \$(XLIB) symbian\\makesis.pl perl
546 allsis: all miniperlexe.sis perlexe.sis perldll.sis perllib.sis perlext.sis perlapp.sis
548 perldll.sis perl$VERSION.sis: perldll_arm pm symbian\\makesis.pl
549 perl \$(XLIB) symbian\\makesis.pl perl${VERSION}dll
552 perl \$(XLIB) symbian\\makesis.pl perl${VERSION}lib
554 perlext.sis: perldll_arm buildext_sis
555 perl symbian\\makesis.pl perl${VERSION}ext
557 EXT = Cwd Data::Dumper Devel::Peek Digest::MD5 Errno Fcntl File::Glob Filter::Util::Call IO List::Util MIME::Base64 PerlIO::scalar PerlIO::via SDBM_File Socket Storable Time::HiRes XSLoader attrs
559 buildext: perldll symbian\\xsbuild.pl
560 perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) \$(EXT)
562 buildext_sis: perldll.sis symbian\\xsbuild.pl
563 perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --sis \$(EXT)
565 cleanext: symbian\\xsbuild.pl
566 perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --clean \$(EXT)
568 distcleanext: symbian\\xsbuild.pl
569 perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --distclean \$(EXT)
571 sis makesis: miniperl perl perldll pm buildext perlapp.sis
572 perl \$(XLIB) symbian\\makesis.pl
574 APIDIR = \\Symbian\\perl\\$R_V_SV
577 -mkdir \\Symbian\\perl
578 -mkdir \\Symbian\\perl\\$R_V_SV
579 -mkdir \$(APIDIR)\\include
580 -mkdir \$(APIDIR)\\include\\symbian
581 -mkdir \$(APIDIR)\\lib
582 -mkdir \$(APIDIR)\\lib\\ExtUtils
583 -mkdir \$(APIDIR)\\pod
584 -mkdir \$(APIDIR)\\bin
586 copy /y *.h \$(APIDIR)\\include
587 - copy /y *.inc \$(APIDIR)\\include
588 copy /y lib\\ExtUtils\\xsubpp \$(APIDIR)\\lib\\ExtUtils
589 copy /y lib\\ExtUtils\\typemap \$(APIDIR)\\lib\\ExtUtils
590 copy /y symbian\\xsbuild.pl \$(APIDIR)\\bin
591 copy /y symbian\\PerlBase.h \$(APIDIR)\\include
592 copy /y symbian\\symbian*.h \$(APIDIR)\\include\\symbian
593 copy /y symbian\\PerlBase.pod \$(APIDIR)\\pod
595 RELDIR = $SDK\\epoc32\\release
596 RELWIN = \$(RELDIR)\\\$(WIN)\\udeb
597 RELARM = \$(RELDIR)\\\$(ARM)\\$UARM
599 perlsdk.zip: perldll sdkinstall
600 zip -r perl${VERSION}sdk.zip \$(RELWIN)\\perl$VERSION.* \$(RELARM)\\perl$VERSION.* \$(APIDIR)
601 \@echo perl${VERSION}sdk.zip created.
603 perlapp: sdkinstall perlapp_win perlapp_arm
605 perlapp_win: config.h
606 cd symbian; make perlapp_win
608 perlapp_arm: config.h
609 cd symbian; make perlapp_arm
611 perlapp_demo_extract:
612 cd symbian; make perlapp_demo_extract
614 perlapp.sis: perlapp_arm
615 cd symbian; make perlapp.sis
618 cd symbian; zip perlapp.zip PerlApp.* PerlRecog.* PerlBase.* demo_pl
620 zip: perlsdk.zip perlapp.zip
622 freeze: freeze_win freeze_arm
625 abld freeze \$(WIN) perl$VERSION
628 abld freeze \$(ARM) perl$VERSION
630 defrost: defrost_win defrost_arm
646 clean: clean_win clean_arm rerename_makedef
649 -del /f lib\\Config.pm.bak
650 -del /f xlib\\symbian\\Config_heavy.pl
653 -del /f DynaLoader.pm ext\\DynaLoader\\DynaLoader.pm
654 -del /f ext\\DynaLoader\\Makefile
655 -del /f ext\\SDBM_File\\sdbm\\Makefile
656 -del /f symbian\\*.lst
657 -del /f abld.bat @unclean *.pkg *.sis *.zip
658 -del /f symbian\\abld.bat symbian\\*.sis symbian\\*.zip
659 -del /f symbian\\perl5*.pkg symbian\\miniperl.pkg
660 -del arm_*.mf win_*.mf vc6*.mf
661 -perl symbian\\xsbuild.pl \$(XSBOPT) --clean \$(EXT)
662 -rmdir /s /q perl${VERSION}_Data
663 -cd symbian; make clean
665 reallyclean: abld.bat
668 distclean: defrost reallyclean clean
669 -perl symbian\\xsbuild.pl \$(XSBOPT) --distclean \$(EXT)
670 -del /f config.h config.sh.bak symbian\\symbian_port.h
671 -del /f Makefile symbian\\PerlApp.mmp
673 -del /f *.cwlink *.resources *.pref
674 -del /f perl${VERSION}.xml perl${VERSION}.mcp uid.cpp
676 cd symbian; make distclean
677 -del /f symbian\\Makefile
682 warn "$0: failed to create Makefile: $!\n";
685 if ( open( MAKEFILE, ">symbian/Makefile")) {
686 my $wrap = $S60SDK eq '1.2' && $SDK !~ /_CW$/;
687 my $ABLD = $wrap ? 'perl b.pl': 'abld';
688 print "\tsymbian/Makefile\n";
689 print MAKEFILE <<__EOF__;
697 perlapp_win: abld.bat ..\\config.h PerlApp.h PerlApp.cpp
699 \$(ABLD) build \$(WIN) udeb
701 perlapp_arm: ..\\config.h PerlApp.h PerlApp.cpp
703 \$(ABLD) build \$(ARM) $UARM
709 perlapp_demo_extract:
712 perlapp.sis: perlapp_arm perlapp_demo_extract
715 copy /y perlapp.SIS ..\\perlapp.SIS
718 -perl demo_pl cleanup
723 -del /f *.cwlink *.resources *.pref
724 -del /f PerlApp.xml PerlApp.mcp uid.cpp
725 -rmdir /s /q PerlApp_Data
730 if ( open( B_PL, ">symbian/b.pl")) {
731 print B_PL <<'__EOF__';
734 # nmake doesn't like MFLAGS and MAKEFLAGS being set to -w and w.
736 delete $ENV{MAKEFLAGS};
738 system("abld @ARGV");
742 warn "$0: failed to create symbian/b.pl: $!\n";
746 warn "$0: failed to create symbian/Makefile: $!\n";
749 print "Deleting...\n";
751 # Do not delete config.h here.
754 "xlib\\symbian\\Config.pm",
755 "xlib\\symbian\\Config_heavy.pl",