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.

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