This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Win32API-File to CPAN version 0.1201
[perl5.git] / cpan / Win32API-File / Makefile.PL
CommitLineData
00701878 1#!/usr/bin/perl -w
3826db83 2use 5.001; #not tested
00701878
SH
3use ExtUtils::MakeMaker;
4use Config;
5use strict;
6# See lib/ExtUtils/MakeMaker.pm for details of how to influence
7# the contents of the Makefile that is written.
3826db83
SH
8unless ($^O eq "MSWin32" || $^O eq "cygwin" || $^O eq "interix") { #not tested on Interix
9 die "OS unsupported\n";
10}
11
00f02a57 12WriteMakefile1(
00701878
SH
13 'NAME' => 'Win32API::File',
14 'VERSION_FROM' => 'File.pm', # finds $VERSION
15 ( $Config{archname} =~ /-object\b/i ? ( 'CAPI' => 'TRUE' ) : () ),
3826db83
SH
16 'AUTHOR' => 'Tye McQueen <tye@metronet.com>',
17 'ABSTRACT_FROM' => 'File.pm',
00701878
SH
18 'postamble' => { IMPORT_LIST => [qw(/._/ !/[a-z]/ :MEDIA_TYPE)],
19 IFDEF => "!/[a-z\\d]/",
20 CPLUSPLUS => 1,
21 WRITE_PERL => 1,
113b1f2c
CBW
22 #PERL_FILE_LIST => ['File.pm'], #added by Chorny
23 #C_FILE_LIST => ['File.xs'], #added by Chorny
00701878
SH
24 # Comment out next line to rebuild constants defs:
25 NO_REBUILD => 1,
26 },
27 ( ! $Config{libperl} ? () : ( LIBPERL_A => $Config{libperl} ) ),
113b1f2c 28 'INSTALLDIRS' => (($] >= 5.008009 and $] < 5.012) ? 'perl' : 'site'),
00f02a57
CBW
29 'LICENSE' => 'perl',
30 'MIN_PERL_VERSION' => 5.001,
3826db83 31 'PREREQ_PM' => {
3826db83
SH
32 'Math::BigInt' => 0,
33 'Win32' => 0,
113b1f2c 34 'Carp' => 0,
00f02a57 35 'IO::File' => 0,
113b1f2c
CBW
36 },
37 TEST_REQUIRES => {
00f02a57 38 'File::Spec' => 0,
113b1f2c 39 'Test::More' => 0,
00f02a57
CBW
40 },
41
42 META_MERGE => {
43 resources => {
44 repository => 'http://github.com/chorny/Win32API-File',
45 },
46 },
47 $^O =~/win/i ? (
48 dist => {
49 TAR => 'ptar',
50 TARFLAGS => '-c -C -f',
51 },
52 ) : (),
00701878
SH
53);
54
55# Replacement for MakeMaker's "const2perl section" for versions
56# of MakeMaker prior to the addition of this functionality:
57sub MY::postamble
58{
59 my( $self, %attribs )= @_;
60
61 # Don't do anything if MakeMaker has const2perl
62 # that already took care of all of this:
63 return unless %attribs;
64
65 # Don't require these here if we just C<return> above:
66 eval "use ExtUtils::Myconst2perl qw(ParseAttribs); 1" or die "$@";
67 eval "use ExtUtils::MakeMaker qw(neatvalue); 1" or die "$@";
68
69 # If only one module, can skip one level of indirection:
70 my $hvAttr= \%attribs;
71 if( $attribs{IMPORT_LIST} ) {
72 $hvAttr= { $self->{NAME} => \%attribs };
73 }
74
75 my( $module, @m, $_final, @clean, @realclean );
76 foreach $module ( keys %$hvAttr ) {
77 my( $outfile, @perlfiles, @cfiles, $bin, $obj, $final, $noreb );
78
79 # Translate user-friendly options into coder-friendly specifics:
80 ParseAttribs( $module, $hvAttr->{$module}, { OUTFILE => \$outfile,
81 C_FILE_LIST => \@perlfiles, PERL_FILE_LIST => \@cfiles,
82 OBJECT => \$obj, BINARY => \$bin, FINAL_PERL => \$final,
83 NO_REBUILD => \$noreb } );
84 die "IFDEF option in Makefile.PL must be string, not code ref.\n"
85 if ref $hvAttr->{$module}->{IFDEF};
86 die qq{IFDEF option in Makefile.PL must not contain quotes (").\n}
87 if ref $hvAttr->{$module}->{IFDEF};
88
89 # How to create F<$outfile> via ExtUtils::Myconst2perl::Myconst2perl:
90 push @m, "
91$outfile: @perlfiles @cfiles Makefile" . '
92 $(PERL) "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Myconst2perl \\
93 -e "my %attribs;" \\
94 ';
95 $m[-1] =~ s/^/##/gm if $noreb;
96 my( $key, $value );
97 while( ( $key, $value )= each %{$hvAttr->{$module}} ) {
113b1f2c 98 push @m, '-e "$$attribs{' . $key . '}= ' # try {{ }} for dmake
00701878
SH
99 . neatvalue($value) . qq[;" \\\n\t ];
100 $m[-1] =~ s/^/##/gm if $noreb;
101 }
102 push @m, '-e "Myconst2perl(' . neatvalue($module) . ",%attribs)\"\n";
103
104 # If requested extra work to generate Perl instead of XS code:
105 if( $bin ) {
106 my @path= split /::/, $module;
107 my $_final= $final;
108 $_final =~ s/\W/_/g;
109
110 # How to compile F<$outfile> and then run it to produce F<$final>:
111 push @m, "
112$bin: $outfile" . '
113 $(CC) $(INC) $(CCFLAGS) $(OPTIMIZE) $(PERLTYPE) $(LARGE) \\
114 $(SPLIT) $(DEFINE_VERSION) $(XS_DEFINE_VERSION) -I$(PERL_INC) \\
115 $(DEFINE)' . $outfile . " "
116 . $self->catfile(qw[ $(PERL_INC) $(LIBPERL_A) ]) . " -o $bin
117
118$final: $bin
119 " . $self->catfile(".",$bin) . " >$final\n";
120 $m[-1] =~ s/^/##/gm if $noreb;
121
122 # Make sure the rarely-used $(INST_ARCHLIB) directory exists:
123 push @m, $self->dir_target('$(INST_ARCHLIB)');
124
125 ##warn qq{$path[-1].pm should C<require "},
126 ## join("/",@path,$final), qq{">.\n};
127 # Install F<$final> whenever regular pm_to_blib target is built:
128 push @m, "
129pm_to_blib: ${_final}_to_blib
130
131${_final}_to_blib: $final
132 " . '@$(PERL) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)" \\
133 "-I$(PERL_ARCHLIB)" "-I$(PERL_LIB)" -MExtUtils::Install \\
134 -e "pm_to_blib({ ',neatvalue($final),',',
135 neatvalue($self->catfile('$(INST_ARCHLIB)',@path,$final)), ' },',
136 neatvalue($self->catfile(qw[$(INST_LIB) auto])), ')"
6d7cbd59
JH
137 @$(TOUCH) ', $_final, "_to_blib
138
139realclean ::
140 $self->{RM_RF} ", $self->catfile('$(INST_ARCHLIB)', $path[0]), "\n";
00701878
SH
141
142 push( @clean, $outfile, $bin, $obj, $_final . "_to_blib" );
143 push( @realclean, $final ) unless $noreb;
144 } else {
145
146 ##my $name= ( split /::/, $module )[-1];
147 ##warn qq{$name.xs should C<#include "$final"> },
148 ## qq{in the C<BOOT:> section\n};
149 push( @realclean, $outfile ) unless $noreb;
150 }
151 }
152
153 push @m, "
154clean ::
155 $self->{RM_F} @clean\n" if @clean;
156 push @m, "
157realclean ::
158 $self->{RM_F} @realclean\n" if @realclean;
159 return join('',@m);
160}
00f02a57 161
113b1f2c
CBW
162
163sub WriteMakefile1 { #Compatibility code for old versions of EU::MM. Written by Alexandr Ciornii, version 0.23. Added by eumm-upgrade.
00f02a57
CBW
164 my %params=@_;
165 my $eumm_version=$ExtUtils::MakeMaker::VERSION;
166 $eumm_version=eval $eumm_version;
167 die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
168 die "License not specified" if not exists $params{LICENSE};
113b1f2c
CBW
169 if ($params{AUTHOR} and ref($params{AUTHOR}) eq 'ARRAY' and $eumm_version < 6.5705) {
170 $params{META_ADD}->{author}=$params{AUTHOR};
171 $params{AUTHOR}=join(', ',@{$params{AUTHOR}});
172 }
173 if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
174 $params{BUILD_REQUIRES}={ %{$params{BUILD_REQUIRES} || {}} , %{$params{TEST_REQUIRES}} };
175 delete $params{TEST_REQUIRES};
176 }
00f02a57
CBW
177 if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
178 #EUMM 6.5502 has problems with BUILD_REQUIRES
179 $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
180 delete $params{BUILD_REQUIRES};
181 }
182 delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
183 delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
184 delete $params{META_MERGE} if $eumm_version < 6.46;
185 delete $params{META_ADD} if $eumm_version < 6.46;
186 delete $params{LICENSE} if $eumm_version < 6.31;
187 delete $params{AUTHOR} if $] < 5.005;
188 delete $params{ABSTRACT_FROM} if $] < 5.005;
189 delete $params{BINARY_LOCATION} if $] < 5.005;
190
191 WriteMakefile(%params);
192}
193