Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / debian / libwx-perl / usr / lib / perl5 / Wx / build / MakeMaker / Any_OS.pm
1 package Wx::build::MakeMaker::Any_OS;
2
3 use strict;
4 use base 'Wx::build::MakeMaker';
5 use File::Spec::Functions qw(curdir);
6 use Wx::build::Options;
7 use Wx::build::Utils qw(xs_dependencies lib_file);
8
9 my $exp = lib_file( 'Wx/Wx_Exp.pm' );
10 my @generated_xs = qw(XS/ItemContainer.xs XS/ItemContainerImmutable.xs
11                       XS/VarScrollHelperBase.xs XS/VarVScrollHelper.xs
12                       XS/VarHScrollHelper.xs XS/VarHVScrollHelper.xs);
13 sub get_flags {
14   my $this = shift;
15   my %config;
16
17   if( %Wx::build::MakeMaker::additional_arguments ) {
18     $config{WX}{lc $_} = $Wx::build::MakeMaker::additional_arguments{$_}
19       foreach keys %Wx::build::MakeMaker::additional_arguments;
20     $ExtUtils::MakeMaker::Recognized_Att_Keys{WX} = 1;
21     %Wx::build::MakeMaker::additional_arguments = ();
22   }
23
24   if( $config{WX}{wx_overload} ) {
25       $_ = File::Spec->catfile( split /\//, $_ )
26         foreach values %{$config{WX}{wx_overload}};
27   }
28
29   $config{INC} .= '-I' . curdir . ' ';
30   $config{INC} .= '-I' . $this->get_api_directory . ' ';
31
32   unless( $this->_core ) {
33     $config{DEFINE} .= " -DWXPL_EXT ";
34   }
35
36   if( $this->_static ) {
37     $config{DEFINE} .= " -DWXPL_STATIC ";
38   }
39
40   return %config;
41 }
42
43 sub metafile_target_ext {
44     return '' if Wx::build::MakeMaker::is_wxPerl_tree;
45     return shift->MM::metafile_target( @_ );
46 }
47
48 sub metafile_target_core {
49     return shift->MM::metafile_target( @_ );
50 }
51
52 sub configure_core {
53   my $this = shift;
54   my %config = $this->get_flags;
55
56   $config{clean} =
57     { FILES => "$config{WX}{wx_overload}{source}" .
58                " $config{WX}{wx_overload}{header} exists overload Opt" .
59                " copy_files files.lst cpp/combopopup.h cpp/odcombo.h" .
60                " cpp/setup.h cpp/plwindow.h cpp/artprov.h cpp/popupwin.h" .
61                " fix_alien cpp/vlbox.h cpp/vscroll.h cpp/v_cback_def.h" .
62                " " . join( " ", @generated_xs ) .
63                " cpp/vscrl.h overload.lst" };
64
65   return %config;
66 }
67
68 sub configure_ext {
69   my $this = shift;
70   my %config = $this->get_flags;
71
72   my( $ovlc, $ovlh ) = $config{WX}{wx_overload} ?
73     @{$config{WX}{wx_overload}}{qw(source header)} : ();
74   if( $ovlc && $ovlh ) {
75     $config{clean} =
76       { FILES => "$config{WX}{wx_overload}{source}" .
77                  " $config{WX}{wx_overload}{header} overload" };
78   }
79
80   return %config;
81 }
82
83 sub files_with_constants {
84   my( $this ) = @_;
85   return @{$this->{wx_files_with_constants}}
86     if $this->{wx_files_with_constants};
87   return @{$this->{wx_files_with_constants} =
88              [ Wx::build::Utils::files_with_constants ]};
89 }
90
91 sub files_with_overload {
92   my( $this ) = @_;
93   return @{$this->{wx_files_with_overload}}
94     if $this->{wx_files_with_overload};
95   return @{$this->{wx_files_with_overload} =
96              [ Wx::build::Utils::files_with_overload ]};
97
98 }
99
100 sub _depend_common {
101   my $this = shift;
102
103   my $top_file =    $this->{WX}{wx_top}
104                  || $this->{ARGS}{VERSION_FROM}
105                  || $this->{ARGS}{ABSTRACT_FROM}
106                  || 'Wx.pm';
107   my( $ovlc, $ovlh ) = $this->{WX}{wx_overload} ?
108     @{$this->{WX}{wx_overload}}{qw(source header)} : ();
109   return ( xs_dependencies( $this, [ curdir, $this->get_api_directory
110                                      ],
111                             Wx::build::Utils::src_dir( $top_file ) ),
112            # overload
113            ( $ovlc && $ovlh ?
114              ( $ovlc             => 'overload',
115                $ovlh             => $ovlc,
116                ) :
117              ( ) ),
118            );
119 }
120
121 sub depend_core {
122   my $this = shift;
123
124   my %files = $this->files_to_install();
125   my %depend = ( _depend_common( $this ),
126                  $exp              => join( ' ', $this->files_with_constants ),
127                  '$(INST_STATIC)'  => "fix_alien $exp",
128                  '$(INST_DYNAMIC)' => "fix_alien $exp",
129                  'fix_alien'       => 'pm_to_blib',
130                  'pm_to_blib'      => 'copy_files',
131                  'blibdirs'        => 'copy_files',
132                  'blibdirs.ts'     => 'copy_files',
133                  'copy_files'      => join( ' ', keys %files ),
134                  'distmeta'        => 'check_my_metafile',
135                );
136   my %this_depend = @_;
137
138   foreach ( keys %depend ) {
139     $this_depend{$_} .= ' ' . $depend{$_};
140   }
141
142   $this->SUPER::depend_core( %this_depend );
143 }
144
145 sub depend_ext {
146   my $this = shift;
147
148   my %depend = _depend_common( $this );
149   my %this_depend = @_;
150
151   foreach ( keys %depend ) {
152     $this_depend{$_} .= ' ' . $depend{$_};
153   }
154
155   $this->SUPER::depend_ext( %this_depend );
156 }
157
158 sub subdirs_core {
159   my $this = shift;
160   my $text = $this->SUPER::subdirs_core( @_ );
161
162   return <<EOT . $text;
163 subdirs :: overload
164
165 EOT
166 }
167
168 sub subdirs_ext {
169   my $this = shift;
170   my $text = $this->SUPER::subdirs_core( @_ );
171
172   return ( $this->{WX}{wx_overload} ? <<EOT : '' ) . $text;
173 subdirs :: overload
174
175 EOT
176 }
177
178 sub postamble_overload {
179   my( $this ) = @_;
180
181   # command line length workaround
182   if(    !Wx::build::MakeMaker::is_wxPerl_tree
183       || Wx::build::MakeMaker::is_core ) {
184     Wx::build::Utils::write_string( 'overload.lst',
185                                     join "\n", $this->files_with_overload );
186   }
187   my $ovl_script = Wx::build::MakeMaker::is_wxPerl_tree() ?
188       'script/wxperl_overload' : "-S wxperl_overload";
189   my( $ovlc, $ovlh ) = $this->{WX}{wx_overload} ?
190     @{$this->{WX}{wx_overload}}{qw(source header)} : ();
191   return ( $this->{WX}{wx_overload} ? <<EOT : '' );
192 overload :
193 \t\$(PERL) $ovl_script $ovlc $ovlh overload.lst
194 \t\$(TOUCH) overload
195
196 EOT
197 }
198
199 sub postamble_core {
200   my $this = shift;
201   my %files = $this->files_to_install();
202
203   Wx::build::Utils::write_string( 'files.lst',
204                                   Data::Dumper->Dump( [ \%files ] ) );
205   my $text = <<EOT . $this->postamble_overload;
206
207 $exp :
208 \t\$(PERL) script/make_exp_list.pl $exp @{[$this->files_with_constants]}
209
210 copy_files :
211 \t\$(PERL) script/copy_files.pl files.lst
212 \t\$(TOUCH) copy_files
213
214 fix_alien : lib/Wx/Mini.pm
215 \t\$(PERL) script/fix_alien_path.pl lib/Wx/Mini.pm blib/lib/Wx/Mini.pm
216 \t\$(TOUCH) fix_alien
217
218 parser :
219         yapp -v -s -m Wx::XSP::Grammar -o build/Wx/XSP/Grammar.pm build/Wx/XSP/XSP.yp
220
221 typemap : typemap.tmpl script/make_typemap.pl
222         \$(PERL) script/make_typemap.pl typemap.tmpl typemap
223
224 cpp/v_cback_def.h : script/make_v_cback.pl
225         \$(PERL) script/make_v_cback.pl > cpp/v_cback_def.h
226
227 check_my_metafile :
228         \$(PERL) -e "eval 'require ExtUtils::MY_Metafile; 1' || die 'Install ExtUtils::MY_Metafile'"
229
230 EOT
231
232   foreach my $f ( @generated_xs ) {
233       my $file = File::Spec->canonpath( $f );
234       $text .= sprintf <<EOT, $file, $file, $file, $file;
235 %s : %sp typemap.xsp
236         \$(PERL) -MExtUtils::XSpp::Cmd -e xspp -- -t typemap.xsp %sp > %s
237
238 EOT
239   }
240
241   $text .= sprintf <<EOT, join( ' ', @generated_xs );
242 generated : cpp/v_cback_def.h typemap %s overload
243
244 EOT
245
246   $text;
247 }
248
249 sub postamble_ext {
250     my( $this ) = @_;
251
252     return $this->postamble_overload;
253 }
254
255 # here because File::Find::find chdirs, and our is_core is,
256 # er, quite limited
257 sub libscan_ext {
258   my( $this, $inst ) = @_;
259
260   $inst =~ s/(\W+)build\W+Wx/$1Wx/i && return $inst;
261
262   return $this->SUPER::libscan_core( $inst );
263 }
264
265 sub constants_core {
266   my $this = shift;
267
268   foreach my $k ( grep { m/~$/ } keys %{$this->{PM}} ) {
269     delete $this->{PM}{$k};
270   }
271
272   return $this->SUPER::constants_core( @_ );
273 }
274
275 # returns an hash of files to be copied
276 sub files_to_install {
277   my @api = qw(cpp/chkconfig.h
278                cpp/compat.h
279                cpp/constants.h
280                cpp/event.h
281                cpp/e_cback.h
282                cpp/helpers.h
283                cpp/overload.h
284                cpp/setup.h
285                cpp/streams.h
286                cpp/v_cback.h
287                cpp/v_cback_def.h
288                cpp/wxapi.h
289                typemap
290               );
291   # in arch, so $INC{'Opt.pm'} will tell where arch is
292   return ( 'Opt', Wx::build::Utils::arch_file( 'Wx/build/Opt.pm' ),
293            ( map { ( $_ => Wx::build::Utils::lib_file( "Wx/$_" ) ) } @api ),
294          );
295 }
296
297 sub manifypods_core {
298     my( $self ) = @_;
299
300     s{([\\/])build::}{$1} foreach values %{$self->{MAN3PODS}};
301
302     return $self->SUPER::manifypods_core;
303 }
304
305 1;
306
307 # local variables:
308 # mode: cperl
309 # end: