| 1 |
use 5.008; |
|---|
| 2 |
use ExtUtils::MakeMaker; |
|---|
| 3 |
use Cwd; |
|---|
| 4 |
use File::Spec; |
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
our %build_reqs = ( |
|---|
| 8 |
'perl-ExtUtils-Depends' => '0.2', |
|---|
| 9 |
'perl-ExtUtils-PkgConfig' => '1.03', |
|---|
| 10 |
'perl-Glib' => '1.140', |
|---|
| 11 |
'perl-Gtk2' => '1.140', |
|---|
| 12 |
'GtkImageView' => '1.6.0', |
|---|
| 13 |
); |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
our %runtime_reqs = ( |
|---|
| 17 |
'GtkImageView' => undef, |
|---|
| 18 |
); |
|---|
| 19 |
|
|---|
| 20 |
our %PREREQ_PM = ( |
|---|
| 21 |
'ExtUtils::Depends' => $build_reqs{'perl-ExtUtils-Depends'}, |
|---|
| 22 |
'ExtUtils::PkgConfig' => $build_reqs{'perl-ExtUtils-PkgConfig'}, |
|---|
| 23 |
'Glib' => $build_reqs{'perl-Glib'}, |
|---|
| 24 |
'Gtk2' => $build_reqs{'perl-Gtk2'}, |
|---|
| 25 |
); |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
unless (eval "use ExtUtils::Depends;" |
|---|
| 30 |
. "use ExtUtils::PkgConfig;" |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
. "use Glib '$build_reqs{'perl-Glib'}';" |
|---|
| 34 |
. "use Glib::MakeHelper;" |
|---|
| 35 |
. "use Gtk2 '$build_reqs{'perl-Gtk2'}';" |
|---|
| 36 |
. "use Gtk2::CodeGen;" |
|---|
| 37 |
. "1") { |
|---|
| 38 |
warn "$@\n"; |
|---|
| 39 |
WriteMakefile( |
|---|
| 40 |
PREREQ_FATAL => 1, |
|---|
| 41 |
PREREQ_PM => \%PREREQ_PM, |
|---|
| 42 |
); |
|---|
| 43 |
exit 1; |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
%pkgcfg = ExtUtils::PkgConfig->find ('gtkimageview >= ' |
|---|
| 47 |
. $build_reqs{GtkImageView}); |
|---|
| 48 |
|
|---|
| 49 |
$runtime_reqs{GtkImageView} = $pkgcfg{modversion}; |
|---|
| 50 |
|
|---|
| 51 |
mkdir 'build', 0777; |
|---|
| 52 |
|
|---|
| 53 |
chomp(my $includes = `pkg-config --variable includedir gtkimageview`); |
|---|
| 54 |
my @headers = glob($includes . "/gtkimageview/*.h"); |
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
|
|---|
| 59 |
Gtk2::CodeGen->parse_maps('gtkimageviewperl'); |
|---|
| 60 |
Gtk2::CodeGen->write_boot(glob => '*.xs', ignore => '^Gtk2::ImageView$'); |
|---|
| 61 |
|
|---|
| 62 |
our @xs_files = <*.xs>; |
|---|
| 63 |
our %pm_files = ('ImageView.pm' => '$(INST_LIBDIR)/ImageView.pm',); |
|---|
| 64 |
our %pod_files = Glib::MakeHelper->do_pod_files (@xs_files); |
|---|
| 65 |
our @typemaps = qw(build/gtkimageviewperl.typemap); |
|---|
| 66 |
our @headers = qw(gtkimageviewperl.h |
|---|
| 67 |
build/gtkimageviewperl-autogen.h); |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
my $depends = ExtUtils::Depends->new ('Gtk2::ImageView', 'Gtk2', 'Glib'); |
|---|
| 75 |
$depends->set_inc ($pkgcfg{cflags}); |
|---|
| 76 |
$depends->set_libs ($pkgcfg{libs}); |
|---|
| 77 |
$depends->add_xs (@xs_files); |
|---|
| 78 |
$depends->add_pm (%pm_files); |
|---|
| 79 |
my $cwd = cwd(); |
|---|
| 80 |
$depends->add_typemaps (map {File::Spec->catfile($cwd,$_)} @typemaps); |
|---|
| 81 |
|
|---|
| 82 |
$depends->install (@headers); |
|---|
| 83 |
|
|---|
| 84 |
$depends->save_config ('build/IFiles.pm'); |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
my $configure_requires = get_configure_requires_yaml(%PREREQ_PM); |
|---|
| 91 |
|
|---|
| 92 |
WriteMakefile( |
|---|
| 93 |
NAME => 'Gtk2::ImageView', |
|---|
| 94 |
VERSION_FROM => 'ImageView.pm', |
|---|
| 95 |
ABSTRACT => 'Perl bindings for the GtkImageView widget', |
|---|
| 96 |
AUTHOR => 'Jeffrey Ratcliffe', |
|---|
| 97 |
LICENSE => 'lgpl', |
|---|
| 98 |
PREREQ_PM => \%PREREQ_PM, |
|---|
| 99 |
XSPROTOARG => '-noprototypes', |
|---|
| 100 |
MAN3PODS => \%pod_files, |
|---|
| 101 |
$depends->get_makefile_vars, |
|---|
| 102 |
EXTRA_META => qq/ |
|---|
| 103 |
$configure_requires |
|---|
| 104 |
/, |
|---|
| 105 |
); |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
|
|---|
| 114 |
sub get_configure_requires_yaml { |
|---|
| 115 |
|
|---|
| 116 |
my %prereqs = @_; |
|---|
| 117 |
|
|---|
| 118 |
my $yaml = "configure_requires:\n"; |
|---|
| 119 |
while (my ($module, $version) = each %prereqs) { |
|---|
| 120 |
$yaml .= " $module: $version\n"; |
|---|
| 121 |
} |
|---|
| 122 |
|
|---|
| 123 |
return $yaml; |
|---|
| 124 |
} |
|---|
| 125 |
|
|---|
| 126 |
|
|---|
| 127 |
package MY; |
|---|
| 128 |
|
|---|
| 129 |
sub postamble { |
|---|
| 130 |
return Glib::MakeHelper->postamble_clean () |
|---|
| 131 |
. Glib::MakeHelper->postamble_docs_full ( |
|---|
| 132 |
DEPENDS => $depends, |
|---|
| 133 |
COPYRIGHT => "Copyright (C) 2007 by Jeffrey Ratcliffe.\n\nThis software is licensed under the GPL-3; see L<Gtk2::ImageView> for a full notice.", |
|---|
| 134 |
) |
|---|
| 135 |
. Glib::MakeHelper->postamble_rpms ( |
|---|
| 136 |
'GTK_IMAGE_VIEW' => $build_reqs{'GtkImageView'}, |
|---|
| 137 |
'PERL_EXTUTILS_DEPENDS' => |
|---|
| 138 |
$build_reqs{'perl-ExtUtils-Depends'}, |
|---|
| 139 |
'PERL_EXTUTILS_PKGCONFIG' => |
|---|
| 140 |
$build_reqs{'perl-ExtUtils-PkgConfig'}, |
|---|
| 141 |
'PERL_GLIB' => $build_reqs{'perl-Glib'}, |
|---|
| 142 |
'PERL_GTK' => $build_reqs{'perl-Gtk2'}, |
|---|
| 143 |
) |
|---|
| 144 |
." |
|---|
| 145 |
realclean :: |
|---|
| 146 |
-rm -Rf build |
|---|
| 147 |
"; |
|---|
| 148 |
} |
|---|
| 149 |
package MAIN; |
|---|