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