Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Module / Install / Share.pm
1 package Module::Install::Share;
2
3 use strict;
4 use Module::Install::Base ();
5
6 use vars qw{$VERSION @ISA $ISCORE};
7 BEGIN {
8         $VERSION = '0.91';
9         @ISA     = 'Module::Install::Base';
10         $ISCORE  = 1;
11 }
12
13 sub 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");
31 config ::
32 \t\$(NOECHO) \$(MOD_INSTALL) \\
33 \t\t"$dir" \$(INST_LIB)${S}auto${S}share${S}dist${S}\$(DISTNAME)
34
35 END_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");
45 config ::
46 \t\$(NOECHO) \$(MOD_INSTALL) \\
47 \t\t"$dir" \$(INST_LIB)${S}auto${S}share${S}module${S}$module
48
49 END_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
62 1;
63
64 __END__
65
66 =pod
67
68 =head1 NAME
69
70 Module::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
82 As well as Perl modules and Perl binary applications, some distributions
83 need to install read-only data files to a location on the file system
84 for use at run-time.
85
86 XML Schemas, L<YAML> data files, and L<SQLite> databases are examples of
87 the sort of things distributions might typically need to have available
88 after installation.
89
90 C<Module::Install::Share> is a L<Module::Install> extension that provides
91 commands to allow these files to be installed to the applicable location
92 on disk.
93
94 To locate the files after installation so they can be used inside your
95 module, see this extension's companion module L<File::ShareDir>.
96
97 =head1 TO DO
98
99 Currently C<install_share> installs not only the files you want, but
100 if called by the author will also copy F<.svn> and other source-control
101 directories, and other junk.
102
103 Enhance this to copy only files under F<share> that are in the
104 F<MANIFEST>, or possibly those not in F<MANIFEST.SKIP>.
105
106 =head1 AUTHORS
107
108 Audrey Tang E<lt>autrijus@autrijus.orgE<gt>
109
110 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
111
112 =head1 SEE ALSO
113
114 L<Module::Install>, L<File::ShareDir>
115
116 =head1 COPYRIGHT
117
118 Copyright 2006 Audrey Tang, Adam Kennedy.
119
120 This program is free software; you can redistribute it and/or modify it
121 under the same terms as Perl itself.
122
123 See L<http://www.perl.com/perl/misc/Artistic.html>
124
125 =cut