This file is indexed.

/usr/lib/x86_64-linux-gnu/perl5/5.20/Wx/build/MakeMaker.pm is in libwx-perl 1:0.9923-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
package Wx::build::MakeMaker;

use strict;
use ExtUtils::MakeMaker;
use base 'Exporter';
use Config;
use vars qw(@EXPORT $VERSION);
use FindBin;
use File::Basename qw();

$VERSION = '0.28';
@EXPORT = 'wxWriteMakefile';

# get rid of suffix in MakeMaker version to be able treat it like a number in
# comparisons
my $MAKEMAKER_VERSION = $ExtUtils::MakeMaker::VERSION;
$MAKEMAKER_VERSION =~ s/_\d+$//;

# sanitize File::Find on filesystems where nlink of directories is < 2
use File::Find;
$File::Find::dont_use_nlink = 1 if ( stat('.') )[3] < 2;

=head1 NAME

Wx::build::MakeMaker - ExtUtils::MakeMaker specialisation for wxPerl modules

=head1 SYNOPSIS

use Wx::build::MakeMaker;

wxWriteMakefile( NAME         => 'My::Module',
                 VERSION_FROM => 'Module.pm' );

=head1 FUNCTIONS

=head2 wxWriteMakefile

  wxWriteMakefile( arameter => value, ... );

This functions is meant to be used exactly as
ExtUtils::MakeMaker::WriteMakefile (see). It accepts all WriteMakefile's
parameters, plus:

=over 4

=item * WX_CORE_LIB

  WX_CORE_LIB => 'xrc core base'

link libraries from wxWidgets' core or contrib directory.
If not spedified, defaults to 'adv html core net base' for compatibility.

=item * WX_LIB

  WX_LIB => '-lxrc'

Link additional libraries from wxWidgets' contrib directory.

=item * REQUIRE_WX

  REQUIRE_WX => 2.003002  # wxWidgets 2.3.2

Do not build this module if wxWidgets' version is lower than the version
specified.

=item * NO_WX_PLATFORMS

  NO_WX_PLATFORMS => [ 'x11', 'msw' ]

Do not build this module on the specified platform(s).

=item * ON_WX_PLATFORMs

  ON_WX_PLATFORMS => [ 'gtk' ]

only build this module on the specified platform(s).

=back

=head1 PRIVATE FUNCTIONS

These functions are here for reference, do not use them.

=head2 is_core

  if( is_core ) { ... }

True if it is building the wxPerl core (Wx.dll), false otherwise.

=head2 is_wxPerl_tree

  if( is_wxPerl_tree ) { ... }

True if it is building any part of wxPerl, false otherwise.

=cut

my $is_wxperl_tree = 0;

sub is_core() { -f 'Wx.pm' }
sub _set_is_wxPerl_tree { $is_wxperl_tree = $_[0] ? 1 : 0 }
sub is_wxPerl_tree { $is_wxperl_tree }

#   _call_method( 'method', $this, @args );
# calls the _core or _ext version of a method;
sub _call_method {
  my $name = shift;
  my $this = shift;
  $name .= is_core ? '_core' : '_ext';

  return $this->$name( @_ );
}

=head2 set_hook_package

  Wx::build::MakeMaker::set_hook_package( 'package_name' );

Package to be hooked into the MakeMaker inheritance chain.

=cut

# this is the default
my $hook_package;

BEGIN {
  my $package_to_use;
 SWITCH: {
    local $_ = $Config{osname};

    # Win32
    m/MSWin32/ and do {
      local $_ = File::Basename::basename( $Config{cc} );

      m/^cl/i  and $package_to_use = 'Win32_MSVC'  and last SWITCH;
      m/^gcc/i and $package_to_use = 'Win32_MinGW' and last SWITCH;

      # default
      die "Your compiler is not currently supported on Win32"
    };

    # MacOS X is slightly different...
    m/darwin/ and do {
      $package_to_use = 'MacOSX_GCC';
      last SWITCH;
    };

    # default
    $package_to_use = 'Any_wx_config';
    last SWITCH;
  }
  $hook_package = 'Wx::build::MakeMaker::' . $package_to_use;
}

sub set_hook_package {
  $hook_package = shift;
}

# this is a crude hack (at best), we put an arbitrary package
# into ExtUtils::MakeMaker inheritance chain in order to be able
# to customise it
sub import {
  undef *MY::libscan;
  *MY::libscan = _make_hook( 'libscan' );

  Wx::build::MakeMaker->export_to_level( 1, @_ );
}

=head1 METHODS

=head2 get_api_directory

  my $dir = $cfg->get_api_directory;

=head2 get_arch_directory

  my $dir = $cfg->get_arch_directory;

=cut

