Makefile.PL revision 1410:1b2e7ae0aee9
1#
2# CDDL HEADER START
3#
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 2006 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26# ident	"%Z%%M%	%I%	%E% SMI"
27#
28
29require 5.6.1;
30use strict;
31use warnings;
32use ExtUtils::MakeMaker;
33
34#
35# Compare OS versions.
36#
37sub cmp_os_ver
38{
39	our ($a, $b);
40	my @v1 = split(/\./, $a);
41	my @v2 = split(/\./, $b);
42	my $diff = 0;
43	while (@v1 || @v2) {
44		last if (($diff = shift(@v1) - shift(@v2)) != 0);
45	}
46	return ($diff);
47}
48
49# Check we are on a supported OS version.
50my $rel = qx{uname -r}; chomp($rel);
51my $arch = qx{uname -p}; chomp($arch);
52my $pver = sprintf('%vd', $^V);
53
54# Figure out the appropriate Config.pm.  Use an older version if necessary.
55my $configpm = "config/$pver/$rel/$arch/Config.pm";
56if (! -f $configpm) {
57	my $p = "config/$pver";
58	my $dh;
59	opendir($dh, $p) || die("Can't read directory $_: $!\n");
60	my $old_rel = (sort(cmp_os_ver
61	    grep(-d "$p/$_" && $_ =~ /^\d[\d.]+\d$/, readdir($dh))))[-1];
62	closedir($dh);
63	if (defined($old_rel)) {
64		print(STDERR "Warning: No config file for OS version $rel, " .
65		    "using $old_rel file\n");
66		$rel = $old_rel;
67		$configpm = "config/$pver/$rel/$arch/Config.pm";
68	} else {
69		die("Unsupported version of Perl/OS/Architecture " .
70		    "$pver/$rel/$arch\n");
71	}
72}
73
74our %man1pods;
75# Only install the pods for onn-ON builds.
76if (! exists($ENV{CODEMGR_WS}) && ! exists($ENV{ENVCPPFLAGS1})) {
77	$man1pods{'pod/perlgcc.pod'} = '$(INST_MAN1DIR)/perlgcc.$(MAN1EXT)';
78}
79
80WriteMakefile(
81    NAME         => 'Sun::Solaris::PerlGcc',
82    VERSION_FROM => 'perlgcc.PL',
83    PL_FILES     => { 'perlgcc.PL' => 'perlgcc' },
84    EXE_FILES    => [ 'perlgcc' ],
85    PM           => { $configpm => '$(INST_LIBDIR)/PerlGcc/Config.pm' },
86    MAN1PODS     => \%man1pods,
87    MAN3PODS     => { }, # Stop autopodification.
88    clean        => { FILES => 'perlgcc' },
89);
90