[Module::Build] How do I make a Build.PL to install a web app?
Status: Beta
Brought to you by:
kwilliams
|
From: Stephen A. <spa...@gm...> - 2006-04-14 01:29:24
|
Hi,
I want to have a Build.PL which installs more than just scripts and modules=
.
I have a web application, and I want to install "cgi-bin" programs,
lots of files
under "htdocs" (html, css, js, jpg, png, gif), and various files under "sha=
re".
How can I do this? (See examples below.)
Is the "install_extra_dirs" option a good enhancement? (see below)
I have a way to do this (barely) with MakeMaker, and if I can't figure out =
how
to do this with Module::Build, I will have to go back to Makefile.PL in som=
e
of my distributions.
Stephen
#########################################################
# Build.PL (with desired features)
#########################################################
use Module::Build;
my $build =3D Module::Build->new (
dist_name =3D> "Foo-WebApp",
dist_version_from =3D> "lib/Foo/WebApp.pm",
dist_author =3D> "sadkins\@therubicongroup.com",
dist_abstract =3D> "A hot Web App",
license =3D> "perl",
# this is the desired new option.
# it would install the directories and all files from the distribution
# directory to the "install_base" directory.
# i.e. "./htdocs" gets copied to "/usr/local/htdocs".
# meanwhile, shebang substitution also takes place.
install_extra_dirs =3D> [ "bin", "cgi-bin", "htdocs", "share" ],
);
$build->create_build_script;
#########################################################
# Makefile.PL (which basically does the job)
#########################################################
######################################################################
## File: $Id: Makefile.PL,v 1.2 2005/04/13 17:53:58 spadkins Exp $
######################################################################
use ExtUtils::MakeMaker;
my @programs =3D <bin/[a-z]*>;
WriteMakefile(
'NAME' =3D> 'Foo-WebApp',
'DISTNAME' =3D> 'Foo-WebApp',
'VERSION_FROM' =3D> 'lib/Foo/WebApp.pm',
'EXE_FILES' =3D> [ @programs ],
);
# Note: The PREFIX variable must be set at "make" time.
sub MY::postamble {
return <<EOF;
install ::
@\$(MOD_INSTALL) htdocs \$(PREFIX)/htdocs
@\$(MOD_INSTALL) cgi-bin \$(PREFIX)/cgi-bin
@\$(MOD_INSTALL) share \$(PREFIX)/share
\$(PERL) -e "mkdir('\$(PREFIX)/log') if (! -d '\$(PREFIX)/log');"
EOF
}
|