pullup 3232
[pkgsrcv2.git] / mk / bdb.buildlink3.mk
1 # $NetBSD: bdb.buildlink3.mk,v 1.23 2009/03/20 19:25:01 joerg Exp $
2 #
3 # This Makefile fragment is meant to be included by packages that
4 # require a Berkeley DB (BDB) implementation and that are not restricted
5 # to a single one. The available BDB implementations are db1
6 # (if builtin) and db[234].
7 #
8 # FIXME: This Makefile cannot handle packages that can use only a
9 # subset of { db2 db3 db4 }.
10 #
11 # === User-settable variables ===
12 #
13 # BDB_DEFAULT
14 #       This value represents the package we use when either a db-1.85
15 #       interface isn't required, or a db-1.85 interface is required,
16 #       but it's not built-in.
17 #
18 #       FIXME: Improve the wording of the text above so that one can
19 #       understand it.
20 #
21 #       Possible: db1 db2 db3 db4 db5
22 #       Default: db4
23 #
24 # BDB185_DEFAULT
25 #       The package we use when a db-1.85 interface is required.
26 #       It defaults to "db1" if it's built-in, or to ${BDB_DEFAULT}
27 #       otherwise.
28 #
29 # === Package-settable variables ===
30 #
31 # BDB_ACCEPTED
32 #       The list of Berkeley DB implementations that can be used by the
33 #       package.
34 #
35 #       FIXME: If the list does not include db1 and does not include
36 #       BDB_DEFAULT, the package will not build at the moment.
37 #
38 # === Variables set by this file ===
39 #
40 # BDB_TYPE
41 #       The name of the selected BDB implementation.
42 #
43 # BDBBASE
44 #       The base directory of the selected BDB implementation. It has
45 #       subdirectories include/ and lib/.
46 #
47 # BDB_LIBS
48 #       Linker flags to link against the BDB library.
49
50 # Note for when databases/db1 is imported:
51 #   (1) Remove the section that conditionally sets the default
52 #       value for BDB185_DEFAULT and always set it to be "db1".
53 #   (2) Remove the special case for ${BDB_TYPE} == "db1" at the end.
54 #   (3) Move mk/db1.builtin.mk to databases/db1/builtin.mk.
55
56 BDB_BUILDLINK3_MK:=     ${BDB_BUILDLINK3_MK}+
57
58 .include "bsd.fast.prefs.mk"
59
60 .if !empty(BDB_BUILDLINK3_MK:M+)
61
62 _VARGROUPS+=    bdb
63 _USER_VARS.bdb= BDB_DEFAULT BDB185_DEFAULT
64 _PKG_VARS.bdb=  BDB_ACCEPTED
65 _SYS_VARS.bdb=  BDB_TYPE BDBBASE BDB_LIBS
66
67 # If the package specified a list of acceptable Berkeley DB packages,
68 # set USE_DB185 to yes if db1 is included, and otherwise no, thus
69 # preferring to use db1.  Assume that the package's configure process
70 # should know how to probe for the libraries and headers on its own.
71 #
72 .  if defined(BDB_ACCEPTED) && empty(BDB_ACCEPTED:Mdb1)
73 USE_DB185?=     no
74 .  else
75 USE_DB185?=     yes
76 .  endif
77
78 # _BDB_PKGS is an exhaustive list of all of the Berkeley DB
79 # implementations that may be used with bdb.buildlink3.mk.
80 #
81 _BDB_PKGS?=     db1 db2 db3 db4 db5
82
83 BDB_DEFAULT?=   db4
84 BDB_ACCEPTED?=  ${_BDB_PKGS}
85
86 # Decide what to use when DB185 is required.  If builtin db1 is
87 # present, use it, and if not use DBD_DEFAULT.
88 #
89 CHECK_BUILTIN.db1:=     yes
90 .  include "db1.builtin.mk"
91 CHECK_BUILTIN.db1:=     no
92 .  if defined(IS_BUILTIN.db1) && !empty(IS_BUILTIN.db1:M[yY][eE][sS])
93 BDB185_DEFAULT?=        db1
94 .  else
95 BDB185_DEFAULT?=        ${BDB_DEFAULT}
96 .  endif
97
98 _BDB_PKGSRCDIR.db2=             ../../databases/db
99 .  for _bdb_ in ${_BDB_PKGS}
100 _BDB_PKGSRCDIR.${_bdb_}?=       ../../databases/${_bdb_}
101 .  endfor
102
103 _BDB_DEFAULT=           ${BDB_DEFAULT}
104 _BDB185_DEFAULT=        ${BDB185_DEFAULT}
105 _BDB_ACCEPTED=          ${BDB_ACCEPTED}
106
107 .  if !defined(_BDB_TYPE)
108 .    if !empty(USE_DB185:M[yY][eE][sS])
109 _BDB_TYPE=      ${_BDB185_DEFAULT}
110 .    else
111 _BDB_TYPE=      ${_BDB_DEFAULT}
112 .    endif
113 .  endif
114
115 # Note that if BDB_ACCEPTED does not contain db1 or BDB_DEFAULT, this
116 # results in BDB_TYPE being none (rather than the most preferred value
117 # in BDB_ACCEPTED, which might or might not be better.)
118 .  if !empty(_BDB_ACCEPTED:M${_BDB_TYPE})
119 BDB_TYPE=       ${_BDB_TYPE}
120 .  else
121 BDB_TYPE=       none
122 .  endif
123
124 # Define some public variables to refer to package-specific variables.
125 BDBBASE=        ${BUILDLINK_PREFIX.${BDB_TYPE}}
126 BDB_LIBS=       ${BUILDLINK_LDADD.${BDB_TYPE}}
127
128 BUILD_DEFS+=            BDB_DEFAULT BDB185_DEFAULT
129 BUILD_DEFS_EFFECTS+=    BDBBASE BDB_LIBS BDB_TYPE
130
131 .endif  # BDB_BUILDLINK3_MK
132
133 .if ${BDB_TYPE} == "none"
134 PKG_FAIL_REASON=        \
135         "[bdb.buildlink3.mk] ${_BDB_TYPE} is not an acceptable Berkeley DB type for ${PKGNAME}."
136 .elif ${BDB_TYPE} == "db1"
137 BUILDLINK_TREE+=                db1 -db1
138 BUILDLINK_BUILTIN_MK.db1=       ../../mk/db1.builtin.mk
139 .else
140 .  include "${_BDB_PKGSRCDIR.${BDB_TYPE}}/buildlink3.mk"
141 .endif