4 use ExtUtils::MakeMaker 5.16 ;
7 die "DB_File needs Perl 5.8.3 or better. This is $]\n"
19 my @files = ('DB_File.pm', glob "t/*.t") ;
26 { $LIBS = $Config{cc} =~ /gcc/ ? '-ldb' : '-llibdb' }
32 #$LIBS .= " -lthread" if $^O eq 'solaris' ;
35 $LIBS .= " -lpthread" if $^O eq 'aix' ;
37 # OS2 is a special case, so check for it now.
39 $OS2 = "-DOS2" if $Config{'osname'} eq 'os2' ;
46 LIBS => ["-L${LIB_DIR} $LIBS"],
48 VERSION_FROM => 'DB_File.pm',
49 XS_VERSION => eval MM->parse_version('DB_File.pm'),
50 XSPROTOARG => '-noprototypes',
51 DEFINE => "-D_NOT_CORE $OS2 $VER_INFO $COMPAT185 $WALL",
52 OBJECT => 'version$(OBJ_EXT) DB_File$(OBJ_EXT)',
53 ((ExtUtils::MakeMaker->VERSION() gt '6.30')
54 ? ('LICENSE' => 'perl')
59 ? (ABSTRACT_FROM => 'DB_File.pm',
60 AUTHOR => 'Paul Marquess <pmqs@cpan.org>')
64 ($] < 5.008 || $] > 5.011)
65 ? (INSTALLDIRS => 'site')
66 : (INSTALLDIRS => 'perl'),
69 'depend' => { 'Makefile' => 'config.in',
70 'version$(OBJ_EXT)' => 'version.c'},
71 'clean' => { FILES => 'constants.h constants.xs DB_File.pm.bak t/db-btree.t.bak t/db-hash.t.bak t/db-recno.t.bak t/pod.t.bak' },
72 'macro' => { my_files => "@files" },
73 'dist' => { COMPRESS => 'gzip', SUFFIX => 'gz',
74 DIST_DEFAULT => 'MyDoubleCheck tardist'},
109 if (eval {require ExtUtils::Constant; 1}) {
110 # Check the constants above all appear in @EXPORT in DB_File.pm
111 my %names = map { $_, 1} @names;
112 open F, "<DB_File.pm" or die "Cannot open DB_File.pm: $!\n";
115 last if /^\s*\@EXPORT\s+=\s+qw\(/ ;
122 delete $names{$1} if defined $1 ;
128 my $missing = join ("\n\t", sort keys %names) ;
129 die "The following names are missing from \@EXPORT in DB_File.pm\n" .
134 ExtUtils::Constant::WriteConstants(
137 C_FILE => 'constants.h',
138 XS_FILE => 'constants.xs',
144 copy ('fallback.h', 'constants.h')
145 or die "Can't copy fallback.h to constants.h: $!";
146 copy ('fallback.xs', 'constants.xs')
147 or die "Can't copy fallback.xs to constants.xs: $!";
159 if $path =~ /(~|\.bak)$/ ||
160 $path =~ /^\..*\.swp$/ ;
166 sub MY::postamble { <<'EOM' } ;
169 @echo Checking config.in is setup for a release
170 @(grep "^LIB.*/usr/local/BerkeleyDB" config.in && \
171 grep "^INCLUDE.*/usr/local/BerkeleyDB" config.in && \
172 grep "^#DBNAME.*" config.in) >/dev/null || \
173 (echo config.in needs fixing ; exit 1)
174 @echo config.in is ok
176 @echo Checking DB_File.xs is ok for a release.
177 @(perl -ne ' exit 1 if /^\s*#\s*define\s+TRACE/ ; ' DB_File.xs || \
178 (echo DB_File.xs needs fixing ; exit 1))
179 @echo DB_File.xs is ok
181 @echo Checking for $$^W in files: $(my_files)
183 exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/;' $(my_files) || \
184 (echo found unexpected $$^W ; exit 1)
187 @echo Checking for 'use vars' in files: $(my_files)
189 exit 0 if /^__(DATA|END)__/; \
190 exit 1 if /^\s*use\s+vars/;' $(my_files) || \
191 (echo found unexpected "use vars"; exit 1)
192 @echo No 'use vars' found.
194 @echo All files are OK for a release.
206 my @Options = qw( INCLUDE LIB PREFIX HASH DBNAME COMPAT185 ) ;
207 my %ValidOption = map {$_, 1} @Options ;
208 my %Parsed = %ValidOption ;
209 my $CONFIG = 'config.in' ;
211 print "Parsing $CONFIG...\n" ;
213 # DBNAME & COMPAT185 are optional, so pretend they have
215 delete $Parsed{'DBNAME'} ;
216 delete $Parsed{'COMPAT185'} ;
217 $Info{COMPAT185} = "No" ;
220 open(F, "$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
223 next if /^\s*$/ or /^\s*#/ ;
226 ($k, $v) = split(/\s+=\s+/, $_, 2) ;
228 if ($ValidOption{$k}) {
238 print "Unknown keys in $CONFIG ignored [@badkey]\n"
241 # check parsed values
243 die "The following keys are missing from $CONFIG file: [@missing]\n"
244 if @missing = keys %Parsed ;
246 $INC_DIR = $ENV{'DB_FILE_INCLUDE'} || $Info{'INCLUDE'} ;
247 $LIB_DIR = $ENV{'DB_FILE_LIB'} || $Info{'LIB'} ;
248 $DB_NAME = $ENV{'DB_FILE_NAME'} || $Info{'DBNAME'} ;
249 $COMPAT185 = "-DCOMPAT185 -DDB_LIBRARY_COMPATIBILITY_API"
250 if (defined $ENV{'DB_FILE_COMPAT185'} &&
251 $ENV{'DB_FILE_COMPAT185'} =~ /^\s*(on|true|1)\s*$/i) ||
252 $Info{'COMPAT185'} =~ /^\s*(on|true|1)\s*$/i ;
253 my $PREFIX = $Info{'PREFIX'} ;
254 my $HASH = $Info{'HASH'} ;
256 $VER_INFO = "-DmDB_Prefix_t=${PREFIX} -DmDB_Hash_t=${HASH}" ;
267 print "Looks Good.\n" ;
275 # our is stable from 5.6.0 onward
276 # warnings is stable from 5.6.1 onward
278 # Note: this code assumes that each statement it modifies is not
279 # split across multiple lines.
286 # From: use|no warnings "blah"
287 # To: local ($^W) = 1; # use|no warnings "blah"
291 # From: warnings::warnif(x,y);
292 # To: $^W && carp(y); # warnif -- x
294 s/^(\s*)(no\s+warnings)/${1}local (\$^W) = 0; #$2/ ;
295 s/^(\s*)(use\s+warnings)/${1}local (\$^W) = 1; #$2/ ;
297 s/^(\s*)warnings::warnif\s*\((.*?)\s*,\s*(.*?)\)\s*;/${1}\$^W && carp($3); # warnif - $2/ ;
301 # From: local ($^W) = 1; # use|no warnings "blah"
302 # To: use|no warnings "blah"
306 # From: $^W && carp(y); # warnif -- x
307 # To: warnings::warnif(x,y);
309 s/^(\s*)local\s*\(\$\^W\)\s*=\s*\d+\s*;\s*#\s*((no|use)\s+warnings.*)/$1$2/ ;
310 s/^(\s*)\$\^W\s+\&\&\s*carp\s*\((.*?)\)\s*;\s*#\s*warnif\s*-\s*(.*)/${1}warnings::warnif($3, $2);/ ;
316 if ( /^(\s*)our\s+\(\s*([^)]+\s*)\)/ ) {
318 my $vars = join ' ', split /\s*,\s*/, $2;
319 $_ = "${indent}use vars qw($vars);\n";
325 if ( /^(\s*)use\s+vars\s+qw\((.*?)\)/ ) {
327 my $vars = join ', ', split ' ', $2;
328 $_ = "${indent}our ($vars);\n";
334 { doUpDown($our_sub, $warn_sub, $_) }
341 my $warn_sub = shift;
343 local ($^I) = ".bak" ;
344 local (@ARGV) = shift;
348 print, last if /^__(END|DATA)__/ ;
361 # end of file Makefile.PL