my
%require
=
(
"Pod::HtmlPsPdf"
=>
"0.01"
,
);
for
(
keys
%require
) {
chk_version(
$_
=>
$require
{
$_
}) or
warn
"\n"
.
"*** For "
.__PACKAGE__.
" to work you require version $require{$_}, or later, of\n"
.
"$_.pm from CPAN\n\n"
;
}
sub
chk_version{
my
(
$pkg
,
$wanted
) =
@_
;
no
strict
'refs'
;
local
$| = 1;
print
"Checking for $pkg..."
;
eval
{ (
my
$p
=
$pkg
.
".pm"
) =~ s
print
(
"not ok\n$@"
),
return
if
$@;
my
$vstr
= ${
"${pkg}::VERSION"
} ?
"found v"
. ${
"${pkg}::VERSION"
}
:
"not found"
;
my
$vnum
= ${
"${pkg}::VERSION"
} || 0;
print
$vnum
>=
$wanted
?
"ok\n"
:
" "
.
$vstr
.
"\n"
;
$vnum
>=
$wanted
;
}
my
$target_dir
= get_target_dir();
WriteMakefile
(
NAME
=> __PACKAGE__,
VERSION_FROM
=>
'src/Version.pm'
,
AUTHOR
=>
'Stas Bekman <stas@stason.org>'
,
ABSTRACT
=>
'mod_perl Guide'
,
clean
=> {
FILES
=>
'ps_html rel_html'
},
dist
=> {
PREOP
=>
'pod2text mod_perl_guide.pm > README'
,
COMPRESS
=>
'gzip -9f'
,
SUFFIX
=>
'.gz'
,
DIST_DEFAULT
=>
'tardist'
,
},
);
sub
MY::manifypods{
return
<<END;
SRC_DIR = $FindBin::Bin
manifypods :
\$(SRC_DIR)/bin/build -m
\@echo
\@echo "The Guide was built in \$(SRC_DIR)/rel_html"
END
}
sub
MY::install{
return
<<END;
TARGET_DIR = $target_dir
SRC_DIR = $FindBin::Bin
install : manifypods
\@cp -r \$(SRC_DIR)/rel_html/* \$(TARGET_DIR)
\@echo "The Guide was installed in \$(TARGET_DIR)"
END
}
sub
MY::top_targets {
my
(
$inherited
) =
shift
->SUPER::top_targets(
@_
);
$inherited
=~ s/pure_all ::.*/pure_all ::/;
$inherited
;
}
sub
Prompt{
my
(
$prompt
,
$def
) =
@_
;
$def
=
""
unless
defined
$def
;
chomp
(
$prompt
);
prompt(
$prompt
,
$def
);
}
sub
get_target_dir{
my
@try_dirs
=
qw(/home/httpd/docs /home/httpd/html /home/httpd/htdocs
/home/www/docs /home/www/html /home/www/htdocs )
;
my
$suggest_dir
=
"/home/httpd/docs"
;
for
(
@try_dirs
) {
$suggest_dir
=
$_
,
last
if
-e
$_
;
}
my
$target_dir
=
''
;
TARGET_DIR {
print
<<END;
The guide is a collection of HTML files intended to be installed under
your webserver's DocRoot directory. This will allow you to browse the
files through you favorite Netscape browser.
END
my
$prompt
=
"Enter the directory to install the html files :"
;
my
$def
=
"$suggest_dir/manual/mod_perl_guide"
;
$target_dir
= Prompt(
$prompt
,
$def
);
unless
(-d
$target_dir
and -w _) {
my
$prompt
=
"Directory $target_dir doesn't exist. Create it? (y/n) :"
;
my
$def
=
"y"
;
my
$answer
= Prompt(
$prompt
,
$def
);
if
(
$answer
=~ /^(y|yes)/i){
eval
{
system
"mkdir -p $target_dir"
;};
print
(
"Error: $@\n"
),
redo
TARGET_DIR
if
$@;
}
else
{
redo
TARGET_DIR;
}
}
}
return
$target_dir
;
}