xref: /onnv-gate/usr/src/cmd/perl/contrib/Sun/Solaris/PerlGcc/Makefile.PL (revision 12639:884a64bb4385)
10Sstevel@tonic-gate#
20Sstevel@tonic-gate# CDDL HEADER START
30Sstevel@tonic-gate#
40Sstevel@tonic-gate# The contents of this file are subject to the terms of the
51410Salanbur# Common Development and Distribution License (the "License").
61410Salanbur# You may not use this file except in compliance with the License.
70Sstevel@tonic-gate#
80Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate# See the License for the specific language governing permissions
110Sstevel@tonic-gate# and limitations under the License.
120Sstevel@tonic-gate#
130Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate#
190Sstevel@tonic-gate# CDDL HEADER END
200Sstevel@tonic-gate#
211410Salanbur
220Sstevel@tonic-gate#
23*12639SJohn.Sonnenschein@Oracle.com# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate#
250Sstevel@tonic-gate
268287SJohn.Sonnenschein@Sun.COMrequire 5.8.4;
270Sstevel@tonic-gateuse strict;
280Sstevel@tonic-gateuse warnings;
290Sstevel@tonic-gateuse ExtUtils::MakeMaker;
300Sstevel@tonic-gate
311410Salanbur#
321410Salanbur# Compare OS versions.
331410Salanbur#
341410Salanbursub cmp_os_ver
351410Salanbur{
361410Salanbur	our ($a, $b);
371410Salanbur	my @v1 = split(/\./, $a);
381410Salanbur	my @v2 = split(/\./, $b);
391410Salanbur	my $diff = 0;
401410Salanbur	while (@v1 || @v2) {
411410Salanbur		last if (($diff = shift(@v1) - shift(@v2)) != 0);
421410Salanbur	}
431410Salanbur	return ($diff);
441410Salanbur}
451410Salanbur
460Sstevel@tonic-gate# Check we are on a supported OS version.
471410Salanburmy $rel = qx{uname -r}; chomp($rel);
481410Salanburmy $arch = qx{uname -p}; chomp($arch);
490Sstevel@tonic-gatemy $pver = sprintf('%vd', $^V);
500Sstevel@tonic-gate
511410Salanbur# Figure out the appropriate Config.pm.  Use an older version if necessary.
52*12639SJohn.Sonnenschein@Oracle.commy $perlarch = ($arch eq "sparc") ? "sun4-solaris-64int":"i86pc-solaris-64int";
53*12639SJohn.Sonnenschein@Oracle.com
54*12639SJohn.Sonnenschein@Oracle.commy $configpm = "/usr/perl5/$pver/lib/$perlarch/Config.pm";
551410Salanburif (! -f $configpm) {
561410Salanbur	my $p = "config/$pver";
571410Salanbur	my $dh;
581410Salanbur	opendir($dh, $p) || die("Can't read directory $_: $!\n");
591410Salanbur	my $old_rel = (sort(cmp_os_ver
601410Salanbur	    grep(-d "$p/$_" && $_ =~ /^\d[\d.]+\d$/, readdir($dh))))[-1];
611410Salanbur	closedir($dh);
621410Salanbur	if (defined($old_rel)) {
631410Salanbur		print(STDERR "Warning: No config file for OS version $rel, " .
641410Salanbur		    "using $old_rel file\n");
651410Salanbur		$rel = $old_rel;
661410Salanbur		$configpm = "config/$pver/$rel/$arch/Config.pm";
671410Salanbur	} else {
681410Salanbur		die("Unsupported version of Perl/OS/Architecture " .
691410Salanbur		    "$pver/$rel/$arch\n");
701410Salanbur	}
71*12639SJohn.Sonnenschein@Oracle.com} else {
72*12639SJohn.Sonnenschein@Oracle.com	open CONFIGPM, "<", $configpm or die $!;
73*12639SJohn.Sonnenschein@Oracle.com	open CONFIGPM_OUT, ">", "Config.pm" or die $!;
74*12639SJohn.Sonnenschein@Oracle.com	while(<CONFIGPM>) {
75*12639SJohn.Sonnenschein@Oracle.com		if (/'cc/) {
76*12639SJohn.Sonnenschein@Oracle.com			s/=>\s*'cc/=> 'gcc/;
77*12639SJohn.Sonnenschein@Oracle.com			s/=\s*'cc/='gcc/;
78*12639SJohn.Sonnenschein@Oracle.com		}
79*12639SJohn.Sonnenschein@Oracle.com		print CONFIGPM_OUT $_;
80*12639SJohn.Sonnenschein@Oracle.com	}
81*12639SJohn.Sonnenschein@Oracle.com	close CONFIGPM;
82*12639SJohn.Sonnenschein@Oracle.com	close CONFIGPM_OUT;
83*12639SJohn.Sonnenschein@Oracle.com	$configpm = "Config.pm";
841410Salanbur}
850Sstevel@tonic-gate
860Sstevel@tonic-gateour %man1pods;
870Sstevel@tonic-gate# Only install the pods for onn-ON builds.
880Sstevel@tonic-gateif (! exists($ENV{CODEMGR_WS}) && ! exists($ENV{ENVCPPFLAGS1})) {
890Sstevel@tonic-gate	$man1pods{'pod/perlgcc.pod'} = '$(INST_MAN1DIR)/perlgcc.$(MAN1EXT)';
900Sstevel@tonic-gate}
910Sstevel@tonic-gate
920Sstevel@tonic-gateWriteMakefile(
930Sstevel@tonic-gate    NAME         => 'Sun::Solaris::PerlGcc',
940Sstevel@tonic-gate    VERSION_FROM => 'perlgcc.PL',
950Sstevel@tonic-gate    PL_FILES     => { 'perlgcc.PL' => 'perlgcc' },
960Sstevel@tonic-gate    EXE_FILES    => [ 'perlgcc' ],
970Sstevel@tonic-gate    PM           => { $configpm => '$(INST_LIBDIR)/PerlGcc/Config.pm' },
980Sstevel@tonic-gate    MAN1PODS     => \%man1pods,
990Sstevel@tonic-gate    MAN3PODS     => { }, # Stop autopodification.
1000Sstevel@tonic-gate    clean        => { FILES => 'perlgcc' },
1010Sstevel@tonic-gate);
102