1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
#!/usr/bin/perl -w
use ExtUtils::MakeMaker;
use Config;
use strict;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'Win32API::File',
'VERSION_FROM' => 'File.pm', # finds $VERSION
( $Config{archname} =~ /-object\b/i ? ( 'CAPI' => 'TRUE' ) : () ),
( $] < 5.005 ? () :
( 'AUTHOR' => 'Tye McQueen <tye@metronet.com>',
'ABSTRACT_FROM' => 'File.pm' )
),
'postamble' => { IMPORT_LIST => [qw(/._/ !/[a-z]/ :MEDIA_TYPE)],
IFDEF => "!/[a-z\\d]/",
CPLUSPLUS => 1,
WRITE_PERL => 1,
# Comment out next line to rebuild constants defs:
NO_REBUILD => 1,
},
( ! $Config{libperl} ? () : ( LIBPERL_A => $Config{libperl} ) ),
);
# Replacement for MakeMaker's "const2perl section" for versions
# of MakeMaker prior to the addition of this functionality:
sub MY::postamble
{
my( $self, %attribs )= @_;
# Don't do anything if MakeMaker has const2perl
# that already took care of all of this:
return unless %attribs;
# Don't require these here if we just C<return> above:
eval "use ExtUtils::Myconst2perl qw(ParseAttribs); 1" or die "$@";
eval "use ExtUtils::MakeMaker qw(neatvalue); 1" or die "$@";
# If only one module, can skip one level of indirection:
my $hvAttr= \%attribs;
if( $attribs{IMPORT_LIST} ) {
$hvAttr= { $self->{NAME} => \%attribs };
}
my( $module, @m, $_final, @clean, @realclean );
foreach $module ( keys %$hvAttr ) {
my( $outfile, @perlfiles, @cfiles, $bin, $obj, $final, $noreb );
# Translate user-friendly options into coder-friendly specifics:
ParseAttribs( $module, $hvAttr->{$module}, { OUTFILE => \$outfile,
C_FILE_LIST => \@perlfiles, PERL_FILE_LIST => \@cfiles,
OBJECT => \$obj, BINARY => \$bin, FINAL_PERL => \$final,
NO_REBUILD => \$noreb } );
die "IFDEF option in Makefile.PL must be string, not code ref.\n"
if ref $hvAttr->{$module}->{IFDEF};
die qq{IFDEF option in Makefile.PL must not contain quotes (").\n}
if ref $hvAttr->{$module}->{IFDEF};
# How to create F<$outfile> via ExtUtils::Myconst2perl::Myconst2perl:
push @m, "
$outfile: @perlfiles @cfiles Makefile" . '
$(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Myconst2perl \\
-e "my %attribs;" \\
';
$m[-1] =~ s/^/##/gm if $noreb;
my( $key, $value );
while( ( $key, $value )= each %{$hvAttr->{$module}} ) {
push @m, '-e "$$attribs{' . $key . '}= '
. neatvalue($value) . qq[;" \\\n\t ];
$m[-1] =~ s/^/##/gm if $noreb;
}
push @m, '-e "Myconst2perl(' . neatvalue($module) . ",%attribs)\"\n";
# If requested extra work to generate Perl instead of XS code:
if( $bin ) {
my @path= split /::/, $module;
my $_final= $final;
$_final =~ s/\W/_/g;
# How to compile F<$outfile> and then run it to produce F<$final>:
push @m, "
$bin: $outfile" . '
$(CC) $(INC) $(CCFLAGS) $(OPTIMIZE) $(PERLTYPE) $(LARGE) \\
$(SPLIT) $(DEFINE_VERSION) $(XS_DEFINE_VERSION) -I$(PERL_INC) \\
$(DEFINE)' . $outfile . " "
. $self->catfile(qw[ $(PERL_INC) $(LIBPERL_A) ]) . " -o $bin
$final: $bin
" . $self->catfile(".",$bin) . " >$final\n";
$m[-1] =~ s/^/##/gm if $noreb;
# Make sure the rarely-used $(INST_ARCHLIB) directory exists:
push @m, $self->dir_target('$(INST_ARCHLIB)');
##warn qq{$path[-1].pm should C<require "},
## join("/",@path,$final), qq{">.\n};
# Install F<$final> whenever regular pm_to_blib target is built:
push @m, "
pm_to_blib: ${_final}_to_blib
${_final}_to_blib: $final
" . '@$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \\
"-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \\
-e "pm_to_blib({ ',neatvalue($final),',',
neatvalue($self->catfile('$(INST_ARCHLIB)',@path,$final)), ' },',
neatvalue($self->catfile(qw[$(INST_LIB) auto])), ')"
@$(TOUCH) ', $_final, "_to_blib\n";
push( @clean, $outfile, $bin, $obj, $_final . "_to_blib" );
push( @realclean, $final ) unless $noreb;
} else {
##my $name= ( split /::/, $module )[-1];
##warn qq{$name.xs should C<#include "$final"> },
## qq{in the C<BOOT:> section\n};
push( @realclean, $outfile ) unless $noreb;
}
}
push @m, "
clean ::
$self->{RM_F} @clean\n" if @clean;
push @m, "
realclean ::
$self->{RM_F} @realclean\n" if @realclean;
return join('',@m);
}
|