1 |
######################### -*- Mode: Perl -*- ######################### |
2 |
## |
3 |
## $Basename: Makefile.PL $ |
4 |
## $Revision: 1.13 $ |
5 |
## |
6 |
## Author : Ulrich Pfeifer |
7 |
## Created On : Tue Aug 20 12:15:44 1996 |
8 |
## |
9 |
## Last Modified By : Ulrich Pfeifer |
10 |
## Last Modified On : Fri Dec 29 14:14:54 2000 |
11 |
## |
12 |
## Copyright (c) 1996-1997, Ulrich Pfeifer |
13 |
## |
14 |
###################################################################### |
15 |
|
16 |
use strict; |
17 |
|
18 |
use Config; |
19 |
use ExtUtils::MakeMaker qw(:DEFAULT neatvalue); |
20 |
use File::Path; |
21 |
use Getopt::Long; |
22 |
|
23 |
&check_perl(5.00307); # need pack 'w', ... |
24 |
|
25 |
my %OPT = (default => 0); |
26 |
GetOptions(\%OPT, 'default!'); |
27 |
|
28 |
&init($OPT{default}); |
29 |
|
30 |
my @pl_files = glob('script/*'); |
31 |
|
32 |
my %seen; |
33 |
my @objects = grep { s![^.]+$!o!; !$seen{$_}++ } glob('*.[cx]*'); |
34 |
|
35 |
WriteMakefile( |
36 |
'PREREQ_PM' => {'Term::ReadLine' => 0, |
37 |
'DB_File' => 1.03, |
38 |
'Data::Dumper' => 2.02, |
39 |
'Pod::Text' => 1.02, |
40 |
'HTML::Entities' => 0, |
41 |
'LockFile::Simple' => 0, |
42 |
}, |
43 |
'NAME' => 'WAIT', |
44 |
'OBJECT' => join(' ', @objects), |
45 |
'VERSION_FROM' => 'lib/WAIT.pm', |
46 |
'EXE_FILES' => \@pl_files, |
47 |
'dist' => { |
48 |
PREOP => 'cp README.header README && pod2text lib/WAIT.pm >> README', |
49 |
SUFFIX => 'gz', |
50 |
COMPRESS => 'gzip -9f', |
51 |
}, |
52 |
); |
53 |
|
54 |
|
55 |
## ################################################################### |
56 |
## subs |
57 |
## ################################################################### |
58 |
|
59 |
sub MY::postamble |
60 |
{ |
61 |
q[ |
62 |
lib/WAIT/Query/Wais.pm: waisquery.y |
63 |
byacc -P -l waisquery.y; |
64 |
sed -n '2,$$ p' y.tab.pl | ]. "$Config{cpp} $Config{cppminus}" . |
65 |
q[ | sed -e '/^# [0-9]/ d' > $@ && rm -f y.tab.pl |
66 |
|
67 |
TAGS: MANIFEST |
68 |
etags `].$^X.q[ -ane 'print "$$F[0]\n"' MANIFEST` |
69 |
] |
70 |
} |
71 |
|
72 |
|
73 |
sub init |
74 |
{ |
75 |
my $use_defaults = shift; |
76 |
|
77 |
$WAIT::Config = {}; |
78 |
eval { require WAIT::Config; }; |
79 |
|
80 |
my $answer; |
81 |
|
82 |
|
83 |
## WAIT database directory |
84 |
print <<"EOF"; |
85 |
The WAIT module needs a directory of its own to store the databases. |
86 |
This may be a site-wide directory or a personal directory. |
87 |
EOF |
88 |
; |
89 |
|
90 |
$answer = $WAIT::Config->{WAIT_home}; |
91 |
$answer = '' unless $answer && -d $answer; |
92 |
$answer = prompt("WAIT database directory?", $answer) unless $use_defaults; |
93 |
|
94 |
#mkpath($answer) unless $answer && -d $answer; # dies if it can't |
95 |
$WAIT::Config->{WAIT_home} = $answer; |
96 |
|
97 |
|
98 |
## get manual pages |
99 |
my $help = q{ |
100 |
|
101 |
Now you need to tell me which manual directories you want to index. |
102 |
If you want to enter a path, just type it in. To select a path type |
103 |
'+' an the number. To deselect type '-' an the number. Enter 'q' if |
104 |
you are finished. |
105 |
|
106 |
}; |
107 |
my %seen; |
108 |
my @manpath = @{$WAIT::Config->{manpath} || |
109 |
[grep (-d $_, split(':', $ENV{MANPATH}), |
110 |
'/usr/man', |
111 |
'/usr/local/man')]}; |
112 |
|
113 |
@manpath = grep !$seen{$_}++, @manpath; |
114 |
my %select; @select{0 .. @manpath} = ('+') x @manpath; |
115 |
|
116 |
for (split(':', $ENV{MANPATH}), '/usr/man', '/usr/local/man') { |
117 |
next unless -d $_; |
118 |
next if $seen{$_}; |
119 |
$select{@manpath} = '-'; |
120 |
push @manpath, $_; |
121 |
} |
122 |
|
123 |
print $help; |
124 |
while (! $use_defaults) { |
125 |
my $i; |
126 |
for $i (0 .. $#manpath) { |
127 |
printf "%2d %c %s\n", $i, ord($select{$i}), $manpath[$i]; |
128 |
} |
129 |
$answer = prompt("path|[+-]number|q>"); |
130 |
if ($answer eq 'q') { |
131 |
last; |
132 |
} elsif ($answer =~ /^(\+|\-)\s*(\d+)?$/) { |
133 |
if (defined $2) { |
134 |
if (0 <= $2 and $2 <= $#manpath) { |
135 |
$select{$2} = $1; |
136 |
} |
137 |
else { |
138 |
print $help; |
139 |
} |
140 |
} else { |
141 |
for (keys %select) { |
142 |
$select{$_} = $1; |
143 |
} |
144 |
} |
145 |
} elsif (-d $answer) { |
146 |
push @manpath, $answer; |
147 |
$select{$#manpath} = '+'; |
148 |
} else { |
149 |
print "Directory '$answer' does not seem to exists?\n"; |
150 |
print $help; |
151 |
} |
152 |
} |
153 |
$WAIT::Config->{manpath} = []; |
154 |
my $i; |
155 |
foreach $i (0 .. $#manpath) { |
156 |
if ($select{$i} eq '+') { |
157 |
push @{$WAIT::Config->{manpath}}, $manpath[$i]; |
158 |
} |
159 |
} |
160 |
|
161 |
|
162 |
## pager |
163 |
print "\nWhat pager do you want to use?\n"; |
164 |
print "Your perl administrator recommends '$Config{pager}'\n"; |
165 |
print "We would prefer 'less', if you have that installed\n" |
166 |
unless $Config{pager} =~ /less/; |
167 |
|
168 |
$answer = $WAIT::Config->{pager} || $Config{pager} || 'less'; |
169 |
$answer = prompt("pager?", $answer) unless $use_defaults; |
170 |
$WAIT::Config->{pager} = $answer; |
171 |
|
172 |
|
173 |
## write config |
174 |
my $configpmdir = MM->catdir('lib', 'WAIT'); |
175 |
mkpath $configpmdir; |
176 |
my $configpm = MM->catfile('lib', 'WAIT', 'Config.pm/' ); |
177 |
|
178 |
open FH, "> $configpm" or die "Couldn't write open $configpm: $!\n"; |
179 |
print FH qq[\$WAIT::Config = \{\n]; |
180 |
foreach (sort keys %$WAIT::Config) { |
181 |
print FH " '$_' => ", neatvalue($WAIT::Config->{$_}), ",\n"; |
182 |
} |
183 |
|
184 |
print FH "};\n1;\n"; |
185 |
} |
186 |
|
187 |
|
188 |
sub check_perl |
189 |
{ |
190 |
my $perlversion = shift; |
191 |
|
192 |
if ($] < $perlversion) { |
193 |
print <<"EOF"; |
194 |
Your Perl version is less than $perlversion. Please install a Perl with version |
195 |
$perlversion or higher. Get it from CPAN: http://www.perl.org/CPAN/ |
196 |
EOF |
197 |
; |
198 |
die "\n"; |
199 |
} |
200 |
else { |
201 |
print "Your perl has version $] (higher than $perlversion). Ok!\n"; |
202 |
} |
203 |
} |
204 |
|