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