Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Module / Install / Share.pm
CommitLineData
3fea05b9 1package Module::Install::Share;
2
3use strict;
4use Module::Install::Base ();
5
6use vars qw{$VERSION @ISA $ISCORE};
7BEGIN {
8 $VERSION = '0.91';
9 @ISA = 'Module::Install::Base';
10 $ISCORE = 1;
11}
12
13sub install_share {
14 my $self = shift;
15 my $dir = @_ ? pop : 'share';
16 my $type = @_ ? shift : 'dist';
17 unless ( defined $type and $type eq 'module' or $type eq 'dist' ) {
18 die "Illegal or invalid share dir type '$type'";
19 }
20 unless ( defined $dir and -d $dir ) {
21 die "Illegal or missing directory install_share param";
22 }
23
24 # Split by type
25 my $S = ($^O eq 'MSWin32') ? "\\" : "\/";
26 if ( $type eq 'dist' ) {
27 die "Too many parameters to install_share" if @_;
28
29 # Set up the install
30 $self->postamble(<<"END_MAKEFILE");
31config ::
32\t\$(NOECHO) \$(MOD_INSTALL) \\
33\t\t"$dir" \$(INST_LIB)${S}auto${S}share${S}dist${S}\$(DISTNAME)
34
35END_MAKEFILE
36 } else {
37 my $module = Module::Install::_CLASS($_[0]);
38 unless ( defined $module ) {
39 die "Missing or invalid module name '$_[0]'";
40 }
41 $module =~ s/::/-/g;
42
43 # Set up the install
44 $self->postamble(<<"END_MAKEFILE");
45config ::
46\t\$(NOECHO) \$(MOD_INSTALL) \\
47\t\t"$dir" \$(INST_LIB)${S}auto${S}share${S}module${S}$module
48
49END_MAKEFILE
50 }
51
52 # The above appears to behave incorrectly when used with old versions
53 # of ExtUtils::Install (known-bad on RHEL 3, with 5.8.0)
54 # So when we need to install a share directory, make sure we add a
55 # dependency on a moderately new version of ExtUtils::MakeMaker.
56 $self->build_requires( 'ExtUtils::MakeMaker' => '6.11' );
57
58 # 99% of the time we don't want to index a shared dir
59 $self->no_index( directory => $dir );
60}
61
621;
63
64__END__
65
66=pod
67
68=head1 NAME
69
70Module::Install::Share - Install non-code files for use during run-time
71
72=head1 SYNOPSIS
73
74 # Put everything inside ./share/ into the distribution 'auto' path
75 install_share 'share';
76
77 # Same thing as above using the default directory name
78 install_share;
79
80=head1 DESCRIPTION
81
82As well as Perl modules and Perl binary applications, some distributions
83need to install read-only data files to a location on the file system
84for use at run-time.
85
86XML Schemas, L<YAML> data files, and L<SQLite> databases are examples of
87the sort of things distributions might typically need to have available
88after installation.
89
90C<Module::Install::Share> is a L<Module::Install> extension that provides
91commands to allow these files to be installed to the applicable location
92on disk.
93
94To locate the files after installation so they can be used inside your
95module, see this extension's companion module L<File::ShareDir>.
96
97=head1 TO DO
98
99Currently C<install_share> installs not only the files you want, but
100if called by the author will also copy F<.svn> and other source-control
101directories, and other junk.
102
103Enhance this to copy only files under F<share> that are in the
104F<MANIFEST>, or possibly those not in F<MANIFEST.SKIP>.
105
106=head1 AUTHORS
107
108Audrey Tang E<lt>autrijus@autrijus.orgE<gt>
109
110Adam Kennedy E<lt>adamk@cpan.orgE<gt>
111
112=head1 SEE ALSO
113
114L<Module::Install>, L<File::ShareDir>
115
116=head1 COPYRIGHT
117
118Copyright 2006 Audrey Tang, Adam Kennedy.
119
120This program is free software; you can redistribute it and/or modify it
121under the same terms as Perl itself.
122
123See L<http://www.perl.com/perl/misc/Artistic.html>
124
125=cut