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
|
#! /usr/bin/perl -w
use 5.008;
use strict;
use warnings;
use Cwd;
use File::Spec;
use ExtUtils::MakeMaker;
# minimum required version of dependancies we need to build
our %build_reqs = (
'perl-ExtUtils-Depends' => '0.2',
'perl-ExtUtils-PkgConfig' => '1.0',
'perl-Glib' => '1.103',
'perl-Gtk2' => '1.100',
'perl-Cairo' => '1.00',
'goocanvas' => '0.9',
);
our %prereqs = (
'Glib' => $build_reqs{'perl-Glib'},
'Gtk2' => $build_reqs{'perl-Gtk2'},
'Cairo' => $build_reqs{'perl-Cairo'},
'ExtUtils::Depends' => $build_reqs{'perl-ExtUtils-Depends'},
'ExtUtils::PkgConfig' => $build_reqs{'perl-ExtUtils-PkgConfig'},
);
# Writing a fake Makefile ensures that CPAN will pick up the correct
# dependencies and install them.
unless (
eval "use ExtUtils::Depends;"
. "use ExtUtils::PkgConfig;"
. "use Gtk2::CodeGen;"
. "use Cairo;"
# just seeing if Glib is available isn't enough, make sure
# it's recent enough, too
. "use Glib '$build_reqs{'perl-Glib'}';"
. "use Gtk2 '$build_reqs{'perl-Gtk2'}';"
. "use Glib::MakeHelper;" . "1"
)
{
warn "$@\n";
WriteMakefile(
PREREQ_FATAL => 1,
PREREQ_PM => \%prereqs,
);
exit 1; # not reached
}
mkdir 'build', 0777;
our %pkgcfg = ExtUtils::PkgConfig->find ('goocanvas');
# now we're ready to start creating the makefile.
# we need to use ExtUtils::Depends to get relevant information out of
# the Glib extension, and to save config information for other modules which
# will chain from this one.
our @xs_files = <xs/*.xs>;
our %pm_files = (
'lib/Goo/Canvas.pm' => '$(INST_LIBDIR)/Canvas.pm',
);
our %pod_files;
%pod_files = (
'lib/Goo/Canvas.pm' => '$(INST_MAN3DIR)/Goo::Canvas.$(MAN3EXT)',
Glib::MakeHelper->do_pod_files (@xs_files),
);
ExtUtils::PkgConfig->write_version_macros (
"build/goocanvas-perl-version.h",
'goocanvas' => 'GOO_CANVAS'
);
#
# autogeneration
#
Gtk2::CodeGen->parse_maps ('goocanvas-perl');
Gtk2::CodeGen->write_boot (ignore => '^Goo::Canvas$');
my $goo = ExtUtils::Depends->new ('Goo::Canvas', 'Gtk2', 'Glib', 'Cairo');
$goo->set_inc ($pkgcfg{cflags} . ' -I./build ');
if ( $^O eq 'MSWin32' ) {
my @a = split /\s+/,$pkgcfg{libs};
for (@a) {
next if /gdi32|imm32|shell32|ole32|\-lm/;
$_ = '-luser32',next if /user32/;
$_ = '-luuid',next if /uuid/;
$_ .= '.dll.a' if /^-l/;
}
$goo->set_libs (join(' ',@a) . find_extra_libs());
} else {
$goo->set_libs ($pkgcfg{libs});
}
$goo->add_xs (@xs_files);
$goo->add_pm (%pm_files);
my $cwd = cwd();
$goo->add_typemaps (
File::Spec->catfile( $cwd, 'build/goocanvas-perl.typemap'),
File::Spec->catfile( $cwd, 'goocanvas.typemap'),
);
$goo->install (qw(goocanvas-perl.h
build/goocanvas-perl-autogen.h
build/goocanvas-perl-version.h));
$goo->save_config ('build/IFiles.pm');
use Data::Dumper qw(Dumper);
WriteMakefile(
NAME => 'Goo::Canvas',
VERSION_FROM => 'lib/Goo/Canvas.pm', # finds $VERSION
PREREQ_PM => \%prereqs,
ABSTRACT_FROM => 'lib/Goo/Canvas.pm', # retrieve abstract from module
XSPROTOARG => '-noprototypes',
'EXE_FILES' => ['bin/perltetris.pl', 'bin/perlmine.pl'],
MAN3PODS => \%pod_files,
( $^O eq 'MSWin32' ?
(dynamic_lib => { OTHERLDFLAGS=>"-Wl,-out-implib,blib\\arch\\auto\\Goo\\Canvas\\Canvas.lib.a \$(EXPORT_LIST) " })
: ()),
$goo->get_makefile_vars,
);
# this probably needs to go into ExtUtils::Depends.
sub find_extra_libs {
# right now we need this terrible hack only for windows.
# unfortunately, this code doesn't work on cygwin. :-/
return "" unless $^O eq "MSWin32";
# win32 does not allow unresolved symbols in libraries, but
# Gtk2 uses on symbols in the dll created for Glib.
# so, we have to break all this nice abstraction and encapsulation
# and find the actual Glib.dll and Glib.lib installed by perl when
# the Glib module was built, and add it to the list of lib files.
#
# when we depend on Cairo, the same applies to Cairo.lib.
#
# say it with me: "i hate win32."
my $retstring = "";
use File::Find;
find (sub {
$retstring .= " ".$File::Find::name
if /(Glib\.lib|libGlib|Glib\.dll)/i;
$retstring .= " ".$File::Find::name
if /(Cairo\.lib|libCairo|Cairo\.dll)/i;
$retstring .= " ".$File::Find::name
if /(Gtk2\.lib|libGtk2|Gtk2\.dll)/i;
}, @INC);
return $retstring;
}
sub MY::postamble {
my $res = Glib::MakeHelper->postamble_clean ()
. Glib::MakeHelper->postamble_docs (@main::xs_files)
. Glib::MakeHelper->postamble_rpms (
'GOO_CANVAS' => $build_reqs{'goocanvas'},
'PERL_EXTUTILS_DEPENDS' =>
$build_reqs{'perl-ExtUtils-Depends'},
'PERL_EXTUTILS_PKGCONFIG' =>
$build_reqs{'perl-ExtUtils-PkgConfig'},
'PERL_GLIB' => $build_reqs{'perl-Glib'},
'PERL_GTK' => $build_reqs{'perl-Gtk2'},
'PERL_CAIRO' => $build_reqs{'perl-Cairo'},
);
return $res;
}
|