1 # 2 # Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. 3 # 4 5 # 6 # Makefile.PL for ::Exacct 7 # 8 9 # 10 # Linker flags note: 11 # The various .so files that comprise the ::Exacct module need to be able to 12 # cross-call each other, and therefore to prevent runtime linker errors it is 13 # necessary to establish linker dependencies between the various .so files. 14 # 15 # This causes several problems. The first of these is that perl .so files are 16 # built in one directory (under ../blib in this case) and installed into 17 # another, so it is necessary to record the dependency using a path relative to 18 # the dependent. This can be done with the $ORIGIN linker mechanism. 19 20 # The second problem is that it is necessary to specify the name of the 21 # dependee at link edit time in a manner that doesn't result in the build-time 22 # path of the dependee being hard coded in to the dependent, as this would 23 # stop ld.so.1 performing its normal search process for the files. This can't 24 # be done with the normal '--L/my/lib/path -lmylib' mechanism, because the XSUB 25 # .so files aren't prefixed with 'lib'. To do this the -h linker flag is used 26 # to explicitly set the SONAME in the dependee. This is then used as the name 27 # of the dependent in the dependee rather than the full path by which it was 28 # found at link edit time. 29 # 30 # For more details, refer to the Linker and Libraries Guide. 31 # 32 33 require 5.8.4; 34 use strict; 35 use warnings; 36 use ExtUtils::MakeMaker; 37 38 our (@defines, @man3pods); 39 40 # 41 # MakeMaker overrides. 42 # 43 package MY; 44 no warnings qw(once); 45 46 # 47 # Overrides that are common to both the ON and non-ON build environments. 48 # 49 50 # 51 # Force the parent directory to be built first, because the sub-modules all 52 # have a linker dependency against Exacct.so. 53 # 54 sub top_targets 55 { 56 my $self = shift(@_); 57 my $txt = $self->SUPER::top_targets(@_); 58 $txt =~ s/pm_to_blib subdirs/pm_to_blib \$(LINKTYPE) .WAIT subdirs/; 59 return($txt); 60 } 61 62 # 63 # Make 'install' wait for 'all' to complete. 64 # 65 sub install 66 { 67 my $self = shift(@_); 68 my $txt = $self->SUPER::install(@_); 69 $txt =~ s/ all / all .WAIT /g; 70 return($txt); 71 } 72 73 # 74 # Suppress the setting of LD_RUN_PATH, as it isn't necessary. 75 # 76 sub const_loadlibs 77 { 78 my $self = shift(@_); 79 delete($self->{LD_RUN_PATH}); 80 return($self->SUPER::const_loadlibs(@_)); 81 } 82 83 sub dynamic_lib 84 { 85 my $self = shift(@_); 86 my $txt = $self->SUPER::dynamic_lib(@_); 87 $txt =~ s/LD_RUN_PATH=\S*\s*//; 88 return($txt); 89 } 90 91 # 92 # ON-specific overrides. 93 # 94 if (exists($ENV{CODEMGR_WS}) && exists($ENV{ENVCPPFLAGS1})) { 95 # 96 # Override postamble and replace it with one that explicitly records 97 # the dependency between Exacct.c (generated from Exacct.xs by xsubpp) 98 # and the ExacctDefs.xi file (generated from sys/exacct.h by 99 # extract_defines). Note we have to mimic the -I processing done by cc 100 # to find the correct version of the file, as we want the copy from the 101 # proto area rather than /usr/include. This ensures that the constant 102 # values exported by the perl module stay up-to date with the 103 # corresponding #defines. 104 # 105 *postamble = sub { 106 return <<'EOF'; 107 EXACCT_H:sh= \ 108 for dir in $ENVCPPFLAGS1 $ENVCPPFLAGS2 $ENVCPPFLAGS3 $ENVCPPFLAGS4 \ 109 /usr/include; do \ 110 dir=`expr $dir : '^-I\(.*\)$' \| $dir`; \ 111 file="$dir/sys/exacct.h"; \ 112 test -f $file && echo $file && break; \ 113 done; 114 115 Exacct.c: ExacctDefs.xi 116 117 ExacctDefs.xi: extract_defines $(EXACCT_H) 118 $(PERL) extract_defines Exacct $@ $(EXACCT_H) 119 EOF 120 }; 121 122 # Enable/disable debugging as required. 123 @main::defines = ( DEFINE => '-DEXACCT_DEBUG' ) 124 if (! exists($ENV{RELEASE_BUILD})); 125 126 # Don't install POD pages for ON. 127 @main::man3pods = ( MAN3PODS => {} ); 128 129 # 130 # Non-ON overrides. 131 # 132 } else { 133 # 134 # Override postamble and replace it with one that explicitly records 135 # the dependency between Exacct.c (generated from Exacct.xs by xsubpp) 136 # and the ExacctDefs.xi file (generated from /usr/include/sys/exacct.h 137 # by extract_defines). This ensures that the constant values exported 138 # by the perl module stay up-to date with the corresponding #defines. 139 # 140 *postamble = sub { 141 return <<'EOF'; 142 EXACCT_H = /usr/include/sys/exacct.h 143 144 Exacct.c: ExacctDefs.xi 145 146 ExacctDefs.xi: extract_defines $(EXACCT_H) 147 $(PERL) extract_defines Exacct $@ $(EXACCT_H) 148 EOF 149 }; 150 151 # Install the POD documentation for non-ON builds. 152 my $man3pfx = '$(INST_MAN3DIR)/Sun::Solaris::Exacct'; 153 @main::man3pods = ( 154 MAN3PODS => { 'pod/Exacct.pod' => $man3pfx . '.$(MAN3EXT)' } 155 ); 156 } 157 158 # 159 # Having set everything up, write the Makefile. 160 # 161 package main; 162 163 WriteMakefile( 164 NAME => 'Sun::Solaris::Exacct', 165 VERSION_FROM => 'Exacct.pm', 166 DIR => [ qw(Catalog File Object) ], 167 H => [ 'exacct_common.xh' ], 168 LIBS => [ '-lexacct' ], 169 @defines, 170 @man3pods, 171 dynamic_lib => { OTHERLDFLAGS => '-h $(DLBASE).$(DLEXT)' }, 172 realclean => { FILES => 'ExacctDefs.xi' }, 173 );