4 use Config qw(%Config);
5 use ExtUtils::MakeMaker;
8 push(@extra, DEFINE => "-DU32_ALIGNMENT_REQUIRED") unless free_u32_alignment();
9 push(@extra, INSTALLDIRS => 'perl') if $] >= 5.008 && $] < 5.012;
12 if (defined($Config{ccname})) {
13 if (grep(/VMS_VAX/, @INC) && ($Config{ccname} eq 'DEC')) {
14 # VAX compiler optimizer even as late as v6.4 gets stuck
15 push(@extra, OPTIMIZE => "/Optimize=(NODISJOINT)");
22 'NAME' => 'Digest::MD5',
23 'VERSION_FROM' => 'MD5.pm',
24 'ABSTRACT' => 'Perl interface to the MD-5 algorithm',
25 'AUTHOR' => 'Gisle Aas <gisle@activestate.com>',
27 'MIN_PERL_VERSION' => 5.006,
29 'Digest::base' => '1.00',
34 repository => 'http://github.com/gisle/digest-md5',
42 sub free_u32_alignment
45 if (exists $Config{d_u32align}) {
46 print "Perl's config says that U32 access must ";
47 print "not " unless $Config{d_u32align};
48 print "be aligned.\n";
49 return !$Config{d_u32align};
52 if ($^O eq 'VMS' || $^O eq 'MSWin32') {
53 print "Assumes that $^O implies free alignment for U32 access.\n";
57 if ($^O eq 'hpux' && $Config{osvers} < 11.0) {
58 print "Will not test for free alignment on older HP-UX.\n";
62 print "Testing alignment requirements for U32... ";
63 open(ALIGN_TEST, ">u32align.c") or die "$!";
64 print ALIGN_TEST <<'EOT'; close(ALIGN_TEST);
65 /*--------------------------------------------------------------*/
66 /* This program allocates a buffer of U8 (char) and then tries */
67 /* to access it through a U32 pointer at every offset. The */
68 /* program is expected to die with a bus error/seg fault for */
69 /* machines that do not support unaligned integer read/write */
70 /*--------------------------------------------------------------*/
80 int main(int argc, char** argv, char** env)
82 #if BYTEORDER == 0x1234 || BYTEORDER == 0x4321
83 volatile U8 buf[] = "\0\0\0\1\0\0\0\0";
87 if (sizeof(U32) != 4) {
88 printf("sizeof(U32) is not 4, but %d\n", sizeof(U32));
94 for (i = 0; i < 4; i++) {
96 if (! ((*up == 1 << (8*i)) || /* big-endian */
97 (*up == 1 << (8*(3-i))) /* little-endian */
101 printf("read failed (%x)\n", *up);
107 for (i = 0; i < 4; i++) {
108 up = (U32*)(buf + i);
111 printf("write failed (%x)\n", *up);
116 printf("no restrictions\n");
119 printf("unusual byteorder, playing safe\n");
124 /*--------------------------------------------------------------*/
127 my $cc_cmd = "$Config{cc} $Config{ccflags} -I$Config{archlibexp}/CORE";
128 my $exe = "u32align$Config{exe_ext}";
129 $cc_cmd .= " -o $exe";
131 $rc = system("$cc_cmd $Config{ldflags} u32align.c $Config{libs}");
133 print "Can't compile test program. Will ensure alignment to play safe.\n\n";
134 unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
138 $rc = system("./$exe");
139 unlink("u32align.c", $exe, "u32align$Config{obj_ext}");
144 (my $cp = $rc) >>= 8;
145 print "Test program exit status was $cp\n";
149 unlink("core") && print "Core dump deleted\n";
151 print "signal $rc\n" if $rc && $rc < 0x80;
156 # compatibility with older versions of MakeMaker
157 my $developer = -d ".git";
162 MIN_PERL_VERSION => 6.48,
164 undef(*WriteMakefile);
165 *WriteMakefile = sub {
168 unless (eval { ExtUtils::MakeMaker->VERSION($mm_req{$_}) }) {
169 warn "$_ $@" if $developer;
173 ExtUtils::MakeMaker::WriteMakefile(%arg);