Symbian/beginnings of Series 80 support
[p5sagit/p5-mst-13.2.git] / symbian / config.pl
1 #!/usr/bin/perl -w
2
3 # Copyright (c) 2004-2005 Nokia.  All rights reserved.
4 # This utility is licensed under the same terms as Perl itself.
5
6 use strict;
7 use lib "symbian";
8
9 print "Configuring...\n";
10 print "Configuring with: Perl version $] ($^X)\n";
11
12 do "sanity.pl";
13
14 my %VERSION = %{ do "version.pl" };
15
16 printf "Configuring for:  Perl version $VERSION{REVISION}.%03d%03d\n",
17   $VERSION{VERSION}, $VERSION{SUBVERSION};
18
19 my $VERSION = "$VERSION{REVISION}$VERSION{VERSION}$VERSION{SUBVERSION}";
20 my $R_V_SV  = "$VERSION{REVISION}.$VERSION{VERSION}.$VERSION{SUBVERSION}";
21
22 my ($SYMBIAN_ROOT, $SYMBIAN_VERSION, $SDK_NAME, $SDK_VARIANT, $SDK_VERSION) =
23     @{ do "sdk.pl" };
24 my %PORT = %{ do "port.pl" };
25
26 if ($SYMBIAN_ROOT eq 'C:\Symbian\Series60_1_2_CW') {
27     ( $SYMBIAN_VERSION, $SDK_VERSION ) = qw(6.1 1.2);
28 }
29
30 my $WIN = $ENV{WIN} ; # 'wins', 'winscw' (from sdk.pl)
31 my $ARM = 'thumb';    # 'thumb', 'armv5'
32 my $S60SDK = $ENV{S60SDK}; # qw(1.2 2.0 2.1 2.6) (from sdk.pl)
33 my $S80SDK = $ENV{S80SDK}; # qw(2.0) (from sdk.pl)
34
35 my $UREL = $ENV{UREL}; # from sdk.pl
36 $UREL =~ s/-ARM-/$ARM/;
37 my $UARM = $ENV{UARM}; # from sdk.pl
38
39 die "$0: SDK not recognized\n"
40   if !defined($SYMBIAN_VERSION) ||
41      !defined($SDK_VERSION) ||
42      (!defined($S60SDK) && !defined($S80SDK));
43
44 die "$0: does not know which Windows compiler to use\n"
45     unless defined $WIN;
46
47 print "Symbian $SYMBIAN_VERSION SDK $SDK_VARIANT $SDK_VERSION ($WIN) installed at $SYMBIAN_ROOT\n";
48
49 my $CWD = do "cwd.pl";
50 print "Build directory $CWD\n";
51
52 die "$0: '+' in cwd does not work with Series 60 SDK 1.2\n"
53     if defined $S60SDK && $S60SDK eq '1.2' && $CWD =~ /\+/;
54
55 my @unclean;
56 my @mmp;
57
58 sub create_mmp {
59     my ( $target, $type, @x ) = @_;
60     my $miniperl = $target eq 'miniperl';
61     my $perl     = $target eq 'perl';
62     my $mmp        = "$target.mmp";
63     my $targetpath = $miniperl
64       || $perl ? "TARGETPATH\t\\System\\Apps\\Perl" : "";
65     if ( open( my $fh, ">$mmp" ) ) {
66         print "\t$mmp\n";
67         push @mmp,     $mmp;
68         push @unclean, $mmp;
69         print $fh <<__EOF__;
70 TARGET          $target.$type
71 TARGETTYPE      $type
72 $targetpath
73 EPOCHEAPSIZE    1024 8388608
74 EPOCSTACKSIZE   65536
75 EXPORTUNFROZEN
76 SRCDBG
77 __EOF__
78         if ($SDK_VARIANT eq 'S60') {
79             print $fh "MACRO\t__SERIES60__\n";
80             print $fh "MACRO\t__SERIES60_1X__\n" if $S60SDK =~ /^1\./;
81             print $fh "MACRO\t__SERIES60_2X__\n" if $S60SDK =~ /^2\./;
82         }
83         if ($SDK_VARIANT eq 'S80') {
84             print $fh "MACRO\t__SERIES80__\n";
85             print $fh "MACRO\t__SERIES80_1X__\n" if $S80SDK =~ /^1\./;
86             print $fh "MACRO\t__SERIES80_2X__\n" if $S80SDK =~ /^2\./;
87         }
88         my ( @c, %c );
89         @c = map  { glob } qw(*.c);       # Find the .c files.
90         @c = map  { lc } @c;              # Lowercase the names.
91         @c = grep { !/malloc\.c/ } @c;    # Use the system malloc.
92         @c = grep { !/main\.c/ } @c;      # main.c must be explicit.
93         push @c, map { lc } @x;
94         @c = map { s:^\.\./::; $_ } @c;    # Remove the leading ../
95         @c = map { $c{$_}++ } @c;          # Uniquefy.
96         @c = sort keys %c;                 # Beautify.
97
98         for (@c) {
99             print $fh "SOURCE\t\t$_\n";
100         }
101         print $fh <<__EOF__;
102 SOURCEPATH      $CWD
103 USERINCLUDE     $CWD
104 USERINCLUDE     $CWD\\ext\\DynaLoader
105 USERINCLUDE     $CWD\\symbian
106 SYSTEMINCLUDE   \\epoc32\\include\\libc
107 SYSTEMINCLUDE   \\epoc32\\include
108 LIBRARY         euser.lib
109 LIBRARY         estlib.lib
110 __EOF__
111         if ( $miniperl || $perl || $type eq 'dll' ) {
112             print $fh <<__EOF__;
113 LIBRARY         charconv.lib
114 LIBRARY         commonengine.lib
115 LIBRARY         hal.lib
116 LIBRARY         estor.lib
117 __EOF__
118         }
119         if ( $type eq 'exe' ) {
120             print $fh <<__EOF__;
121 STATICLIBRARY   ecrt0.lib
122 __EOF__
123         }
124         if ($miniperl) {
125             print $fh <<__EOF__;
126 MACRO           PERL_MINIPERL
127 __EOF__
128         }
129         if ($perl) {
130             print $fh <<__EOF__;
131 MACRO           PERL_PERL
132 __EOF__
133         }
134         print $fh <<__EOF__;
135 MACRO           PERL_CORE
136 MACRO           MULTIPLICITY
137 MACRO           PERL_IMPLICIT_CONTEXT
138 __EOF__
139         unless ( $miniperl || $perl ) {
140             print $fh <<__EOF__;
141 MACRO           PERL_GLOBAL_STRUCT
142 MACRO           PERL_GLOBAL_STRUCT_PRIVATE
143 __EOF__
144         }
145         close $fh;
146     }
147     else {
148         warn "$0: failed to open $mmp for writing: $!\n";
149     }
150 }
151
152 sub create_bld_inf {
153     if ( open( BLD_INF, ">bld.inf" ) ) {
154         print "\tbld.inf\n";
155         push @unclean, "bld.inf";
156         print BLD_INF <<__EOF__;
157 PRJ_PLATFORMS
158 ${WIN} ${ARM}
159 PRJ_MMPFILES
160 __EOF__
161         for (@mmp) { print BLD_INF $_, "\n" }
162         close BLD_INF;
163     }
164     else {
165         warn "$0: failed to open bld.inf for writing: $!\n";
166     }
167 }
168
169 my %config;
170
171 sub load_config_sh {
172     if ( open( CONFIG_SH, "symbian/config.sh" ) ) {
173         while (<CONFIG_SH>) {
174             if (/^(\w+)=['"]?(.*?)["']?$/) {
175                 my ( $var, $val ) = ( $1, $2 );
176                 $val =~ s/x.y.z/$R_V_SV/gi;
177                 $val =~ s/thumb/$ARM/gi;
178                 $val = "'$SYMBIAN_VERSION'" if $var eq 'osvers';
179                 $val = "'$SDK_VERSION'"     if $var eq 'sdkvers';
180                 $config{$var} = $val;
181             }
182         }
183         close CONFIG_SH;
184     }
185     else {
186         warn "$0: failed to open symbian\\config.sh for reading: $!\n";
187     }
188 }
189
190 sub create_config_h {
191     load_config_sh();
192     if ( open( CONFIG_H, ">config.h" ) ) {
193         print "\tconfig.h\n";
194         push @unclean, "config.h";
195         if ( open( CONFIG_H_SH, "config_h.SH" ) ) {
196             while (<CONFIG_H_SH>) {
197                 last if /\#ifndef _config_h_/;
198             }
199             print CONFIG_H <<__EOF__;
200 /*
201  * Package name      : perl
202  * Source directory  : .
203  * Configuration time: 
204  * Configured by     : 
205  * Target system     : symbian
206  */
207
208 #ifndef _config_h_
209 __EOF__
210             while (<CONFIG_H_SH>) {
211                 last if /!GROK!THIS/;
212                 s/\$(\w+)/exists $config{$1} ? $config{$1} : ""/eg;
213                 s/^#undef\s+(\S+).+/#undef $1/g;
214                 s:\Q/**/::;
215                 print CONFIG_H;
216             }
217             close CONFIG_H_SH;
218         }
219         else {
220             warn "$0: failed to open ../config_h.SH for reading: $!\n";
221         }
222         close CONFIG_H;
223     }
224     else {
225         warn "$0: failed to open config.h for writing: $!\n";
226     }
227 }
228
229 sub create_DynaLoader_cpp {
230     print "\text\\DynaLoader\\DynaLoader.cpp\n";
231     system(
232 q[perl -Ilib lib\ExtUtils\xsubpp ext\DynaLoader\dl_symbian.xs >ext\DynaLoader\DynaLoader.cpp]
233       ) == 0
234       or die "$0: creating DynaLoader.cpp failed: $!\n";
235     push @unclean, 'ext\DynaLoader\DynaLoader.cpp';
236
237 }
238
239 sub create_symbian_port_h {
240     print "\tsymbian\\symbian_port.h\n";
241     if ( open( SYMBIAN_PORT_H, ">symbian/symbian_port.h" ) ) {
242         my ($sdkmajor, $sdkminor);
243         if ($SDK_VARIANT eq 'S60') {
244             $S60SDK =~ /^(\d+)\.(\d+)$/;
245             ($sdkmajor, $sdkminor) = ($1, $2);
246         }
247         if ($SDK_VARIANT eq 'S80') {
248             $S80SDK =~ /^(\d+)\.(\d+)$/;
249             ($sdkmajor, $sdkminor) = ($1, $2);
250         }
251         print SYMBIAN_PORT_H <<__EOF__;
252 /* Copyright (c) 2004-2005, Nokia.  All rights reserved. */
253
254 #ifndef __symbian_port_h__
255 #define __symbian_port_h__
256
257 #define PERL_SYMBIANPORT_MAJOR $PORT{dll}->{MAJOR}
258 #define PERL_SYMBIANPORT_MINOR $PORT{dll}->{MINOR}
259 #define PERL_SYMBIANPORT_PATCH $PORT{dll}->{PATCH}
260
261 #define PERL_SYMBIANSDK_FLAVOR  L"$SDK_VARIANT"
262 #define PERL_SYMBIANSDK_MAJOR   $sdkmajor
263 #define PERL_SYMBIANSDK_MINOR   $sdkminor
264
265 #endif /* #ifndef __symbian_port_h__ */
266 __EOF__
267         close(SYMBIAN_PORT_H);
268         push @unclean, 'symbian\symbian_port.h';
269     }
270     else {
271         warn "$0: failed to open symbian/symbian_port.h for writing: $!\n";
272     }
273 }
274
275 sub create_perlmain_c {
276     print "\tperlmain.c\n";
277     system(
278 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]
279       ) == 0
280       or die "$0: Creating perlmain.c failed: $!\n";
281     push @unclean, 'perlmain.c';
282 }
283
284 sub create_PerlApp_pkg {
285     print "\tsymbian\\PerlApp.pkg\n";
286     if ( open( PERLAPP_PKG, ">symbian\\PerlApp.pkg" ) ) {
287         my $ProductId =
288             defined $S60SDK ?
289 qq[;Supports Series 60 v0.9\n(0x101F6F88), 0, 0, 0, {"Series60ProductID"}\n] :
290             defined $S80SDK ?
291 qq[;Supports Series 80 v2.0\n(0x101F8ED2), 0, 0, 0, {"Series80ProductID"}\n] :
292             ";Supports Series NN";
293         my $APPS = $UREL;
294         if (($SDK_VARIANT eq 'S60' && $SDK_VERSION ne '1.2' || $WIN eq 'winscw') || defined $S80SDK) { # Do only if not in S60 1.2 VC.
295             $APPS =~ s!\\epoc32\\release\\(.+)\\$UARM$!\\epoc32\\data\\z\\system\\apps\\PerlApp!i;
296         }
297         # In S60 3.0 there will be no more recognizers.
298         my $mdl = qq["$UREL\\PerlRecog.mdl"-"!:\\system\\recogs\\PerlRecog.mdl";];
299         print PERLAPP_PKG <<__EOF__;
300 ; !!!!!!   DO NOT EDIT THIS FILE   !!!!!!
301 ; This file is built by symbian\\config.pl.
302 ; Any changes made here will be lost!
303 ;
304 ; PerlApp.pkg
305 ;
306 ; Note that the demo_pl needs to be run to create the demo .pl scripts.
307 ;
308 ; Languages
309 &EN;
310
311 ; Standard SIS file header
312 #{"PerlApp"},(0x102015F6),0,2,0
313
314 $ProductId
315
316 ; Files
317 "$UREL\\PerlApp.APP"-"!:\\system\\apps\\PerlApp\\PerlApp.app"
318 $mdl
319 "$APPS\\PerlApp.rsc"-"!:\\system\\apps\\PerlApp\\PerlApp.rsc"
320 "$APPS\\PerlApp.aif"-"!:\\system\\apps\\PerlApp\\PerlApp.aif"
321 __EOF__
322         if ( open( DEMOS, "perl symbian\\demo_pl list |" ) ) {
323             while (<DEMOS>) {
324                 chomp;
325                 print PERLAPP_PKG qq["$_"-"!:\\Perl\\$_"\n];
326             }
327             close(DEMOS);
328         }
329         close(PERLAPP_PKG);
330     }
331     else {
332         die "$0: symbian\\PerlApp.pkg: $!\n";
333     }
334     push @unclean, 'symbian\PerlApp.pkg';
335 }
336
337 print "Creating...\n";
338 create_mmp(
339     'miniperl',             'exe',
340     'miniperlmain.c',       'symbian\symbian_stubs.c',
341     'symbian\PerlBase.cpp',
342     'symbian\PerlUtil.cpp',
343     'symbian\symbian_utils.cpp',
344 );
345 create_mmp(
346     "perl",                      'exe',
347     'perlmain.c',                'symbian\symbian_stubs.c',
348     'symbian\symbian_utils.cpp', 'symbian\PerlBase.cpp',
349     'symbian\PerlUtil.cpp',
350     'ext\DynaLoader\DynaLoader.cpp',
351 );
352
353 create_mmp(
354     "perl$VERSION",              'dll',
355     'symbian\symbian_dll.cpp',   'symbian\symbian_stubs.c',
356     'symbian\symbian_utils.cpp', 'symbian\PerlBase.cpp',
357     'symbian\PerlUtil.cpp',
358     'ext\DynaLoader\DynaLoader.cpp',
359 );
360
361 create_bld_inf();
362 create_config_h();
363 create_perlmain_c();
364 create_symbian_port_h();
365 create_DynaLoader_cpp();
366 create_PerlApp_pkg();
367
368 if ( open( PERLAPP_MMP, ">symbian/PerlApp.mmp" ) ) {
369     my @MACRO;
370     my @LIB;
371     if (defined $S60SDK) {
372         push @MACRO, '__SERIES60__';
373         push @MACRO, '__SERIES60_1X__' if $S60SDK =~ /^1\./;
374         push @MACRO, '__SERIES60_2X__' if $S60SDK =~ /^2\./;
375         push @LIB, <<__EOF__;
376 LIBRARY         avkon.lib
377 LIBRARY         commondialogs.lib 
378 __EOF__
379     }
380     if (defined $S80SDK) {
381         push @MACRO, '__SERIES80__';
382         push @MACRO, '__SERIES80_1X__' if $S80SDK =~ /^1\./;
383         push @MACRO, '__SERIES80_2X__' if $S80SDK =~ /^2\./;
384         push @LIB, <<__EOF__;
385 LIBRARY         eikctl.lib
386 LIBRARY         eikcoctl.lib
387 LIBRARY         ckndlg.lib
388 __EOF__
389     }
390     print PERLAPP_MMP <<__EOF__;
391 // !!!!!!   DO NOT EDIT THIS FILE   !!!!!!
392 // This file is built by symbian\\config.pl.
393 // Any changes made here will be lost!
394 TARGET            PerlApp.app
395 TARGETTYPE        app
396 UID               0x100039CE 0x102015F6
397 TARGETPATH        \\system\\apps\\PerlApp
398 SRCDBG
399 EXPORTUNFROZEN
400 SOURCEPATH        .
401 SOURCE            PerlApp.cpp 
402
403 RESOURCE          PerlApp.rss
404
405 USERINCLUDE       .
406 USERINCLUDE       ..
407 USERINCLUDE       \\symbian\\perl\\$R_V_SV\\include
408
409 SYSTEMINCLUDE     \\epoc32\\include
410 SYSTEMINCLUDE     \\epoc32\\include\\libc
411
412 LIBRARY           apparc.lib
413 LIBRARY           bafl.lib
414 LIBRARY           charconv.lib 
415 LIBRARY           cone.lib 
416 LIBRARY           efsrv.lib
417 LIBRARY           eikcore.lib 
418 LIBRARY           estlib.lib 
419 LIBRARY           euser.lib
420 LIBRARY           perl$VERSION.lib
421 @LIB
422
423 AIF               PerlApp.aif . PerlAppAif.rss 
424 __EOF__
425     if (@MACRO) {
426         for my $macro (@MACRO) {
427             print PERLAPP_MMP <<__EOF__;
428 MACRO             $macro
429 __EOF__
430         }
431     }
432     close(PERLAPP_MMP);
433     push @unclean, 'symbian\PerlApp.mmp';
434 }
435 else {
436     warn "$0: failed to create symbian\\PerlApp.mmp";
437 }
438
439 if ( open( MAKEFILE, ">Makefile" ) ) {
440     my $perl = "perl$VERSION";
441     my $windef1 = "$SYMBIAN_ROOT\\Epoc32\\Build$CWD\\$perl\\$WIN\\$perl.def";
442     my $windef2 = "..\\BWINS\\${perl}u.def";
443     my $armdef1 = "$SYMBIAN_ROOT\\Epoc32\\Build$CWD\\$perl\\$ARM\\$perl.def";
444     my $armdef2 = "..\\BMARM\\${perl}u.def";
445     print "\tMakefile\n";
446     print MAKEFILE <<__EOF__;
447 help:
448         \@echo === Perl for Symbian ===
449         \@echo Useful targets:
450         \@echo all win arm clean
451         \@echo perldll.sis perlext.sis perlsdk.zip
452
453 WIN     = ${WIN}
454 ARM     = ${ARM}
455
456 all:    build
457
458 build:  rename_makedef build_${WIN} build_arm
459
460 @unclean: symbian\\config.pl
461         perl symbian\\config.pl
462
463 build_${WIN}:   abld.bat ${WIN}_perl.mf ${WIN}_miniperl.mf ${WIN}_${VERSION}.mf perldll_${WIN}
464
465 build_vc6:      abld.bat ${WIN}_perl.mf ${WIN}_miniperl.mf ${WIN}_${VERSION}.mf vc6.mf perldll_wins
466
467 build_cw:       abld.bat ${WIN}_perl.mf ${WIN}_miniperl.mf ${WIN}_${VERSION}.mf cw.mf perldll_winscw
468
469 build_arm:      abld.bat perl_arm miniperl_arm arm_${VERSION}.mf perldll_arm
470
471 miniperl_win miniperl_${WIN}:   miniperl.mmp abld.bat ${WIN}_miniperl.mf rename_makedef
472         abld build ${WIN} udeb miniperl
473
474 miniperl_arm:   miniperl.mmp abld.bat arm_miniperl.mf rename_makedef
475         abld build \$(ARM) $UARM miniperl
476
477 miniperl:       miniperl_${WIN} miniperl_arm
478
479 perl:   perl_${WIN} perl_arm
480
481 perl_win perl_${WIN}:   perl.mmp abld.bat ${WIN}_perl.mf rename_makedef
482         abld build ${WIN} perl
483
484 perl_arm:       perl.mmp abld.bat arm_perl.mf rename_makedef
485         abld build \$(ARM) $UARM perl
486
487 perldll_win perldll_${WIN}: perl${VERSION}_${WIN} freeze_${WIN} perl${VERSION}_${WIN}
488
489 perl${VERSION}_win perl${VERSION}_${WIN}:       perl$VERSION.mmp abld.bat rename_makedef
490         abld build ${WIN} perl$VERSION
491
492 perldll_arm: perl${VERSION}_arm freeze_arm perl${VERSION}_arm
493
494 perl${VERSION}_arm:     perl$VERSION.mmp arm_${VERSION}.mf abld.bat rename_makedef
495         abld build \$(ARM) $UARM perl$VERSION
496
497 perldll perl$VERSION:   perldll_${WIN} perldll_arm
498
499 win ${WIN}:     miniperl_${WIN} perl_${WIN} perldll_${WIN}
500
501 thumb arm:      miniperl_arm perl_arm perldll_arm
502
503 rename_makedef:
504         -ren makedef.pl nomakedef.pl
505
506 # Symbian SDK has a makedef.pl of its own,
507 # and we don't need Perl's.
508 rerename_makedef:
509         -ren nomakedef.pl makedef.pl
510
511 abld.bat abld: bld.inf
512         bldmake bldfiles
513
514 makefiles: win.mf arm.mf vc6.mf cw.mf
515
516 vc6:    win.mf vc6.mf build_vc6
517
518 cw:     win.mf cw.mf build_cw
519
520 ${WIN}_miniperl.mf: abld.bat symbian\\config.pl
521         abld makefile ${WIN} miniperl
522         echo > ${WIN}_miniperl.mf
523
524 ${WIN}_perl.mf: abld.bat symbian\\config.pl
525         abld makefile ${WIN} perl
526         echo > ${WIN}_perl.mf
527
528 ${WIN}_${VERSION}.mf: abld.bat symbian\\config.pl
529         abld makefile ${WIN} perl${VERSION}
530         echo > ${WIN}_${VERSION}.mf
531
532 symbian\\${WIN}.mf:
533         cd symbian; make ${WIN}.mf
534
535 ${WIN}.mf: ${WIN}_miniperl.mf ${WIN}_perl.mf ${WIN}_${VERSION}.mf symbian\\${WIN}.mf
536
537 arm_miniperl.mf: abld.bat symbian\\config.pl
538         abld makefile \$(ARM) miniperl
539         echo > arm_miniperl.mf
540
541 arm_perl.mf: abld.bat symbian\\config.pl
542         abld makefile \$(ARM) perl
543         echo > arm_perl.mf
544
545 arm_${VERSION}.mf: abld.bat symbian\\config.pl
546         abld makefile \$(ARM) perl${VERSION}
547         echo > arm_${VERSION}.mf
548
549 arm.mf: arm_miniperl.mf arm_perl.mf arm_${VERSION}.mf
550
551 win.mf:  vc6.mf cw.mf
552         echo > win.mf
553
554 vc6.mf: abld.bat symbian\\config.pl
555         abld makefile vc6
556         echo > vc6.mf
557
558 cw.mf: abld.bat symbian\\config.pl
559         abld makefile cw_ide
560         echo > cw.mf
561
562 PM  = lib\\Config.pm lib\\Cross.pm lib\\lib.pm ext\\DynaLoader\\DynaLoader.pm ext\\DynaLoader\\XSLoader.pm ext\\Errno\\Errno.pm
563 POD = lib\\Config.pod
564
565 pm:     \$(PM)
566
567 XLIB    = -Ixlib\\symbian
568
569 XSBOPT  = --win=\$(WIN) --arm=\$(ARM)
570
571 lib\\Config.pm:
572         copy symbian\\config.sh config.sh
573         perl -pi.bak -e "s:x\\.y\\.z+:$R_V_SV:g" config.sh
574         perl \$(XLIB) configpm --cross=symbian
575         copy xlib\\symbian\\Config.pm lib\\Config.pm
576         perl -pi.bak -e "s:x\\.y\\.z:$R_V_SV:g" lib\\Config.pm
577         perl -pi.bak -e "s:5\\.\\d+\\.\\d+:$R_V_SV:g" lib\\Config.pm
578         -perl -pi.bak -e "s:x\\.y\\.z:$R_V_SV:g" xlib\\symbian\\Config_heavy.pl
579
580 lib\\lib.pm:
581         perl lib\\lib_pm.PL
582
583 ext\\DynaLoader\\DynaLoader.pm:
584         -del /f ext\\DynaLoader\\DynaLoader.pm
585         perl -Ixlib\\symbian ext\\DynaLoader\\DynaLoader_pm.PL
586         perl -pi.bak -e "s/__END__//" DynaLoader.pm
587         copy /y DynaLoader.pm ext\\DynaLoader\\DynaLoader.pm
588         -del /f DynaLoader.pm DynaLoader.pm.bak
589
590 ext\\DynaLoader\\XSLoader.pm:
591         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) XSLoader
592
593 ext\\Errno\\Errno.pm:
594         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) Errno
595
596 miniperlexe.sis:        miniperl_arm symbian\\makesis.pl
597         perl \$(XLIB) symbian\\makesis.pl miniperl
598
599 perlexe.sis:    perl_arm symbian\\makesis.pl
600         perl \$(XLIB) symbian\\makesis.pl perl
601
602
603 allsis: all miniperlexe.sis perlexe.sis perldll.sis perllib.sis perlext.sis perlapp.sis
604
605 perldll.sis perl$VERSION.sis:   perldll_arm pm symbian\\makesis.pl
606         perl \$(XLIB) symbian\\makesis.pl perl${VERSION}dll
607
608 perl${VERSION}lib.sis perllib.sis:      \$(PM)
609         perl \$(XLIB) symbian\\makesis.pl perl${VERSION}lib
610
611 perl${VERSION}ext.sis perlext.sis:      perldll_arm buildext_sis
612         perl symbian\\makesis.pl perl${VERSION}ext
613
614 EXT =   Compress::Zlib 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
615
616 buildext: perldll symbian\\xsbuild.pl lib\\Config.pm
617         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) \$(EXT)
618
619 buildext_sis: perldll.sis symbian\\xsbuild.pl lib\\Config.pm
620         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --sis \$(EXT)
621
622 cleanext: symbian\\xsbuild.pl
623         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --clean \$(EXT)
624
625 distcleanext: symbian\\xsbuild.pl
626         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --distclean \$(EXT)
627
628 sis makesis:    miniperl perl perldll pm buildext perlapp.sis
629         perl \$(XLIB) symbian\\makesis.pl
630
631 APIDIR = \\Symbian\\perl\\$R_V_SV
632
633 sdkinstall:
634         -mkdir \\Symbian\\perl
635         -mkdir \\Symbian\\perl\\$R_V_SV
636         -mkdir \$(APIDIR)\\include
637         -mkdir \$(APIDIR)\\include\\symbian
638         -mkdir \$(APIDIR)\\lib
639         -mkdir \$(APIDIR)\\lib\\ExtUtils
640         -mkdir \$(APIDIR)\\pod
641         -mkdir \$(APIDIR)\\bin
642         -mkdir \$(BINDIR)
643         copy /y *.h   \$(APIDIR)\\include
644         - copy /y *.inc \$(APIDIR)\\include
645         copy /y lib\\ExtUtils\\xsubpp  \$(APIDIR)\\lib\\ExtUtils
646         copy /y lib\\ExtUtils\\typemap \$(APIDIR)\\lib\\ExtUtils
647         copy /y lib\\ExtUtils\\ParseXS.pm \$(APIDIR)\\lib\\ExtUtils
648         copy /y symbian\\xsbuild.pl    \$(APIDIR)\\bin
649         copy /y symbian\\sisify.pl     \$(APIDIR)\\bin
650         copy /y symbian\\PerlBase.h    \$(APIDIR)\\include
651         copy /y symbian\\PerlUtil.h    \$(APIDIR)\\include
652         copy /y symbian\\symbian*.h    \$(APIDIR)\\include\\symbian
653         copy /y symbian\\PerlBase.pod  \$(APIDIR)\\pod
654         copy /y symbian\\PerlUtil.pod  \$(APIDIR)\\pod
655
656 RELDIR  = $SYMBIAN_ROOT\\epoc32\\release
657 RELWIN = \$(RELDIR)\\\$(WIN)\\udeb
658 RELARM = \$(RELDIR)\\\$(ARM)\\$UARM
659 SDKZIP = perl${VERSION}sdk.zip
660
661
662 \$(SDKZIP) perlsdk.zip: perldll sdkinstall
663         -del /f perl${VERSION}sdk.zip
664         zip -r perl${VERSION}sdk.zip \$(RELWIN)\\perl$VERSION.* \$(RELARM)\\perl$VERSION.* \$(APIDIR)
665         \@echo perl${VERSION}sdk.zip created.
666
667 PERLSIS = perl${VERSION}.SIS perl${VERSION}lib.SIS perl${VERSION}ext.SIS
668 ALLSIS  = \$(PERLSIS) perlapp.sis
669 ETC     = README.symbian symbian\\PerlBase.pod symbian\\PerlUtil.pod symbian\\sisify.pl symbian\\TODO
670
671 perl${VERSION}dist.zip perldist.zip: \$(ALLSIS) \$(SDKZIP) \$(ETC)
672         -del /f perl${VERSION}dist.zip
673         zip -r perl${VERSION}dist.zip \$(ALLSIS) \$(SDKZIP) \$(ETC)
674
675 perlapp:        sdkinstall perlapp_${WIN} perlapp_arm
676
677 perlapp_win perlapp_${WIN}: config.h
678         cd symbian; make perlapp_${WIN}
679
680 perlapp_arm: config.h
681         cd symbian; make perlapp_arm
682
683 perlapp_demo_extract:
684         cd symbian; make perlapp_demo_extract
685
686 perlapp.sis: perlapp_arm
687         cd symbian; make perlapp.sis
688
689 perlapp.zip:
690         cd symbian; zip perlapp.zip PerlApp.* PerlRecog.* PerlBase.* PerlUtil.* demo_pl
691
692 zip:    perlsdk.zip perlapp.zip
693
694 freeze: freeze_${WIN} freeze_arm
695
696 freeze_${WIN}:
697         abld freeze ${WIN} perl$VERSION
698
699 freeze_arm:
700         abld freeze \$(ARM) perl$VERSION
701
702 defrost:        defrost_${WIN} defrost_arm
703
704 defrost_${WIN}:
705         -del /f $windef1
706         -del /f $windef2
707
708 defrost_arm:
709         -del /f $armdef1
710         -del /f $armdef2
711
712 clean_${WIN}: abld.bat
713         abld clean ${WIN}
714
715 clean_arm: abld.bat
716         abld clean \$(ARM)
717
718 clean:  clean_${WIN} clean_arm rerename_makedef
719         -del /f \$(PM)
720         -del /f \$(POD)
721         -del /f lib\\Config.pm.bak
722         -del /f xlib\\symbian\\Config_heavy.pl
723         -rmdir /s /q xlib
724         -del /f config.sh
725         -del /f DynaLoader.pm ext\\DynaLoader\\DynaLoader.pm
726         -del /f ext\\DynaLoader\\Makefile
727         -del /f ext\\SDBM_File\\sdbm\\Makefile
728         -del /f symbian\\*.lst
729         -del /f abld.bat @unclean *.pkg *.sis *.zip
730         -del /f symbian\\abld.bat symbian\\*.sis symbian\\*.zip
731         -del /f symbian\\perl5*.pkg symbian\\miniperl.pkg
732         -del /f symbian\\PerlApp.rss
733         -del arm_*.mf ${WIN}_*.mf vc6*.mf cw*.mf
734         -perl symbian\\xsbuild.pl \$(XSBOPT) --clean \$(EXT)
735         -rmdir /s /q perl${VERSION}_Data
736         -cd symbian; make clean
737
738 reallyclean: abld.bat
739         abld reallyclean
740
741 distclean: defrost reallyclean clean
742         -perl symbian\\xsbuild.pl \$(XSBOPT) --distclean \$(EXT)
743         -del /f config.h config.sh.bak symbian\\symbian_port.h
744         -del /f Makefile symbian\\PerlApp.mmp
745         -del /f BMARM\\*.def
746         -del /f *.cwlink *.resources *.pref
747         -del /f perl${VERSION}.xml perl${VERSION}.mcp uid.cpp
748         -rmdir /s /q BMARM
749         cd symbian; make distclean
750         -del /f symbian\\Makefile
751 __EOF__
752     close MAKEFILE;
753 }
754 else {
755     warn "$0: failed to create Makefile: $!\n";
756 }
757
758 if ( open( MAKEFILE, ">symbian/Makefile")) {
759     my $wrap = defined $S60SDK && $S60SDK eq '1.2' && $WIN ne '${WIN}cw';
760     my $ABLD = $wrap ? 'perl b.pl': 'abld';
761     print "\tsymbian/Makefile\n";
762     print MAKEFILE <<__EOF__;
763 WIN = $WIN
764 ARM = $ARM
765 ABLD = $ABLD
766
767 abld.bat:
768         bldmake bldfiles
769
770 perlapp_${WIN}: abld.bat ..\\config.h PerlApp.h PerlApp.cpp
771         bldmake bldfiles
772         copy PerlApp$SDK_VARIANT.rss PerlApp.rss
773         \$(ABLD) build ${WIN} udeb
774
775 perlapp_arm: ..\\config.h PerlApp.h PerlApp.cpp
776         bldmake bldfiles
777         copy PerlApp$SDK_VARIANT.rss PerlApp.rss
778         \$(ABLD) build ${ARM} $UARM
779
780 win.mf:
781         bldmake bldfiles
782         abld makefile vc6
783         abld makefile cw_ide
784
785 perlapp_demo_extract:
786         perl demo_pl extract
787
788 perlapp.sis: perlapp_arm perlapp_demo_extract
789         -del /f perlapp.SIS
790         makesis perlapp.pkg
791         copy /y perlapp.SIS ..\\perlapp.SIS
792
793 clean:
794         -perl demo_pl cleanup
795         -del /f perlapp.sis
796         -del /f b.pl
797
798 distclean: clean
799         -del /f *.cwlink *.resources *.pref
800         -del /f PerlApp.xml PerlApp.mcp uid.cpp
801         -rmdir /s /q PerlApp_Data
802         -del /f abld.bat
803 __EOF__
804     close(MAKEFILE);
805     if ($wrap) {
806         if ( open( B_PL, ">symbian/b.pl")) {
807             print B_PL <<'__EOF__';
808 # abld.pl wrapper.
809
810 # nmake doesn't like MFLAGS and MAKEFLAGS being set to -w and w.
811 delete $ENV{MFLAGS};
812 delete $ENV{MAKEFLAGS};
813
814 system("abld @ARGV");
815 __EOF__
816             close(B_PL);
817         } else {
818             warn "$0: failed to create symbian/b.pl: $!\n";
819         }
820     }
821 } else {
822     warn "$0: failed to create symbian/Makefile: $!\n";
823 }
824
825 print "Deleting...\n";
826 for my $config (
827                 # Do not delete config.h here.
828                 "config.sh",
829                 "lib\\Config.pm",
830                 "xlib\\symbian\\Config.pm",
831                 "xlib\\symbian\\Config_heavy.pl",
832                 ) {
833     print "\t$config\n";
834     unlink($config);
835 }
836
837 print <<__EOM__;
838 Configuring done.
839 Now you can run:
840     make all
841     make allsis
842 __EOM__
843
844 1;    # Happy End.