Print this page
3900 illumos will not build against gcc compiled perl

@@ -19,16 +19,18 @@
 # CDDL HEADER END
 #
 
 #
 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2013 Racktop Systems.
 #
 
-require 5.8.4;
+require 5.0010;
 use strict;
 use warnings;
 use ExtUtils::MakeMaker;
+use Config;
 
 #
 # Compare OS versions.
 #
 sub cmp_os_ver

@@ -47,13 +49,11 @@
 my $rel = qx{uname -r}; chomp($rel);
 my $arch = qx{uname -p}; chomp($arch);
 my $pver = sprintf('%vd', $^V);
 
 # Figure out the appropriate Config.pm.  Use an older version if necessary.
-my $perlarch = ($arch eq "sparc") ? "sun4-solaris-64int":"i86pc-solaris-64int";
-
-my $configpm = "/usr/perl5/$pver/lib/$perlarch/Config.pm";
+my $configpm = $Config{'archlibexp'} . "/Config.pm";
 if (! -f $configpm) {
         my $p = "config/$pver";
         my $dh;
         opendir($dh, $p) || die("Can't read directory $_: $!\n");
         my $old_rel = (sort(cmp_os_ver

@@ -81,10 +81,45 @@
         close CONFIGPM;
         close CONFIGPM_OUT;
         $configpm = "Config.pm";
 }
 
+# Figure out the appropriate Config_heavy.pl.  Use an older version if necessary.
+my $configpl = $Config{'archlibexp'} . "/Config_heavy.pl";
+if (! -f $configpl) {
+        my $p = "config/$pver";
+        my $dh;
+        opendir($dh, $p) || die("Can't read directory $_: $!\n");
+        my $old_rel = (sort(cmp_os_ver
+            grep(-d "$p/$_" && $_ =~ /^\d[\d.]+\d$/, readdir($dh))))[-1];
+        closedir($dh);
+        if (defined($old_rel)) {
+                print(STDERR "Warning: No config file for OS version $rel, " .
+                    "using $old_rel file\n");
+                $rel = $old_rel;
+                $configpl = "config/$pver/$rel/$arch/Config_heavy.pl";
+        } else {
+                die("Unsupported version of Perl/OS/Architecture " .
+                    "$pver/$rel/$arch\n");
+        }
+} else {
+        open CONFIGPL, "<", $configpl or die $!;
+        open CONFIGPL_OUT, ">", "Config_heavy.pl" or die $!;
+        while(<CONFIGPL>) {
+                if (/^cccdlflags=/) {
+                        print CONFIGPL_OUT "cccdlflags='-fPIC'\n";
+                } elsif (/^optimize=/) {
+                        print CONFIGPL_OUT "optimize='-O2 -fno-strict-aliasing'\n";
+                } else {
+                        print CONFIGPL_OUT $_;
+                }
+        }
+        close CONFIGPL;
+        close CONFIGPL_OUT;
+        $configpl = "Config_heavy.pl";
+}
+
 our %man1pods;
 # Only install the pods for onn-ON builds.
 if (! exists($ENV{CODEMGR_WS}) && ! exists($ENV{ENVCPPFLAGS1})) {
         $man1pods{'pod/perlgcc.pod'} = '$(INST_MAN1DIR)/perlgcc.$(MAN1EXT)';
 }

@@ -92,10 +127,11 @@
 WriteMakefile(
     NAME         => 'Sun::Solaris::PerlGcc',
     VERSION_FROM => 'perlgcc.PL',
     PL_FILES     => { 'perlgcc.PL' => 'perlgcc' },
     EXE_FILES    => [ 'perlgcc' ],
-    PM           => { $configpm => '$(INST_LIBDIR)/PerlGcc/Config.pm' },
+    PM           => { $configpm => '$(INST_LIBDIR)/PerlGcc/Config.pm',
+                      $configpl => '$(INST_LIBDIR)/PerlGcc/Config_heavy.pl' },
     MAN1PODS     => \%man1pods,
     MAN3PODS     => { }, # Stop autopodification.
     clean        => { FILES => 'perlgcc' },
 );