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