On 17/02/2010 20:01, Mattia Barbon wrote:

I'm not sure I understand. Apart from the special case for wxWidgets
2.9.0, is there any reason to _automatically_ set SDK/min version? or
you mean that Build.PL should automatically set SDK/min version to the
lowest possible value?

No - I was just looking for a way to make ActivePerl work 'out of the box' - I'm sure the defaults should be as you have them. On further thinking about this, I think the ActivePerl / gcc-4.0 / 10.4 dependency is just one particular different case - all of which can be dealt with using the wxWidgets-extraflags option noted below.

Re wxWidgets-extraflags option

Looks useful: could you add it?


I've committed the wxWidgets-extraflags option to svn.

For reference for the list, on unices and osx use wxWidgets-extraflags to pass extra arguments to ./configure. You can include anything mentioned by ./configure --help

On MSWin makefile builds wxWidgets-extraflags can contain the make options as defined in build/msw/config.gcc etc.

For example, I want a unicode build using wxGraphicsContext and I want Alien-wxWidgets to download and build wxWidgets 2.8.10 for me without intervention:

Unices

perl Build.PL --wxWidgets-build='yes' --wxWidgets-source='tar.gz' --wxWidgets-unicode=1 --wxWidgets-version=2.8.10 --wxWidgets-extraflags="-enable-graphics_ctx"

OSX

perl Build.PL --wxWidgets-build='yes' --wxWidgets-source='tar.gz' --wxWidgets-unicode=1 --wxWidgets-version=2.8.10 --wxWidgets-universal --wxWidgets-extraflags="-enable-graphics_ctx"

MSWin

perl Build.PL --wxWidgets-source=tar.gz --wxWidgets-unicode=1 --wxWidgets-mslu=0 --wxWidgets-version=2.8.10 wxWidgets-unicode=1 wxWidgets-extraflags="USE_GDIPLUS=1"

(note, for MSWin build USE_GDIPLUS will fail unless you have appropriate platform SDK installed)

Re ExtUtils:FakeConfig / -nostdinc
I do not see a better way. It's a pity that -nostding is both used by
ActivePerl and suggested in the OS X Perl README.


Attached is Config_osx.pm that maybe could be added to ExtUtils::FakeConfig

For reference for the list, primary use is to remove '-nostdinc' from appropriate Config entries and allow Wx to build with new exception handling and ExtUtils::XSpp > 0.6. It will also specify gcc-4.0 if you are using ActivePerl.

For a little more completeness, I added the capability of setting architectures via an environment variable. (as use of this module might prevent use of Config_u)

Of course the possible architectures you get for wxPerl are set when you build wxWidgets.

Simple usage

perl -MConfig_osx Makefile.PL

will just allow you to build Wx if your Perl Config includes '-nostdinc', and will additionally set the gcc version if you are using ActivePerl.



Regards

Mark




#!/usr/bin/perl -w
package Config_osx;

require ExtUtils::FakeConfig;
require Config;

my $ccflags = $Config::Config{ccflags};
my $cppflags = $Config::Config{cppflags};

my $cc = $Config::Config{cc};
my $ccname = $Config::Config{ccname};
my $ld = $Config::Config{ld};
my $cpp = $Config::Config{cpp};
my $cpprun = $Config::Config{cpprun};
my $cppstdin = $Config::Config{cppstdin};
my $lddlflags = $Config::Config{lddlflags};
my $ldflags = $Config::Config{ldflags};

my $flavour = (defined &ActivePerl::BUILD) ? 'activeperl' : 'standard';
my $osxver = get_osx_major_version();

# Remove -nostdinc option
unless(exists($ENV{FAKECONFIG_USE_NOSTDINC}) && $ENV{FAKECONFIG_USE_NOSTDINC}) {
    $ccflags =~ s/-nostdinc //g;
    $cppflags =~ s/-nostdinc //g;
}

# ActivePerl on Snow Leopard +
if(($flavour eq 'activeperl') && ( $osxver >= 10 ) ) {
  $cc       = 'gcc-4.0';
  $ccname   = 'gcc-4.0';
  $ld       = 'g++-4.0';
  $cpp      = 'gcc-4.0 -E';
  $cpprun   = 'gcc-4.0 -E';
  $cppstdin = 'gcc-4.0 -E';
}

# Architectures
if(exists($ENV{FAKECONFIG_USE_ARCHITECTURES}) && 
$ENV{FAKECONFIG_USE_ARCHITECTURES}) {
    my @arches = qw( ppc i386 x86_64 );
    # arch in $ccflags, $lddlflags, $ldflags
    
    for my $arch ( @arches ) {
       # remove exisiting
       $ccflags   =~ s/-arch $arch //g;
       $ldflags   =~ s/-arch $arch //g;
       $lddlflags =~ s/-arch $arch //g;
       # add required
       if( $ENV{FAKECONFIG_USE_ARCHITECTURES} =~ /$arch/ ) {
           print qq(Using architecture $arch\n);
           $ccflags   = qq(-arch $arch ) . $ccflags;
           $ldflags   = qq(-arch $arch ) . $ldflags;
           $lddlflags = qq(-arch $arch ) . $lddlflags;
       }
    }
    
}

my %values =
  ( cc        => $cc,
    ccflags   => $ccflags,
    cppflags  => $cppflags,
    ccname    => $ccname,
    ld        => $ld,
    cpp       => $cpp,
    cpprun    => $cpprun,
    cppstdin  => $cppstdin,
    lddlflags => $lddlflags,
    ldflags   => $ldflags,
    );

ExtUtils::FakeConfig->import( %values );


sub get_osx_major_version {
   my $verstr =  `uname -r`;
   if( $verstr =~ /^(\d+)/ ) {
       return $1;
   } else {
       die qq(Could not determine OSX version number);
   }
}

1;

__DATA__

=head1 NAME

Config_osx - compile Mac OS X modules without '-nostdinc' flag

=head1 SYNOPSIS

  perl -MConfig_osx Makefile.PL
  make
  make test
  make install

with CPAN.pm/CPANPLUS.pm

  set PERL5OPT=-MConfig_osx
  cpanp

=head1 DESCRIPTION

This module is only useful at Makefile.PL invocation time. It modifies
some %Config values allowing compilation of Perl XS modules without passing
the '-nostdinc' flag. For current versions of ActivePerl, will also set
the required compiler version (gcc-4.0).

You may override the -nostdinc exclusion  by setting environment variable

export FAKECONFIG_USE_NOSTDINC=1

The module also allows you to specify which architectures should be built
by setting the environment variable FAKECONFIG_USE_ARCHITECTURES.
Allowed architectures are ppc, i386, x86_64

For example, to specify universal 32 bit binaries

export FAKECONFIG_USE_ARCHITECTURES="i386 ppc"

to specify combined 32 and 64bit intel binaries

export FAKECONFIG_USE_ARCHITECTURES="i386 x86_64"


=head1 AUTHOR

Mark Dootson <mdoot...@cpan.org>

=cut




Reply via email to