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