1use ExtUtils::MakeMaker;
2
3# See lib/ExtUtils/MakeMaker.pm for details of how to influence
4# the contents of the Makefile that is written.
5
6use vars qw($real);
7
8sub modcheck () {
9    # check to see if our template modules are present, as they're optional
10    my($failed, $ok) = ('','');
11    print "\nDoing FormBuilder pre-req checks...\n\n";
12    for ('HTML::Template     2.06  (for CGI::FormBuilder::Template::HTML)',
13         'Text::Template     1.43  (for CGI::FormBuilder::Template::Text)',
14         'Template           2.08  (for CGI::FormBuilder::Template::TT2)',
15         'CGI::FastTemplate  1.09  (for CGI::FormBuilder::Template::Fast)',
16         'CGI::SSI           0.92  (for CGI::FormBuilder::Template::CGI_SSI)',
17         'CGI::Session       3.95   (for CGI::FormBuilder::Multi)'
18    ) {
19        my($mod,$ver) = split;
20        eval "use $mod $ver";
21        if ($@) {
22            my($err) = split / at | \(/, $@;
23            $failed .= sprintf "    %-18s $ver  (%s)\n", $mod, $err;
24        } else {
25            eval "require $mod; \$real = \$$mod\::VERSION";
26            (my $t = $_) =~ s/\d+\.\d+/sprintf "%-4s", $real/e;
27            $ok .= "    $t\n";
28        }
29    }
30    if ($ok) {
31        print <<EOP;
32Cool, I found the following plug-in modules ok:
33
34$ok
35EOP
36    }
37    if ($failed) {
38        print <<EOW;
39Warning: The following *OPTIONAL* modules are NOT installed:
40
41$failed
42FormBuilder will still work just fine, a-ok, no problem... unless you
43want to use one of these modules for templates. You can always install
44them later, FormBuilder will run without them.
45
46EOW
47        if ($ENV{STRICT_FB_TESTS}) {
48            die "Fatal: Missing optional module(s) and FormBuilder STRICT_FB_TESTS is set\n";
49        }
50        sleep 2;
51    }
52    return {};      # hashref is expected by MakeMaker
53}
54
55WriteMakefile(
56    NAME           => 'CGI::FormBuilder',
57    VERSION_FROM   => 'lib/CGI/FormBuilder/Util.pm',     # finds $VERSION
58    PREREQ_PM      => { CGI => 0 },
59    CONFIGURE      => \&modcheck,
60    ($] >= 5.005 ?
61      (ABSTRACT_FROM => 'lib/CGI/FormBuilder.pod',  # abstract from POD
62       AUTHOR        => 'Nate Wiger (nate@wiger.org)') : ()
63    ),
64);
65