avoid "defined %hash"
[sepia.git] / Makefile.PL
blob0e231d3575f4b2155b5b8a88a1a7c00f8e541e1b
1 use ExtUtils::MakeMaker qw(WriteMakefile prompt);
2 use 5.006;                      # for "no warnings" -- sorry!
3 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
4 # the contents of the Makefile that is written.
6 my %prereq = (
7     'Data::Dumper'    => 0,
8     'Scalar::Util'    => 0,
9 );
11 ## Poor man's optional deps.
12 sub test_for
14     my $mod = shift;
15     eval "require $mod";
16     if ($@) {
17         my $resp = prompt("@_.  Install $mod (y/n)? ", 'n');
18         $prereq{$mod} = 0 if $resp =~ /^y/i;
19     }
22 test_for 'Devel::Peek', 'Printing internals requires Devel::Peek';
23 test_for 'Devel::Size', 'Printing variable sizes requires Devel::Size';
24 test_for 'IO::Scalar', 'Printing internals requires IO::Scalar because Devel::Peek sucks.';
25 test_for 'Lexical::Persistence', 'Strict mode requires Lexical::Persistence';
26 test_for 'LWP::Simple', 'CPAN documentation browsing requires LWP::Simple';
27 test_for 'Module::CoreList', 'sepia-core-version requires Module::CoreList';
28 test_for 'Module::Info', 'Required for some Emacs functions';
29 test_for 'PadWalker', 'Stack/lexical inspection requires PadWalker >= 1.0';
30 test_for 'BSD::Resource', 'Detailed command timing.';
31 test_for 'Time::HiRes', 'Basic command timing.';
32 # test_for 'Pod::Webserver', 'Pod::Webserver creates nice documentation.';
33 # test_for 'Scope::Upper', 'Required for return-from-context';
35 # try to compile and install Elisp files, but don't die if we can't.
36 $install_el = 0;
37 $emacs = quotemeta prompt("What is your emacs? ", $ENV{EMACS} || 'emacs');
38 $lp = `$emacs --batch --eval '(message "\%s" load-path)' 2>&1`;
39 $lp =~ s/^.*\(//s;
40 $lp =~ s/\).*$//s;
41 for (split ' ', $lp) {
42     if (/site-lisp$/ && -d $_) {
43         $site_lisp = $_;
44         last;
45     }
47 $site_lisp = prompt("Elisp install directory?", $site_lisp);
48 if (-d $site_lisp) {
49     $install_el = 1;
50 } else {
51     warn "$site_lisp is not a directory.\n";
54 $site_lisp = quotemeta $site_lisp;
56 # Also try to install texinfo documentation.
57 $install_info = quotemeta prompt("install-info program?", 'install-info');
58 $info_dir = `$emacs --batch --eval '(progn (require (quote info)) (message "\%s" (car Info-default-directory-list)))' 2>&1`;
59 chomp $info_dir;
60 $info_dir = prompt("Info directory?", $info_dir);
61 if (!-d $info_dir) {
62     warn "Not installing info files.\n";
63     undef $install_info;
66 $info_dir = quotemeta $info_dir;
68 sub MY::postamble
70     my $ret;
71     if ($install_info) {
72         $ret = <<EOS;
73         \$(CP) sepia.info $info_dir
74         $install_info $info_dir/sepia.info $info_dir/dir
75 EOS
76     }
77     if ($install_el) {
78         $ret .= <<EOS;
79 install ::
80         \@echo Compiling Elisp files.
81         $emacs -L '$ENV{PWD}' --batch -f batch-byte-compile *.el 2>/dev/null
82         \$(CP) *.el *.elc $site_lisp
83 EOS
84     } else {
85         print <<EOS;
86 NOTE:
87     To actually use this package, you need to move the Emacs Lisp files
88     somewhere Emacs will find them.
90     You may also want to install the HTML documentation somewhere
91     appropriate to your system.
92 EOS
93     }
94     $ret;
97 WriteMakefile(
98     'NAME'              => 'Sepia',
99     'VERSION_FROM'      => 'lib/Sepia.pm', # finds $VERSION
100     'PREREQ_PM'         => \%prereq,
101     AUTHOR     => "Sean O'Rourke <seano\@cpan.org>",
102     ABSTRACT => 'Simple Emacs-Perl InterAction',