root/plgtkimageview/Makefile.PL

Revision 501, 4.6 kB (checked in by jeffrey, 5 years ago)

Change licence to LGPL

Line 
1 use 5.008;
2 use ExtUtils::MakeMaker;
3 use Cwd;
4 use File::Spec;
5
6 # minimum required version of dependancies we need to build
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 # minimum required version of dependancies we need to run
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 # Writing a fake Makefile ensures that CPAN will pick up the correct
28 # dependencies and install them.
29 unless (eval "use ExtUtils::Depends;"
30            . "use ExtUtils::PkgConfig;"
31            # just seeing if Glib is available isn't enough, make sure
32            # it's recent enough, too
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; # not reached
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 # autogeneration
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 # now we're ready to start creating the makefile.
70 # we need to use ExtUtils::Depends to get relevant information out of
71 # the Glib extension, and to save config information for other modules which
72 # will chain from this one.
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 # As soon as a stable release with Glib::MakeHelper->get_configure_requires_yaml
87 # hits Sid, change use it, and take out the sub below.
88 #   my $configure_requires =
89 #                      Glib::MakeHelper->get_configure_requires_yaml(%PREREQ_PM);
90 my $configure_requires = get_configure_requires_yaml(%PREREQ_PM);
91
92 WriteMakefile(
93     NAME            => 'Gtk2::ImageView',
94     VERSION_FROM    => 'ImageView.pm', # finds $VERSION
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 # Stolen from Glib-Perl HEAD
109 # Generates YAML code that lists every module found in I<%module_to_version>
110 # under the C<configure_requires> key.  This can be used with
111 # I<ExtUtils::MakeMaker>'s C<EXTRA_META> parameter to specify which modules are
112 # needed at I<Makefile.PL> time.
113
114 sub get_configure_requires_yaml {
115 #  shift; # package name
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;
Note: See TracBrowser for help on using the browser.