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.

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