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