1use strict;
2use warnings;
3use ExtUtils::MakeMaker;
4use Config;
5
6my @pack = (["primitive.pd", qw(Primitive PDL::Primitive)]);
7
8if ($^O eq 'dec_osf') {
9       require Config;
10       if ($Config::Config{cc} =~ /^cc/) {
11               my $no_optimize = ($::PDL_OPTIONS{OPTIMIZE} && $::PDL_OPTIONS{OPTIMIZE})
12                                || $Config::Config{optimize}
13                                || '-g2';
14               $no_optimize =~ s/(\s|^)(-O)\d/$1${2}0/;
15               $no_optimize =~ s/(\s|^)(-g)\d/$1${2}2/;
16               print <<EOT;
17       Digital Unix cc optimizer has a bug that is
18       triggered by primitive.c. Therefore
19EOT
20               # Becaue OPTIMIZE in PASTHRU it can't be overridden so
21               # it gets hard coded in Makefile
22               eval q|
23                       sub MY::const_cccmd {
24                               package MY;
25                               my $defval = shift->SUPER::const_cccmd(@_);
26                               $defval =~ s/\$\(OPTIMIZE\)/|
27                                       . $no_optimize . q|/gs;
28                               print "$defval\n";
29                               return $defval;
30                       };
31               |;
32       }
33}
34
35my %hash = pdlpp_stdargs_int(@pack);
36$hash{LIBS}->[0] .= ' -lm';
37
38# If we don't do this, and Perl core is using the wrapped API, then it will
39# call (say) srand48_r(), and get its random numbers from drand48_r(), but we
40# will get ours from drand48(), and srand48() never gets called.
41$hash{CCFLAGS} ||= $Config{ccflags};
42$hash{CCFLAGS} .= ' -DPERL_REENTR_API';
43
44undef &MY::postamble; # suppress warning
45*MY::postamble = sub {
46	pdlpp_postamble_int(@pack);
47};
48
49WriteMakefile(%hash);
50