Wx-PdfDocument

 view release on metacpan or  search on metacpan

inc/Module/Build/PdfDocument.pm  view on Meta::CPAN


use 5.008;
use strict;
use warnings;
use Module::Build;
use Config;
use File::Copy;
use Cwd;

our @ISA = qw( Module::Build );

our $wxpdfversion = '0.9.5';

our $VERSION = '0.62';

sub wxpdf_builderclass {

	# get builder class
	# based on OS && Config as we can't
	# load alien and we are never likely
	# to support a *nix toolkit other than
	# gtk

	my $bclass;

	if ( $^O =~ /^mswin/i ) {
		if ( $Config{cc} eq 'cl' ) {
			require Module::Build::PdfDocument::MSW;
			$bclass = 'Module::Build::PdfDocument::MSW';
		} else {
			require Module::Build::PdfDocument::MSWgcc;
			$bclass = 'Module::Build::PdfDocument::MSWgcc';
		}
	} elsif ( $^O =~ /^darwin/i ) {
		require Module::Build::PdfDocument::OSX;
		$bclass = 'Module::Build::PdfDocument::OSX';
	} else {
		require Module::Build::PdfDocument::GTK;
		$bclass = 'Module::Build::PdfDocument::GTK';
	}

	return $bclass;
}

sub wxpdf_prebuild_check { 1; }

sub wxpdf_libdirectory { 'wxpdfdoc-' . $wxpdfversion; }

sub wxpdf_source_file  { 'wxpdfdoc-' . $wxpdfversion . '.tar.gz';  }
					   
sub wxpdf_source_url   { 'http://sourceforge.net/projects/wxcode/files/Components/wxPdfDocument/' . wxpdf_source_file();  }

sub wxpdf_wxconfig {
	my $self = shift;

	# not available on windows
	return $self->{_wxpdf_config_wxconfig} if $self->{_wxpdf_config_wxconfig};
	my $binpathconfig;
	my $sympathconfig = Alien::wxWidgets->prefix . '/bin/wx-config';

	# sometimes the symlink is broken - if there has been relocation etc.
	# but we know where it should be if installed by Alien::wxWidgets
	# For system installs, 'wx-config' should work

	eval {
		my $location = readlink($sympathconfig);
		my @sympaths = split( /\//, $location );
		my $testpath = Alien::wxWidgets->prefix . '/lib/wx/config/' . $sympaths[-1];
		$binpathconfig = $testpath if -f $testpath;
	};

	my $wxconfig = $binpathconfig || 'wx-config';
	my $configtest = qx($wxconfig --version);
	if ( $configtest !~ /^\d+\.\d+\.\d+/ ) {
		die
			'Cannot find wx-config for wxWidgets. Perhaps you need to install wxWidgets development libraries for your system?';
	}
	$self->{_wxpdf_config_wxconfig} = $wxconfig;
	return $self->{_wxpdf_config_wxconfig};
}

sub wxpdf_version_split {
	my $class   = shift;
	my $version = Alien::wxWidgets->version;
	my $major   = substr( $version, 0, 1 );
	my $minor   = 1 * substr( $version, 2, 3 );
	my $release = 1 * substr( $version, 5, 3 );
	return ( $major, $minor, $release );
}

sub wxpdf_linker {
	my $self    = shift;
	my $command = $self->wxpdf_wxconfig . ' --ld';
	my $linker  = qx($command);
	chomp($linker);
	return $linker;
}

sub wxpdf_ldflags {
	my $self = shift;
	return Alien::wxWidgets->link_flags;
}

sub wxpdf_defines {
	my $self = shift;
	my $defines =
		Alien::wxWidgets->defines . ' -DWXBUILDING -DWXUSINGDLL -D__WX__';
	return $defines;
}

sub wxpdf_compiler {
	my $self     = shift;
	my $command  = $self->wxpdf_wxconfig . ' --cc';
	my $compiler = qx($command);
	chomp($compiler);
	{
		my @commands = split( /\s/, $compiler );
		$commands[0] =~ s/^gcc/g\+\+/;
		$commands[0] .= ' -c';
		$compiler = join( ' ', @commands );
	}



( run in 2.245 seconds using v1.01-cache-2.11-cpan-71847e10f99 )