You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

180 lines
6.2 KiB

  1. #
  2. # Copyright (C) 2019 Sebastian Kemper <sebastian_ml@gmx.net>
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=libmariadb
  9. PKG_VERSION:=3.1.12
  10. PKG_RELEASE:=$(AUTORELEASE)
  11. PKG_SOURCE:=mariadb-connector-c-$(PKG_VERSION)-src.tar.gz
  12. PKG_SOURCE_URL := \
  13. https://mirror.netcologne.de/mariadb/connector-c-$(PKG_VERSION) \
  14. https://mirror.lstn.net/mariadb/connector-c-$(PKG_VERSION) \
  15. https://ftp.yz.yamagata-u.ac.jp/pub/dbms/mariadb/connector-c-$(PKG_VERSION) \
  16. https://downloads.mariadb.org/interstitial/connector-c-$(PKG_VERSION)
  17. PKG_HASH:=2f5ae14708b4813e4ff6857d152c22e6fc0e551c9fa743c1ef81a68e3254fe63
  18. PKG_BUILD_DIR:=$(BUILD_DIR)/mariadb-connector-c-$(PKG_VERSION)-src
  19. PKG_MAINTAINER:=Michal Hrusecky <Michal@Hrusecky.net>
  20. PKG_LICENSE:=LGPL-2.1-or-later
  21. PKG_LICENSE_FILES:=COPYING.LIB
  22. PKG_CPE_ID:=cpe:/a:mariadb:mariadb
  23. MARIADB_CONF_DIR:=/etc/mysql
  24. MARIADB_PLUGIN_DIR:=/usr/lib/mariadb/plugin
  25. MARIADB_PORT=3306
  26. MARIADB_SOCKET=/var/run/mysql/mysql.sock
  27. MARIADB_CLIENT_PLUGINS := \
  28. auth_gssapi_client \
  29. remote_io
  30. PKG_BUILD_DEPENDS:=curl
  31. PKG_CONFIG_DEPENDS := \
  32. $(patsubst %,CONFIG_PACKAGE_$(PKG_NAME)-plugin-%,$(subst _,-,$(MARIADB_CLIENT_PLUGINS)))
  33. plugin-auth_gssapi_client := CLIENT_PLUGIN_AUTH_GSSAPI_CLIENT
  34. plugin-remote_io := CLIENT_PLUGIN_REMOTE_IO
  35. include $(INCLUDE_DIR)/package.mk
  36. include $(INCLUDE_DIR)/nls.mk
  37. include $(INCLUDE_DIR)/cmake.mk
  38. # Pass CPPFLAGS in the CFLAGS as otherwise the build system will
  39. # ignore them.
  40. TARGET_CFLAGS+=$(TARGET_CPPFLAGS)
  41. define Package/$(PKG_NAME)/install/plugin
  42. $(INSTALL_BIN) $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/$(2).so $(1)$(MARIADB_PLUGIN_DIR)
  43. endef
  44. define Package/$(PKG_NAME)/Default
  45. SECTION:=libs
  46. CATEGORY:=Libraries
  47. URL:=https://mariadb.org/
  48. SUBMENU:=Database
  49. endef
  50. define Package/$(PKG_NAME)/description/Default
  51. MariaDB is a very fast and robust SQL database server.
  52. endef
  53. define Package/$(PKG_NAME)
  54. $(call Package/$(PKG_NAME)/Default)
  55. DEPENDS:= \
  56. $(ICONV_DEPENDS) \
  57. +libopenssl \
  58. +zlib
  59. TITLE:=MariaDB database client library
  60. MENU:=1
  61. PROVIDES:=libmariadbclient libmysqlclient libmysqlclient-r
  62. ABI_VERSION:=3
  63. endef
  64. define Package/$(PKG_NAME)/description
  65. $(call Package/$(PKG_NAME)/description/Default)
  66. This package includes the client library.
  67. endef
  68. # We won't need unit tests
  69. CMAKE_OPTIONS += -DWITH_UNIT_TESTS=0
  70. # Make it explicit that we are cross-compiling
  71. CMAKE_OPTIONS += -DCMAKE_CROSSCOMPILING=1
  72. CMAKE_OPTIONS += \
  73. -DDEFAULT_CHARSET=utf8 \
  74. -DDEFAULT_COLLATION=utf8_general_ci \
  75. -DINSTALL_INCLUDEDIR=include/mysql \
  76. -DINSTALL_LIBDIR=lib \
  77. -DINSTALL_PLUGINDIR=lib/mariadb/plugin \
  78. -DMARIADB_UNIX_ADDR=$(MARIADB_SOCKET) \
  79. -DWITH_EXTERNAL_ZLIB=YES \
  80. -DWITH_MYSQLCOMPAT=ON \
  81. -DWITH_SSL=OPENSSL
  82. # Help MariaDB find the correct libiconv.
  83. # nls.mk sets it up so that with CONFIG_BUILD_NLS libiconv-full would be used,
  84. # otherwise libiconv-stub (independent of the selected libc). MariaDB needs a
  85. # leg up to find/pick the right lib.
  86. CMAKE_OPTIONS += \
  87. -DICONV_INCLUDE_DIR=$(ICONV_PREFIX)/include \
  88. -DICONV_LIBRARIES=$(ICONV_PREFIX)/lib/libiconv.$(if $(CONFIG_BUILD_NLS),so,a)
  89. CMAKE_OPTIONS += \
  90. $(foreach p,$(MARIADB_CLIENT_PLUGINS),-D$(plugin-$(p))=$(if $(CONFIG_PACKAGE_$(PKG_NAME)-plugin-$(subst _,-,$(p))),DYNAMIC,OFF))
  91. # LIBICONV_PLUG is used in GNU's libiconv for redefinition of exports [e.g.
  92. # from libiconv_open() to iconv_open()]. But in OpenWrt this variable is not set
  93. # when building libiconv-full. So when MariaDB sets LIBICONV_PLUG it expects
  94. # iconv_open() to be available for example, which is not the case - only
  95. # libiconv_open() is. To address this prevent the variable from being set.
  96. # libiconv-stub does not use this variable, so there is no harm in always doing
  97. # this.
  98. define Build/Prepare
  99. $(call Build/Prepare/Default)
  100. $(SED) '/ADD_DEFINITIONS(-DLIBICONV_PLUG)/d' $(PKG_BUILD_DIR)/CMakeLists.txt
  101. endef
  102. define Build/InstallDev
  103. $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/include $(1)/usr/lib/mysql $(1)/usr/lib/pkgconfig $(2)/bin
  104. $(CP) $(PKG_INSTALL_DIR)/usr/include/mysql $(1)/usr/include
  105. cd $(1)/usr/include/mysql; $(LN) mariadb_version.h mysql_version.h
  106. $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{mariadb,mysqlclient}*.so* $(1)/usr/lib
  107. cd $(1)/usr/lib/mysql; $(LN) ../lib{mariadb,mysqlclient}*.so* .
  108. $(INSTALL_BIN) files/mysql_config $(1)/usr/bin
  109. $(LN) $(STAGING_DIR)/usr/bin/mysql_config $(2)/bin
  110. $(SED) 's/PORT/$(MARIADB_PORT)/' $(1)/usr/bin/mysql_config
  111. $(SED) 's|PLUGIN_DIR|$(MARIADB_PLUGIN_DIR)|' $(1)/usr/bin/mysql_config
  112. $(SED) 's|SOCKET|$(MARIADB_SOCKET)|' $(1)/usr/bin/mysql_config
  113. cd "$(PKG_BUILD_DIR)/mariadb_config"; \
  114. CLIENT_VERSION=`sed -n 's|^#define[[:blank:]]*VERSION[[:blank:]]*"\([0-9.]*\)"|\1|p' mariadb_config.c`; \
  115. $(SED) "s/VERSION/$$$${CLIENT_VERSION}/" $(1)/usr/bin/mysql_config
  116. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libmariadb.pc $(1)/usr/lib/pkgconfig
  117. endef
  118. define Package/$(PKG_NAME)/install
  119. $(INSTALL_DIR) $(1)$(MARIADB_CONF_DIR)/conf.d
  120. $(INSTALL_DIR) $(1)$(MARIADB_PLUGIN_DIR)
  121. $(INSTALL_BIN) \
  122. $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/caching_sha2_password.so \
  123. $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/client_ed25519.so \
  124. $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/dialog.so \
  125. $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/mysql_clear_password.so \
  126. $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/sha256_password.so \
  127. $(1)$(MARIADB_PLUGIN_DIR)
  128. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libmariadb.so.$(ABI_VERSION) $(1)/usr/lib
  129. endef
  130. define BuildPlugin
  131. define Package/$(PKG_NAME)-plugin-$(subst _,-,$(1))
  132. $(call Package/$(PKG_NAME)/Default)
  133. TITLE:=$(PKG_NAME) plugin
  134. DEPENDS:=$(PKG_NAME) $(patsubst +%,+PACKAGE_$(PKG_NAME)-plugin-$(subst _,-,$(1)):%,$(2))
  135. endef
  136. define Package/$(PKG_NAME)-plugin-$(subst _,-,$(1))/description
  137. $(call Package/$(PKG_NAME)/description/Default)
  138. This package provides the $(1) plugin.
  139. endef
  140. define Package/$(PKG_NAME)-plugin-$(subst _,-,$(1))/install
  141. $(INSTALL_DIR) $$(1)$(MARIADB_PLUGIN_DIR)
  142. $(call Package/$(PKG_NAME)/install/plugin,$$(1),$(1))
  143. endef
  144. $$(eval $$(call BuildPackage,$(PKG_NAME)-plugin-$(subst _,-,$(1))))
  145. endef
  146. $(eval $(call BuildPackage,$(PKG_NAME)))
  147. $(eval $(call BuildPlugin,auth_gssapi_client,+krb5-libs))
  148. $(eval $(call BuildPlugin,remote_io,+libcurl))