3 # In general we trust %Config, but for nanosleep() this trust
4 # may be misplaced (it may be linkable but not really functional).
5 # Use $ENV{FORCE_NANOSLEEP_SCAN} to force rescanning whether there
11 use ExtUtils::MakeMaker;
16 my $VERBOSE = $ENV{VERBOSE};
22 our $self; # Used in 'sourcing' the hints.
24 # TBD: Can we just use $Config(exe_ext) here instead of this complex
26 my $ld_exeext = ($^O eq 'cygwin' ||
27 $^O eq 'os2' && $Config{ldflags} =~ /-Zexe\b/) ? '.exe' :
28 (($^O eq 'vos') ? $Config{exe_ext} : '');
30 unless($ENV{PERL_CORE}) {
31 $ENV{PERL_CORE} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
34 sub try_compile_and_link {
41 my $obj_ext = $Config{obj_ext} || ".o";
42 unlink("$tmp.c", "$tmp$obj_ext");
44 if (open(TMPC, '>', "$tmp.c")) {
48 my $cccmd = $args{cccmd};
54 if ($ENV{PERL_CORE}) {
55 my $updir = File::Spec->updir;
56 $COREincdir = File::Spec->catdir(($updir) x 2);
58 $COREincdir = File::Spec->catdir($Config{'archlibexp'}, 'CORE');
61 if ($ENV{PERL_CORE}) {
62 unless (-f File::Spec->catfile($COREincdir, "EXTERN.h")) {
64 Your environment variable PERL_CORE is '$ENV{PERL_CORE}' but there
65 is no EXTERN.h in $COREincdir.
66 Cannot continue, aborting.
71 my $ccflags = $Config{'ccflags'} . ' ' . "-I$COREincdir"
72 . ' -DPERL_NO_INLINE_FUNCTIONS';
75 $cccmd = "$Config{'cc'} /include=($COREincdir) $tmp.c";
78 if ($args{silent} || !$VERBOSE) {
79 $errornull = "2>/dev/null" unless defined $errornull;
84 $cccmd = "$Config{'cc'} -o $tmp $ccflags $tmp.c @$LIBS $errornull"
85 unless defined $cccmd;
88 open( CMDFILE, '>', "$tmp.com" );
89 print CMDFILE "\$ SET MESSAGE/NOFACILITY/NOSEVERITY/NOIDENT/NOTEXT\n";
90 print CMDFILE "\$ $cccmd\n";
91 print CMDFILE "\$ IF \$SEVERITY .NE. 1 THEN EXIT 44\n"; # escalate
93 system("\@ $tmp.com");
95 for ("$tmp.c", "$tmp$obj_ext", "$tmp.com", "$tmp$Config{exe_ext}") {
101 my $tmp_exe = "$tmp$ld_exeext";
102 printf "cccmd = $cccmd\n" if $VERBOSE;
103 my $res = system($cccmd);
104 $ok = defined($res) && $res == 0 && -s $tmp_exe && -x _;
106 if ( $ok && exists $args{run} && $args{run} && !$ENV{TIME_HIRES_DONT_RUN_PROBES} ) {
108 File::Spec->catfile(File::Spec->curdir, $tmp_exe);
110 unshift @run, $Config{run} if $Config{run} && -e $Config{run};
111 printf "Running $tmp_exe..." if $VERBOSE;
112 if (system(@run) == 0) {
120 *** The test run of '$tmp_exe' failed: status $?
121 *** (the status means: errno = $errno or '$!')
122 *** DO NOT PANIC: this just means that *some* functionality will be missing.
126 unlink("$tmp.c", $tmp_exe);
133 my $TIME_HEADERS = <<EOH;
138 # include <sys/types.h>
141 # include <sys/time.h>
144 # include <sys/select.h> /* struct timeval might be hidden in here */
148 sub has_gettimeofday {
149 # confusing but true (if condition true ==> -DHAS_GETTIMEOFDAY already)
150 return 0 if $Config{d_gettimeod};
151 return 1 if try_compile_and_link(<<EOM);
156 gettimeofday(&tv, 0);
158 int main(int argc, char** argv)
170 try_compile_and_link(<<EOM, %args);
180 # include <sys/types.h>
184 # include <sys/time.h>
187 int main(int argc, char** argv)
198 try_compile_and_link(<<EOM, run => 1);
200 #include <sys/time.h>
205 /* int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); */
207 int main(int argc, char** argv) {
208 struct timespec ts1, ts2;
211 ts1.tv_nsec = 750000000;
215 ret = nanosleep(&ts1, &ts2); /* E.g. in AIX nanosleep() fails and sets errno to ENOSYS. */
216 ret == 0 ? exit(0) : exit(errno ? errno : -1);
224 try_compile_and_link(<<EOM);
230 int main(int argc, char** argv)
238 sub has_clock_xxx_syscall {
240 return 0 unless defined $SYSCALL_H;
242 try_compile_and_link(<<EOM, run => 1);
247 #include <$SYSCALL_H>
248 int main(int argc, char** argv)
251 /* Many Linuxes get ENOSYS even though the syscall exists. */
252 /* All implementations are supposed to support CLOCK_REALTIME. */
253 int ret = syscall(SYS_clock_$x, CLOCK_REALTIME, &ts);
254 ret == 0 ? exit(0) : exit(errno ? errno : -1);
262 try_compile_and_link(<<EOM, run => 1);
267 int main(int argc, char** argv)
270 int ret = clock_$xxx(CLOCK_REALTIME, &ts); /* Many Linuxes get ENOSYS. */
271 /* All implementations are supposed to support CLOCK_REALTIME. */
272 ret == 0 ? exit(0) : exit(errno ? errno : -1);
279 try_compile_and_link(<<EOM, run => 1);
284 int main(int argc, char** argv)
287 clock_t ret = clock();
288 ret == (clock_t)-1 ? exit(errno ? errno : -1) : exit(0);
293 sub has_clock_nanosleep {
295 try_compile_and_link(<<EOM, run => 1);
300 int main(int argc, char** argv)
306 ts1.tv_nsec = 750000000;;
307 /* All implementations are supposed to support CLOCK_REALTIME. */
308 ret = clock_nanosleep(CLOCK_REALTIME, 0, &ts1, &ts2);
309 ret == 0 ? exit(0) : exit(errno ? errno : -1);
316 try_compile_and_link(<<EOM);
320 #include <sys/stat.h>
321 int main(int argc, char** argv)
324 struct timespec ts1[2], ts2[2];
325 ret1 = futimens(0, ts1);
327 read(0, buf, 0); /* Assuming reading nothing updates atime (the [0]) */
328 ret2 = futimens(0, ts2);
329 ret1 == 0 && ret2 == 0 && (ts1[0].tv_nsec != 0 || ts2[0].tv_nsec != 0) ?
330 exit(0) : exit(errno ? errno : -1);
337 try_compile_and_link(<<EOM);
341 #include <sys/stat.h>
343 int main(int argc, char** argv)
346 struct timespec ts1[2], ts2[2];
347 /* We make the brave but probably foolish assumption that systems
348 * modern enough to have utimensat also have the /dev/stdin. */
349 ret1 = utimensat(AT_FDCWD, "/dev/stdin", ts1, 0);
351 read(0, buf, 0); /* Assuming reading nothing updates atime (the [0]) */
352 ret2 = utimensat(AT_FDCWD, "/dev/stdin", ts2, 0);
353 ret1 == 0 && ret2 == 0 && (ts1[0].tv_nsec != 0 || ts2[0].tv_nsec != 0) ?
354 exit(0) : exit(errno ? errno : -1);
361 try_compile_and_link(<<EOM);
366 int main(int argc, char** argv)
368 clockid_t id = CLOCK_REALTIME;
369 exit(id == CLOCK_REALTIME ? 1 : 0);
375 my ($def, $val) = @_;
376 my $define = defined $val ? "$def=$val" : $def ;
377 unless ($DEFINE =~ /(?:^| )-D\Q$define\E(?: |$)/) {
378 $DEFINE .= " -D$define";
383 my $hints = File::Spec->catfile("hints", "$^O.pl");
385 print "Using hints $hints...\n";
388 if (exists $self->{LIBS}) {
389 $LIBS = $self->{LIBS};
390 print "Extra libraries: @$LIBS...\n";
396 if ($Config{d_syscall}) {
397 print "Have syscall()... looking for syscall.h... ";
398 if (has_include('syscall.h')) {
399 $SYSCALL_H = 'syscall.h';
400 } elsif (has_include('sys/syscall.h')) {
401 $SYSCALL_H = 'sys/syscall.h';
404 print "No syscall()...\n";
407 if ($Config{d_syscall}) {
408 if (defined $SYSCALL_H) {
409 print "found <$SYSCALL_H>.\n";
411 print "NOT found.\n";
415 print "Looking for gettimeofday()... ";
416 my $has_gettimeofday;
417 if (exists $Config{d_gettimeod}) {
418 $has_gettimeofday++ if $Config{d_gettimeod};
419 } elsif (has_gettimeofday()) {
420 $DEFINE .= ' -DHAS_GETTIMEOFDAY';
424 if ($has_gettimeofday) {
428 Your operating system does not seem to have the gettimeofday() function.
429 (or, at least, I cannot find it)
431 There is no way Time::HiRes is going to work.
433 I am awfully sorry but I cannot go further.
435 Aborting configuration.
440 print "Looking for setitimer()... ";
442 if (exists $Config{d_setitimer}) {
443 $has_setitimer++ if $Config{d_setitimer};
444 } elsif (has_x("setitimer(ITIMER_REAL, 0, 0)")) {
446 $DEFINE .= ' -DHAS_SETITIMER';
449 if ($has_setitimer) {
452 print "NOT found.\n";
455 print "Looking for getitimer()... ";
457 if (exists $Config{'d_getitimer'}) {
458 $has_getitimer++ if $Config{'d_getitimer'};
459 } elsif (has_x("getitimer(ITIMER_REAL, 0)")) {
461 $DEFINE .= ' -DHAS_GETITIMER';
464 if ($has_getitimer) {
467 print "NOT found.\n";
470 if ($has_setitimer && $has_getitimer) {
471 print "You have interval timers (both setitimer and getitimer).\n";
473 print "You do NOT have interval timers.\n";
476 print "Looking for ualarm()... ";
478 if (exists $Config{d_ualarm}) {
479 $has_ualarm++ if $Config{d_ualarm};
480 } elsif (has_x ("ualarm (0, 0)")) {
482 $DEFINE .= ' -DHAS_UALARM';
488 print "NOT found.\n";
489 if ($has_setitimer) {
490 print "But you have setitimer().\n";
491 print "We can make a Time::HiRes::ualarm().\n";
495 print "Looking for usleep()... ";
497 if (exists $Config{d_usleep}) {
498 $has_usleep++ if $Config{d_usleep};
499 } elsif (has_x ("usleep (0)")) {
501 $DEFINE .= ' -DHAS_USLEEP';
507 print "NOT found.\n";
508 print "Let's see if you have select()... ";
509 if ($Config{'d_select'}) {
511 print "We can make a Time::HiRes::usleep().\n";
513 print "NOT found.\n";
514 print "You won't have a Time::HiRes::usleep().\n";
518 print "Looking for nanosleep()... ";
520 if ($ENV{FORCE_NANOSLEEP_SCAN}) {
521 print "forced scan... ";
522 if (has_nanosleep()) {
524 $DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
527 elsif (exists $Config{d_nanosleep}) {
528 print "believing \$Config{d_nanosleep}... ";
529 if ($Config{d_nanosleep}) {
531 $DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
534 if (has_nanosleep()) {
536 $DEFINE .= ' -DTIME_HIRES_NANOSLEEP';
540 if ($has_nanosleep) {
542 print "You can mix subsecond sleeps with signals, if you want to.\n";
543 print "(It's still not portable, though.)\n";
545 print "NOT found.\n";
546 my $nt = ($^O eq 'os2' ? '' : 'not');
547 print "You can$nt mix subsecond sleeps with signals.\n";
548 print "(It would not be portable anyway.)\n";
551 print "Looking for clockid_t... ";
553 if (has_clockid_t()) {
556 $DEFINE .= ' -DTIME_HIRES_CLOCKID_T';
558 print "NOT found, will use int.\n";
561 print "Looking for clock_gettime()... ";
562 my $has_clock_gettime;
563 my $has_clock_gettime_emulation;
564 if (exists $Config{d_clock_gettime}) {
565 $has_clock_gettime++ if $Config{d_clock_gettime}; # Unlikely...
566 } elsif (has_clock_xxx('gettime')) {
567 $has_clock_gettime++;
568 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME';
569 } elsif (defined $SYSCALL_H && has_clock_xxx_syscall('gettime')) {
570 $has_clock_gettime++;
571 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME -DTIME_HIRES_CLOCK_GETTIME_SYSCALL';
572 } elsif ($^O eq 'darwin') {
573 $has_clock_gettime_emulation++;
574 $has_clock_gettime++;
575 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETTIME -DTIME_HIRES_CLOCK_GETTIME_EMULATION';
578 if ($has_clock_gettime) {
579 if ($DEFINE =~ /-DTIME_HIRES_CLOCK_GETTIME_SYSCALL/) {
580 print "found (via syscall).\n";
581 } elsif ($has_clock_gettime_emulation) {
582 print "found (via emulation).\n";
587 print "NOT found.\n";
590 print "Looking for clock_getres()... ";
591 my $has_clock_getres;
592 my $has_clock_getres_emulation;
593 if (exists $Config{d_clock_getres}) {
594 $has_clock_getres++ if $Config{d_clock_getres}; # Unlikely...
595 } elsif (has_clock_xxx('getres')) {
597 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES';
598 } elsif (defined $SYSCALL_H && has_clock_xxx_syscall('getres')) {
600 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES -DTIME_HIRES_CLOCK_GETRES_SYSCALL';
601 } elsif ($^O eq 'darwin') {
602 $has_clock_getres_emulation++;
604 $DEFINE .= ' -DTIME_HIRES_CLOCK_GETRES -DTIME_HIRES_CLOCK_GETRES_EMULATION';
607 if ($has_clock_getres) {
608 if ($DEFINE =~ /-DTIME_HIRES_CLOCK_GETRES_SYSCALL/) {
609 print "found (via syscall).\n";
610 } elsif ($has_clock_getres_emulation) {
611 print "found (via emulation).\n";
616 print "NOT found.\n";
619 print "Looking for clock_nanosleep()... ";
620 my $has_clock_nanosleep;
621 my $has_clock_nanosleep_emulation;
622 if (exists $Config{d_clock_nanosleep}) {
623 $has_clock_nanosleep++ if $Config{d_clock_nanosleep}; # Unlikely...
624 } elsif (has_clock_nanosleep()) {
625 $has_clock_nanosleep++;
626 $DEFINE .= ' -DTIME_HIRES_CLOCK_NANOSLEEP';
627 } elsif ($^O eq 'darwin') {
628 $has_clock_nanosleep++;
629 $has_clock_nanosleep_emulation++;
630 $DEFINE .= ' -DTIME_HIRES_CLOCK_NANOSLEEP -DTIME_HIRES_CLOCK_NANOSLEEP_EMULATION';
633 if ($has_clock_nanosleep) {
634 if ($has_clock_nanosleep_emulation) {
635 print "found (via emulation).\n";
640 print "NOT found.\n";
643 print "Looking for clock()... ";
645 if (exists $Config{d_clock}) {
646 $has_clock++ if $Config{d_clock}; # Unlikely...
647 } elsif (has_clock()) {
649 $DEFINE .= ' -DTIME_HIRES_CLOCK';
655 print "NOT found.\n";
658 print "Looking for working futimens()... ";
660 if (has_futimens()) {
662 $DEFINE .= ' -DHAS_FUTIMENS';
668 print "NOT found.\n";
671 print "Looking for working utimensat()... ";
673 if (has_utimensat()) {
675 $DEFINE .= ' -DHAS_UTIMENSAT';
678 if ($has_utimensat) {
681 print "NOT found.\n";
684 my $has_hires_utime = ($has_futimens && $has_utimensat);
685 if ($has_hires_utime) {
686 $DEFINE .= ' -DTIME_HIRES_UTIME';
687 print "You seem to have subsecond timestamp setting.\n";
689 print "You do NOT seem to have subsecond timestamp setting.\n";
692 print "Looking for stat() subsecond timestamps...\n";
694 print "Trying struct stat st_atimespec.tv_nsec...";
695 my $has_stat_st_xtimespec;
696 if (try_compile_and_link(<<EOM)) {
698 #include <sys/stat.h>
699 int main(int argc, char** argv) {
701 st.st_atimespec.tv_nsec = 0;
704 $has_stat_st_xtimespec++;
705 DEFINE('TIME_HIRES_STAT_ST_XTIMESPEC'); # 1
708 if ($has_stat_st_xtimespec) {
711 print "NOT found.\n";
714 print "Trying struct stat st_atimensec...";
715 my $has_stat_st_xtimensec;
716 if (try_compile_and_link(<<EOM)) {
718 #include <sys/stat.h>
719 int main(int argc, char** argv) {
724 $has_stat_st_xtimensec++;
725 DEFINE('TIME_HIRES_STAT_ST_XTIMENSEC'); # 2
728 if ($has_stat_st_xtimensec) {
731 print "NOT found.\n";
734 print "Trying struct stat st_atime_n...";
735 my $has_stat_st_xtime_n;
736 if (try_compile_and_link(<<EOM)) {
738 #include <sys/stat.h>
739 int main(int argc, char** argv) {
744 $has_stat_st_xtime_n++;
745 DEFINE('TIME_HIRES_STAT_ST_XTIME_N'); # 3
748 if ($has_stat_st_xtime_n) {
751 print "NOT found.\n";
754 print "Trying struct stat st_atim.tv_nsec...";
755 my $has_stat_st_xtim;
756 if (try_compile_and_link(<<EOM)) {
758 #include <sys/stat.h>
759 int main(int argc, char** argv) {
761 st.st_atim.tv_nsec = 0;
765 DEFINE('TIME_HIRES_STAT_XTIM'); # 4
768 if ($has_stat_st_xtim) {
771 print "NOT found.\n";
774 print "Trying struct stat st_uatime...";
775 my $has_stat_st_uxtime;
776 if (try_compile_and_link(<<EOM)) {
778 #include <sys/stat.h>
779 int main(int argc, char** argv) {
784 $has_stat_st_uxtime++;
785 DEFINE('TIME_HIRES_STAT_ST_UXTIME'); # 5
788 if ($has_stat_st_uxtime) {
791 print "NOT found.\n";
794 # See HiRes.xs hrstatns()
795 if ($has_stat_st_xtimespec) {
796 DEFINE('TIME_HIRES_STAT', 1);
797 } elsif ($has_stat_st_xtimensec) {
798 DEFINE('TIME_HIRES_STAT', 2);
799 } elsif ($has_stat_st_xtime_n) {
800 DEFINE('TIME_HIRES_STAT', 3);
801 } elsif ($has_stat_st_xtim) {
802 DEFINE('TIME_HIRES_STAT', 4);
803 } elsif ($has_stat_st_uxtime) {
804 DEFINE('TIME_HIRES_STAT', 5);
807 my $has_hires_stat = ($DEFINE =~ /-DTIME_HIRES_STAT=(\d+)/) ? $1 : 0;
808 if ($has_hires_stat) {
809 print "You seem to have subsecond timestamp reading.\n";
810 print "(Your struct stat has them, but the filesystems must help.)\n";
811 unless ($has_hires_utime) {
812 print "However, you do NOT seem to have subsecond timestamp setting.\n";
815 print "You do NOT seem to have subsecond timestamp reading.\n";
818 my $has_w32api_windows_h;
820 if ($^O eq 'cygwin') {
821 print "Looking for <w32api/windows.h>... ";
822 if (has_include('w32api/windows.h')) {
823 $has_w32api_windows_h++;
824 DEFINE('HAS_W32API_WINDOWS_H');
826 if ($has_w32api_windows_h) {
829 print "NOT found.\n";
835 if (open(XDEFINE, '>', 'xdefine')) {
836 print XDEFINE $DEFINE, "\n";
843 my @makefileopts = ();
845 DEFINE('USE_PPPORT_H') unless $ENV{PERL_CORE};
848 'NAME' => 'Time::HiRes',
849 'AUTHOR' => 'Jarkko Hietaniemi <jhi@iki.fi>',
850 'ABSTRACT_FROM' => 'HiRes.pm',
851 'VERSION_FROM' => 'HiRes.pm', # finds $VERSION
852 'LIBS' => $LIBS, # e.g., '-lm'
853 'DEFINE' => $DEFINE, # e.g., '-DHAS_SOMETHING'
855 # Do not even think about 'INC' => '-I/usr/ucbinclude',
856 # Solaris will avenge.
857 'INC' => '', # e.g., '-I/usr/include/other'
858 'INSTALLDIRS' => ($] >= 5.008 && $] < 5.011 ? 'perl' : 'site'),
863 'ExtUtils::MakeMaker' => 0,
871 'COMPRESS' => 'gzip -9f',
874 clean => { FILES => "xdefine" },
875 realclean => { FILES=> 'const-c.inc const-xs.inc' },
878 if ($^O eq "MSWin32" && !(grep { /\ALD[A-Z]*=/ } @ARGV)) {
879 my $libperl = $Config{libperl} || "";
880 my $gccversion = $Config{gccversion} || "";
881 if ($gccversion =~ /\A3\.4\.[0-9]+/ and $libperl =~ /\.lib\z/) {
882 # Avoid broken linkage with ActivePerl, by linking directly
883 # against the Perl DLL rather than the import library.
884 (my $llibperl = "-l$libperl") =~ s/\.lib\z//;
885 my $lddlflags = $Config{lddlflags} || "";
886 my $ldflags = $Config{ldflags} || "";
887 s/-L(?:".*?"|\S+)//g foreach $lddlflags, $ldflags;
888 my $libdirs = join ' ',
889 map { s/(?<!\\)((?:\\\\)*")/\\$1/g; qq[-L"$_"] }
890 @Config{qw/bin sitebin/};
891 push @makefileopts, macro => {
892 LDDLFLAGS => "$lddlflags $libdirs $llibperl",
893 LDFLAGS => "$ldflags $libdirs $llibperl",
899 if ($ENV{PERL_CORE}) {
900 push @makefileopts, MAN3PODS => {};
903 if ($ExtUtils::MakeMaker::VERSION >= 6.48) {
904 push @makefileopts, (MIN_PERL_VERSION => '5.006',);
907 if ($ExtUtils::MakeMaker::VERSION >= 6.31) {
908 push @makefileopts, (LICENSE => 'perl_5');
911 if ($ExtUtils::MakeMaker::VERSION >= 6.46) {
912 push @makefileopts, (
915 repository => 'https://github.com/Perl/perl5.git',
916 bugtracker => 'https://github.com/Perl/perl5/issues',
917 homepage => "https://github.com/Perl/perl5",
923 WriteMakefile(@makefileopts);
927 if (eval {require ExtUtils::Constant; 1}) {
928 # More or less this same list is in HiRes.pm. Should unify.
934 CLOCK_MONOTONIC_COARSE
936 CLOCK_MONOTONIC_PRECISE
939 CLOCK_PROCESS_CPUTIME_ID
941 CLOCK_REALTIME_COARSE
943 CLOCK_REALTIME_PRECISE
947 CLOCK_THREAD_CPUTIME_ID
961 foreach (qw (d_usleep d_ualarm d_gettimeofday d_getitimer d_setitimer
962 d_nanosleep d_clock_gettime d_clock_getres
963 d_clock d_clock_nanosleep d_hires_stat
964 d_futimens d_utimensat d_hires_utime)) {
966 if ($macro =~ /^(d_nanosleep|d_clock)$/) {
967 $macro =~ s/^d_(.+)/TIME_HIRES_\U$1/;
968 } elsif ($macro =~ /^(d_hires_stat)$/) {
969 my $d_hires_stat = $1 if ($DEFINE =~ /-DTIME_HIRES_STAT=(\d+)/);
970 if (defined $d_hires_stat) {
971 push @names, {name => $_, macro => "TIME_HIRES_STAT", value => $d_hires_stat,
972 default => ["IV", "0"]};
975 } elsif ($macro =~ /^(d_hires_utime)$/) {
977 ($DEFINE =~ /-DHAS_FUTIMENS/ ||
978 $DEFINE =~ /-DHAS_UTIMENSAT/);
979 push @names, {name => $_, macro => "TIME_HIRES_UTIME", value => $d_hires_utime,
980 default => ["IV", "0"]};
982 } elsif ($macro =~ /^(d_clock_gettime|d_clock_getres|d_clock_nanosleep)$/) {
983 $macro =~ s/^d_(.+)/TIME_HIRES_\U$1/;
984 my $val = ($DEFINE =~ /-D$macro\b/) ? 1 : 0;
985 push @names, {name => $_, macro => $macro, value => $val,
986 default => ["IV", "0"]};
989 $macro =~ s/^d_(.+)/HAS_\U$1/;
991 push @names, {name => $_, macro => $macro, value => 1,
992 default => ["IV", "0"]};
994 ExtUtils::Constant::WriteConstants(
995 NAME => 'Time::HiRes',
1000 foreach $file ('const-c.inc', 'const-xs.inc') {
1001 my $fallback = File::Spec->catfile('fallback', $file);
1003 open IN, '<', $fallback or die "Can't open $fallback: $!";
1004 open OUT, '>', $file or die "Can't open $file: $!";
1005 print OUT <IN> or die $!;
1006 close OUT or die "Can't close $file: $!";
1007 close IN or die "Can't close $fallback: $!";
1013 if (-f "xdefine" && !(@ARGV && $ARGV[0] =~ /^--(?:configure|force)$/)) {
1014 print qq[$0: The "xdefine" exists, skipping the configure step.\n];
1015 print qq[Use "$^X $0 --configure"\n];
1016 print qq[or: "$^X $0 --force\n];
1017 print qq[to force the configure step.\n];
1019 print "Configuring Time::HiRes...\n";
1020 1 while unlink("define");
1021 if ($^O =~ /Win32/i) {
1022 DEFINE('SELECT_IS_BROKEN');
1023 # we provide our own implementations of those functions on win32
1024 DEFINE('TIME_HIRES_CLOCK_GETTIME');
1025 DEFINE('TIME_HIRES_CLOCK_GETRES');
1027 print "System is $^O, skipping full configure...\n";
1028 open(XDEFINE, '>', 'xdefine') or die "$0: Cannot create xdefine: $!\n";
1036 my $make = $Config{'make'} || "make";
1037 unless (exists $ENV{PERL_CORE} && $ENV{PERL_CORE}) {
1039 Now you may issue '$make'. Do not forget also '$make test'.
1042 ((exists $ENV{LC_ALL} && $ENV{LC_ALL} =~ /utf-?8/i) ||
1043 (exists $ENV{LC_CTYPE} && $ENV{LC_CTYPE} =~ /utf-?8/i) ||
1044 (exists $ENV{LANG} && $ENV{LANG} =~ /utf-?8/i))) {
1047 NOTE: if you get an error like this (the Makefile line number may vary):
1048 Makefile:91: *** missing separator
1049 then set the environment variable LC_ALL to "C" and retry
1050 from scratch (re-run perl "Makefile.PL").
1051 (And consider upgrading your Perl to, say, at least Perl 5.8.8.)
1052 (You got this message because you seem to have
1053 an UTF-8 locale active in your shell environment, this used
1054 to cause broken Makefiles to be created from Makefile.PLs)