Commit | Line | Data |
3ef515df |
1 | use 5.007003; |
2c674647 |
2 | use ExtUtils::MakeMaker; |
14a8264b |
3 | |
a999c27c |
4 | # Just for sure :) |
5 | unless($ENV{PERL_CORE}) { |
6 | $ENV{PERL_CORE} = 1 if ($^X =~ m{\bminiperl[^/\\\]>:]*$}o); |
7 | } |
8 | |
5d030b67 |
9 | my %tables = |
10 | ( |
071db25d |
11 | def_t => ['ascii.ucm', |
12 | '8859-1.ucm', |
13 | ] |
5d030b67 |
14 | ); |
14a8264b |
15 | |
3ef515df |
16 | my @exe_files = qw(bin/enc2xs |
17 | bin/piconv |
18 | ); |
19 | my @more_exe_files = qw( |
a999c27c |
20 | unidump |
3ef515df |
21 | ); |
22 | my @pmlibdirs = qw(lib Encode); |
67d7b5ef |
23 | for my $arg (@ARGV){ |
037b88d6 |
24 | if ($arg eq "MORE_SCRIPTS"){ |
67d7b5ef |
25 | push @exe_files, @more_exe_files; |
26 | } |
3ef515df |
27 | if ($arg eq "INSTALL_UCM"){ |
28 | push @pmlibdirs, "ucm"; |
29 | } |
67d7b5ef |
30 | } |
31 | |
2c674647 |
32 | WriteMakefile( |
18586f54 |
33 | NAME => "Encode", |
67d7b5ef |
34 | EXE_FILES => \@exe_files, |
023d8852 |
35 | VERSION_FROM => 'Encode.pm', |
18586f54 |
36 | OBJECT => '$(O_FILES)', |
37 | 'dist' => { |
38 | COMPRESS => 'gzip -9f', |
39 | SUFFIX => 'gz', |
40 | DIST_DEFAULT => 'all tardist', |
41 | }, |
42 | MAN3PODS => {}, |
3ef515df |
43 | INC => "-I./Encode", |
44 | PMLIBDIRS => \@pmlibdirs, |
f74b3917 |
45 | INSTALLDIRS => 'perl', |
18586f54 |
46 | ); |
2f2b4ff2 |
47 | |
48 | package MY; |
49 | |
311a0942 |
50 | |
51 | sub post_initialize |
52 | { |
18586f54 |
53 | my ($self) = @_; |
54 | my %o; |
55 | # Find existing O_FILES |
56 | foreach my $f (@{$self->{'O_FILES'}}) |
57 | { |
58 | $o{$f} = 1; |
59 | } |
60 | my $x = $self->{'OBJ_EXT'}; |
61 | # Add the table O_FILES |
62 | foreach my $e (keys %tables) |
14a8264b |
63 | { |
18586f54 |
64 | $o{$e.$x} = 1; |
14a8264b |
65 | } |
18586f54 |
66 | # Trick case-blind filesystems. |
67 | delete $o{'encode'.$x}; |
68 | $o{'Encode'.$x} = 1; |
69 | # Reset the variable |
70 | $self->{'O_FILES'} = [sort keys %o]; |
71 | my @files; |
72 | foreach my $table (keys %tables) |
73 | { |
e7cbefb8 |
74 | foreach my $ext (qw($(OBJ_EXT) .c .h .exh .fnm)) |
18586f54 |
75 | { |
76 | push (@files,$table.$ext); |
77 | } |
78 | } |
79 | $self->{'clean'}{'FILES'} .= join(' ',@files); |
80 | return ''; |
311a0942 |
81 | } |
82 | |
2f2b4ff2 |
83 | sub postamble |
84 | { |
18586f54 |
85 | my $self = shift; |
3ef515df |
86 | my $dir = $self->catdir($self->curdir,'ucm'); |
e7cbefb8 |
87 | my $str = "# Encode\$(OBJ_EXT) depends on .h and .exh files not .c files - but all written by enc2xs\n"; |
18586f54 |
88 | $str .= 'Encode$(OBJ_EXT) :'; |
89 | foreach my $table (keys %tables) |
14a8264b |
90 | { |
18586f54 |
91 | $str .= " $table.c"; |
14a8264b |
92 | } |
18586f54 |
93 | $str .= "\n\n"; |
94 | foreach my $table (keys %tables) |
14a8264b |
95 | { |
18586f54 |
96 | my $numlines = 1; |
97 | my $lengthsofar = length($str); |
98 | my $continuator = ''; |
67d7b5ef |
99 | my $enc2xs = $self->catfile('bin', 'enc2xs'); |
100 | $str .= "$table.c : $enc2xs Makefile.PL"; |
18586f54 |
101 | foreach my $file (@{$tables{$table}}) |
102 | { |
103 | $str .= $continuator.' '.$self->catfile($dir,$file); |
104 | if ( length($str)-$lengthsofar > 128*$numlines ) |
105 | { |
106 | $continuator .= " \\\n\t"; |
107 | $numlines++; |
108 | } else { |
109 | $continuator = ''; |
110 | } |
111 | } |
46fc212f |
112 | my $plib = $self->{PERL_CORE} ? '"-I$(PERL_LIB)"' : ''; |
b88803e8 |
113 | $plib .= " -MCross=$::Cross::platform" if defined $::Cross::platform; |
46fc212f |
114 | my $ucopts = '-"Q" -"O"'; |
115 | $str .= |
a999c27c |
116 | qq{\n\t\$(PERL) $plib $enc2xs $ucopts -o \$\@ -f $table.fnm\n\n}; |
18586f54 |
117 | open (FILELIST, ">$table.fnm") |
118 | || die "Could not open $table.fnm: $!"; |
119 | foreach my $file (@{$tables{$table}}) |
120 | { |
121 | print FILELIST $self->catfile($dir,$file) . "\n"; |
122 | } |
123 | close(FILELIST); |
14a8264b |
124 | } |
18586f54 |
125 | return $str; |
2f2b4ff2 |
126 | } |