From edc4b1a149e328e94d71fd41a78496b9387bd43e Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 25 Apr 2016 16:17:31 +0000 Subject: Move MySQL support from bsd.databases.mk to Uses/mysql.mk. Also, USE_MYSQL can't happen after bsd.port.pre.mk because it is a USES. PR: 208971 Submitted by: mat Exp-run by: antoine With hat: portmgr Sponsored by: Absolight Differential Revision: https://reviews.freebsd.org/D5951 --- Mk/Uses/mysql.mk | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Mk/bsd.database.mk | 125 ------------------------------------------------ Mk/bsd.port.mk | 16 +++++-- Mk/bsd.sanity.mk | 4 +- 4 files changed, 151 insertions(+), 130 deletions(-) create mode 100644 Mk/Uses/mysql.mk delete mode 100644 Mk/bsd.database.mk (limited to 'Mk') diff --git a/Mk/Uses/mysql.mk b/Mk/Uses/mysql.mk new file mode 100644 index 00000000000..b5e8549232e --- /dev/null +++ b/Mk/Uses/mysql.mk @@ -0,0 +1,136 @@ +# $FreeBSD$ +# +# Provide support for MySQL +# Feature: mysql +# Usage: USES=mysql or USES=mysql:args +# Valid ARGS: , server, embedded +# +# version If no version is given (by the maintainer via the port), try to +# find the currently installed version. Fall back to default if +# necessary (MySQL-5.6 = 56). +# server/embedded +# Depend on the server at run/build time. If none of these is +# set, depends on the client. +# +# IGNORE_WITH_MYSQL +# This variable can be defined if the ports does not support one +# or more versions of MySQL. +# WITH_MYSQL_VER +# User defined variable to set MySQL version. +# MYSQL_VER +# Detected MySQL version. +# +# MAINTAINER: ports@FreeBSD.org + +.if !defined(_INCLUDE_USES_MYSQL_MK) +_INCLUDE_USES_MYSQL_MK= yes + +.include "${PORTSDIR}/Mk/bsd.default-versions.mk" + +.if !empty(mysql_ARGS) +.undef _WANT_MYSQL_VER +.undef _WANT_MYSQL_SERVER +.undef _WANT_MYSQL_EMBEDDED +_MYSQL_ARGS= ${mysql_ARGS:S/,/ /g} +.if ${_MYSQL_ARGS:Mserver} +_WANT_MYSQL_SERVER= yes +_MYSQL_ARGS:= ${_MYSQL_ARGS:Nserver} +.endif +.if ${_MYSQL_ARGS:Membedded} +_WANT_MYSQL_EMBEDDED= yes +_MYSQL_ARGS:= ${_MYSQL_ARGS:Nembedded} +.endif + +# Port requested a version +.if !empty(_MYSQL_ARGS) +_WANT_MYSQL_VER= ${_MYSQL_ARGS} +.endif +.endif # !empty(mysql_ARGS) + +.if defined(DEFAULT_MYSQL_VER) +WARNING+= "DEFAULT_MYSQL_VER is defined, consider using DEFAULT_VERSIONS=mysql=${DEFAULT_MYSQL_VER} instead" +.endif + +DEFAULT_MYSQL_VER?= ${MYSQL_DEFAULT:S/.//} +# MySQL client version currently supported. +# When adding a version, please keep the comment in +# Mk/bsd.default-versions.mk in sync. +MYSQL51_LIBVER= 16 +MYSQL55_LIBVER= 18 +MYSQL55m_LIBVER= 18 +MYSQL55p_LIBVER= 18 +MYSQL56_LIBVER= 18 +MYSQL56p_LIBVER= 18 +MYSQL57_LIBVER= 20 +MYSQL100m_LIBVER= 18 +MYSQL101m_LIBVER= 18 + +# Setting/finding MySQL version we want. +.if exists(${LOCALBASE}/bin/mysql) +_MYSQL!= ${LOCALBASE}/bin/mysql --version | ${SED} -e 's/.*Distrib \([0-9]\{1,2\}\)\.\([0-9]*\).*/\1\2/' +_PERCONA!= ${LOCALBASE}/bin/mysql --version | ${GREP} Percona | wc -l +_MARIADB!= ${LOCALBASE}/bin/mysql --version | ${GREP} MariaDB | wc -l + +.if ${_PERCONA} == 1 +_MYSQL_VER= ${_MYSQL}p +.elif ${_MARIADB} == 1 +_MYSQL_VER= ${_MYSQL}m +.else +_MYSQL_VER= ${_MYSQL} +.endif +.endif + +.if defined(_WANT_MYSQL_VER) +.if defined(WITH_MYSQL_VER) && ${WITH_MYSQL_VER} != ${_WANT_MYSQL_VER} +IGNORE= cannot install: the port wants mysql${_WANT_MYSQL_VER}-client and you try to install mysql${WITH_MYSQL_VER}-client +.endif +MYSQL_VER= ${_WANT_MYSQL_VER} +.elif defined(WITH_MYSQL_VER) +MYSQL_VER= ${WITH_MYSQL_VER} +.else +.if defined(_MYSQL_VER) +MYSQL_VER= ${_MYSQL_VER} +.else +MYSQL_VER= ${DEFAULT_MYSQL_VER} +.endif +.endif # _WANT_MYSQL_VER + +.if defined(_MYSQL_VER) +.if ${_MYSQL_VER} != ${MYSQL_VER} +IGNORE= cannot install: MySQL versions mismatch: mysql${_MYSQL_VER}-client is installed and wanted version is mysql${MYSQL_VER}-client +.endif +.endif + +.if (${MYSQL_VER:C/[0-9]*//} == "m") +_MYSQL_FLAVOUR= mariadb +.elif (${MYSQL_VER:C/[0-9]*//} == "p") +_MYSQL_FLAVOUR= percona +.else +_MYSQL_FLAVOUR= mysql +.endif + +_MYSQL_CLIENT= databases/${_MYSQL_FLAVOUR}${MYSQL_VER:C/[mp]//}-client +_MYSQL_SERVER= databases/${_MYSQL_FLAVOUR}${MYSQL_VER:C/[mp]//}-server + +# And now we are checking if we can use it +.if defined(MYSQL${MYSQL_VER}_LIBVER) +.if defined(IGNORE_WITH_MYSQL) +. for VER in ${IGNORE_WITH_MYSQL} +. if (${MYSQL_VER} == "${VER}") +IGNORE= cannot install: does not work with MySQL version ${MYSQL_VER} (MySQL ${IGNORE_WITH_MYSQL} not supported) +. endif +. endfor +.endif # IGNORE_WITH_MYSQL +.if defined(_WANT_MYSQL_SERVER) || defined(_WANT_MYSQL_EMBEDDED) +RUN_DEPENDS+= ${LOCALBASE}/libexec/mysqld:${_MYSQL_SERVER} +.if defined(_WANT_MYSQL_EMBEDDED) +BUILD_DEPENDS+= ${LOCALBASE}/lib/mysql/libmysqld.a:${_MYSQL_SERVER} +.endif +.else +LIB_DEPENDS+= libmysqlclient.so.${MYSQL${MYSQL_VER}_LIBVER}:${_MYSQL_CLIENT} +.endif +.else +IGNORE= cannot install: unknown MySQL version: ${MYSQL_VER} +.endif # Check for correct libs + +.endif diff --git a/Mk/bsd.database.mk b/Mk/bsd.database.mk deleted file mode 100644 index 6ef5d9466c8..00000000000 --- a/Mk/bsd.database.mk +++ /dev/null @@ -1,125 +0,0 @@ -# $FreeBSD$ -# - -.if defined(_POSTMKINCLUDED) && !defined(Database_Post_Include) - -Database_Post_Include= bsd.database.mk -Database_Include_MAINTAINER= ports@FreeBSD.org - -# This file contains some routines to interact with different databases, such -# as MySQL. To include this file, define macro -# USE_[DATABASE], for example USE_MYSQL. Defining macro like -# USE_[DATABASE]_VER or WANT_[DATABASE]_VER will include this file as well. -# -## -# USE_MYSQL - Add MySQL (client/server/embedded) dependency (default: -# client). -# If no version is given (by the maintainer via the port or -# by the user via defined variable), try to find the -# currently installed version. Fall back to default if -# necessary (MySQL-5.6 = 56). -# DEFAULT_MYSQL_VER -# - MySQL default version. Can be overridden within a port. -# Default: 56. -# WANT_MYSQL_VER -# - Maintainer can set an arbitrary version of MySQL to always -# build this port with (overrides WITH_MYSQL_VER). -# IGNORE_WITH_MYSQL -# - This variable can be defined if the ports does not support -# one or more versions of MySQL. -# WITH_MYSQL_VER -# - User defined variable to set MySQL version. -# MYSQL_VER -# - Detected MySQL version. - -.include "${PORTSDIR}/Mk/bsd.default-versions.mk" - -.if defined(DEFAULT_MYSQL_VER) -WARNING+= "DEFAULT_MYSQL_VER is defined, consider using DEFAULT_VERSIONS=mysql=${DEFAULT_MYSQL_VER} instead" -.endif - -.if defined(USE_MYSQL) -DEFAULT_MYSQL_VER?= ${MYSQL_DEFAULT:S/.//} -# MySQL client version currently supported. -# When adding a version, please keep the comment in -# Mk/bsd.default-versions.mk in sync. -MYSQL51_LIBVER= 16 -MYSQL55_LIBVER= 18 -MYSQL55m_LIBVER= 18 -MYSQL55p_LIBVER= 18 -MYSQL56_LIBVER= 18 -MYSQL56p_LIBVER= 18 -MYSQL57_LIBVER= 20 -MYSQL100m_LIBVER= 18 -MYSQL101m_LIBVER= 18 - -# Setting/finding MySQL version we want. -.if exists(${LOCALBASE}/bin/mysql) -_MYSQL!= ${LOCALBASE}/bin/mysql --version | ${SED} -e 's/.*Distrib \([0-9]\{1,2\}\)\.\([0-9]*\).*/\1\2/' -_PERCONA!= ${LOCALBASE}/bin/mysql --version | ${GREP} Percona | wc -l -_MARIADB!= ${LOCALBASE}/bin/mysql --version | ${GREP} MariaDB | wc -l - -.if ${_PERCONA} == 1 -_MYSQL_VER= ${_MYSQL}p -.elif ${_MARIADB} == 1 -_MYSQL_VER= ${_MYSQL}m -.else -_MYSQL_VER= ${_MYSQL} -.endif -.endif - -.if defined(WANT_MYSQL_VER) -.if defined(WITH_MYSQL_VER) && ${WITH_MYSQL_VER} != ${WANT_MYSQL_VER} -IGNORE= cannot install: the port wants mysql${WANT_MYSQL_VER}-client and you try to install mysql${WITH_MYSQL_VER}-client -.endif -MYSQL_VER= ${WANT_MYSQL_VER} -.elif defined(WITH_MYSQL_VER) -MYSQL_VER= ${WITH_MYSQL_VER} -.else -.if defined(_MYSQL_VER) -MYSQL_VER= ${_MYSQL_VER} -.else -MYSQL_VER= ${DEFAULT_MYSQL_VER} -.endif -.endif # WANT_MYSQL_VER - -.if defined(_MYSQL_VER) -.if ${_MYSQL_VER} != ${MYSQL_VER} -IGNORE= cannot install: MySQL versions mismatch: mysql${_MYSQL_VER}-client is installed and wanted version is mysql${MYSQL_VER}-client -.endif -.endif - -.if (${MYSQL_VER:C/[0-9]*//} == "m") -_MYSQL_FLAVOUR= mariadb -.elif (${MYSQL_VER:C/[0-9]*//} == "p") -_MYSQL_FLAVOUR= percona -.else -_MYSQL_FLAVOUR= mysql -.endif - -_MYSQL_CLIENT= databases/${_MYSQL_FLAVOUR}${MYSQL_VER:C/[mp]//}-client -_MYSQL_SERVER= databases/${_MYSQL_FLAVOUR}${MYSQL_VER:C/[mp]//}-server - -# And now we are checking if we can use it -.if defined(MYSQL${MYSQL_VER}_LIBVER) -.if defined(IGNORE_WITH_MYSQL) -. for VER in ${IGNORE_WITH_MYSQL} -. if (${MYSQL_VER} == "${VER}") -IGNORE= cannot install: does not work with MySQL version ${MYSQL_VER} (MySQL ${IGNORE_WITH_MYSQL} not supported) -. endif -. endfor -.endif # IGNORE_WITH_MYSQL -.if (${USE_MYSQL} == "server" || ${USE_MYSQL} == "embedded") -RUN_DEPENDS+= ${LOCALBASE}/libexec/mysqld:${_MYSQL_SERVER} -.if (${USE_MYSQL} == "embedded") -BUILD_DEPENDS+= ${LOCALBASE}/lib/mysql/libmysqld.a:${_MYSQL_SERVER} -.endif -.else -LIB_DEPENDS+= libmysqlclient.so.${MYSQL${MYSQL_VER}_LIBVER}:${_MYSQL_CLIENT} -.endif -.else -IGNORE= cannot install: unknown MySQL version: ${MYSQL_VER} -.endif # Check for correct libs -.endif # USE_MYSQL - -.endif # defined(_POSTMKINCLUDED) && !defined(Database_Post_Include) diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk index b05a22b3267..e8fe347f594 100644 --- a/Mk/bsd.port.mk +++ b/Mk/bsd.port.mk @@ -1407,6 +1407,18 @@ USES+= mate USES+=bdb:${USE_BDB} .endif +.if defined(USE_MYSQL) +USE_MYSQL:= ${USE_MYSQL:N[yY][eE][sS]:Nclient} +.if defined(WANT_MYSQL_VER) +.if empty(USE_MYSQL) +USE_MYSQL:=${WANT_MYSQL_VER} +.else +USE_MYSQL:=${USE_MYSQL},${WANT_MYSQL_VER} +.endif +.endif +USES+=mysql:${USE_MYSQL} +.endif + .if defined(WANT_WX) || defined(USE_WX) || defined(USE_WX_NOT) .include "${PORTSDIR}/Mk/bsd.wx.mk" .endif @@ -1867,10 +1879,6 @@ _FORCE_POST_PATTERNS= rmdir kldxref mkfontscale mkfontdir fc-cache \ .include "${PORTSDIR}/Mk/bsd.xorg.mk" .endif -.if defined(USE_MYSQL) || defined(WANT_MYSQL_VER) -.include "${PORTSDIR}/Mk/bsd.database.mk" -.endif - .if defined(WANT_GSTREAMER) || defined(USE_GSTREAMER) || defined(USE_GSTREAMER1) .include "${PORTSDIR}/Mk/bsd.gstreamer.mk" .endif diff --git a/Mk/bsd.sanity.mk b/Mk/bsd.sanity.mk index cb8fc114130..7f5258ba811 100644 --- a/Mk/bsd.sanity.mk +++ b/Mk/bsd.sanity.mk @@ -169,7 +169,7 @@ SANITY_UNSUPPORTED= USE_OPENAL USE_FAM USE_MAKESELF USE_ZIP USE_LHA USE_CMAKE \ PYDISTUTILS_AUTOPLIST PYTHON_PY3K_PLIST_HACK PYDISTUTILS_NOEGGINFO \ USE_PYTHON_PREFIX USE_BZIP2 USE_XZ USE_PGSQL NEED_ROOT \ UNIQUENAME LATEST_LINK USE_SQLITE USE_FIREBIRD -SANITY_DEPRECATED= PYTHON_PKGNAMESUFFIX USE_AUTOTOOLS PLIST_DIRSTRY USE_BDB +SANITY_DEPRECATED= PYTHON_PKGNAMESUFFIX USE_AUTOTOOLS PLIST_DIRSTRY USE_BDB USE_MYSQL WANT_MYSQL_VER SANITY_NOTNEEDED= WX_UNICODE USE_AUTOTOOLS_ALT= USES=autoreconf and GNU_CONFIGURE=yes @@ -211,6 +211,8 @@ PLIST_DIRSTRY_ALT= PLIST_DIRS USE_SQLITE_ALT= USES=sqlite USE_FIREBIRD_ALT= USES=firebird USE_BDB_ALT= USES=bdb:${USE_BDB} +USE_MYSQL_ALT= USES=mysql:${USE_MYSQL} +WANT_MYSQL_VER_ALT= USES=mysql:${WANT_MYSQL_VER} .for a in ${SANITY_DEPRECATED} .if defined(${a}) -- cgit