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