1 package Module::Install::Share;
4 use Module::Install::Base ();
6 use vars qw{$VERSION @ISA $ISCORE};
9 @ISA = 'Module::Install::Base';
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'";
20 unless ( defined $dir and -d $dir ) {
21 die "Illegal or missing directory install_share param";
25 my $S = ($^O eq 'MSWin32') ? "\\" : "\/";
26 if ( $type eq 'dist' ) {
27 die "Too many parameters to install_share" if @_;
30 $self->postamble(<<"END_MAKEFILE");
32 \t\$(NOECHO) \$(MOD_INSTALL) \\
33 \t\t"$dir" \$(INST_LIB)${S}auto${S}share${S}dist${S}\$(DISTNAME)
37 my $module = Module::Install::_CLASS($_[0]);
38 unless ( defined $module ) {
39 die "Missing or invalid module name '$_[0]'";
44 $self->postamble(<<"END_MAKEFILE");
46 \t\$(NOECHO) \$(MOD_INSTALL) \\
47 \t\t"$dir" \$(INST_LIB)${S}auto${S}share${S}module${S}$module
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' );
58 # 99% of the time we don't want to index a shared dir
59 $self->no_index( directory => $dir );
70 Module::Install::Share - Install non-code files for use during run-time
74 # Put everything inside ./share/ into the distribution 'auto' path
75 install_share 'share';
77 # Same thing as above using the default directory name
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
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
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
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>.
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.
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>.
108 Audrey Tang E<lt>autrijus@autrijus.orgE<gt>
110 Adam Kennedy E<lt>adamk@cpan.orgE<gt>
114 L<Module::Install>, L<File::ShareDir>
118 Copyright 2006 Audrey Tang, Adam Kennedy.
120 This program is free software; you can redistribute it and/or modify it
121 under the same terms as Perl itself.
123 See L<http://www.perl.com/perl/misc/Artistic.html>