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