1 package Wx::build::Options;
7 Wx::build::Options - retrieve wxWidgets/wxPerl build options
14 Getopt::Long::Configure( 'pass_through' );
19 my $extra_cflags = '';
28 $v =~ m/(\d+)\.(\d+)(?:\.(\d+))?/
29 or die 'Invalid version specification: ', $v, "\n";
32 $wx{version} = [ $1 + ( $2 + $3 / 1000 ) / 1000,
33 $1 + ( $2 + ( $3 + 1 ) / 1000 ) / 1000 ];
35 $wx{version} = [ $1 + $2 / 1000,
36 $1 + ( $2 + 1 ) / 1000 ];
43 $options = do 'Wx/build/Opt.pm';
44 die "Unable to load options: $@" unless $options;
46 ( $extra_cflags, $extra_libs, $alien_key )
47 = @{$options}{qw(extra_cflags extra_libs alien_key)};
49 require Alien::wxWidgets;
50 Alien::wxWidgets->load( key => $alien_key );
61 my $result = GetOptions( 'help' => \$help,
62 'mksymlinks' => \$mksymlinks,
63 'extra-libs=s' => \$extra_libs,
64 'extra-cflags=s' => \$extra_cflags,
65 # for Alien::wxWidgets
66 'wx-debug!' => \($wx{debug}),
67 'wx-unicode!' => \($wx{unicode}),
68 'wx-mslu!' => \($wx{mslu}),
69 'wx-version=s' => \&_wx_version,
70 'wx-toolkit=s' => \($wx{toolkit}),
71 '<>' => \&_process_options,
74 @ARGV = @argv; @argv = ();
76 if( !$result || $help ) {
78 Usage: perl Makefile.PL [options]
79 --enable/disable-foo where foo is one of: dnd filesys grid help
80 html mdi print xrc stc docview calendar datetime
81 --help you are reading it
82 --mksymlinks create a symlink tree
83 --extra-libs=libs specify extra linking flags
84 --extra-cflags=flags specify extra compilation flags
86 --[no-]wx-debug [Non-] debugging wxWidgets
87 --[no-]wx-unicode [Non-] Unicode wxWidgets
88 --[no-]wx-mslu [Non-] MSLU wxWidgets (Windows only)
90 --wx-toolkit=msw|gtk|gtk2|motif|mac|wce|...
96 if( $wx{toolkit} && $wx{toolkit} eq 'wce' ) {
97 $wx{compiler_kind} = 'evc';
100 if( Alien::wxWidgets->can( 'load' ) ) {
101 Alien::wxWidgets->load( map { $_ => $wx{$_} }
102 grep { defined $wx{$_} }
104 $alien_key = Alien::wxWidgets->key;
108 sub _process_options {
111 unless( $i =~ m/^-/ ) {
116 if( $i =~ m/^--(enable|disable)-(\w+)$/ ) {
117 $subdirs{$2} = ( $1 eq 'enable' ? 1 : 0 );
119 die "invalid option $i";
123 =head2 get_makemaker_options
125 my %mm_options = Wx::build::Options->get_makemaker_options;
127 Returns options meaningful at wxPerl building time.
129 my %options = ( mksymlinks => 0,
132 subdirs => { stc => 1,
137 sub get_makemaker_options {
139 my $from = shift || '';
141 if( $from eq 'saved' ) {
147 return ( mksymlinks => $mksymlinks,
148 extra_libs => $extra_libs,
149 extra_cflags => $extra_cflags,
150 subdirs => \%subdirs );
153 =head2 write_config_file
155 my $ok = Wx::build::Options->write_config_file( '/path/to/file' );
157 Writes a machine-readable representation of command-line options given to
158 top-level Makefile.PL
162 sub write_config_file {
166 require Data::Dumper;
167 my $str = Data::Dumper->Dump( [ { extra_libs => $extra_libs,
168 extra_cflags => $extra_cflags,
169 alien_key => $alien_key,
172 Wx::build::Utils::write_string( $file, $str );