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