sub get_api_directory {
  if( is_wxPerl_tree() ) {
    return Wx::build::Utils::src_dir( 'Wx.pm' );
  } else {
    my $path = $INC{'Wx/build/MakeMaker.pm'};
    my( $vol, $dir, $file ) = File::Spec->splitpath( $path );
    my @dirs = File::Spec->splitdir( $dir ); pop @dirs; pop @dirs;
    return File::Spec->catpath( $vol, File::Spec->catdir( @dirs ) );
  }
}

sub get_arch_directory {
  if( is_wxPerl_tree() ) {
    require Carp;
    Carp::confess( "Should not be called!" );
  } else {
    my $path = $INC{'Wx/build/Opt.pm'};
    my( $vol, $dir, $file ) = File::Spec->splitpath( $path );
    my @dirs = File::Spec->splitdir( $dir ); pop @dirs; pop @dirs; pop @dirs;
    return File::Spec->catpath( $vol, File::Spec->catdir( @dirs ) );
  }
}

sub check_core_lib {
  my( $this, @libs ) = @_;

  return eval { Alien::wxWidgets->libraries( @libs ); 1 } ? 1 : 0;
}

sub get_core_lib {
  my( $this, @libs ) = @_;

  return join ' ', Alien::wxWidgets->libraries( @libs );
}

our $is_core = 0;

sub get_wx_platform { Alien::wxWidgets->config->{toolkit} }
sub get_wx_version { Alien::wxWidgets->version }
sub _unicode { Alien::wxWidgets->config->{unicode} }
sub _mslu    { Alien::wxWidgets->config->{mslu} }
sub _debug   { Alien::wxWidgets->config->{debug} }
sub _core    { $is_core }
sub _static  { Alien::wxWidgets->config->{static} }

sub _make_hook {
  my $hook_sub = shift;

  return sub {
    my $this = $_[0];
    my $class = ref $this;
    ( my $file = $hook_package ) =~ s{::}{/}g;
    no strict 'refs';
    require "$file.pm";
    undef *{"${class}::${hook_sub}"};
    unshift @{"${class}::ISA"}, $hook_package;

    shift->$hook_sub( @_ );
  }
}

# this method calls ->configure
# in the appropriate Wx::build::MakeMaker::PACKAGE,
# and merges the results with its inputs
use vars qw(%cfg1 %cfg2);

sub _libs($) { ref( $_[0] ) ? @{$_[0]} : ( $_[0] ) }

# removes the -L/path from the imput and returns them and
# the cleaned input
sub _split_lib($) {
  my $str = shift || '';
  my @paths = $str =~ m/(-L[^ ]+)/g;
  $str =~ s/-L[^ ]+ +//g;

  return ( $str, @paths );
}

sub merge_config {
  my( $cfg1, $cfg2 ) = @_;
  local *cfg1 = $cfg1;
  local *cfg2 = $cfg2;
  my %cfg = %cfg1;

  foreach my $i ( keys %cfg2 ) {
    if( exists $cfg{$i} ) {
      # merging libraries is always a mess; the hope is that
      # this will work in all cases, but there are no guarantees...
      if( $i eq 'LIBS' ) {
        my @a = _libs(  $cfg{LIBS} );
        my @b = _libs( $cfg2{LIBS} );

        my @c;
        foreach my $i ( @b ) {
          my( $mi, @ipaths ) = _split_lib( $i );
          foreach my $j ( @a ) {
            my( $mj, @jpaths ) = _split_lib( $j );
            push @c, " @ipaths @jpaths $mj $mi ";
          }
        }

        $cfg{LIBS} = \@c;
        next;
      }

      if( $i eq 'clean' || $i eq 'realclean' ) {
        $cfg{$i}{FILES} .= ' ' . $cfg{$i}{FILES};
        next;
      }

      if( ref($cfg{$i}) || ref($cfg2{$i}) ) {
        die "non scalar key '$i' while merging configuration information";
        $cfg{$i} = $cfg2{$i};
      } else {
        $cfg{$i} .= " $cfg2{$i}";
      }
    } else {
      $cfg{$i} = $cfg2{$i};
    }
  }

  return %cfg;
}

sub configure {
  ( my $file = $hook_package ) =~ s{::}{/}g;
  require "$file.pm";

  # do it at runtime
  require Alien::wxWidgets;
  Alien::wxWidgets->VERSION( 0.04 );

  my $this = $_[0];
  my %cfg1 = %{$_[1]};
  my %cfg2 = _call_method( 'configure', $hook_package );
  my %cfg = merge_config( \%cfg1, \%cfg2 );

  return \%cfg;
}

sub _make_override {
  my $name = shift;
  my $sub = sub {
    package MY;
    my $this = shift;
    my $full = "SUPER::$name";
    $this->$full( @_ );
  };
  no strict 'refs';
  *{"${name}_core"} = $sub;
  *{"${name}_ext"}  = $sub;
  *{"${name}"}      = sub { _call_method( $name, @_ ) };
}

