summaryrefslogtreecommitdiff
path: root/mk/mysql.buildlink3.mk
blob: 0975d534ae266b4f1ecc1e31351cb70a242dda01 (plain)
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
# $NetBSD: mysql.buildlink3.mk,v 1.38 2021/09/27 15:25:54 ryoon Exp $
#
# This file is included by packages that require some version of the
# MySQL database client.
#
# User-settable variables:
#
# MYSQL_VERSION_DEFAULT
#	The preferred MySQL version.
#
#	Possible: 57 56 80 mariadb106 mariadb105 mariadb104
#	Default: mariadb106
#
# Package-settable variables:
#
# MYSQL_VERSIONS_ACCEPTED
#	The list of MySQL versions that the package accepts.
#
#	Possible: (see MYSQL_VERSION_DEFAULT)
#	Default: (all)
#
# Variables set by this file:
#
# MYSQL_VERSION

.if !defined(MYSQL_VERSION_MK)
MYSQL_VERSION_MK=	# defined

BUILD_DEFS+=		MYSQL_VERSION_DEFAULT
BUILD_DEFS_EFFECTS+=	MYSQL_VERSION

_VARGROUPS+=		mysql
_USER_VARS.mysql=	MYSQL_VERSION_DEFAULT
_PKG_VARS.mysql=	MYSQL_VERSIONS_ACCEPTED
_SYS_VARS.mysql=	MYSQL_VERSION MYSQL_VERSION_REQD MYSQL_VERSIONS_ALL

#
# Set variables for all possible MySQL variants
#
MYSQL_VERSIONS_ALL=		80 57 56 mariadb106 mariadb105 mariadb104

MYSQL_PKGBASE.80=		mysql-client-8.0.*
MYSQL_PKGSRCDIR.80=		../../databases/mysql80-client

MYSQL_PKGBASE.57=		mysql-client-5.7.*
MYSQL_PKGSRCDIR.57=		../../databases/mysql57-client

MYSQL_PKGBASE.56=		mysql-client-5.6.*
MYSQL_PKGSRCDIR.56=		../../databases/mysql56-client

MYSQL_PKGBASE.mariadb104=	mariadb-client-10.4.*
MYSQL_PKGSRCDIR.mariadb104=	../../databases/mariadb104-client

MYSQL_PKGBASE.mariadb105=	mariadb-client-10.5.*
MYSQL_PKGSRCDIR.mariadb105=	../../databases/mariadb105-client

MYSQL_PKGBASE.mariadb106=	mariadb-client-10.6.*
MYSQL_PKGSRCDIR.mariadb106=	../../databases/mariadb106-client

.for ver in ${MYSQL_VERSIONS_ALL}
MYSQL_OK.${ver}=		no
MYSQL_INSTALLED.${ver}=		no
_SYS_VARS.mysql+=		MYSQL_PKGBASE.${ver} MYSQL_PKGSRCDIR.${ver}
.endfor

.include "../../mk/bsd.prefs.mk"

#
# Ordering here matters.  Unless a more specific version is requested, or if
# the default version is installed, the first accepted installed version will
# be chosen.
#
MYSQL_VERSION_DEFAULT?=		mariadb106
MYSQL_VERSIONS_ACCEPTED?=	57 56 80 mariadb106 mariadb105 mariadb104

#
# Previous versions of this file used shouty caps in the version names.  We
# don't do that any longer, but do still support the older syntax.
#
MYSQL_VERSION_DEFAULT:=		${MYSQL_VERSION_DEFAULT:tl}
MYSQL_VERSIONS_ACCEPTED:=	${MYSQL_VERSIONS_ACCEPTED:tl}

#
# If version is acceptable, mark as OK and check to see if installed.
#
.for ver in ${MYSQL_VERSIONS_ACCEPTED}
MYSQL_OK.${ver}=		yes
MYSQL_INSTALLED.${ver}!=					\
	if ${PKG_INFO} -qe ${MYSQL_PKGBASE.${ver}:Q}; then	\
		${ECHO} yes;					\
	else							\
		${ECHO} no;					\
	fi
.endfor

#
# Selection process, first match wins:
#
#   - If a specific version is explicitly required, use it.
#   - Otherwise if the default version is installed, use that.
#   - Otherwise prefer an already installed version, in order of accepted.
#
# If no acceptable package is already installed:
#
#   - If the default is acceptable, use it.
#   - Otherwise require the first version listed as accepted.
#
.if defined(MYSQL_VERSION_REQD)
MYSQL_VERSION=	${MYSQL_VERSION_REQD}
.elif ${MYSQL_OK.${MYSQL_VERSION_DEFAULT}} == "yes" && \
      ${MYSQL_INSTALLED.${MYSQL_VERSION_DEFAULT}} == "yes"
MYSQL_VERSION=	${MYSQL_VERSION_DEFAULT}
.else
.  for ver in ${MYSQL_VERSIONS_ACCEPTED}
.    if ${MYSQL_INSTALLED.${ver}} == "yes"
MYSQL_VERSION?=	${ver}
.    endif
.  endfor
.endif
.if !defined(MYSQL_VERSION)
.  if ${MYSQL_OK.${MYSQL_VERSION_DEFAULT}} == "yes"
MYSQL_VERSION=	${MYSQL_VERSION_DEFAULT}
.  else
MYSQL_VERSION=	${MYSQL_VERSIONS_ACCEPTED:[1]}
.  endif
.endif

.if defined(MYSQL_PKGSRCDIR.${MYSQL_VERSION})
.  include "${MYSQL_PKGSRCDIR.${MYSQL_VERSION}}/buildlink3.mk"
.else
PKG_FAIL_REASON+=	"[mysql.buildlink3.mk] Invalid MySQL version '${MYSQL_VERSION}'."
.endif

.endif	# MYSQL_VERSION_MK