Add libwx-perl
[pkg-perl] / deb-src / libwx-perl / libwx-perl-0.96 / script / fix_alien_path.pl
1 #!/usr/bin/perl -w
2 #############################################################################
3 ## Name:        script/fix_alien_path.pl
4 ## Purpose:     Substitute Alien::wxWidgets path in modules
5 ## Author:      Mattia Barbon
6 ## Modified by:
7 ## Created:     15/08/2005
8 ## RCS-ID:      $Id: fix_alien_path.pl 2057 2007-06-18 23:03:00Z mbarbon $
9 ## Copyright:   (c) 2005-2006 Mattia Barbon
10 ## Licence:     This program is free software; you can redistribute it and/or
11 ##              modify it under the same terms as Perl itself
12 #############################################################################
13
14 use strict;
15 use blib; # to pick the correct 'Wx::build::Options'
16 use Alien::wxWidgets 0.04 ();
17 use Wx::build::Options;
18 use Fatal qw(open close unlink);
19 use Config;
20 use Data::Dumper;
21 use File::Spec::Functions qw(splitpath splitdir);
22
23 # we do not care about the options, just that Alien::wxWidgets
24 # is initialized with the correct key
25 Wx::build::Options->get_makemaker_options( 'saved' );
26 $Alien::wxWidgets::dont_remap = 1;
27
28 my( $from, $to ) = @ARGV;
29 my $key = Alien::wxWidgets->key;
30 my $version = Alien::wxWidgets->version;
31 my @libs = Alien::wxWidgets->library_keys;
32 my %libs; @libs{@libs} = Alien::wxWidgets->shared_libraries( @libs );
33 my $libs = Data::Dumper::Dumper( \%libs );
34
35 my $keyd;
36 if( $^O =~ /mswin/i ) {
37     $keyd = $key;
38 } else {
39     my( $vol, $dir, $file ) = splitpath( Alien::wxWidgets->prefix );
40     $keyd = $file ? $file : ( splitdir( $dir ) )[-1];
41 }
42
43 unlink $to if -f $to;
44 open my $in, "< $from"; binmode $in;
45 open my $out, "> $to"; binmode $out;
46
47 while( <$in> ) {
48     s/XXXALIENDXXX/$keyd/g;
49     s/XXXALIENXXX/$key/g;
50     s/Wx::wxVERSION\(\)/$version/g;
51     s/XXXDLLSXXX/$libs/g;
52     print $out $_;
53 }
54
55 close $in;
56 close $out;
57
58 exit 0;