Upgrade to Encode 1.92.
[p5sagit/p5-mst-13.2.git] / wince / makedist.pl
CommitLineData
2e64bfdb 1use strict;
2use Cwd;
3use File::Path;
4use File::Find;
5
6my %opts = (
7 #defaults
8 'distdir' => 'distdir',
9 'unicode' => 1, # include unicode by default
10 'minimal' => 0, # minimal possible distribution.
11 # actually this is just perl.exe and perlXX.dll
12 # but can be extended by additional exts
13 # ... (as soon as this will be implemented :)
14 'include-modules' => '', # TODO
15 'exclude-modules' => '', # TODO
16 #??? 'only-modules' => '', # TODO
17 'platform' => 'wince',
18 'strip-pod' => 0, # TODO strip POD from perl modules
19 'adaptation' => 0, # TODO do some adaptation, such as stripping such
20 # occurences as "if ($^O eq 'VMS'){...}" for certain modules
21 'zip' => 0, # perform zip (TODO)
22 'clean-exts' => 0,
23 #options itself
24 (map {/^--([\-_\w]+)=(.*)$/} @ARGV), # --opt=smth
25 (map {/^no-?(.*)$/i?($1=>0):($_=>1)} map {/^--([\-_\w]+)$/} @ARGV), # --opt --no-opt --noopt
26 );
27
28# TODO -- error checking. When something goes wrong, just exit with rc!=0
29
30my $cwd = cwd;
31
32if ($opts{'clean-exts'}) {
33 # unfortunately, unlike perl58.dll and like, extensions for different
34 # platforms are built in same directory, therefore we must be able to clean
35 # them often
36 unlink '../config.sh'; # delete cache config file, which remembers our previous config
37 chdir '../ext';
38 find({no_chdir=>1,wanted => sub{
39 unlink if /((?:\.obj|\/makefile|\/errno\.pm))$/i;
40 }
41 },'.');
42 exit;
43}
44
45my (%libexclusions, %extexclusions);
46my @lfiles;
47sub copy($$);
48
49# lib
50chdir '../lib';
51find({no_chdir=>1,wanted=>sub{push @lfiles, $_ if /\.p[lm]$/}},'.');
52chdir $cwd;
53# exclusions
54@lfiles = grep {!exists $libexclusions{$_}} @lfiles;
55#inclusions
56#...
57#copy them
58for (@lfiles) {
59 /^(.*)\/[^\/]+$/;
60 mkpath "$opts{distdir}/lib/$1";
61 copy "../lib/$_", "$opts{distdir}/lib/$_";
62}
63
64#ext
65my @efiles;
66chdir '../ext';
67find({no_chdir=>1,wanted=>sub{push @efiles, $_ if /\.pm$/}},'.');
68chdir $cwd;
69# exclusions
70#...
71#inclusions
72#...
73#copy them
74#{s[/(\w+)/\1\.pm][/$1.pm]} @efiles;
75for (@efiles) {
76 /^(.*)\/([^\/]+)\/([^\/]+)$/;
77 copy "../ext/$_", "$opts{distdir}/lib/$1/$3";
78}
79
80# Config.pm
81copy "../xlib/$opts{platform}/Config.pm", "$opts{distdir}/lib/Config.pm";
82
83# auto
84my @afiles;
85chdir "../xlib/$opts{platform}/auto";
86find({no_chdir=>1,wanted=>sub{push @afiles, $_ if /\.(dll|bs)$/}},'.');
87chdir $cwd;
88for (@afiles) {
89 copy "../xlib/$opts{platform}/auto/$_", "$opts{distdir}/lib/auto/$_";
90}
91
92sub copy {
93 my ($fnfrom, $fnto) = @_;
94 my $ffrom = do {local (@ARGV,$/) = $fnfrom; <>};
95 if ($opts{'strip-pod'}) {
96 # actually following regexp is suspicious to not work everywhere.
97 # but we've checked on our set of modules, and it's fit for our purposes
98 $ffrom =~ s/^=\w+.*?^=cut(?:\n|\Z)//msg;
99 # $ffrom =~ s/^__END__.*\Z//msg; # TODO -- deal with Autoload
100 }
101 mkpath $1 if $fnto=~/^(.*)\/([^\/]+)$/;
102 open my $fhout, ">$fnto";
103 print $fhout $ffrom;
104}
105
106BEGIN {
107%libexclusions = map {$_=>1} split/\s/, <<"EOS";
108abbrev.pl bigfloat.pl bigint.pl bigrat.pl cacheout.pl complete.pl ctime.pl
109dotsh.pl exceptions.pl fastcwd.pl flush.pl ftp.pl getcwd.pl getopt.pl
110getopts.pl hostname.pl look.pl newgetopt.pl pwd.pl termcap.pl
111EOS
112%extexclusions = map {$_=>1} split/\s/, <<"EOS";
113EOS
114
115}
116