embed.fnc cleanup + SvPVX_const usage
[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,1,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', 'symbian\symbian_utils.cpp',
317 );
318 create_mmp(
319     "perl",                      'exe',
320     'perlmain.c',                'symbian\symbian_stubs.c',
321     'symbian\symbian_utils.cpp', 'symbian\PerlBase.cpp',
322     'ext\DynaLoader\DynaLoader.cpp',
323 );
324
325 create_mmp(
326     "perl$VERSION",              'dll',
327     'symbian\symbian_dll.cpp',   'symbian\symbian_stubs.c',
328     'symbian\symbian_utils.cpp', 'symbian\PerlBase.cpp',
329     'ext\DynaLoader\DynaLoader.cpp',
330 );
331
332 create_bld_inf();
333 create_config_h();
334 create_perlmain_c();
335 create_symbian_port_h();
336 create_DynaLoader_cpp();
337 create_PerlApp_pkg();
338
339 if ( open( PERLAPP_MMP, ">symbian/PerlApp.mmp" ) ) {
340     my @MACRO;
341     push @MACRO, '__SERIES60_1X__' if $S60SDK =~ /^1\./;
342     push @MACRO, '__SERIES60_2X__' if $S60SDK =~ /^2\./;
343     print PERLAPP_MMP <<__EOF__;
344 // !!!!!!   DO NOT EDIT THIS FILE   !!!!!!
345 // This file is built by symbian\\config.pl.
346 // Any changes made here will be lost!
347 TARGET            PerlApp.app
348 TARGETTYPE        app
349 UID               0x100039CE 0x102015F6
350 TARGETPATH        \\system\\apps\\PerlApp
351 SRCDBG
352 EXPORTUNFROZEN
353 SOURCEPATH        .
354 SOURCE            PerlApp.cpp 
355
356 RESOURCE          PerlApp.rss
357
358 USERINCLUDE       .
359 USERINCLUDE       ..
360 USERINCLUDE       \\symbian\\perl\\$R_V_SV\\include
361
362 SYSTEMINCLUDE     \\epoc32\\include
363 SYSTEMINCLUDE     \\epoc32\\include\\libc
364
365 LIBRARY           apparc.lib
366 LIBRARY           avkon.lib 
367 LIBRARY           bafl.lib
368 LIBRARY           charconv.lib 
369 LIBRARY           commondialogs.lib 
370 LIBRARY           cone.lib 
371 LIBRARY           efsrv.lib
372 LIBRARY           eikcore.lib 
373 LIBRARY           estlib.lib 
374 LIBRARY           euser.lib
375 LIBRARY           perl$VERSION.lib
376
377 AIF               PerlApp.aif . PerlAppAif.rss 
378 __EOF__
379     if (@MACRO) {
380         for my $macro (@MACRO) {
381             print PERLAPP_MMP <<__EOF__;
382 MACRO             $macro
383 __EOF__
384         }
385     }
386     close(PERLAPP_MMP);
387     push @unclean, 'symbian\PerlApp.mmp';
388 }
389 else {
390     warn "$0: failed to create symbian\\PerlApp.mmp";
391 }
392
393 if ( open( MAKEFILE, ">Makefile" ) ) {
394     my $perl = "perl$VERSION";
395     my $windef1 = "$SDK\\Epoc32\\Build$CWD\\$perl\\$WIN\\$perl.def";
396     my $windef2 = "..\\BWINS\\${perl}u.def";
397     my $armdef1 = "$SDK\\Epoc32\\Build$CWD\\$perl\\$ARM\\$perl.def";
398     my $armdef2 = "..\\BMARM\\${perl}u.def";
399     print "\tMakefile\n";
400     print MAKEFILE <<__EOF__;
401 help:
402         \@echo === Perl for Symbian ===
403         \@echo Useful targets:
404         \@echo all win arm clean
405         \@echo perldll.sis perlext.sis perlsdk.zip
406
407 WIN     = ${WIN}
408 ARM     = ${ARM}
409
410 all:    build
411
412 build:  rename_makedef build_win build_arm
413
414 @unclean: symbian\\config.pl
415         perl symbian\\config.pl
416
417 build_win:      abld.bat win_perl.mf win_miniperl.mf win_${VERSION}.mf perldll_win
418
419 build_vc6:      abld.bat win_perl.mf win_miniperl.mf win_${VERSION}.mf vc6.mf perldll_win
420
421 build_arm:      abld.bat perl_arm miniperl_arm arm_${VERSION}.mf perldll_arm
422
423 miniperl_win:   miniperl.mmp abld.bat win_miniperl.mf rename_makedef
424         abld build \$(WIN) udeb miniperl
425
426 miniperl_arm:   miniperl.mmp abld.bat arm_miniperl.mf rename_makedef
427         abld build \$(ARM) $UARM miniperl
428
429 miniperl:       miniperl_win miniperl_arm
430
431 perl:   perl_win perl_arm
432
433 perl_win:       perl.mmp abld.bat win_perl.mf rename_makedef
434         abld build \$(WIN) perl
435
436 perl_arm:       perl.mmp abld.bat arm_perl.mf rename_makedef
437         abld build \$(ARM) $UARM perl
438
439 perldll_win: perl${VERSION}_win freeze_win perl${VERSION}_win
440
441 perl${VERSION}_win:     perl$VERSION.mmp abld.bat rename_makedef
442         abld build \$(WIN) perl$VERSION
443
444 perldll_arm: perl${VERSION}_arm freeze_arm perl${VERSION}_arm
445
446 perl${VERSION}_arm:     perl$VERSION.mmp arm_${VERSION}.mf abld.bat rename_makedef
447         abld build \$(ARM) $UARM perl$VERSION
448
449 perldll perl$VERSION:   perldll_win perldll_arm
450
451 win:    miniperl_win perl_win perldll_win
452
453 arm:    miniperl_arm perl_arm perldll_arm
454
455 rename_makedef:
456         -ren makedef.pl nomakedef.pl
457
458 # Symbian SDK has a makedef.pl of its own,
459 # and we don't need Perl's.
460 rerename_makedef:
461         -ren nomakedef.pl makedef.pl
462
463 abld.bat abld: bld.inf
464         bldmake bldfiles
465
466 makefiles: win.mf arm.mf vc6.mf
467
468 vc6:    win.mf vc6.mf build_vc6
469
470 win_miniperl.mf: abld.bat symbian\\config.pl
471         abld makefile \$(WIN) miniperl
472         echo > win_miniperl.mf
473
474 win_perl.mf: abld.bat symbian\\config.pl
475         abld makefile \$(WIN) perl
476         echo > win_perl.mf
477
478 win_${VERSION}.mf: abld.bat symbian\\config.pl
479         abld makefile \$(WIN) perl${VERSION}
480         echo > win_${VERSION}.mf
481
482 symbian\\win.mf:
483         cd symbian; make win.mf
484
485 win.mf: win_miniperl.mf win_perl.mf win_${VERSION}.mf symbian\\win.mf
486
487 arm_miniperl.mf: abld.bat symbian\\config.pl
488         abld makefile \$(ARM) miniperl
489         echo > arm_miniperl.mf
490
491 arm_perl.mf: abld.bat symbian\\config.pl
492         abld makefile \$(ARM) perl
493         echo > arm_perl.mf
494
495 arm_${VERSION}.mf: abld.bat symbian\\config.pl
496         abld makefile \$(ARM) perl${VERSION}
497         echo > arm_${VERSION}.mf
498
499 arm.mf: arm_miniperl.mf arm_perl.mf arm_${VERSION}.mf
500
501 vc6.mf: abld.bat symbian\\config.pl
502         abld makefile vc6
503         echo > vc6.mf
504
505 PM  = lib\\Config.pm lib\\Cross.pm lib\\lib.pm ext\\DynaLoader\\DynaLoader.pm ext\\DynaLoader\\XSLoader.pm ext\\Errno\\Errno.pm
506 POD = lib\\Config.pod
507
508 pm:     \$(PM)
509
510 XLIB    = -Ixlib\\symbian
511
512 XSBOPT  = --win=\$(WIN) --arm=\$(ARM)
513
514 lib\\Config.pm:
515         copy symbian\\config.sh config.sh
516         perl -pi.bak -e "s:x\\.y\\.z+:$R_V_SV:g" config.sh
517         perl \$(XLIB) configpm --cross=symbian
518         copy xlib\\symbian\\Config.pm lib\\Config.pm
519         perl -pi.bak -e "s:x\\.y\\.z:$R_V_SV:g" lib\\Config.pm
520         perl -pi.bak -e "s:5\\.\\d+\\.\\d+:$R_V_SV:g" lib\\Config.pm
521         -perl -pi.bak -e "s:x\\.y\\.z:$R_V_SV:g" xlib\\symbian\\Config_heavy.pl
522
523 lib\\lib.pm:
524         perl lib\\lib_pm.PL
525
526 ext\\DynaLoader\\DynaLoader.pm:
527         -del /f ext\\DynaLoader\\DynaLoader.pm
528         perl -Ixlib\\symbian ext\\DynaLoader\\DynaLoader_pm.PL
529         perl -pi.bak -e "s/__END__//" DynaLoader.pm
530         copy /y DynaLoader.pm ext\\DynaLoader\\DynaLoader.pm
531         -del /f DynaLoader.pm DynaLoader.pm.bak
532
533 ext\\DynaLoader\\XSLoader.pm:
534         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) XSLoader
535
536 ext\\Errno\\Errno.pm:
537         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) Errno
538
539 miniperlexe.sis:        miniperl_arm symbian\\makesis.pl
540         perl \$(XLIB) symbian\\makesis.pl miniperl
541
542 perlexe.sis:    perl_arm symbian\\makesis.pl
543         perl \$(XLIB) symbian\\makesis.pl perl
544
545
546 allsis: all miniperlexe.sis perlexe.sis perldll.sis perllib.sis perlext.sis perlapp.sis
547
548 perldll.sis perl$VERSION.sis:   perldll_arm pm symbian\\makesis.pl
549         perl \$(XLIB) symbian\\makesis.pl perl${VERSION}dll
550
551 perllib.sis:    \$(PM)
552         perl \$(XLIB) symbian\\makesis.pl perl${VERSION}lib
553
554 perlext.sis:    perldll_arm buildext_sis
555         perl symbian\\makesis.pl perl${VERSION}ext
556
557 EXT =   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
558
559 buildext: perldll symbian\\xsbuild.pl
560         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) \$(EXT)
561
562 buildext_sis: perldll.sis symbian\\xsbuild.pl
563         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --sis \$(EXT)
564
565 cleanext: symbian\\xsbuild.pl
566         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --clean \$(EXT)
567
568 distcleanext: symbian\\xsbuild.pl
569         perl \$(XLIB) symbian\\xsbuild.pl \$(XSBOPT) --distclean \$(EXT)
570
571 sis makesis:    miniperl perl perldll pm buildext perlapp.sis
572         perl \$(XLIB) symbian\\makesis.pl
573
574 APIDIR = \\Symbian\\perl\\$R_V_SV
575
576 sdkinstall:
577         -mkdir \\Symbian\\perl
578         -mkdir \\Symbian\\perl\\$R_V_SV
579         -mkdir \$(APIDIR)\\include
580         -mkdir \$(APIDIR)\\include\\symbian
581         -mkdir \$(APIDIR)\\lib
582         -mkdir \$(APIDIR)\\lib\\ExtUtils
583         -mkdir \$(APIDIR)\\pod
584         -mkdir \$(APIDIR)\\bin
585         -mkdir \$(BINDIR)
586         copy /y *.h   \$(APIDIR)\\include
587         - copy /y *.inc \$(APIDIR)\\include
588         copy /y lib\\ExtUtils\\xsubpp  \$(APIDIR)\\lib\\ExtUtils
589         copy /y lib\\ExtUtils\\typemap \$(APIDIR)\\lib\\ExtUtils
590         copy /y symbian\\xsbuild.pl    \$(APIDIR)\\bin
591         copy /y symbian\\PerlBase.h    \$(APIDIR)\\include
592         copy /y symbian\\symbian*.h    \$(APIDIR)\\include\\symbian
593         copy /y symbian\\PerlBase.pod  \$(APIDIR)\\pod
594
595 RELDIR  = $SDK\\epoc32\\release
596 RELWIN = \$(RELDIR)\\\$(WIN)\\udeb
597 RELARM = \$(RELDIR)\\\$(ARM)\\$UARM
598
599 perlsdk.zip: perldll sdkinstall
600         zip -r perl${VERSION}sdk.zip \$(RELWIN)\\perl$VERSION.* \$(RELARM)\\perl$VERSION.* \$(APIDIR)
601         \@echo perl${VERSION}sdk.zip created.
602
603 perlapp:        sdkinstall perlapp_win perlapp_arm
604
605 perlapp_win: config.h
606         cd symbian; make perlapp_win
607
608 perlapp_arm: config.h
609         cd symbian; make perlapp_arm
610
611 perlapp_demo_extract:
612         cd symbian; make perlapp_demo_extract
613
614 perlapp.sis: perlapp_arm
615         cd symbian; make perlapp.sis
616
617 perlapp.zip:
618         cd symbian; zip perlapp.zip PerlApp.* PerlRecog.* PerlBase.* demo_pl
619
620 zip:    perlsdk.zip perlapp.zip
621
622 freeze: freeze_win freeze_arm
623
624 freeze_win:
625         abld freeze \$(WIN) perl$VERSION
626
627 freeze_arm:
628         abld freeze \$(ARM) perl$VERSION
629
630 defrost:        defrost_win defrost_arm
631
632 defrost_win:
633         -del /f $windef1
634         -del /f $windef2
635
636 defrost_arm:
637         -del /f $armdef1
638         -del /f $armdef2
639
640 clean_win: abld.bat
641         abld clean \$(WIN)
642
643 clean_arm: abld.bat
644         abld clean \$(ARM)
645
646 clean:  clean_win clean_arm rerename_makedef
647         -del /f \$(PM)
648         -del /f \$(POD)
649         -del /f lib\\Config.pm.bak
650         -del /f xlib\\symbian\\Config_heavy.pl
651         -rmdir /s /q xlib
652         -del /f config.sh
653         -del /f DynaLoader.pm ext\\DynaLoader\\DynaLoader.pm
654         -del /f ext\\DynaLoader\\Makefile
655         -del /f ext\\SDBM_File\\sdbm\\Makefile
656         -del /f symbian\\*.lst
657         -del /f abld.bat @unclean *.pkg *.sis *.zip
658         -del /f symbian\\abld.bat symbian\\*.sis symbian\\*.zip
659         -del /f symbian\\perl5*.pkg symbian\\miniperl.pkg
660         -del arm_*.mf win_*.mf vc6*.mf
661         -perl symbian\\xsbuild.pl \$(XSBOPT) --clean \$(EXT)
662         -rmdir /s /q perl${VERSION}_Data
663         -cd symbian; make clean
664
665 reallyclean: abld.bat
666         abld reallyclean
667
668 distclean: defrost reallyclean clean
669         -perl symbian\\xsbuild.pl \$(XSBOPT) --distclean \$(EXT)
670         -del /f config.h config.sh.bak symbian\\symbian_port.h
671         -del /f Makefile symbian\\PerlApp.mmp
672         -del /f BMARM\\*.def
673         -del /f *.cwlink *.resources *.pref
674         -del /f perl${VERSION}.xml perl${VERSION}.mcp uid.cpp
675         -rmdir /s /q BMARM
676         cd symbian; make distclean
677         -del /f symbian\\Makefile
678 __EOF__
679     close MAKEFILE;
680 }
681 else {
682     warn "$0: failed to create Makefile: $!\n";
683 }
684
685 if ( open( MAKEFILE, ">symbian/Makefile")) {
686     my $wrap = $S60SDK eq '1.2' && $SDK !~ /_CW$/;
687     my $ABLD = $wrap ? 'perl b.pl': 'abld';
688     print "\tsymbian/Makefile\n";
689     print MAKEFILE <<__EOF__;
690 WIN = $WIN
691 ARM = $ARM
692 ABLD = $ABLD
693
694 abld.bat:
695         bldmake bldfiles
696
697 perlapp_win: abld.bat ..\\config.h PerlApp.h PerlApp.cpp
698         bldmake bldfiles
699         \$(ABLD) build \$(WIN) udeb
700
701 perlapp_arm: ..\\config.h PerlApp.h PerlApp.cpp
702         bldmake bldfiles
703         \$(ABLD) build \$(ARM) $UARM
704
705 win.mf:
706         bldmake bldfiles
707         abld makefile vc6
708
709 perlapp_demo_extract:
710         perl demo_pl extract
711
712 perlapp.sis: perlapp_arm perlapp_demo_extract
713         -del /f perlapp.SIS
714         makesis perlapp.pkg
715         copy /y perlapp.SIS ..\\perlapp.SIS
716
717 clean:
718         -perl demo_pl cleanup
719         -del /f perlapp.sis
720         -del /f b.pl
721
722 distclean: clean
723         -del /f *.cwlink *.resources *.pref
724         -del /f PerlApp.xml PerlApp.mcp uid.cpp
725         -rmdir /s /q PerlApp_Data
726         -del /f abld.bat
727 __EOF__
728     close(MAKEFILE);
729     if ($wrap) {
730         if ( open( B_PL, ">symbian/b.pl")) {
731             print B_PL <<'__EOF__';
732 # abld.pl wrapper.
733
734 # nmake doesn't like MFLAGS and MAKEFLAGS being set to -w and w.
735 delete $ENV{MFLAGS};
736 delete $ENV{MAKEFLAGS};
737
738 system("abld @ARGV");
739 __EOF__
740             close(B_PL);
741         } else {
742             warn "$0: failed to create symbian/b.pl: $!\n";
743         }
744     }
745 } else {
746     warn "$0: failed to create symbian/Makefile: $!\n";
747 }
748
749 print "Deleting...\n";
750 for my $config (
751                 # Do not delete config.h here.
752                 "config.sh",
753                 "lib\\Config.pm",
754                 "xlib\\symbian\\Config.pm",
755                 "xlib\\symbian\\Config_heavy.pl",
756                 ) {
757     print "\t$config\n";
758     unlink($config);
759 }
760
761 print <<__EOM__;
762 Configuring done.
763 Now you can run:
764     make all
765     make allsis
766 __EOM__
767
768 1;    # Happy End.