1 #
   2 # Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved.
   3 #
   4 
   5 #
   6 # Makefile.PL for ::Exacct::File
   7 #
   8 
   9 # See ../Makefile.PL for an explanation of the linker flag manipulations.
  10 
  11 require 5.8.4;
  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 File.c (generated from File.xs by xsubpp)
  61         # and the FileDefs.xi file (generated from sys/exacct_catalog.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/exacct.h"; \
  75                 test -f $file && echo $file && break; \
  76         done;
  77 
  78 File.c: FileDefs.xi
  79 
  80 FileDefs.xi:    ../extract_defines $(EXACCT_H)
  81         $(PERL) ../extract_defines File $@ $(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 File.c (generated from File.xs by xsubpp)
  99         # and the FileDefs.xi file (generated from /usr/include/exacct.h by
 100         # extract_defines).  This ensures # that the constant values exported
 101         # by the perl module stay up-to date with the corresponding #defines.
 102         #
 103         *postamble = sub {
 104                 return <<'EOF';
 105 EXACCT_H = /usr/include/exacct.h
 106 
 107 File.c: FileDefs.xi
 108 
 109 FileDefs.xi:    ../extract_defines $(EXACCT_H)
 110         $(PERL) ../extract_defines File $@ $(EXACCT_H)
 111 EOF
 112         };
 113 
 114         # Install the POD documentation for non-ON builds.
 115         my $man3pfx = '$(INST_MAN3DIR)/Sun::Solaris::Exacct';
 116         @main::man3pods = (
 117             MAN3PODS => { '../pod/File.pod' =>
 118             $man3pfx . '::File.$(MAN3EXT)' }
 119         );
 120 }
 121 
 122 #
 123 # Having set everything up, write the Makefile.
 124 #
 125 package main;
 126 
 127 WriteMakefile(
 128     NAME         => 'Sun::Solaris::Exacct::File',
 129     VERSION_FROM => 'File.pm',
 130     H            => [ '../exacct_common.xh' ],
 131     TYPEMAPS     => [ '../typemap' ],
 132     @defines,
 133     @man3pods,
 134     dynamic_lib  => { OTHERLDFLAGS =>
 135         '-h $(DLBASE).$(DLEXT) ' .
 136         '-R\$$ORIGIN/.. $(INST_ARCHAUTODIR)/../Exacct.so'
 137         },
 138     realclean    => { FILES => 'FileDefs.xi' },
 139 );