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.

183 lines
6.3 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/mysqld/mysqld.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 ../../devel/ninja/ninja-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:=+mariadb-common \
  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)/conffiles
  65. $(MARIADB_CONF_DIR)/conf.d/50-client.cnf
  66. endef
  67. define Package/$(PKG_NAME)/description
  68. $(call Package/$(PKG_NAME)/description/Default)
  69. This package includes the client library.
  70. endef
  71. # We won't need unit tests
  72. CMAKE_OPTIONS += -DWITH_UNIT_TESTS=0
  73. # Make it explicit that we are cross-compiling
  74. CMAKE_OPTIONS += -DCMAKE_CROSSCOMPILING=1
  75. CMAKE_OPTIONS += \
  76. -DINSTALL_INCLUDEDIR=include/mysql \
  77. -DINSTALL_LIBDIR=lib \
  78. -DINSTALL_PLUGINDIR=lib/mariadb/plugin \
  79. -DMARIADB_UNIX_ADDR=$(MARIADB_SOCKET) \
  80. -DWITH_EXTERNAL_ZLIB=YES \
  81. -DWITH_MYSQLCOMPAT=ON \
  82. -DWITH_SSL=OPENSSL
  83. # Help MariaDB find the correct libiconv.
  84. # nls.mk sets it up so that with CONFIG_BUILD_NLS libiconv-full would be used,
  85. # otherwise libiconv-stub (independent of the selected libc). MariaDB needs a
  86. # leg up to find/pick the right lib.
  87. CMAKE_OPTIONS += \
  88. -DICONV_INCLUDE_DIR=$(ICONV_PREFIX)/include \
  89. -DICONV_LIBRARIES=$(ICONV_PREFIX)/lib/libiconv.$(if $(CONFIG_BUILD_NLS),so,a)
  90. CMAKE_OPTIONS += \
  91. $(foreach p,$(MARIADB_CLIENT_PLUGINS),-D$(plugin-$(p))=$(if $(CONFIG_PACKAGE_$(PKG_NAME)-plugin-$(subst _,-,$(p))),DYNAMIC,OFF))
  92. # LIBICONV_PLUG is used in GNU's libiconv for redefinition of exports [e.g.
  93. # from libiconv_open() to iconv_open()]. But in OpenWrt this variable is not set
  94. # when building libiconv-full. So when MariaDB sets LIBICONV_PLUG it expects
  95. # iconv_open() to be available for example, which is not the case - only
  96. # libiconv_open() is. To address this prevent the variable from being set.
  97. # libiconv-stub does not use this variable, so there is no harm in always doing
  98. # this.
  99. define Build/Prepare
  100. $(call Build/Prepare/Default)
  101. $(SED) '/ADD_DEFINITIONS(-DLIBICONV_PLUG)/d' $(PKG_BUILD_DIR)/CMakeLists.txt
  102. endef
  103. define Build/InstallDev
  104. $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/include $(1)/usr/lib/mysql $(1)/usr/lib/pkgconfig $(2)/bin
  105. $(CP) $(PKG_INSTALL_DIR)/usr/include/mysql $(1)/usr/include
  106. cd $(1)/usr/include/mysql; $(LN) mariadb_version.h mysql_version.h
  107. $(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{mariadb,mysqlclient}*.so* $(1)/usr/lib
  108. cd $(1)/usr/lib/mysql; $(LN) ../lib{mariadb,mysqlclient}*.so* .
  109. $(INSTALL_BIN) files/mysql_config $(1)/usr/bin
  110. $(LN) $(STAGING_DIR)/usr/bin/mysql_config $(2)/bin
  111. $(SED) 's/PORT/$(MARIADB_PORT)/' $(1)/usr/bin/mysql_config
  112. $(SED) 's|PLUGIN_DIR|$(MARIADB_PLUGIN_DIR)|' $(1)/usr/bin/mysql_config
  113. $(SED) 's|SOCKET|$(MARIADB_SOCKET)|' $(1)/usr/bin/mysql_config
  114. cd "$(PKG_BUILD_DIR)/mariadb_config"; \
  115. CLIENT_VERSION=`sed -n 's|^#define[[:blank:]]*VERSION[[:blank:]]*"\([0-9.]*\)"|\1|p' mariadb_config.c`; \
  116. $(SED) "s/VERSION/$$$${CLIENT_VERSION}/" $(1)/usr/bin/mysql_config
  117. $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libmariadb.pc $(1)/usr/lib/pkgconfig
  118. endef
  119. define Package/$(PKG_NAME)/install
  120. $(INSTALL_DIR) $(1)$(MARIADB_CONF_DIR)/conf.d
  121. $(INSTALL_DIR) $(1)$(MARIADB_PLUGIN_DIR)
  122. $(INSTALL_BIN) \
  123. $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/caching_sha2_password.so \
  124. $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/client_ed25519.so \
  125. $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/dialog.so \
  126. $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/mysql_clear_password.so \
  127. $(PKG_INSTALL_DIR)$(MARIADB_PLUGIN_DIR)/sha256_password.so \
  128. $(1)$(MARIADB_PLUGIN_DIR)
  129. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/libmariadb.so.$(ABI_VERSION) $(1)/usr/lib
  130. $(INSTALL_DATA) conf/50-client.cnf $(1)$(MARIADB_CONF_DIR)/conf.d
  131. endef
  132. define BuildPlugin
  133. define Package/$(PKG_NAME)-plugin-$(subst _,-,$(1))
  134. $(call Package/$(PKG_NAME)/Default)
  135. TITLE:=$(PKG_NAME) plugin
  136. DEPENDS:=$(PKG_NAME) $(patsubst +%,+PACKAGE_$(PKG_NAME)-plugin-$(subst _,-,$(1)):%,$(2))
  137. endef
  138. define Package/$(PKG_NAME)-plugin-$(subst _,-,$(1))/description
  139. $(call Package/$(PKG_NAME)/description/Default)
  140. This package provides the $(1) plugin.
  141. endef
  142. define Package/$(PKG_NAME)-plugin-$(subst _,-,$(1))/install
  143. $(INSTALL_DIR) $$(1)$(MARIADB_PLUGIN_DIR)
  144. $(call Package/$(PKG_NAME)/install/plugin,$$(1),$(1))
  145. endef
  146. $$(eval $$(call BuildPackage,$(PKG_NAME)-plugin-$(subst _,-,$(1))))
  147. endef
  148. $(eval $(call BuildPackage,$(PKG_NAME)))
  149. $(eval $(call BuildPlugin,auth_gssapi_client,+krb5-libs))
  150. $(eval $(call BuildPlugin,remote_io,+libcurl))