File: Makefile.PL

package info (click to toggle)
libberkeleydb-perl 0.55-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,480 kB
  • ctags: 331
  • sloc: perl: 11,228; ansic: 6,451; makefile: 56
file content (152 lines) | stat: -rw-r--r-- 3,211 bytes parent folder | download | duplicates (20)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#! perl -w

# It should not be necessary to edit this file. The configuration for
# BerkeleyDB is controlled from the file config.in


BEGIN { die "BerkeleyDB needs Perl 5.004_04 or greater" if $] < 5.004_04 ; }

use strict ;
use ExtUtils::MakeMaker ;
use Config ;

# Check for the presence of sfio
if ($Config{'d_sfio'}) {
   print <<EOM;

WARNING: Perl seems to have been built with SFIO support enabled.
         Please read the SFIO Notes in the README file.

EOM
}

my $LIB_DIR ;
my $INC_DIR ;
my $DB_NAME ;
my $LIBS ;

ParseCONFIG() ;

if (defined $DB_NAME)
  { $LIBS = $DB_NAME }
else {
    if ($^O eq 'MSWin32')
      { $LIBS = '-llibdb' }
    elsif ($^O =~ /aix/i )  {
      $LIBS .= '-ldb -lpthread ';
      if ($Config{'cc'} eq 'gcc' && $Config{'osvers'} eq '5.1')
        { $LIBS .= '-lgcc_s' }
    }
    else
      { $LIBS = '-ldb' }
}

# OS2 is a special case, so check for it now.
my $OS2 = "" ;
$OS2 = "-DOS2" if $^O eq 'os2' ;

my $WALL = '';
#$WALL = ' -Wall ' if $Config{'cc'} =~ /gcc/ ;


WriteMakefile(
	NAME 		=> 'BerkeleyDB',
	LIBS 		=> ["-L${LIB_DIR} $LIBS"],
	#MAN3PODS        => {},         # Pods will be built by installman. 
	INC		=> "-I$INC_DIR",
	VERSION_FROM	=> 'BerkeleyDB.pm',
	XSPROTOARG	=> '-noprototypes',
	DEFINE		=> "$OS2 $WALL",
	#'macro'		=> { INSTALLDIRS => 'perl' },
        'dist'          => {COMPRESS=>'gzip', SUFFIX=>'gz'},    
	($] >= 5.005
	    ? (ABSTRACT_FROM	=> 'BerkeleyDB.pod',
	       AUTHOR  	=> 'Paul Marquess <pmqs@cpan.org>')
	    : ()
	),
    ((ExtUtils::MakeMaker->VERSION() gt '6.30') 
        ?  ('LICENSE'  => 'perl')         
        : ()
    ),

	);


sub MY::libscan
{
    my $self = shift ;
    my $path = shift ;

    return undef
        if $path =~ /(~|\.bak)$/ || 
           $path =~ /^\..*\.swp$/ ;

    return $path;    
}

    
sub MY::postamble {
	'
$(NAME).pod:	$(NAME).pod.P t/examples.t.T t/examples3.t.T mkpod
	perl ./mkpod

$(NAME).xs:	typemap
	$(TOUCH) $(NAME).xs

Makefile:	config.in 


' ;
}

sub ParseCONFIG
{
    my ($k, $v) ;
    my @badkey = () ;
    my %Info = () ;
    my @Options = qw( INCLUDE LIB DBNAME ) ;
    my %ValidOption = map {$_, 1} @Options ;
    my %Parsed = %ValidOption ;
    my $CONFIG = 'config.in' ;

    print "Parsing $CONFIG...\n" ;

    # DBNAME is optional, so pretend it has been parsed.
    delete $Parsed{'DBNAME'} ;

    open(F, "$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
    while (<F>) {
	s/^\s*|\s*$//g ;
	next if /^\s*$/ or /^\s*#/ ;
	s/\s*#\s*$// ;

	($k, $v) = split(/\s+=\s+/, $_, 2) ;
	$k = uc $k ;
	if ($ValidOption{$k}) {
	    delete $Parsed{$k} ;
	    $Info{$k} = $v ;
	}
	else {
	    push(@badkey, $k) ;
	}
    }
    close F ;

    print "Unknown keys in $CONFIG ignored [@badkey]\n"
	if @badkey ;

    # check parsed values
    my @missing = () ;
    die "The following keys are missing from $CONFIG file: [@missing]\n" 
        if @missing = keys %Parsed ;

    $INC_DIR =  $ENV{'BERKELEYDB_INCLUDE'} || $Info{'INCLUDE'} ;
    $LIB_DIR =  $ENV{'BERKELEYDB_LIB'} || $Info{'LIB'} ;
    $DB_NAME = $ENV{BERKELEYDB_NAME} || $Info{'DBNAME'} ;
    #$DB_NAME =  $ENV{} || $Info{'DBNAME'} if defined $Info{'DBNAME'} ;

    print "Looks Good.\n" ;

}

# end of file Makefile.PL