10Sstevel@tonic-gate# 2*12388SJohn.Sonnenschein@Sun.COM# Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. 30Sstevel@tonic-gate# 4*12388SJohn.Sonnenschein@Sun.COM 50Sstevel@tonic-gate# 60Sstevel@tonic-gate# Makefile.PL for ::Exacct 70Sstevel@tonic-gate# 80Sstevel@tonic-gate 90Sstevel@tonic-gate# 100Sstevel@tonic-gate# Linker flags note: 110Sstevel@tonic-gate# The various .so files that comprise the ::Exacct module need to be able to 120Sstevel@tonic-gate# cross-call each other, and therefore to prevent runtime linker errors it is 130Sstevel@tonic-gate# necessary to establish linker dependencies between the various .so files. 140Sstevel@tonic-gate# 150Sstevel@tonic-gate# This causes several problems. The first of these is that perl .so files are 160Sstevel@tonic-gate# built in one directory (under ../blib in this case) and installed into 170Sstevel@tonic-gate# another, so it is necessary to record the dependency using a path relative to 180Sstevel@tonic-gate# the dependent. This can be done with the $ORIGIN linker mechanism. 190Sstevel@tonic-gate 200Sstevel@tonic-gate# The second problem is that it is necessary to specify the name of the 210Sstevel@tonic-gate# dependee at link edit time in a manner that doesn't result in the build-time 220Sstevel@tonic-gate# path of the dependee being hard coded in to the dependent, as this would 230Sstevel@tonic-gate# stop ld.so.1 performing its normal search process for the files. This can't 240Sstevel@tonic-gate# be done with the normal '--L/my/lib/path -lmylib' mechanism, because the XSUB 250Sstevel@tonic-gate# .so files aren't prefixed with 'lib'. To do this the -h linker flag is used 260Sstevel@tonic-gate# to explicitly set the SONAME in the dependee. This is then used as the name 270Sstevel@tonic-gate# of the dependent in the dependee rather than the full path by which it was 280Sstevel@tonic-gate# found at link edit time. 290Sstevel@tonic-gate# 300Sstevel@tonic-gate# For more details, refer to the Linker and Libraries Guide. 310Sstevel@tonic-gate# 320Sstevel@tonic-gate 338287SJohn.Sonnenschein@Sun.COMrequire 5.8.4; 340Sstevel@tonic-gateuse strict; 350Sstevel@tonic-gateuse warnings; 360Sstevel@tonic-gateuse ExtUtils::MakeMaker; 370Sstevel@tonic-gate 380Sstevel@tonic-gateour (@defines, @man3pods); 390Sstevel@tonic-gate 400Sstevel@tonic-gate# 410Sstevel@tonic-gate# MakeMaker overrides. 420Sstevel@tonic-gate# 430Sstevel@tonic-gatepackage MY; 440Sstevel@tonic-gateno warnings qw(once); 450Sstevel@tonic-gate 460Sstevel@tonic-gate# 470Sstevel@tonic-gate# Overrides that are common to both the ON and non-ON build environments. 480Sstevel@tonic-gate# 490Sstevel@tonic-gate 500Sstevel@tonic-gate# 510Sstevel@tonic-gate# Force the parent directory to be built first, because the sub-modules all 520Sstevel@tonic-gate# have a linker dependency against Exacct.so. 530Sstevel@tonic-gate# 540Sstevel@tonic-gatesub top_targets 550Sstevel@tonic-gate{ 560Sstevel@tonic-gate my $self = shift(@_); 570Sstevel@tonic-gate my $txt = $self->SUPER::top_targets(@_); 580Sstevel@tonic-gate $txt =~ s/pm_to_blib subdirs/pm_to_blib \$(LINKTYPE) .WAIT subdirs/; 590Sstevel@tonic-gate return($txt); 600Sstevel@tonic-gate} 610Sstevel@tonic-gate 620Sstevel@tonic-gate# 630Sstevel@tonic-gate# Make 'install' wait for 'all' to complete. 640Sstevel@tonic-gate# 650Sstevel@tonic-gatesub install 660Sstevel@tonic-gate{ 670Sstevel@tonic-gate my $self = shift(@_); 680Sstevel@tonic-gate my $txt = $self->SUPER::install(@_); 690Sstevel@tonic-gate $txt =~ s/ all / all .WAIT /g; 700Sstevel@tonic-gate return($txt); 710Sstevel@tonic-gate} 720Sstevel@tonic-gate 730Sstevel@tonic-gate# 740Sstevel@tonic-gate# Suppress the setting of LD_RUN_PATH, as it isn't necessary. 750Sstevel@tonic-gate# 760Sstevel@tonic-gatesub const_loadlibs 770Sstevel@tonic-gate{ 780Sstevel@tonic-gate my $self = shift(@_); 790Sstevel@tonic-gate delete($self->{LD_RUN_PATH}); 800Sstevel@tonic-gate return($self->SUPER::const_loadlibs(@_)); 810Sstevel@tonic-gate} 820Sstevel@tonic-gate 830Sstevel@tonic-gatesub dynamic_lib 840Sstevel@tonic-gate{ 850Sstevel@tonic-gate my $self = shift(@_); 860Sstevel@tonic-gate my $txt = $self->SUPER::dynamic_lib(@_); 870Sstevel@tonic-gate $txt =~ s/LD_RUN_PATH=\S*\s*//; 880Sstevel@tonic-gate return($txt); 890Sstevel@tonic-gate} 900Sstevel@tonic-gate 910Sstevel@tonic-gate# 920Sstevel@tonic-gate# ON-specific overrides. 930Sstevel@tonic-gate# 940Sstevel@tonic-gateif (exists($ENV{CODEMGR_WS}) && exists($ENV{ENVCPPFLAGS1})) { 950Sstevel@tonic-gate # 960Sstevel@tonic-gate # Override postamble and replace it with one that explicitly records 970Sstevel@tonic-gate # the dependency between Exacct.c (generated from Exacct.xs by xsubpp) 980Sstevel@tonic-gate # and the ExacctDefs.xi file (generated from sys/exacct.h by 990Sstevel@tonic-gate # extract_defines). Note we have to mimic the -I processing done by cc 1000Sstevel@tonic-gate # to find the correct version of the file, as we want the copy from the 1010Sstevel@tonic-gate # proto area rather than /usr/include. This ensures that the constant 1020Sstevel@tonic-gate # values exported by the perl module stay up-to date with the 1030Sstevel@tonic-gate # corresponding #defines. 1040Sstevel@tonic-gate # 1050Sstevel@tonic-gate *postamble = sub { 1060Sstevel@tonic-gate return <<'EOF'; 1070Sstevel@tonic-gateEXACCT_H:sh= \ 1080Sstevel@tonic-gate for dir in $ENVCPPFLAGS1 $ENVCPPFLAGS2 $ENVCPPFLAGS3 $ENVCPPFLAGS4 \ 1090Sstevel@tonic-gate /usr/include; do \ 1100Sstevel@tonic-gate dir=`expr $dir : '^-I\(.*\)$' \| $dir`; \ 1110Sstevel@tonic-gate file="$dir/sys/exacct.h"; \ 1120Sstevel@tonic-gate test -f $file && echo $file && break; \ 1130Sstevel@tonic-gate done; 1140Sstevel@tonic-gate 1150Sstevel@tonic-gateExacct.c: ExacctDefs.xi 1160Sstevel@tonic-gate 1170Sstevel@tonic-gateExacctDefs.xi: extract_defines $(EXACCT_H) 1180Sstevel@tonic-gate $(PERL) extract_defines Exacct $@ $(EXACCT_H) 1190Sstevel@tonic-gateEOF 1200Sstevel@tonic-gate }; 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate # Enable/disable debugging as required. 1230Sstevel@tonic-gate @main::defines = ( DEFINE => '-DEXACCT_DEBUG' ) 1240Sstevel@tonic-gate if (! exists($ENV{RELEASE_BUILD})); 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate # Don't install POD pages for ON. 1270Sstevel@tonic-gate @main::man3pods = ( MAN3PODS => {} ); 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate# 1300Sstevel@tonic-gate# Non-ON overrides. 1310Sstevel@tonic-gate# 1320Sstevel@tonic-gate} else { 1330Sstevel@tonic-gate # 1340Sstevel@tonic-gate # Override postamble and replace it with one that explicitly records 1350Sstevel@tonic-gate # the dependency between Exacct.c (generated from Exacct.xs by xsubpp) 1360Sstevel@tonic-gate # and the ExacctDefs.xi file (generated from /usr/include/sys/exacct.h 1370Sstevel@tonic-gate # by extract_defines). This ensures that the constant values exported 1380Sstevel@tonic-gate # by the perl module stay up-to date with the corresponding #defines. 1390Sstevel@tonic-gate # 1400Sstevel@tonic-gate *postamble = sub { 1410Sstevel@tonic-gate return <<'EOF'; 1420Sstevel@tonic-gateEXACCT_H = /usr/include/sys/exacct.h 1430Sstevel@tonic-gate 1440Sstevel@tonic-gateExacct.c: ExacctDefs.xi 1450Sstevel@tonic-gate 1460Sstevel@tonic-gateExacctDefs.xi: extract_defines $(EXACCT_H) 1470Sstevel@tonic-gate $(PERL) extract_defines Exacct $@ $(EXACCT_H) 1480Sstevel@tonic-gateEOF 1490Sstevel@tonic-gate }; 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate # Install the POD documentation for non-ON builds. 1520Sstevel@tonic-gate my $man3pfx = '$(INST_MAN3DIR)/Sun::Solaris::Exacct'; 1530Sstevel@tonic-gate @main::man3pods = ( 1540Sstevel@tonic-gate MAN3PODS => { 'pod/Exacct.pod' => $man3pfx . '.$(MAN3EXT)' } 1550Sstevel@tonic-gate ); 1560Sstevel@tonic-gate} 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate# 1590Sstevel@tonic-gate# Having set everything up, write the Makefile. 1600Sstevel@tonic-gate# 1610Sstevel@tonic-gatepackage main; 1620Sstevel@tonic-gate 1630Sstevel@tonic-gateWriteMakefile( 1640Sstevel@tonic-gate NAME => 'Sun::Solaris::Exacct', 1650Sstevel@tonic-gate VERSION_FROM => 'Exacct.pm', 1660Sstevel@tonic-gate DIR => [ qw(Catalog File Object) ], 1670Sstevel@tonic-gate H => [ 'exacct_common.xh' ], 1680Sstevel@tonic-gate LIBS => [ '-lexacct' ], 1690Sstevel@tonic-gate @defines, 1700Sstevel@tonic-gate @man3pods, 1710Sstevel@tonic-gate dynamic_lib => { OTHERLDFLAGS => '-h $(DLBASE).$(DLEXT)' }, 1720Sstevel@tonic-gate realclean => { FILES => 'ExacctDefs.xi' }, 1730Sstevel@tonic-gate); 174