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