Use Emacs' stdout to avoid catching load messages.
[sepia.git] / Makefile.PL
blobb00bc3ab01e46dc6881f922384ba1eba088ea25b
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 '(dolist (x load-path) (princ x) (terpri))' 2>/dev/null`;
39 chomp @lp;
40 for (@lp) {
41     if (/site-lisp$/ && -d $_) {
42         $site_lisp = $_;
43         last;
44     }
46 $site_lisp = prompt("Elisp install directory?", $site_lisp);
47 if (-d $site_lisp) {
48     $install_el = 1;
49 } else {
50     warn "$site_lisp is not a directory.\n";
53 $site_lisp = quotemeta $site_lisp;
55 # Also try to install texinfo documentation.
56 $install_info = quotemeta prompt("install-info program?", 'install-info');
57 $info_dir = `$emacs --batch --eval '(progn (require (quote info)) (princ (car Info-default-directory-list)))' 2>/dev/null`;
58 chomp $info_dir;
59 $info_dir = prompt("Info directory?", $info_dir);
60 if (!-d $info_dir) {
61     warn "Not installing info files.\n";
62     undef $install_info;
65 $info_dir = quotemeta $info_dir;
67 sub MY::postamble
69     my $ret;
70     if ($install_info) {
71         $ret = <<EOS;
72         \$(CP) sepia.info $info_dir
73         $install_info $info_dir/sepia.info $info_dir/dir
74 EOS
75     }
76     if ($install_el) {
77         $ret .= <<EOS;
78 install ::
79         \@echo Compiling Elisp files.
80         $emacs -L '$ENV{PWD}' --batch -f batch-byte-compile *.el 2>/dev/null
81         \$(CP) *.el *.elc $site_lisp
82 EOS
83     } else {
84         print <<EOS;
85 NOTE:
86     To actually use this package, you need to move the Emacs Lisp files
87     somewhere Emacs will find them.
89     You may also want to install the HTML documentation somewhere
90     appropriate to your system.
91 EOS
92     }
93     $ret;
96 WriteMakefile(
97     'NAME'              => 'Sepia',
98     'VERSION_FROM'      => 'lib/Sepia.pm', # finds $VERSION
99     'PREREQ_PM'         => \%prereq,
100     AUTHOR     => "Sean O'Rourke <seano\@cpan.org>",
101     ABSTRACT => 'Simple Emacs-Perl InterAction',