_make_override( 'subdirs' );
_make_override( 'postamble' );
_make_override( 'depend' );
_make_override( 'install' );
_make_override( 'libscan' );
_make_override( 'constants' );
_make_override( 'metafile_target' );
_make_override( 'manifypods' );
sub ppd { package MY; shift->SUPER::ppd( @_ ) }
sub dynamic_lib { package MY; shift->SUPER::dynamic_lib( @_ ) }
sub const_config { package MY; shift->SUPER::const_config( @_ ) }

use vars qw(%args %additional_arguments $wx_top_file);
sub _process_mm_arguments {
  my( $args, $has_alien ) = @_;
  local *args = $args;
  my $build = 1;
  my %options =
    Wx::build::Options->get_makemaker_options( is_wxPerl_tree()
                                               ? () : ( 'saved' ) );

  $additional_arguments{WX_TOP} = $wx_top_file if $wx_top_file;
  unless( $has_alien ) {
      $args{depend} = { '$(FIRST_MAKEFILE)' => 'alien_wxwidgets_missing' };
      delete $args{$_} foreach grep /WX_|_WX/, keys %args;
      return 1;
  }
  my $platform = Alien::wxWidgets->config->{toolkit};

  $args{CCFLAGS} .= $options{extra_cflags} ? ' ' . $options{extra_cflags} : '';
  $args{LIBS} .=  $options{extra_libs} ? ' ' . $options{extra_libs} : '';
  $args{WX_CORE_LIB} ||= 'adv html core net base';

  foreach ( keys %args ) {
    my $v = $args{$_};

    m/^(NO|ON)_WX_PLATFORMS$/ and do {
      my $on = $1 eq 'ON';

      if( $on ) {
        # build if platform is explicitly listed
        $build &&= grep { $_ eq $platform } @$v;
      } else {
        # build unless platform is explicitly listed
        $build &&= !grep { $_ eq $platform } @$v;
      }

      delete $args{$_};
    };

    m/^REQUIRE_WX$/ and do {
      $build &&= __PACKAGE__->get_wx_version() >= $v;
      delete $args{$_};
    };

    m/^REQUIRE_WX_LIB$/ and do {
      my @libs = split ' ', $v;
      $build &&= __PACKAGE__->check_core_lib( @libs ) if $v=~/\S/;
      delete $args{$_};
    };
  }

  return $build unless $build;

  foreach ( keys %args ) {
    my $v = $args{$_};

    m/^WX_CORE_LIB_MAYBE$/ and do {
      my @libs = split ' ', $v;
      $args{LIBS} .= ' ' . join ' ',
                           map  { __PACKAGE__->get_core_lib( $_ ) }
                           grep { __PACKAGE__->check_core_lib( $_ ) }
                                ( $v=~/\S/ ? @libs : () );
      delete $args{$_};
    };

    m/^WX_CORE_LIB$/ and do {
      my @libs = split ' ', $v;
      $args{LIBS} .= ' ' . join ' ', __PACKAGE__->get_core_lib( @libs ) if $v=~/\S/;
      delete $args{$_};
    };

    m/^WX_LIB$/ and do {
      die "Please use WX_CORE_LIB instead of WX_LIB";
    };

    m/^(?:ABSTRACT_FROM|AUTHOR)/ and do {
      # args not known prior to Perl 5.005_03 (the check is a bit conservative)
      delete $args{$_} if $MAKEMAKER_VERSION < 5.43;
    };

    m/^(?:LICENSE)/ and do {
      # args not known prior to MakeMaker 6.32
      delete $args{$_} if $MAKEMAKER_VERSION < 6.32;
    };

    m/^WX_TOP$/ and do {
      $wx_top_file = $args{$_};
    };

    m/^WX_/ and do {
      $additional_arguments{$_} = delete $args{$_};
    };
  }

  return $build;
}

sub wxWriteMakefile {
  my %params = @_;
  local $is_core = 0;

  my $has_alien = $Wx::build::MakeMaker::Core::has_alien;
  $has_alien = defined( $has_alien ) ? $has_alien : 1;

  $params{XSOPT}     = ' -noprototypes' .
    ( is_wxPerl_tree() ? ' -nolinenumbers ' : ' ' );
  if( $has_alien ) {
    $params{CONFIGURE} = \&Wx::build::MakeMaker::configure;
    require Wx::build::MakeMaker::Any_OS;
    push @{$params{TYPEMAPS} ||= []},
      File::Spec->catfile( __PACKAGE__->get_api_directory, 'typemap' );
    ( $params{PREREQ_PM} ||= {} )->{Wx} ||= '0.19' unless is_wxPerl_tree();
  }

  my $build = Wx::build::MakeMaker::_process_mm_arguments( \%params, $has_alien );

  if( $build ) {
    WriteMakefile( %params );
  } else {
    ExtUtils::MakeMaker::WriteEmptyMakefile( %params );
  }
}

1;

# local variables:
# mode: cperl
# end: