1#! perl -w 2 3# It should not be necessary to edit this file. The configuration for 4# BerkeleyDB is controlled from the file config.in 5 6 7BEGIN { die "BerkeleyDB needs Perl 5.004_04 or greater" if $] < 5.004_04 ; } 8 9use strict ; 10use ExtUtils::MakeMaker ; 11use Config ; 12 13# Check for the presence of sfio 14if ($Config{'d_sfio'}) { 15 print <<EOM; 16 17WARNING: Perl seems to have been built with SFIO support enabled. 18 Please read the SFIO Notes in the README file. 19 20EOM 21} 22 23my $LIB_DIR ; 24my $INC_DIR ; 25my $DB_NAME ; 26my $LIBS ; 27 28ParseCONFIG() ; 29 30if (defined $DB_NAME) 31 { $LIBS = $DB_NAME } 32else { 33 if ($^O eq 'MSWin32') 34 { $LIBS = '-llibdb' } 35 elsif ($^O =~ /aix/i ) { 36 $LIBS .= '-ldb -lpthread '; 37 if ($Config{'cc'} eq 'gcc' && $Config{'osvers'} eq '5.1') 38 { $LIBS .= '-lgcc_s' } 39 } 40 else 41 { $LIBS = '-ldb' } 42} 43 44# OS2 is a special case, so check for it now. 45my $OS2 = "" ; 46$OS2 = "-DOS2" if $^O eq 'os2' ; 47 48my $WALL = ''; 49#$WALL = ' -Wall ' if $Config{'cc'} =~ /gcc/ ; 50 51 52WriteMakefile( 53 NAME => 'BerkeleyDB', 54 LIBS => ["-L${LIB_DIR} $LIBS"], 55 #MAN3PODS => {}, # Pods will be built by installman. 56 INC => "-I$INC_DIR", 57 VERSION_FROM => 'BerkeleyDB.pm', 58 XSPROTOARG => '-noprototypes', 59 DEFINE => "$OS2 $WALL", 60 #'macro' => { INSTALLDIRS => 'perl' }, 61 'dist' => {COMPRESS=>'gzip', SUFFIX=>'gz'}, 62 ($] >= 5.005 63 ? (ABSTRACT_FROM => 'BerkeleyDB.pod', 64 AUTHOR => 'Paul Marquess <pmqs@cpan.org>') 65 : () 66 ), 67 ((ExtUtils::MakeMaker->VERSION() gt '6.30') 68 ? ('LICENSE' => 'perl') 69 : () 70 ), 71 72 ); 73 74 75sub MY::libscan 76{ 77 my $self = shift ; 78 my $path = shift ; 79 80 return undef 81 if $path =~ /(~|\.bak)$/ || 82 $path =~ /^\..*\.swp$/ ; 83 84 return $path; 85} 86 87 88sub MY::postamble { 89 ' 90$(NAME).pod: $(NAME).pod.P t/examples.t.T t/examples3.t.T mkpod 91 perl ./mkpod 92 93$(NAME).xs: typemap 94 $(TOUCH) $(NAME).xs 95 96Makefile: config.in 97 98 99' ; 100} 101 102sub ParseCONFIG 103{ 104 my ($k, $v) ; 105 my @badkey = () ; 106 my %Info = () ; 107 my @Options = qw( INCLUDE LIB DBNAME ) ; 108 my %ValidOption = map {$_, 1} @Options ; 109 my %Parsed = %ValidOption ; 110 my $CONFIG = 'config.in' ; 111 112 print "Parsing $CONFIG...\n" ; 113 114 # DBNAME is optional, so pretend it has been parsed. 115 delete $Parsed{'DBNAME'} ; 116 117 open(F, "$CONFIG") or die "Cannot open file $CONFIG: $!\n" ; 118 while (<F>) { 119 s/^\s*|\s*$//g ; 120 next if /^\s*$/ or /^\s*#/ ; 121 s/\s*#\s*$// ; 122 123 ($k, $v) = split(/\s+=\s+/, $_, 2) ; 124 $k = uc $k ; 125 if ($ValidOption{$k}) { 126 delete $Parsed{$k} ; 127 $Info{$k} = $v ; 128 } 129 else { 130 push(@badkey, $k) ; 131 } 132 } 133 close F ; 134 135 print "Unknown keys in $CONFIG ignored [@badkey]\n" 136 if @badkey ; 137 138 # check parsed values 139 my @missing = () ; 140 die "The following keys are missing from $CONFIG file: [@missing]\n" 141 if @missing = keys %Parsed ; 142 143 $INC_DIR = $ENV{'BERKELEYDB_INCLUDE'} || $Info{'INCLUDE'} ; 144 $LIB_DIR = $ENV{'BERKELEYDB_LIB'} || $Info{'LIB'} ; 145 $DB_NAME = $ENV{BERKELEYDB_NAME} || $Info{'DBNAME'} ; 146 #$DB_NAME = $ENV{} || $Info{'DBNAME'} if defined $Info{'DBNAME'} ; 147 148 print "Looks Good.\n" ; 149 150} 151 152# end of file Makefile.PL 153