Home | History | Annotate | Download | only in Object
      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 # Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
     23 # Use is subject to license terms.
     24 #
     25 # Makefile.PL for ::Exacct::Object
     26 #
     27 
     28 # See ../Makefile.PL for an explanation of the linker flag manipulations.
     29 
     30 require 5.8.4;
     31 use strict;
     32 use warnings;
     33 use ExtUtils::MakeMaker;
     34 
     35 #
     36 # Some later versions of ExtUtils::MakeMaker are broken,
     37 # and complain about function redefinitions in the child Makefile.PLs.
     38 # Stop the warnings.
     39 #
     40 no warnings qw(redefine);
     41 
     42 our (@defines, @man3pods);
     43 
     44 #
     45 # MakeMaker overrides.
     46 #
     47 package MY;
     48 no warnings qw(once);
     49 
     50 #
     51 # Overrides that are common to both the ON and non-ON build environments.
     52 #
     53 
     54 #
     55 # Suppress the setting of LD_RUN_PATH, as it isn't necessary.
     56 #
     57 
     58 sub const_loadlibs
     59 {
     60 	my $self = shift(@_);
     61 	delete($self->{LD_RUN_PATH});
     62 	return($self->SUPER::const_loadlibs(@_));
     63 }
     64 
     65 sub dynamic_lib
     66 {
     67 	my $self = shift(@_);
     68 	my $txt = $self->SUPER::dynamic_lib(@_);
     69 	$txt =~ s/LD_RUN_PATH=\S*\s*//;
     70 	return($txt);
     71 }
     72 
     73 #
     74 # ON-specific overrides.
     75 #
     76 if (exists($ENV{CODEMGR_WS}) && exists($ENV{ENVCPPFLAGS1})) {
     77 	#
     78 	# Override postamble and replace it with one that explicitly records
     79 	# the dependency between Object.c (generated from Object.xs by xsubpp)
     80 	# and the ObjectDefs.xi file (generated from sys/exacct.h by
     81 	# extract_defines).  Note we have to mimic the -I processing done by cc
     82 	# to find the correct version of the file, as we want the copy from the
     83 	# proto area rather than /usr/include.  This ensures that the constant
     84 	# values exported by the perl module stay up-to date with the
     85 	# corresponding #defines.
     86 	#
     87 	*postamble = sub {
     88 		return <<'EOF';
     89 EXACCT_H:sh= \
     90 	for dir in $ENVCPPFLAGS1 $ENVCPPFLAGS2 $ENVCPPFLAGS3 $ENVCPPFLAGS4 \
     91 	    /usr/include; do \
     92 		dir=`expr $dir : '^-I\(.*\)$' \| $dir`; \
     93 		file="$dir/sys/exacct.h"; \
     94 		test -f $file && echo $file && break; \
     95 	done;
     96 
     97 Object.c:	ObjectDefs.xi
     98 
     99 ObjectDefs.xi:	../extract_defines $(EXACCT_H)
    100 	$(PERL) ../extract_defines Object $@ $(EXACCT_H)
    101 EOF
    102 	};
    103 
    104 	# Enable/disable debugging as required.
    105 	@main::defines = ( DEFINE => '-DEXACCT_DEBUG' )
    106 	    if (! exists($ENV{RELEASE_BUILD}));
    107 
    108 	# Don't install POD pages for ON.
    109 	@main::man3pods = ( MAN3PODS => {} );
    110 
    111 #
    112 # Non-ON overrides.
    113 #
    114 } else {
    115 	#
    116 	# Override postamble and replace it with one that explicitly records
    117 	# the dependency between Object.c (generated from Object.xs by xsubpp)
    118 	# and the ObjectDefs.xi file (generated from /usr/include/sys/exacct.h
    119 	# by # extract_defines).  This ensures # that the constant values
    120 	# exported by the perl module stay up-to date with the corresponding
    121 	# #defines.
    122 	#
    123 	*postamble = sub {
    124 		return <<'EOF';
    125 EXACCT_H = /usr/include/sys/exacct.h
    126 
    127 Object.c:	ObjectDefs.xi
    128 
    129 ObjectDefs.xi:	../extract_defines $(EXACCT_H)
    130 	$(PERL) ../extract_defines Object $@ $(EXACCT_H)
    131 EOF
    132 	};
    133 
    134 	# Install the POD documentation for non-ON builds.
    135 	my $man3pfx = '$(INST_MAN3DIR)/Sun::Solaris::Exacct';
    136 	@main::man3pods = ( MAN3PODS => {
    137 	    '../pod/Object.pod' => $man3pfx . '::Object.$(MAN3EXT)',
    138 	    '../pod/Item.pod' => $man3pfx . '::Object::Item.$(MAN3EXT)',
    139 	    '../pod/Group.pod' => $man3pfx . '::Object::Group.$(MAN3EXT)'
    140 	});
    141 }
    142 
    143 #
    144 # Having set everything up, write the Makefile.
    145 #
    146 package main;
    147 
    148 WriteMakefile(
    149     NAME         => 'Sun::Solaris::Exacct::Object',
    150     VERSION_FROM => 'Object.pm',
    151     H            => [ '../exacct_common.xh' ],
    152     TYPEMAPS     => [ '../typemap' ],
    153     @defines,
    154     @man3pods,
    155     dynamic_lib  => { OTHERLDFLAGS =>
    156         '-h $(DLBASE).$(DLEXT) ' .
    157         '-R\$$ORIGIN/.. $(INST_ARCHAUTODIR)/../Exacct.so'
    158 	},
    159     realclean    => { FILES => 'ObjectDefs.xi' },
    160 );
    161