This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Typo fixes from Robin Houston in
[perl5.git] / ext / Time / HiRes / Makefile.PL
CommitLineData
56c1b3bd
RGS
1#!/usr/bin/perl
2#
3# In general we trust %Config, but for nanosleep() this trust
3d0346a5 4# may be misplaced (it may be linkable but not really functional).
56c1b3bd
RGS
5# Use $ENV{FORCE_NANOSLEEP_SCAN} to force rescanning whether there
6# really is hope.
7
3f2ee006
HS
8require 5.002;
9
10use Config;
dcf686c9 11use ExtUtils::MakeMaker;
98b50af3 12use strict;
3f2ee006
HS
13
14my $VERBOSE = $ENV{VERBOSE};
98b50af3 15my $DEFINE;
046e3f33 16my $LIBS = [];
56c1b3bd 17my $XSOPT = '';
ced84e60 18my $SYSCALL_H;
98b50af3 19
046e3f33
JH
20use vars qw($self); # Used in 'sourcing' the hints.
21
4ed0e2d4
RGS
22my $ld_exeext = ($^O eq 'cygwin' ||
23 $^O eq 'os2' && $Config{ldflags} =~ /-Zexe\b/) ? '.exe' : '';
622913ab 24
12724655
IZ
25unless($ENV{PERL_CORE}) {
26 $ENV{PERL_CORE} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
98b50af3
JH
27}
28
29# Perls 5.002 and 5.003 did not have File::Spec, fake what we need.
3f2ee006
HS
30
31sub my_dirsep {
32 $^O eq 'VMS' ? '.' :
33 $^O =~ /mswin32|netware|djgpp/i ? '\\' :
34 $^O eq 'MacOS' ? ':'
35 : '/';
36}
37
38sub my_catdir {
39 shift;
40 my $catdir = join(my_dirsep, @_);
98b50af3
JH
41 $^O eq 'VMS' ? "[$catdir]" : $catdir;
42}
43
44sub my_catfile {
45 shift;
46 return join(my_dirsep, @_) unless $^O eq 'VMS';
47 my $file = pop;
48 return my_catdir (undef, @_) . $file;
3f2ee006
HS
49}
50
51sub my_updir {
52 shift;
53 $^O eq 'VMS' ? "-" : "..";
54}
55
56BEGIN {
57 eval { require File::Spec };
58 if ($@) {
25ca0970
JH
59 *File::Spec::catdir = \&my_catdir;
60 *File::Spec::updir = \&my_updir;
98b50af3 61 *File::Spec::catfile = \&my_catfile;
3f2ee006
HS
62 }
63}
64
98b50af3
JH
65# Avoid 'used only once' warnings.
66my $nop1 = *File::Spec::catdir;
67my $nop2 = *File::Spec::updir;
68my $nop3 = *File::Spec::catfile;
69
3f2ee006
HS
70# if you have 5.004_03 (and some slightly older versions?), xsubpp
71# tries to generate line numbers in the C code generated from the .xs.
72# unfortunately, it is a little buggy around #ifdef'd code.
5d899d7e 73# my choice is leave it in and have people with old perls complain
3f2ee006 74# about the "Usage" bug, or leave it out and be unable to compile myself
5d899d7e 75# without changing it, and then I'd always forget to change it before a
3f2ee006
HS
76# release. Sorry, Edward :)
77
3f2ee006
HS
78sub try_compile_and_link {
79 my ($c, %args) = @_;
80
81 my ($ok) = 0;
2359510d 82 my ($tmp) = "tmp$$";
3f2ee006
HS
83 local(*TMPC);
84
85 my $obj_ext = $Config{obj_ext} || ".o";
86 unlink("$tmp.c", "$tmp$obj_ext");
87
88 if (open(TMPC, ">$tmp.c")) {
89 print TMPC $c;
90 close(TMPC);
91
98b50af3 92 my $cccmd = $args{cccmd};
3f2ee006
HS
93
94 my $errornull;
95
96 my $COREincdir;
98b50af3 97
3f2ee006
HS
98 if ($ENV{PERL_CORE}) {
99 my $updir = File::Spec->updir;
100 $COREincdir = File::Spec->catdir(($updir) x 3);
101 } else {
102 $COREincdir = File::Spec->catdir($Config{'archlibexp'}, 'CORE');
103 }
98b50af3 104
3f2ee006 105 my $ccflags = $Config{'ccflags'} . ' ' . "-I$COREincdir";
98b50af3 106
3f2ee006
HS
107 if ($^O eq 'VMS') {
108 if ($ENV{PERL_CORE}) {
3d036c2b 109 # Fragile if the extensions change hierarchy within
6a20eacc
HS
110 # the Perl core but this should do for now.
111 $cccmd = "$Config{'cc'} /include=([---]) $tmp.c";
3f2ee006
HS
112 } else {
113 my $perl_core = $Config{'installarchlib'};
114 $perl_core =~ s/\]$/.CORE]/;
98b50af3 115 $cccmd = "$Config{'cc'} /include=(perl_root:[000000],$perl_core) $tmp.c";
3f2ee006
HS
116 }
117 }
118
119 if ($args{silent} || !$VERBOSE) {
120 $errornull = "2>/dev/null" unless defined $errornull;
121 } else {
122 $errornull = '';
123 }
124
98b50af3 125 $cccmd = "$Config{'cc'} -o $tmp $ccflags $tmp.c @$LIBS $errornull"
3f2ee006 126 unless defined $cccmd;
98b50af3 127
c1363767 128 if ($^O eq 'VMS') {
3f2ee006
HS
129 open( CMDFILE, ">$tmp.com" );
130 print CMDFILE "\$ SET MESSAGE/NOFACILITY/NOSEVERITY/NOIDENT/NOTEXT\n";
131 print CMDFILE "\$ $cccmd\n";
98b50af3 132 print CMDFILE "\$ IF \$SEVERITY .NE. 1 THEN EXIT 44\n"; # escalate
3f2ee006
HS
133 close CMDFILE;
134 system("\@ $tmp.com");
135 $ok = $?==0;
5d899d7e 136 for ("$tmp.c", "$tmp$obj_ext", "$tmp.com", "$tmp$Config{exe_ext}") {
98b50af3 137 1 while unlink $_;
3f2ee006
HS
138 }
139 }
140 else
141 {
622913ab 142 my $tmp_exe = "$tmp$ld_exeext";
3f2ee006 143 printf "cccmd = $cccmd\n" if $VERBOSE;
622913ab 144 my $res = system($cccmd);
ced84e60 145 $ok = defined($res) && $res == 0 && -s $tmp_exe && -x _;
26e22fd9
RGS
146
147 if ( $ok && exists $args{run} && $args{run}) {
06252d99
RGS
148 my $tmp_exe =
149 File::Spec->catfile(File::Spec->curdir, $tmp_exe);
150 printf "Running $tmp_exe..." if $VERBOSE;
151 if (system($tmp_exe) == 0) {
56c1b3bd 152 $ok = 1;
26e22fd9 153 } else {
56c1b3bd 154 $ok = 0;
ced84e60
SP
155 my $errno = $? >> 8;
156 local $! = $errno;
157 printf <<EOF;
158
159*** The test run of '$tmp_exe' failed: status $?
160*** (the status means: errno = $errno or '$!')
161*** DO NOT PANIC: this just means that *some* functionality will be missing.
162EOF
26e22fd9
RGS
163 }
164 }
622913ab 165 unlink("$tmp.c", $tmp_exe);
3f2ee006
HS
166 }
167 }
5d899d7e 168
26e22fd9 169 return $ok;
3f2ee006
HS
170}
171
172sub has_gettimeofday {
173 # confusing but true (if condition true ==> -DHAS_GETTIMEOFDAY already)
56c1b3bd 174 return 0 if $Config{d_gettimeod};
98b50af3 175 return 1 if try_compile_and_link(<<EOM);
5d899d7e
JH
176#include "EXTERN.h"
177#include "perl.h"
178#include "XSUB.h"
179#ifdef I_SYS_TYPES
3f2ee006
HS
180# include <sys/types.h>
181#endif
182
183#ifdef I_SYS_TIME
184# include <sys/time.h>
185#endif
186
187#ifdef I_SYS_SELECT
188# include <sys/select.h> /* struct timeval might be hidden in here */
189#endif
190static int foo()
191{
192 struct timeval tv;
193 gettimeofday(&tv, 0);
194}
195int main _((int argc, char** argv, char** env))
196{
197 foo();
198}
199EOM
200 return 0;
201}
202
203sub has_x {
98b50af3 204 my ($x, %args) = @_;
3f2ee006
HS
205
206 return 1 if
207 try_compile_and_link(<<EOM, %args);
208#include "EXTERN.h"
209#include "perl.h"
210#include "XSUB.h"
211
212#ifdef I_UNISTD
213# include <unistd.h>
214#endif
215
216#ifdef I_SYS_TYPES
217# include <sys/types.h>
218#endif
219
220#ifdef I_SYS_TIME
221# include <sys/time.h>
222#endif
223
224int main _((int argc, char** argv, char** env))
225{
226 $x;
227}
228EOM
229 return 0;
230}
231
26e22fd9 232sub has_nanosleep {
3d0346a5 233 print "testing... ";
26e22fd9
RGS
234 return 1 if
235 try_compile_and_link(<<EOM, run => 1);
236#include <time.h>
237#include <sys/time.h>
238#include <stdio.h>
239#include <stdlib.h>
240#include <errno.h>
241
242/* int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); */
243
244int main() {
245 struct timespec ts1, ts2;
56c1b3bd 246 int ret;
26e22fd9
RGS
247 ts1.tv_sec = 0;
248 ts1.tv_nsec = 750000000;
249 ts2.tv_sec = 0;
250 ts2.tv_nsec = 0;
56c1b3bd 251 errno = 0;
ced84e60 252 ret = nanosleep(&ts1, &ts2); /* E.g. in AIX nanosleep() fails and sets errno to ENOSYS. */
56c1b3bd 253 ret == 0 ? exit(0) : exit(errno ? errno : -1);
26e22fd9
RGS
254}
255EOM
256}
257
4ed0e2d4
RGS
258sub has_include {
259 my ($inc) = @_;
260 return 1 if
261 try_compile_and_link(<<EOM);
262#include "EXTERN.h"
263#include "perl.h"
264#include "XSUB.h"
265
266#include <$inc>
267int main _((int argc, char** argv, char** env))
268{
269 return 0;
270}
271EOM
272 return 0;
273}
274
ced84e60
SP
275sub has_clock_x_syscall {
276 my $x = shift;
277 return 0 unless defined $SYSCALL_H;
278 return 1 if
279 try_compile_and_link(<<EOM, run => 1);
280#include "EXTERN.h"
281#include "perl.h"
282#include "XSUB.h"
283#include <$SYSCALL_H>
284int main _((int argc, char** argv, char** env))
285{
286 struct timespec ts;
287 /* Many Linuxes get ENOSYS even though the syscall exists. */
288 /* All implementations are supposed to support CLOCK_REALTIME. */
289 int ret = syscall(SYS_clock_$x, CLOCK_REALTIME, &ts);
290 ret == 0 ? exit(0) : exit(errno ? errno : -1);
291}
292EOM
293}
294
295sub has_clock_x {
296 my $x = shift;
297 return 1 if
298 try_compile_and_link(<<EOM, run => 1);
299#include "EXTERN.h"
300#include "perl.h"
301#include "XSUB.h"
302int main _((int argc, char** argv, char** env))
303{
304 struct timespec ts;
305 int ret = clock_$x(CLOCK_REALTIME, &ts); /* Many Linuxes get ENOSYS. */
306 /* All implementations are supposed to support CLOCK_REALTIME. */
307 ret == 0 ? exit(0) : exit(errno ? errno : -1);
308}
309EOM
310}
311
046e3f33
JH
312sub init {
313 my $hints = File::Spec->catfile("hints", "$^O.pl");
314 if (-f $hints) {
315 print "Using hints $hints...\n";
316 local $self;
317 do $hints;
318 if (exists $self->{LIBS}) {
319 $LIBS = $self->{LIBS};
320 print "Extra libraries: @$LIBS...\n";
3f2ee006
HS
321 }
322 }
046e3f33
JH
323
324 $DEFINE = '';
3f2ee006 325
ced84e60 326 if ($Config{d_syscall}) {
a5929ff3 327 print "Have syscall()... looking for syscall.h... ";
ced84e60
SP
328 if (has_include('syscall.h')) {
329 $SYSCALL_H = 'syscall.h';
330 } elsif (has_include('sys/syscall.h')) {
331 $SYSCALL_H = 'sys/syscall.h';
332 }
a5929ff3
RGS
333 } else {
334 print "No syscall()...\n";
ced84e60
SP
335 }
336
a5929ff3
RGS
337 if ($Config{d_syscall}) {
338 if (defined $SYSCALL_H) {
339 print "found <$SYSCALL_H>.\n";
340 } else {
341 print "NOT found.\n";
342 }
ced84e60
SP
343 }
344
98b50af3 345 print "Looking for gettimeofday()... ";
3f2ee006 346 my $has_gettimeofday;
5d899d7e
JH
347 if (exists $Config{d_gettimeod}) {
348 $has_gettimeofday++ if $Config{d_gettimeod};
3f2ee006
HS
349 } elsif (has_gettimeofday()) {
350 $DEFINE .= ' -DHAS_GETTIMEOFDAY';
351 $has_gettimeofday++;
352 }
353
354 if ($has_gettimeofday) {
98b50af3 355 print "found.\n";
3f2ee006
HS
356 } else {
357 die <<EOD
358Your operating system does not seem to have the gettimeofday() function.
359(or, at least, I cannot find it)
360
361There is no way Time::HiRes is going to work.
362
363I am awfully sorry but I cannot go further.
364
365Aborting configuration.
366
367EOD
368 }
369
98b50af3 370 print "Looking for setitimer()... ";
3f2ee006 371 my $has_setitimer;
5d899d7e
JH
372 if (exists $Config{d_setitimer}) {
373 $has_setitimer++ if $Config{d_setitimer};
3f2ee006
HS
374 } elsif (has_x("setitimer(ITIMER_REAL, 0, 0)")) {
375 $has_setitimer++;
376 $DEFINE .= ' -DHAS_SETITIMER';
377 }
378
379 if ($has_setitimer) {
98b50af3 380 print "found.\n";
3f2ee006 381 } else {
98b50af3 382 print "NOT found.\n";
3f2ee006
HS
383 }
384
98b50af3 385 print "Looking for getitimer()... ";
3f2ee006 386 my $has_getitimer;
5d899d7e
JH
387 if (exists $Config{'d_getitimer'}) {
388 $has_getitimer++ if $Config{'d_getitimer'};
3f2ee006
HS
389 } elsif (has_x("getitimer(ITIMER_REAL, 0)")) {
390 $has_getitimer++;
391 $DEFINE .= ' -DHAS_GETITIMER';
392 }
393
394 if ($has_getitimer) {
98b50af3 395 print "found.\n";
3f2ee006 396 } else {
98b50af3 397 print "NOT found.\n";
3f2ee006
HS
398 }
399
400 if ($has_setitimer && $has_getitimer) {
4ed0e2d4 401 print "You have interval timers (both setitimer and getitimer).\n";
3f2ee006 402 } else {
98b50af3 403 print "You do not have interval timers.\n";
3f2ee006
HS
404 }
405
98b50af3
JH
406 print "Looking for ualarm()... ";
407 my $has_ualarm;
5d899d7e
JH
408 if (exists $Config{d_ualarm}) {
409 $has_ualarm++ if $Config{d_ualarm};
3f2ee006
HS
410 } elsif (has_x ("ualarm (0, 0)")) {
411 $has_ualarm++;
412 $DEFINE .= ' -DHAS_UALARM';
413 }
414
415 if ($has_ualarm) {
98b50af3 416 print "found.\n";
3f2ee006 417 } else {
98b50af3
JH
418 print "NOT found.\n";
419 if ($has_setitimer) {
420 print "But you have setitimer().\n";
421 print "We can make a Time::HiRes::ualarm().\n";
3f2ee006
HS
422 }
423 }
424
98b50af3 425 print "Looking for usleep()... ";
3f2ee006 426 my $has_usleep;
5d899d7e
JH
427 if (exists $Config{d_usleep}) {
428 $has_usleep++ if $Config{d_usleep};
3f2ee006
HS
429 } elsif (has_x ("usleep (0)")) {
430 $has_usleep++;
431 $DEFINE .= ' -DHAS_USLEEP';
432 }
433
434 if ($has_usleep) {
98b50af3 435 print "found.\n";
3f2ee006 436 } else {
98b50af3
JH
437 print "NOT found.\n";
438 print "Let's see if you have select()... ";
56c1b3bd 439 if ($Config{'d_select'}) {
98b50af3
JH
440 print "found.\n";
441 print "We can make a Time::HiRes::usleep().\n";
3f2ee006 442 } else {
98b50af3
JH
443 print "NOT found.\n";
444 print "You won't have a Time::HiRes::usleep().\n";
3f2ee006
HS
445 }
446 }
447
98b50af3 448 print "Looking for nanosleep()... ";
3f2ee006 449 my $has_nanosleep;
3d0346a5
SP
450 if ($ENV{FORCE_NANOSLEEP_SCAN}) {
451 print "forced scan... ";
452 if (has_nanosleep()) {
453 $has_nanosleep++;
454 $DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
455 }
456 }
457 elsif (exists $Config{d_nanosleep}) {
458 print "believing \$Config{d_nanosleep}... ";
c1363767
JH
459 if ($Config{d_nanosleep}) {
460 $has_nanosleep++;
461 $DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
462 }
3d0346a5
SP
463 } elsif ($^O =~ /^(mpeix)$/) {
464 # MPE/iX falsely finds nanosleep from its libc equivalent.
465 print "skipping because in $^O... ";
466 } else {
467 if (has_nanosleep()) {
468 $has_nanosleep++;
469 $DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
470 }
3f2ee006
HS
471 }
472
473 if ($has_nanosleep) {
98b50af3 474 print "found.\n";
4ed0e2d4
RGS
475 print "You can mix subsecond sleeps with signals, if you want to.\n";
476 print "(It's still not portable, though.)\n";
3f2ee006 477 } else {
98b50af3 478 print "NOT found.\n";
622913ab
IZ
479 my $nt = ($^O eq 'os2' ? '' : 'not');
480 print "You can$nt mix subsecond sleeps with signals.\n";
4ed0e2d4
RGS
481 print "(It would not be portable anyway.)\n";
482 }
483
ced84e60
SP
484 print "Looking for clock_gettime()... ";
485 my $has_clock_gettime;
486 if (exists $Config{d_clock_gettime}) {
487 $has_clock_gettime++ if $Config{d_clock_gettime}; # Unlikely...
488 } elsif (has_clock_x('gettime')) {
489 $has_clock_gettime++;
490 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME';
491 } elsif (defined $SYSCALL_H && has_clock_x_syscall('gettime')) {
492 $has_clock_gettime++;
493 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME -DTIME_HIRES_CLOCK_GETTIME_SYSCALL';
494 }
495
496 if ($has_clock_gettime) {
497 if ($DEFINE =~ /-DTIME_HIRES_CLOCK_GETTIME_SYSCALL/) {
498 print "found (via syscall).\n";
499 } else {
500 print "found.\n";
501 }
502 } else {
503 print "NOT found.\n";
504 }
505
506 print "Looking for clock_getres()... ";
507 my $has_clock_getres;
508 if (exists $Config{d_clock_getres}) {
509 $has_clock_getres++ if $Config{d_clock_getres}; # Unlikely...
510 } elsif (has_clock_x('getres')) {
511 $has_clock_getres++;
512 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES';
513 } elsif (defined $SYSCALL_H && has_clock_x_syscall('getres')) {
514 $has_clock_getres++;
515 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES -DTIME_HIRES_CLOCK_GETRES_SYSCALL';
516 }
517
518 if ($has_clock_getres) {
519 if ($DEFINE =~ /-DTIME_HIRES_CLOCK_GETRES_SYSCALL/) {
520 print "found (via syscall).\n";
521 } else {
522 print "found.\n";
523 }
524 } else {
525 print "NOT found.\n";
526 }
527
4ed0e2d4
RGS
528 my $has_w32api_windows_h;
529 if ($^O eq 'cygwin') {
530 print "Looking for <w32api/windows.h>... ";
531 if (has_include('w32api/windows.h')) {
532 $has_w32api_windows_h++;
533 $DEFINE .= ' -DHAS_W32API_WINDOWS_H';
534 }
535 if ($has_w32api_windows_h) {
536 print "found.\n";
537 } else {
538 print "NOT found.\n";
539 }
3f2ee006
HS
540 }
541
542 if ($DEFINE) {
543 $DEFINE =~ s/^\s+//;
544 if (open(XDEFINE, ">xdefine")) {
545 print XDEFINE $DEFINE, "\n";
546 close(XDEFINE);
547 }
548 }
549}
550
551sub doMakefile {
98b50af3 552 my @makefileopts = ();
3f2ee006
HS
553
554 if ($] >= 5.005) {
555 push (@makefileopts,
556 'AUTHOR' => 'Jarkko Hietaniemi <jhi@iki.fi>',
557 'ABSTRACT_FROM' => 'HiRes.pm',
558 );
559 $DEFINE .= " -DATLEASTFIVEOHOHFIVE";
560 }
561
562 push (@makefileopts,
563 'NAME' => 'Time::HiRes',
564 'VERSION_FROM' => 'HiRes.pm', # finds $VERSION
5d899d7e
JH
565 'LIBS' => $LIBS, # e.g., '-lm'
566 'DEFINE' => $DEFINE, # e.g., '-DHAS_SOMETHING'
3f2ee006 567 'XSOPT' => $XSOPT,
ced84e60
SP
568 # Do not even think about 'INC' => '-I/usr/ucbinclude',
569 # Solaris will avenge.
5d899d7e 570 'INC' => '', # e.g., '-I/usr/include/other'
9649b81b 571 'INSTALLDIRS' => ($] >= 5.008 ? 'perl' : 'site'),
3f2ee006
HS
572 'dist' => {
573 'CI' => 'ci -l',
5d899d7e 574 'COMPRESS' => 'gzip -9f',
3f2ee006
HS
575 'SUFFIX' => 'gz',
576 },
577 clean => { FILES => "xdefine" },
1caec985 578 realclean => { FILES=> 'const-c.inc const-xs.inc' },
3f2ee006
HS
579 );
580
9ac5eb64
JH
581 if ($ENV{PERL_CORE}) {
582 push @makefileopts, MAN3PODS => {};
583 }
584
3f2ee006
HS
585 WriteMakefile(@makefileopts);
586}
587
98b50af3
JH
588sub doConstants {
589 if (eval {require ExtUtils::Constant; 1}) {
ced84e60
SP
590 my @names = (qw(CLOCK_HIGHRES CLOCK_MONOTONIC
591 CLOCK_PROCESS_CPUTIME_ID
592 CLOCK_REALTIME
593 CLOCK_THREAD_CPUTIME_ID
594 CLOCK_TIMEOFDAY
595 ITIMER_REAL ITIMER_VIRTUAL ITIMER_PROF
98b50af3
JH
596 ITIMER_REALPROF));
597 foreach (qw (d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer
ced84e60 598 d_nanosleep d_clock_gettime d_clock_getres)) {
98b50af3 599 my $macro = $_;
ced84e60 600 if ($macro =~ /^(d_nanosleep|d_clock_gettime|d_clock_getres)$/) {
82cbdcc3 601 $macro =~ s/^d_(.+)/TIME_HIRES_\U$1/;
672f6857 602 } else {
82cbdcc3 603 $macro =~ s/^d_(.+)/HAS_\U$1/;
672f6857 604 }
98b50af3
JH
605 push @names, {name => $_, macro => $macro, value => 1,
606 default => ["IV", "0"]};
607 }
608 ExtUtils::Constant::WriteConstants(
609 NAME => 'Time::HiRes',
610 NAMES => \@names,
611 );
612 } else {
1fbb4de4
RGS
613 my $file;
614 foreach $file ('const-c.inc', 'const-xs.inc') {
98b50af3
JH
615 my $fallback = File::Spec->catfile('fallback', $file);
616 local $/;
617 open IN, "<$fallback" or die "Can't open $fallback: $!";
618 open OUT, ">$file" or die "Can't open $file: $!";
619 print OUT <IN> or die $!;
620 close OUT or die "Can't close $file: $!";
621 close IN or die "Can't close $fallback: $!";
622 }
623 }
624}
3f2ee006 625
98b50af3
JH
626sub main {
627 print "Configuring Time::HiRes...\n";
1fbb4de4
RGS
628 if ($] == 5.007002) {
629 die "Cannot Configure Time::HiRes for Perl $], aborting.\n";
630 }
3f2ee006
HS
631
632 if ($^O =~ /Win32/i) {
633 $DEFINE = '-DSELECT_IS_BROKEN';
046e3f33 634 $LIBS = [];
a5929ff3 635 print "System is $^O, skipping full configure...\n";
3f2ee006 636 } else {
046e3f33 637 init();
3f2ee006 638 }
3f2ee006 639 doMakefile;
98b50af3 640 doConstants;
3f2ee006 641 my $make = $Config{'make'} || "make";
1fbb4de4 642 unless (exists $ENV{PERL_CORE} && $ENV{PERL_CORE}) {
3f2ee006 643 print <<EOM;
3f2ee006 644Now you may issue '$make'. Do not forget also '$make test'.
dfffa540 645EOM
1fbb4de4
RGS
646 if ((exists $ENV{LC_ALL} && $ENV{LC_ALL} =~ /utf-?8/i) ||
647 (exists $ENV{LC_CTYPE} && $ENV{LC_CTYPE} =~ /utf-?8/i) ||
648 (exists $ENV{LANG} && $ENV{LANG} =~ /utf-?8/i)) {
dfffa540 649 print <<EOM;
ced84e60 650NOTE: if you get an error like this (the Makefile line number may vary):
d7358e6a 651Makefile:91: *** missing separator
1caec985
DM
652then set the environment variable LC_ALL to "C" and retry
653from scratch (re-run perl "Makefile.PL").
3f2ee006 654EOM
dfffa540 655 }
3f2ee006
HS
656 }
657}
658
659&main;
dcf686c9 660
3f2ee006 661# EOF