/[Apache-SVN]/httpd/apreq/branches/1.x/Makefile.PL
ViewVC logotype

Contents of /httpd/apreq/branches/1.x/Makefile.PL

Parent Directory Parent Directory | Revision Log Revision Log


Revision 169403 - (show annotations) (download)
Tue May 10 03:10:43 2005 UTC (19 years, 3 months ago) by stas
File MIME type: text/plain
File size: 5730 byte(s)
move the mod_perl version detection to the top of Makefile.PL, so
Apache-Test and other things won't fool around with %INC and confuse
the detection code.

1 use ExtUtils::MakeMaker;
2 use strict;
3 use FindBin;
4 use 5.005;
5
6 BEGIN {
7 unless (eval {require mod_perl}) {
8 die "Please install mod_perl: 1.25 < version < 1.99\n($@)";
9 }
10 my $file = $INC{"mod_perl.pm"};
11 my $have = "Found $file: version $mod_perl::VERSION";
12 if ($mod_perl::VERSION < 1.2402) {
13 die "$have\nPlease upgrade mod_perl to 1.24_02 or greater";
14 }
15 elsif ($mod_perl::VERSION > 1.98) {
16 die "$have\nmod_perl 1.x ( < 1.99) is required";
17 }
18 }
19
20 use File::Path qw(mkpath);
21 use lib qw(Apache-Test/lib);
22
23 use constant MIN_A_T_VERSION => 1.13;
24
25 use constant HAS_APACHE_TEST => eval {
26 require Apache::Test &&
27 $Apache::Test::VERSION >= MIN_A_T_VERSION;
28 };
29
30 use constant WIN32 => ($^O eq "MSWin32") || $ENV{WIN32_TEST};
31 if (WIN32) {
32 win32_setup() unless ($ENV{APACHE} || grep /^-httpd$/, @ARGV);
33 }
34
35 # enable 'make test|clean'
36 if (HAS_APACHE_TEST) {
37 require Apache::TestMM;
38 Apache::TestMM->import(qw(test clean));
39 }
40
41 my $conf_data = join '', <DATA>;
42 $conf_data =~ s|(blib/arch)|$FindBin::Bin/$1|;
43
44 if (HAS_APACHE_TEST) {
45 # accept the configs from command line
46 Apache::TestMM::filter_args();
47 Apache::TestMM::generate_script('t/TEST');
48 }
49 else {
50 print "\nskipping test setup... which requires Apache::Test " .
51 MIN_A_T_VERSION . " or higher\n";
52 *MY::test = sub {
53 return <<'EOF';
54 test : pure_all
55 @echo \*** This test suite requires Apache::Test available
56 @echo \*** available from CPAN
57
58 EOF
59 };
60 }
61
62 # prerequisites
63 my %require = (
64 "Apache::Test" => MIN_A_T_VERSION,
65 );
66
67 my $myVERSION = MM->parse_version('Request/Request.pm');
68 $myVERSION =~ s/(\d\d)(\d\d)$/$1_$2/;
69 my $lib;
70 check_compat();
71
72 if (WIN32) {
73 require Cwd;
74 my $cwd = Cwd::cwd();
75 $cwd =~ s#\\#/#g;
76
77 my $root = "$cwd/blib/arch/auto";
78 mkpath $root, 1, 0755 unless -d $root;
79 mkpath "$root/libapreq", 1, 0755 unless -d "$root/libapreq";
80 $lib = "$root/libapreq/libapreq.lib";
81
82 open (FILE, ">>$lib")
83 or die "Cannot touch $lib: $!\n";
84 close FILE;
85
86 require Apache::MyConfig;
87 $ENV{APREQ_LIB} = "$root/libapreq";
88 $ENV{AP_INC} = $Apache::MyConfig::Setup{APACHE_INC};
89 $ENV{MP_INC} = $Apache::MyConfig::Setup{MODPERL_INC};
90 $ENV{AP_LIB} = $Apache::MyConfig::Setup{APACHE_LIB};
91 $ENV{MP_LIB} = $Apache::MyConfig::Setup{MODPERL_LIB};
92
93 unless (-f "$ENV{MP_LIB}/mod_perl.so") {
94 die "Cannot find mod_perl.so in $ENV{MP_LIB}. " .
95 "Please build mod_perl first";
96 }
97
98 unless (-f "$ENV{AP_LIB}/ApacheCore.lib") {
99 die "Cannot find ApacheCore.lib in $ENV{AP_LIB}. " .
100 "Please build apache first.";
101 }
102 }
103
104 WriteMakefile(
105 NAME => 'libapreq',
106 VERSION => $myVERSION,
107 DIR => [qw(c Request Cookie)],
108 PREREQ_PM => \%require,
109 clean => {
110 FILES => "@{ clean_files() }",
111 },
112 );
113
114 sub clean_files {
115 return [qw( t/TEST )];
116 }
117
118 if (WIN32 and -e $lib) {
119 unlink $lib or die "Cannot unlink $lib: $!\n";
120 }
121
122 sub check_compat {
123 eval { require Apache::Request };
124 return if $@;
125
126 my $v = $Apache::Request::VERSION;
127 return if $v >= 0.2000;
128
129 print "libapreq is not compatible with Apache::Request version $v\n";
130 my $ans = prompt("Continue?", "n");
131 if ($ans =~ /^n/i) {
132 print "Aborting.\n";
133 exit;
134 }
135 }
136
137 sub MY::pasthru {
138 my $self = shift;
139 chomp(my $str = $self->MM::pasthru);
140 join $/, "$str\\", "\t".'DEFINE="$(DEFINE)"', "";
141 }
142
143 sub MY::postamble {
144 return <<'EOF';
145
146 cvs_tag :
147 cvs tag v$(VERSION_SYM) .
148 @echo update the VERSION in Apache/Request.pm now
149
150 EOF
151 }
152
153 sub win32_setup {
154 eval{ require Win32 };
155 die "The libwin32 package is needed" if $@;
156
157 require File::Spec;
158 my $apache;
159 my $exe = 'Apache.exe';
160
161 SEARCH: {
162 my $candidate;
163 for (File::Spec->path) {
164 $candidate = File::Spec->catfile($_, $exe);
165 if (-e $candidate and check_win32_apache($candidate)) {
166 $apache = $candidate;
167 last SEARCH;
168 }
169 }
170
171 my @drives = drives();
172 last SEARCH unless (@drives > 0);
173 for my $drive (@drives) {
174 for ('Apache', 'Program Files/Apache',
175 'Program Files/Apache Group/Apache') {
176 $candidate = File::Spec->catfile($drive, $_, $exe);
177 if (-e $candidate and check_win32_apache($candidate)) {
178 $apache = $candidate;
179 last SEARCH;
180 }
181 }
182 }
183 }
184
185 unless (-e $apache) {
186 $apache = prompt("Please supply the full path to Apache.exe:",
187 $apache);
188 }
189
190 if (-d $apache) {
191 $apache = File::Spec->catfile($apache, $exe);
192 }
193 die "Can't find Apache.exe!"
194 unless (-e $apache and check_win32_apache($apache));
195
196 $apache = Win32::GetShortPathName($apache);
197 $apache =~ s!\\!/!g;
198 push @ARGV, '-httpd', $apache;
199 print qq{Using "$apache".\n};
200 }
201
202 sub check_win32_apache {
203 my $apache = shift;
204 my $vers = qx{"$apache" -v};
205 return ($vers =~ m!Apache/1.3!) ? 1 : 0;
206 }
207
208 sub drives {
209 my @drives = ();
210 eval { require Win32API::File };
211 return map {"$_:\\"} ('C' .. 'Z') if $@;
212
213 my @r = Win32API::File::getLogicalDrives();
214 return unless @r > 0;
215 for (@r) {
216 my $t = Win32API::File::GetDriveType($_);
217 push @drives, $_ if ($t == 3 or $t == 4);
218 }
219 return @drives > 0 ? @drives : undef;
220 }
221
222 __DATA__
223 <Perl>
224 unshift @INC, "blib/arch";
225 </Perl>
226 PerlModule Apache::PerlRun
227 PerlModule Apache::Request
228 PerlModule Apache::Cookie
229
230 <FilesMatch "\.pl">
231 SetHandler perl-script
232 PerlHandler Apache::PerlRun
233 Options +ExecCGI
234 </FilesMatch>
235
236
237
238
239
240
241
242
243
244
245

Properties

Name Value
svn:eol-style native

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26