File: Makefile.PL

package info (click to toggle)
libgtk2-sourceview2-perl 0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 236 kB
  • ctags: 28
  • sloc: perl: 1,066; ansic: 58; makefile: 4
file content (120 lines) | stat: -rw-r--r-- 2,588 bytes parent folder | download | duplicates (2)
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
use strict;
use warnings;

use ExtUtils::MakeMaker;

use Cwd;
use File::Spec;

use Gtk2::CodeGen;
use Glib::MakeHelper;
use ExtUtils::Depends;
use ExtUtils::PkgConfig;

my $DEPENDS;
my @XS_FILES = ();

exit main();

sub main {
	
	# Create the build folder used by the code generation utilities
	mkdir 'build', 0777;
	
	my @typemaps = ();
	my @deps = ('Glib');
	my %pkgconfig;
	
	# Find gtksourceview 2.0
	eval {
		%pkgconfig = ExtUtils::PkgConfig->find("gtksourceview-2.0");
		push @XS_FILES, <xs/*.xs>;
		push @typemaps, 'maps';
		push @deps, 'Gtk2';
	};
	if (my $error = $@) {
		warn "FAIL: ", $error;
		return;
	}
	
	$DEPENDS = ExtUtils::Depends->new('Gtk2::SourceView2', @deps);
	
	$DEPENDS->add_pm(
		File::Spec->catfile('lib', 'Gtk2', 'SourceView2.pm'),
		File::Spec->catfile('$(INST_LIBDIR)', 'SourceView2.pm'),
	);
	
	# Code generation
	Gtk2::CodeGen->parse_maps('gtk2-sourceview2', input => [ @typemaps ]);
	Gtk2::CodeGen->write_boot(
		ignore   => qr/^Gtk2::SourceView2$/,
		xs_files => [ @XS_FILES ],
	);
	
	
	$DEPENDS->set_inc($pkgconfig{cflags} . ' -I./build');
	$DEPENDS->set_libs($pkgconfig{libs});
	$DEPENDS->add_xs(@XS_FILES);
	$DEPENDS->add_typemaps(
		File::Spec->catfile(cwd(), 'build', 'gtk2-sourceview2.typemap'),
	);
	$DEPENDS->install(
		File::Spec->catfile('build', 'gtk2-sourceview2-autogen.h'),
		'gtk2-sourceview2-perl.h',
	);
	$DEPENDS->save_config(File::Spec->catfile('build', 'IFiles.pm'));
	

	# Create the Makefile
	WriteMakefile(
		AUTHOR        => 'Emmanuel Rodriguez <potyl@cpan.org>',
		NAME          => 'Gtk2::SourceView2',
		VERSION_FROM  => File::Spec->catfile('lib', 'Gtk2', 'SourceView2.pm'),
		ABSTRACT_FROM => File::Spec->catfile('lib', 'Gtk2', 'SourceView2.pm'),
		LICENSE       => 'perl, gpl',

		PREREQ_PM     => {
			'Gtk2' => '1.160',
		},

		CONFIGURE_REQUIRES => {
			'Gtk2::CodeGen'       => 0,
			'Glib::MakeHelper'    => 0,
			'ExtUtils::Depends'   => 0,
			'ExtUtils::PkgConfig' => 0,
		},

		PREREQ_FATAL  => 1,
		
		XSPROTOARG    => '-noprototypes',
		MAN3PODS      => {
			Glib::MakeHelper->do_pod_files(@XS_FILES),
		},
		
		META_MERGE => {
			repository => 'http://github.com/potyl/gtk2-sourceview2',
		},
		
		$DEPENDS->get_makefile_vars(),
		
		# Remove the build folder when doing "make clean"
		clean => {
			FILES => 'build',
		},
	);
	
	return 0;
}


sub MY::postamble {
	
	my $postamble = Glib::MakeHelper->postamble_clean();
	$postamble .= Glib::MakeHelper->postamble_docs_full(
		DEPENDS   => $DEPENDS,
		XS_FILES  => [ @XS_FILES ],
		COPYRIGHT => 'Copyright (C) 2009 by Emmanuel Rodriguez'
	);
	
	return $postamble;
}