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


   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.

  24 #
  25 
  26 require 5.8.4;
  27 use strict;
  28 use warnings;
  29 use ExtUtils::MakeMaker;

  30 
  31 #
  32 # Compare OS versions.
  33 #
  34 sub cmp_os_ver
  35 {
  36         our ($a, $b);
  37         my @v1 = split(/\./, $a);
  38         my @v2 = split(/\./, $b);
  39         my $diff = 0;
  40         while (@v1 || @v2) {
  41                 last if (($diff = shift(@v1) - shift(@v2)) != 0);
  42         }
  43         return ($diff);
  44 }
  45 
  46 # Check we are on a supported OS version.
  47 my $rel = qx{uname -r}; chomp($rel);
  48 my $arch = qx{uname -p}; chomp($arch);
  49 my $pver = sprintf('%vd', $^V);
  50 
  51 # Figure out the appropriate Config.pm.  Use an older version if necessary.
  52 my $perlarch = ($arch eq "sparc") ? "sun4-solaris-64int":"i86pc-solaris-64int";
  53 
  54 my $configpm = "/usr/perl5/$pver/lib/$perlarch/Config.pm";
  55 if (! -f $configpm) {
  56         my $p = "config/$pver";
  57         my $dh;
  58         opendir($dh, $p) || die("Can't read directory $_: $!\n");
  59         my $old_rel = (sort(cmp_os_ver
  60             grep(-d "$p/$_" && $_ =~ /^\d[\d.]+\d$/, readdir($dh))))[-1];
  61         closedir($dh);
  62         if (defined($old_rel)) {
  63                 print(STDERR "Warning: No config file for OS version $rel, " .
  64                     "using $old_rel file\n");
  65                 $rel = $old_rel;
  66                 $configpm = "config/$pver/$rel/$arch/Config.pm";
  67         } else {
  68                 die("Unsupported version of Perl/OS/Architecture " .
  69                     "$pver/$rel/$arch\n");
  70         }
  71 } else {
  72         open CONFIGPM, "<", $configpm or die $!;
  73         open CONFIGPM_OUT, ">", "Config.pm" or die $!;
  74         while(<CONFIGPM>) {
  75                 if (/'cc/) {
  76                         s/=>\s*'cc/=> 'gcc/;
  77                         s/=\s*'cc/='gcc/;
  78                 }
  79                 print CONFIGPM_OUT $_;
  80         }
  81         close CONFIGPM;
  82         close CONFIGPM_OUT;
  83         $configpm = "Config.pm";
  84 }
  85 



































  86 our %man1pods;
  87 # Only install the pods for onn-ON builds.
  88 if (! exists($ENV{CODEMGR_WS}) && ! exists($ENV{ENVCPPFLAGS1})) {
  89         $man1pods{'pod/perlgcc.pod'} = '$(INST_MAN1DIR)/perlgcc.$(MAN1EXT)';
  90 }
  91 
  92 WriteMakefile(
  93     NAME         => 'Sun::Solaris::PerlGcc',
  94     VERSION_FROM => 'perlgcc.PL',
  95     PL_FILES     => { 'perlgcc.PL' => 'perlgcc' },
  96     EXE_FILES    => [ 'perlgcc' ],
  97     PM           => { $configpm => '$(INST_LIBDIR)/PerlGcc/Config.pm' },

  98     MAN1PODS     => \%man1pods,
  99     MAN3PODS     => { }, # Stop autopodification.
 100     clean        => { FILES => 'perlgcc' },
 101 );


   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License (the "License").
   6 # You may not use this file except in compliance with the License.
   7 #
   8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 # or http://www.opensolaris.org/os/licensing.
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 
  22 #
  23 # Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  24 # Copyright (c) 2013 Racktop Systems.
  25 #
  26 
  27 require 5.0010;
  28 use strict;
  29 use warnings;
  30 use ExtUtils::MakeMaker;
  31 use Config;
  32 
  33 #
  34 # Compare OS versions.
  35 #
  36 sub cmp_os_ver
  37 {
  38         our ($a, $b);
  39         my @v1 = split(/\./, $a);
  40         my @v2 = split(/\./, $b);
  41         my $diff = 0;
  42         while (@v1 || @v2) {
  43                 last if (($diff = shift(@v1) - shift(@v2)) != 0);
  44         }
  45         return ($diff);
  46 }
  47 
  48 # Check we are on a supported OS version.
  49 my $rel = qx{uname -r}; chomp($rel);
  50 my $arch = qx{uname -p}; chomp($arch);
  51 my $pver = sprintf('%vd', $^V);
  52 
  53 # Figure out the appropriate Config.pm.  Use an older version if necessary.
  54 my $configpm = $Config{'archlibexp'} . "/Config.pm";


  55 if (! -f $configpm) {
  56         my $p = "config/$pver";
  57         my $dh;
  58         opendir($dh, $p) || die("Can't read directory $_: $!\n");
  59         my $old_rel = (sort(cmp_os_ver
  60             grep(-d "$p/$_" && $_ =~ /^\d[\d.]+\d$/, readdir($dh))))[-1];
  61         closedir($dh);
  62         if (defined($old_rel)) {
  63                 print(STDERR "Warning: No config file for OS version $rel, " .
  64                     "using $old_rel file\n");
  65                 $rel = $old_rel;
  66                 $configpm = "config/$pver/$rel/$arch/Config.pm";
  67         } else {
  68                 die("Unsupported version of Perl/OS/Architecture " .
  69                     "$pver/$rel/$arch\n");
  70         }
  71 } else {
  72         open CONFIGPM, "<", $configpm or die $!;
  73         open CONFIGPM_OUT, ">", "Config.pm" or die $!;
  74         while(<CONFIGPM>) {
  75                 if (/'cc/) {
  76                         s/=>\s*'cc/=> 'gcc/;
  77                         s/=\s*'cc/='gcc/;
  78                 }
  79                 print CONFIGPM_OUT $_;
  80         }
  81         close CONFIGPM;
  82         close CONFIGPM_OUT;
  83         $configpm = "Config.pm";
  84 }
  85 
  86 # Figure out the appropriate Config_heavy.pl.  Use an older version if necessary.
  87 my $configpl = $Config{'archlibexp'} . "/Config_heavy.pl";
  88 if (! -f $configpl) {
  89         my $p = "config/$pver";
  90         my $dh;
  91         opendir($dh, $p) || die("Can't read directory $_: $!\n");
  92         my $old_rel = (sort(cmp_os_ver
  93             grep(-d "$p/$_" && $_ =~ /^\d[\d.]+\d$/, readdir($dh))))[-1];
  94         closedir($dh);
  95         if (defined($old_rel)) {
  96                 print(STDERR "Warning: No config file for OS version $rel, " .
  97                     "using $old_rel file\n");
  98                 $rel = $old_rel;
  99                 $configpl = "config/$pver/$rel/$arch/Config_heavy.pl";
 100         } else {
 101                 die("Unsupported version of Perl/OS/Architecture " .
 102                     "$pver/$rel/$arch\n");
 103         }
 104 } else {
 105         open CONFIGPL, "<", $configpl or die $!;
 106         open CONFIGPL_OUT, ">", "Config_heavy.pl" or die $!;
 107         while(<CONFIGPL>) {
 108                 if (/^cccdlflags=/) {
 109                         print CONFIGPL_OUT "cccdlflags='-fPIC'\n";
 110                 } elsif (/^optimize=/) {
 111                         print CONFIGPL_OUT "optimize='-O2 -fno-strict-aliasing'\n";
 112                 } else {
 113                         print CONFIGPL_OUT $_;
 114                 }
 115         }
 116         close CONFIGPL;
 117         close CONFIGPL_OUT;
 118         $configpl = "Config_heavy.pl";
 119 }
 120 
 121 our %man1pods;
 122 # Only install the pods for onn-ON builds.
 123 if (! exists($ENV{CODEMGR_WS}) && ! exists($ENV{ENVCPPFLAGS1})) {
 124         $man1pods{'pod/perlgcc.pod'} = '$(INST_MAN1DIR)/perlgcc.$(MAN1EXT)';
 125 }
 126 
 127 WriteMakefile(
 128     NAME         => 'Sun::Solaris::PerlGcc',
 129     VERSION_FROM => 'perlgcc.PL',
 130     PL_FILES     => { 'perlgcc.PL' => 'perlgcc' },
 131     EXE_FILES    => [ 'perlgcc' ],
 132     PM           => { $configpm => '$(INST_LIBDIR)/PerlGcc/Config.pm',
 133                       $configpl => '$(INST_LIBDIR)/PerlGcc/Config_heavy.pl' },
 134     MAN1PODS     => \%man1pods,
 135     MAN3PODS     => { }, # Stop autopodification.
 136     clean        => { FILES => 'perlgcc' },
 137 );