Merge from vendor branch TNF:
[pkgsrc.git] / mk / bdb.buildlink3.mk
1 # $NetBSD: bdb.buildlink3.mk,v 1.13 2005/01/09 23:56:21 jlam Exp $
2 #
3 # This Makefile fragment is meant to be included by packages that
4 # require a Berkeley DB implementation.  bdb.buildlink3.mk will:
5 #
6 #       * set BDBBASE to the base directory of the Berkeley DB files;
7 #       * set BDB_LIBS to the library option needed to link against
8 #         the Berkeley DB library;
9 #       * set BDB_TYPE to the Berkeley DB implementation used.
10 #
11 # There are two variables that can be used to tweak the selection of
12 # the Berkeley DB implementation:
13 #
14 # BDB_DEFAULT is a user-settable variable whose value represents the
15 #       package we use when either a db-1.85 interface isn't required,
16 #       or a db-1.85 interface is required, but it's not built-in.
17 #
18 # BDB185_DEFAULT is a user-settable variable whose value represents the
19 #       package we use when a db-1.85 interface is required.  It defaults
20 #       to "db1" if it's built-in, or to ${BDB_DEFAULT} otherwise.
21 #
22 # BDB_ACCEPTED is a package-settable list of Berkeley DB implementations
23 #       that may be used by the package.
24 #
25 # Note for when databases/db1 is imported:
26 #   (1) Remove the section that conditionally sets the default
27 #       value for BDB185_DEFAULT and always set it to be "db1".
28 #   (2) Remove the special case for ${BDB_TYPE} == "db1" at the end.
29 #   (3) Move mk/db1.builtin.mk to databases/db1/builtin.mk.
30
31 BDB_BUILDLINK3_MK:=     ${BDB_BUILDLINK3_MK}+
32
33 .include "../../mk/bsd.prefs.mk"
34
35 .if !empty(BDB_BUILDLINK3_MK:M+)
36
37 # If we've specified a list of acceptable Berkeley DB packages and it
38 # doesn't include db1, then don't set USE_DB185 to yes.  The package's
39 # configure process should know how to probe for the libraries and
40 # headers on its own.
41 #
42 .  if defined(BDB_ACCEPTED) && empty(BDB_ACCEPTED:Mdb1)
43 USE_DB185?=     no
44 .  else
45 USE_DB185?=     yes
46 .  endif
47
48 # _BDB_PKGS is an exhaustive list of all of the Berkeley DB
49 # implementations that may be used with bdb.buildlink3.mk.
50 #
51 _BDB_PKGS?=     db1 db2 db3 db4
52
53 BDB_DEFAULT?=   db4
54 BDB_ACCEPTED?=  ${_BDB_PKGS}
55
56 CHECK_BUILTIN.db1:=     yes
57 .  include "../../mk/db1.builtin.mk"
58 CHECK_BUILTIN.db1:=     no
59 .  if defined(IS_BUILTIN.db1) && !empty(IS_BUILTIN.db1:M[yY][eE][sS])
60 BDB185_DEFAULT?=        db1
61 .  else
62 BDB185_DEFAULT?=        ${BDB_DEFAULT}
63 .  endif
64
65 _BDB_PKGSRCDIR.db2=             ../../databases/db
66 .  for _bdb_ in ${_BDB_PKGS}
67 _BDB_PKGSRCDIR.${_bdb_}?=       ../../databases/${_bdb_}
68 .  endfor
69
70 _BDB_DEFAULT=           ${BDB_DEFAULT}
71 _BDB185_DEFAULT=        ${BDB185_DEFAULT}
72 _BDB_ACCEPTED=          ${BDB_ACCEPTED}
73
74 .  if !defined(_BDB_TYPE)
75 .    if !empty(USE_DB185:M[yY][eE][sS])
76 _BDB_TYPE=      ${_BDB185_DEFAULT}
77 .    else
78 _BDB_TYPE=      ${_BDB_DEFAULT}
79 .    endif
80 .  endif
81
82 .  if !empty(_BDB_ACCEPTED:M${_BDB_TYPE})
83 BDB_TYPE=       ${_BDB_TYPE}
84 .  else
85 BDB_TYPE=       none
86 .  endif
87
88 # Define some public variables to refer to package-specific variables.
89 BDBBASE=        ${BUILDLINK_PREFIX.${BDB_TYPE}}
90 BDB_LIBS=       ${BUILDLINK_LDADD.${BDB_TYPE}}
91
92 BUILD_DEFS+=    BDB_TYPE
93 BUILD_DEFS+=    BDBBASE
94
95 .endif  # BDB_BUILDLINK3_MK
96
97 .if ${BDB_TYPE} == "none"
98 PKG_FAIL_REASON=        \
99         "${_BDB_TYPE} is not an acceptable Berkeley DB type for ${PKGNAME}."
100 .elif ${BDB_TYPE} == "db1"
101 BUILDLINK_PACKAGES:=            ${BUILDLINK_PACKAGES:Ndb1}
102 BUILDLINK_PACKAGES+=            db1
103 BUILDLINK_BUILTIN_MK.db1=       ../../mk/db1.builtin.mk
104 .else
105 .  include "${_BDB_PKGSRCDIR.${BDB_TYPE}}/buildlink3.mk"
106 .endif