07007f475ea2eef113e8b60ecce743743abbfa31
[p5sagit/p5-mst-13.2.git] / ext / DB_File / Makefile.PL
1 use strict;
2 use warnings;
3
4 use ExtUtils::MakeMaker ;
5 use ExtUtils::Constant qw(WriteConstants);
6 use Config ;
7
8 # OS2 is a special case, so check for it now.
9 my $OS2 = "-DOS2" if $Config{'osname'} eq 'os2' ;
10
11 my $LIB = "-ldb" ;
12 # so is win32
13 if ( $^O eq 'MSWin32' ) {
14         $LIB = $Config{cc} =~ /gcc/ ? "-ldb" : "-llibdb";
15 }
16
17 WriteMakefile(
18         NAME            => 'DB_File',
19         LIBS            => ["-L/usr/local/lib $LIB"],
20         MAN3PODS        => {},         # Pods will be built by installman.
21         #INC            => '-I/usr/local/include',
22         VERSION_FROM    => 'DB_File.pm',
23         OBJECT          => 'version$(OBJ_EXT) DB_File$(OBJ_EXT)',
24         XSPROTOARG      => '-noprototypes',
25         DEFINE          => $OS2 || "",
26         INC             => ($^O eq "MacOS" ? "-i ::::db:include" : ""),
27         XS_VERSION      => eval MM->parse_version('DB_File.pm'),
28     ((ExtUtils::MakeMaker->VERSION() gt '6.30')
29             ?  ('LICENSE'  => 'perl')
30             : ()
31     ),
32     (
33         $] >= 5.005
34             ? (ABSTRACT_FROM => 'DB_File.pm',
35                 AUTHOR       => 'Paul Marquess <pmqs@cpan.org>')
36             : ()
37     ),
38
39         'depend'        => {'version$(OBJ_EXT)' => 'version.c'},
40         'clean'         => {FILES => 'constants.h constants.xs'},
41         );
42
43 my @names = qw(
44         BTREEMAGIC
45         BTREEVERSION
46         DB_LOCK
47         DB_SHMEM
48         DB_TXN
49         HASHMAGIC
50         HASHVERSION
51         MAX_PAGE_NUMBER
52         MAX_PAGE_OFFSET
53         MAX_REC_NUMBER
54         RET_ERROR
55         RET_SPECIAL
56         RET_SUCCESS
57         R_CURSOR
58         R_DUP
59         R_FIRST
60         R_FIXEDLEN
61         R_IAFTER
62         R_IBEFORE
63         R_LAST
64         R_NEXT
65         R_NOKEY
66         R_NOOVERWRITE
67         R_PREV
68         R_RECNOSYNC
69         R_SETCURSOR
70         R_SNAPSHOT
71         __R_UNUSED
72         );
73
74     # Check the constants above all appear in @EXPORT in DB_File.pm
75     my %names = map { $_, 1} @names;
76     open F, "<DB_File.pm" or die "Cannot open DB_File.pm: $!\n";
77     while (<F>)
78     {
79         last if /^\s*\@EXPORT\s+=\s+qw\(/ ;
80     }
81
82     while (<F>)
83     {
84         last if /^\s*\)/ ;
85         /(\S+)/ ;
86         delete $names{$1} if defined $1 ;
87     }
88     close F ;
89
90     if ( keys %names )
91     {
92         my $missing = join ("\n\t", sort keys %names) ;
93         die "The following names are missing from \@EXPORT in DB_File.pm\n" .
94             "\t$missing\n" ;
95     }
96     
97
98     WriteConstants( NAME => 'DB_File',
99                     NAMES => \@names,
100                     C_FILE  => 'constants.h',
101                     XS_FILE  => 'constants.xs',
102                   );