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