This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Digest-MD5-2.39
[perl5.git] / ext / Digest-MD5 / Makefile.PL
CommitLineData
ee7ea0b1
RGS
1#!perl -w
2
3357b1b1
JH
3use strict;
4use Config qw(%Config);
5use ExtUtils::MakeMaker;
6
7my @extra;
9a03235d 8@extra = (DEFINE => "-DU32_ALIGNMENT_REQUIRED") unless free_u32_alignment();
92dc3567 9
55315086
PP
10if ($^O eq 'VMS') {
11 if (defined($Config{ccname})) {
614d5782
CB
12 if (grep(/VMS_VAX/, @INC) && ($Config{ccname} eq 'DEC')) {
13 # VAX compiler optimizer even as late as v6.4 gets stuck
9a03235d 14 push(@extra, OPTIMIZE => "/Optimize=(NODISJOINT)");
55315086
PP
15 }
16 }
17}
3357b1b1 18
77e6095e 19push(@extra, 'INSTALLDIRS' => 'perl') if $] >= 5.008;
fc0bcb62 20push @extra, 'LICENSE' => 'perl' if eval($ExtUtils::MakeMaker::VERSION) >= "6.30";
9a03235d 21
3357b1b1
JH
22WriteMakefile(
23 'NAME' => 'Digest::MD5',
24 'VERSION_FROM' => 'MD5.pm',
ee7ea0b1
RGS
25 'PREREQ_PM' => { 'File::Spec' => 0,
26 'Digest::base' => '1.00',
47a7661d 27 'XSLoader' => 0,
ee7ea0b1 28 },
3357b1b1
JH
29 @extra,
30 'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
31);
3357b1b1 32
9a03235d
GA
33
34
35sub free_u32_alignment
36{
ee7ea0b1
RGS
37 $|=1;
38 if (exists $Config{d_u32align}) {
39 print "Perl's config says that U32 access must ";
40 print "not " unless $Config{d_u32align};
41 print "be aligned.\n";
42 return !$Config{d_u32align};
43 }
44
45 if ($^O eq 'VMS' || $^O eq 'MSWin32') {
46 print "Assumes that $^O implies free alignment for U32 access.\n";
47 return 1;
48 }
49
50 if ($^O eq 'hpux' && $Config{osvers} < 11.0) {
51 print "Will not test for free alignment on older HP-UX.\n";
52 return 0;
53 }
54
55 print "Testing alignment requirements for U32... ";
56 open(ALIGN_TEST, ">u32align.c") or die "$!";
57 print ALIGN_TEST <<'EOT'; close(ALIGN_TEST);
58/*--------------------------------------------------------------*/
59/* This program allocates a buffer of U8 (char) and then tries */
60/* to access it through a U32 pointer at every offset. The */
61/* program is expected to die with a bus error/seg fault for */
62/* machines that do not support unaligned integer read/write */
63/*--------------------------------------------------------------*/
64
65#include <stdio.h>
66#include "EXTERN.h"
67#include "perl.h"
68
69#ifdef printf
70 #undef printf
71#endif
72
73int main(int argc, char** argv, char** env)
74{
75#if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
76 U8 buf[] = "\0\0\0\1\0\0\0\0";
77 U32 *up;
78 int i;
79
80 if (sizeof(U32) != 4) {
81 printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
82 exit(1);
83 }
84
85 fflush(stdout);
86
87 for (i = 0; i < 4; i++) {
88 up = (U32*)(buf + i);
89 if (! ((*up == 1 << (8*i)) || /* big-endian */
90 (*up == 1 << (8*(3-i))) /* little-endian */
91 )
92 )
93 {
94 printf("read failed (%x)\n", *up);
95 exit(2);
96 }
97 }
98
99 /* write test */
100 for (i = 0; i < 4; i++) {
101 up = (U32*)(buf + i);
102 *up = 0xBeef;
103 if (*up != 0xBeef) {
104 printf("write failed (%x)\n", *up);
105 exit(3);
106 }
107 }
108
109 printf("no restrictions\n");
110 exit(0);
111#else
112 printf("unusual byteorder, playing safe\n");
113 exit(1);
114#endif
115 return 0;
116}
117/*--------------------------------------------------------------*/
118EOT
119
120 my $cc_cmd = "$Config{cc} $Config{ccflags} -I$Config{archlibexp}/CORE";
121 my $exe = "u32align$Config{exe_ext}";
122 $cc_cmd .= " -o $exe";
123 my $rc;
124 $rc = system("$cc_cmd $Config{ldflags} u32align.c $Config{libs}");
125 if ($rc) {
126 print "Can't compile test program. Will ensure alignment to play safe.\n\n";
127 unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
128 return 0;
129 }
130
131 $rc = system("./$exe");
132 unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
133
134 return 1 unless $rc;
135
136 if ($rc > 0x80) {
6e770d9c
SP
137 (my $cp = $rc) >>= 8;
138 print "Test program exit status was $cp\n";
139 }
140 if ($rc & 0x80) {
141 $rc &= ~0x80;
142 unlink("core") && print "Core dump deleted\n";
ee7ea0b1 143 }
6e770d9c 144 print "signal $rc\n" if $rc && $rc < 0x80;
9a03235d
GA
145 return 0;
146}