77538b278654acdbc8741bb2d4a615ca256b5005
[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         eikdlg.lib
388 LIBRARY         ckndlg.lib
389 __EOF__
390     }
391     print PERLAPP_MMP <<__EOF__;
392 // !!!!!!   DO NOT EDIT THIS FILE   !!!!!!
393 // This file is built by symbian\\config.pl.
394 // Any changes made here will be lost!
395 TARGET            PerlApp.app
396 TARGETTYPE        app
397 UID               0x100039CE 0x102015F6
398 TARGETPATH        \\system\\apps\\PerlApp
399 SRCDBG
400 EXPORTUNFROZEN
401 SOURCEPATH        .
402 SOURCE            PerlApp.cpp 
403
404 RESOURCE          PerlApp.rss
405
406 USERINCLUDE       .
407 USERINCLUDE       ..
408 USERINCLUDE       \\symbian\\perl\\$R_V_SV\\include
409
410 SYSTEMINCLUDE     \\epoc32\\include
411 SYSTEMINCLUDE     \\epoc32\\include\\libc
412
413 LIBRARY           apparc.lib
414 LIBRARY           bafl.lib
415 LIBRARY           charconv.lib 
416 LIBRARY           cone.lib 
417 LIBRARY           efsrv.lib
418 LIBRARY           eikcore.lib 
419 LIBRARY           estlib.lib 
420 LIBRARY           euser.lib
421 LIBRARY           perl$VERSION.lib
422 @LIB
423
424 AIF               PerlApp.aif . PerlAppAif.rss 
425 __EOF__
426     if (@MACRO) {
427         for my $macro (@MACRO) {
428             print PERLAPP_MMP <<__EOF__;
429 MACRO             $macro
430 __EOF__
431         }
432     }
433     close(PERLAPP_MMP);
434     push @unclean, 'symbian\PerlApp.mmp';
435 }
436 else {
437     warn "$0: failed to create symbian\\PerlApp.mmp";
438 }
439
440 if ( open( MAKEFILE, ">Makefile" ) ) {
441     my $perl = "perl$VERSION";
442     my $windef1 = "$SYMBIAN_ROOT\\Epoc32\\Build$CWD\\$perl\\$WIN\\$perl.def";
443     my $windef2 = "..\\BWINS\\${perl}u.def";
444     my $armdef1 = "$SYMBIAN_ROOT\\Epoc32\\Build$CWD\\$perl\\$ARM\\$perl.def";
445     my $armdef2 = "..\\BMARM\\${perl}u.def";
446     print "\tMakefile\n";
447     print MAKEFILE <<__EOF__;
448 help:
449         \@echo === Perl for Symbian ===
450         \@echo Useful targets:
451         \@echo all win arm clean
452         \@echo perldll.sis perlext.sis perlsdk.zip
453
454 WIN     = ${WIN}
455 ARM     = ${ARM}
456
457 all:    build
458
459 build:  rename_makedef build_${WIN} build_arm
460
461 @unclean: symbian\\config.pl
462         perl symbian\\config.pl
463
464 build_${WIN}:   abld.bat ${WIN}_perl.mf ${WIN}_miniperl.mf ${WIN}_${VERSION}.mf perldll_${WIN}
465
466 build_vc6:      abld.bat ${WIN}_perl.mf ${WIN}_miniperl.mf ${WIN}_${VERSION}.mf vc6.mf perldll_wins
467
468 build_vc7:      abld.bat ${WIN}_perl.mf ${WIN}_miniperl.mf ${WIN}_${VERSION}.mf vc7.mf perldll_wins
469
470 build_cw:       abld.bat ${WIN}_perl.mf ${WIN}_miniperl.mf ${WIN}_${VERSION}.mf cw.mf perldll_winscw
471
472 build_arm:      abld.bat perl_arm miniperl_arm arm_${VERSION}.mf perldll_arm
473
474 miniperl_win miniperl_${WIN}:   miniperl.mmp abld.bat ${WIN}_miniperl.mf rename_makedef
475         abld build ${WIN} udeb miniperl
476
477 miniperl_arm:   miniperl.mmp abld.bat arm_miniperl.mf rename_makedef
478         abld build \$(ARM) $UARM miniperl
479
480 miniperl:       miniperl_${WIN} miniperl_arm
481
482 perl:   perl_${WIN} perl_arm
483
484 perl_win perl_${WIN}:   perl.mmp abld.bat ${WIN}_perl.mf rename_makedef
485         abld build ${WIN} perl
486
487 perl_arm:       perl.mmp abld.bat arm_perl.mf rename_makedef
488         abld build \$(ARM) $UARM perl
489
490 perldll_win perldll_${WIN}: perl${VERSION}_${WIN} freeze_${WIN} perl${VERSION}_${WIN}
491
492 perl${VERSION}_win perl${VERSION}_${WIN}:       perl$VERSION.mmp abld.bat rename_makedef
493         abld build ${WIN} perl$VERSION
494
495 perldll_arm: perl${VERSION}_arm freeze_arm perl${VERSION}_arm
496
497 perl${VERSION}_arm:     perl$VERSION.mmp arm_${VERSION}.mf abld.bat rename_makedef
498         abld build \$(ARM) $UARM perl$VERSION
499
500 perldll perl$VERSION:   perldll_${WIN} perldll_arm
501
502 win ${WIN}:     miniperl_${WIN} perl_${WIN} perldll_${WIN}
503
504 thumb arm:      miniperl_arm perl_arm perldll_arm
505
506 rename_makedef:
507         -ren makedef.pl nomakedef.pl
508
509 # Symbian SDK has a makedef.pl of its own,
510 # and we don't need Perl's.
511 rerename_makedef:
512         -ren nomakedef.pl makedef.pl
513
514 abld.bat abld: bld.inf
515         bldmake bldfiles
516
517 makefiles: win.mf arm.mf vc6 vc7.mf cw.mf
518
519 vc6:    win.mf vc6.mf build_vc6
520
521 vc7:    win.mf vc7.mf build_vc7
522
523 cw:     win.mf cw.mf build_cw
524
525 ${WIN}_miniperl.mf: abld.bat symbian\\config.pl
526         abld makefile ${WIN} miniperl
527         echo > ${WIN}_miniperl.mf
528
529 ${WIN}_perl.mf: abld.bat symbian\\config.pl
530         abld makefile ${WIN} perl
531         echo > ${WIN}_perl.mf
532
533 ${WIN}_${VERSION}.mf: abld.bat symbian\\config.pl
534         abld makefile ${WIN} perl${VERSION}
535         echo > ${WIN}_${VERSION}.mf
536
537 symbian\\${WIN}.mf:
538         cd symbian; make ${WIN}.mf
539
540 ${WIN}.mf: ${WIN}_miniperl.mf ${WIN}_perl.mf ${WIN}_${VERSION}.mf symbian\\${WIN}.mf
541
542 arm_miniperl.mf: abld.bat symbian\\config.pl
543         abld makefile \$(ARM) miniperl
544         echo > arm_miniperl.mf
545
546 arm_perl.mf: abld.bat symbian\\config.pl
547         abld makefile \$(ARM) perl
548         echo > arm_perl.mf
549
550 arm_${VERSION}.mf: abld.bat symbian\\config.pl
551         abld makefile \$(ARM) perl${VERSION}
552         echo > arm_${VERSION}.mf
553
554 arm.mf: arm_miniperl.mf arm_perl.mf arm_${VERSION}.mf
555
556 win.mf:  vc6.mf cw.mf
557         echo > win.mf
558
559 vc6.mf: abld.bat symbian\\config.pl
560         abld makefile vc6
561         echo > vc6.mf
562
563 vc7.mf: abld.bat symbian\\config.pl
564         abld makefile vc7
565         echo > vc7.mf
566
567 cw.mf: abld.bat symbian\\config.pl
568         abld makefile cw_ide
569         echo > cw.mf
570
571 PM  = lib\\Config.pm lib\\Cross.pm lib\\lib.pm ext\\DynaLoader\\DynaLoader.pm ext\\DynaLoader\\XSLoader.pm ext\\Errno\\Errno.pm
572 POD = lib\\Config.pod
573
574 pm:     \$(PM)
575
576 XLIB    = -Ixlib\\symbian
577
578 XSBOPT  = --win=\$(WIN) --arm=\$(ARM)
579
580 lib\\Config.pm:
581         copy symbian\\config.sh config.sh
582         perl -pi.bak -e "s:x\\.y\\.z+:$R_V_SV:g" config.sh
583         perl \$(XLIB) configpm --cross=symbian
584         copy xlib\\symbian\\Config.pm lib\\Config.pm
585         perl -pi.bak -e "s:x\\.y\\.z:$R_V_SV:g" lib\\Config.pm
586         perl -pi.bak -e "s:5\\.\\d+\\.\\d+:$R_V_SV:g" lib\\Config.pm
587         -perl -pi.bak -e "s:x\\.y\\.z:$R_V_SV:g" xlib\\symbian\\Config_heavy.pl
588
589 lib\\lib.pm:
590         perl lib\\lib_pm.PL
591
592 ext\\DynaLoader\\DynaLoader.pm:
593         -del /f ext\\DynaLoader\\DynaLoader.pm
594         perl -Ixlib\\symbian ext\\DynaLoader\\DynaLoader_pm.PL
595         perl -pi.bak -e "s/__END__//" DynaLoader.pm
596         copy /y DynaLoader.pm ext\\DynaLoader\\DynaLoader.pm
597         -del /f DynaLoader.pm DynaLoader.pm.bak
598
599 ext\\DynaLoader\\XSLoader.pm:
600         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) XSLoader
601
602 ext\\Errno\\Errno.pm:
603         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) Errno
604
605 miniperlexe.sis:        miniperl_arm symbian\\makesis.pl
606         perl \$(XLIB) symbian\\makesis.pl miniperl
607
608 perlexe.sis:    perl_arm symbian\\makesis.pl
609         perl \$(XLIB) symbian\\makesis.pl perl
610
611
612 allsis: all miniperlexe.sis perlexe.sis perldll.sis perllib.sis perlext.sis perlapp.sis
613
614 perldll.sis perl$VERSION.sis:   perldll_arm pm symbian\\makesis.pl
615         perl \$(XLIB) symbian\\makesis.pl perl${VERSION}dll
616
617 perl${VERSION}lib.sis perllib.sis:      \$(PM)
618         perl \$(XLIB) symbian\\makesis.pl perl${VERSION}lib
619
620 perl${VERSION}ext.sis perlext.sis:      perldll_arm buildext_sis
621         perl symbian\\makesis.pl perl${VERSION}ext
622
623 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
624
625 buildext: perldll symbian\\xsbuild.pl lib\\Config.pm
626         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) \$(EXT)
627
628 buildext_sis: perldll.sis symbian\\xsbuild.pl lib\\Config.pm
629         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --sis \$(EXT)
630
631 cleanext: symbian\\xsbuild.pl
632         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --clean \$(EXT)
633
634 distcleanext: symbian\\xsbuild.pl
635         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --distclean \$(EXT)
636
637 sis makesis:    miniperl perl perldll pm buildext perlapp.sis
638         perl \$(XLIB) symbian\\makesis.pl
639
640 APIDIR = \\Symbian\\perl\\$R_V_SV
641
642 sdkinstall:
643         -mkdir \\Symbian\\perl
644         -mkdir \\Symbian\\perl\\$R_V_SV
645         -mkdir \$(APIDIR)\\include
646         -mkdir \$(APIDIR)\\include\\symbian
647         -mkdir \$(APIDIR)\\lib
648         -mkdir \$(APIDIR)\\lib\\ExtUtils
649         -mkdir \$(APIDIR)\\pod
650         -mkdir \$(APIDIR)\\bin
651         -mkdir \$(BINDIR)
652         copy /y *.h   \$(APIDIR)\\include
653         - copy /y *.inc \$(APIDIR)\\include
654         copy /y lib\\ExtUtils\\xsubpp  \$(APIDIR)\\lib\\ExtUtils
655         copy /y lib\\ExtUtils\\typemap \$(APIDIR)\\lib\\ExtUtils
656         copy /y lib\\ExtUtils\\ParseXS.pm \$(APIDIR)\\lib\\ExtUtils
657         copy /y symbian\\xsbuild.pl    \$(APIDIR)\\bin
658         copy /y symbian\\sisify.pl     \$(APIDIR)\\bin
659         copy /y symbian\\PerlBase.h    \$(APIDIR)\\include
660         copy /y symbian\\PerlUtil.h    \$(APIDIR)\\include
661         copy /y symbian\\symbian*.h    \$(APIDIR)\\include\\symbian
662         copy /y symbian\\PerlBase.pod  \$(APIDIR)\\pod
663         copy /y symbian\\PerlUtil.pod  \$(APIDIR)\\pod
664
665 RELDIR  = $SYMBIAN_ROOT\\epoc32\\release
666 RELWIN = \$(RELDIR)\\\$(WIN)\\udeb
667 RELARM = \$(RELDIR)\\\$(ARM)\\$UARM
668 SDKZIP = perl${VERSION}sdk.zip
669
670
671 \$(SDKZIP) perlsdk.zip: perldll sdkinstall
672         -del /f perl${VERSION}sdk.zip
673         zip -r perl${VERSION}sdk.zip \$(RELWIN)\\perl$VERSION.* \$(RELARM)\\perl$VERSION.* \$(APIDIR)
674         \@echo perl${VERSION}sdk.zip created.
675
676 PERLSIS = perl${VERSION}.SIS perl${VERSION}lib.SIS perl${VERSION}ext.SIS
677 ALLSIS  = \$(PERLSIS) perlapp.sis
678 ETC     = README.symbian symbian\\PerlBase.pod symbian\\PerlUtil.pod symbian\\sisify.pl symbian\\TODO
679
680 perl${VERSION}dist.zip perldist.zip: \$(ALLSIS) \$(SDKZIP) \$(ETC)
681         -del /f perl${VERSION}dist.zip
682         zip -r perl${VERSION}dist.zip \$(ALLSIS) \$(SDKZIP) \$(ETC)
683
684 perlapp:        sdkinstall perlapp_${WIN} perlapp_arm
685
686 perlapp_arm_minimal sisify_hex perlappmin.hex perlrscmin.hex:   sdkinstall config.h
687         cd symbian; make perlapp_arm USERDEFS=-DCreatePerlAppMinimal
688         perl symbian\\hexdump.pl
689
690 perlapp_win perlapp_${WIN}: config.h
691         cd symbian; make perlapp_${WIN}
692
693 perlapp_arm: config.h
694         cd symbian; make perlapp_arm
695
696 perlapp_arm_clean:
697         cd symbian; make clean
698
699 perlapp_demo_extract:
700         cd symbian; make perlapp_demo_extract
701
702 perlapp.sis: perlapp_arm
703         cd symbian; make perlapp.sis
704
705 perlapp.zip:
706         cd symbian; zip perlapp.zip PerlApp.* PerlRecog.* PerlBase.* PerlUtil.* demo_pl
707
708 zip:    perlsdk.zip perlapp.zip
709
710 freeze: freeze_${WIN} freeze_arm
711
712 freeze_${WIN}:
713         abld freeze ${WIN} perl$VERSION
714
715 freeze_arm:
716         abld freeze \$(ARM) perl$VERSION
717
718 defrost:        defrost_${WIN} defrost_arm
719
720 defrost_${WIN}:
721         -del /f $windef1
722         -del /f $windef2
723
724 defrost_arm:
725         -del /f $armdef1
726         -del /f $armdef2
727
728 clean_${WIN}: abld.bat
729         abld clean ${WIN}
730
731 clean_arm: abld.bat
732         abld clean \$(ARM)
733
734 clean:  clean_${WIN} clean_arm rerename_makedef
735         -del /f \$(PM)
736         -del /f \$(POD)
737         -del /f lib\\Config.pm.bak
738         -del /f xlib\\symbian\\Config_heavy.pl
739         -rmdir /s /q xlib
740         -del /f config.sh
741         -del /f DynaLoader.pm ext\\DynaLoader\\DynaLoader.pm
742         -del /f ext\\DynaLoader\\Makefile
743         -del /f ext\\SDBM_File\\sdbm\\Makefile
744         -del /f symbian\\*.lst
745         -del /f abld.bat @unclean *.pkg *.sis *.zip
746         -del /f symbian\\abld.bat symbian\\*.sis symbian\\*.zip
747         -del /f symbian\\perl5*.pkg symbian\\miniperl.pkg
748         -del /f symbian\\PerlApp.rss
749         -del arm_*.mf ${WIN}_*.mf vc*.mf cw*.mf
750         -del perlappmin.hex perlrscmin.hex
751         -perl symbian\\xsbuild.pl \$(XSBOPT) --clean \$(EXT)
752         -rmdir /s /q perl${VERSION}_Data
753         -cd symbian; make clean
754
755 reallyclean: abld.bat
756         abld reallyclean
757
758 distclean: defrost reallyclean clean
759         -perl symbian\\xsbuild.pl \$(XSBOPT) --distclean \$(EXT)
760         -del /f config.h config.sh.bak symbian\\symbian_port.h
761         -del /f Makefile symbian\\PerlApp.mmp
762         -del /f BMARM\\*.def
763         -del /f *.cwlink *.resources *.pref
764         -del /f perl${VERSION}.xml perl${VERSION}.mcp uid.cpp
765         -rmdir /s /q BMARM
766         cd symbian; make distclean
767         -del /f symbian\\Makefile
768 __EOF__
769     close MAKEFILE;
770 }
771 else {
772     warn "$0: failed to create Makefile: $!\n";
773 }
774
775 if ( open( MAKEFILE, ">symbian/Makefile")) {
776     my $wrap = defined $S60SDK && $S60SDK eq '1.2' && $WIN ne '${WIN}cw';
777     my $ABLD = $wrap ? 'perl b.pl': 'abld';
778     print "\tsymbian/Makefile\n";
779     print MAKEFILE <<__EOF__;
780 WIN = $WIN
781 ARM = $ARM
782 ABLD = $ABLD
783
784 abld.bat:
785         bldmake bldfiles
786
787 perlapp_${WIN}: abld.bat ..\\config.h PerlApp.h PerlApp.cpp
788         bldmake bldfiles
789         copy PerlApp$SDK_VARIANT.rss PerlApp.rss
790         \$(ABLD) build ${WIN} udeb
791
792 perlapp_arm: ..\\config.h PerlApp.h PerlApp.cpp
793         bldmake bldfiles
794         copy PerlApp$SDK_VARIANT.rss PerlApp.rss
795         \$(ABLD) build ${ARM} $UARM
796
797 win.mf:
798         bldmake bldfiles
799         abld makefile vc6
800         abld makefile vc7
801         abld makefile cw_ide
802
803 perlapp_demo_extract:
804         perl demo_pl extract
805
806 perlapp.sis: perlapp_arm perlapp_demo_extract
807         -del /f perlapp.SIS
808         makesis perlapp.pkg
809         copy /y perlapp.SIS ..\\perlapp.SIS
810
811 clean:
812         -perl demo_pl cleanup
813         -del /f perlapp.sis
814         -del /f b.pl
815         abld clean $WIN
816         abld clean thumb
817
818 distclean: clean
819         -del /f *.cwlink *.resources *.pref
820         -del /f PerlApp.xml PerlApp.mcp uid.cpp
821         -rmdir /s /q PerlApp_Data
822         -del /f abld.bat
823 __EOF__
824     close(MAKEFILE);
825     if ($wrap) {
826         if ( open( B_PL, ">symbian/b.pl")) {
827             print B_PL <<'__EOF__';
828 # abld.pl wrapper.
829
830 # nmake doesn't like MFLAGS and MAKEFLAGS being set to -w and w.
831 delete $ENV{MFLAGS};
832 delete $ENV{MAKEFLAGS};
833
834 system("abld @ARGV");
835 __EOF__
836             close(B_PL);
837         } else {
838             warn "$0: failed to create symbian/b.pl: $!\n";
839         }
840     }
841 } else {
842     warn "$0: failed to create symbian/Makefile: $!\n";
843 }
844
845 print "Deleting...\n";
846 for my $config (
847                 # Do not delete config.h here.
848                 "config.sh",
849                 "lib\\Config.pm",
850                 "xlib\\symbian\\Config.pm",
851                 "xlib\\symbian\\Config_heavy.pl",
852                 ) {
853     print "\t$config\n";
854     unlink($config);
855 }
856
857 print <<__EOM__;
858 Configuring done.
859 Now you can run:
860     make all
861     make allsis
862 __EOM__
863
864 1;    # Happy End.