File private_library.patch of Package mariadb-connector-c

Author: Adam Majer <amajer@suse.de>
Date: Thu Mar 23 11:54:11 CET 2017
Summary: Build private symbols library

Some of the private symbols have very generic names and are required
by other connectors, like the ODBC connector. Instead of using
static linking, create a private shared library that simply
exports all symbols. With the exception of exported symbols, it is
identical to the regular library.

Index: mariadb-connector-c-2.3.2-src/libmariadb/CMakeLists.txt
===================================================================
--- mariadb-connector-c-2.3.2-src.orig/libmariadb/CMakeLists.txt
+++ mariadb-connector-c-2.3.2-src/libmariadb/CMakeLists.txt
@@ -397,13 +397,22 @@ IF(UNIX)
 ENDIF()
 SIGN_TARGET(libmariadb)
 
+ADD_LIBRARY(libmariadbprivate SHARED ${libmariadb_RC} $<TARGET_OBJECTS:mariadb_obj> ${EMPTY_FILE} ${EXPORT_LINK})
+TARGET_LINK_LIBRARIES(libmariadbprivate ${SYSTEM_LIBS})
+IF(UNIX)
+  SET_TARGET_PROPERTIES(libmariadbprivate PROPERTIES COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
+ENDIF()
+
 IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
   TARGET_LINK_LIBRARIES (libmariadb "-Wl,--no-undefined")
   TARGET_LINK_LIBRARIES (libmariadb "-Wl,--version-script=${EXPORT_FILE}")
   TARGET_LINK_LIBRARIES (mariadbclient "-Wl,--no-undefined")
   TARGET_LINK_LIBRARIES (mariadbclient "-Wl,--version-script=${EXPORT_FILE}")
+  TARGET_LINK_LIBRARIES (libmariadbprivate "-Wl,--no-undefined")
 ENDIF()
 
+SET_TARGET_PROPERTIES(libmariadbprivate PROPERTIES PREFIX "")
+
 SET_TARGET_PROPERTIES(libmariadb PROPERTIES PREFIX "")
 
 SET_TARGET_PROPERTIES(libmariadb PROPERTIES VERSION 
@@ -429,7 +438,7 @@ ENDIF()
 
 
 INSTALL(TARGETS
-          libmariadb mariadbclient
+          libmariadb libmariadbprivate mariadbclient
           RUNTIME DESTINATION "${LIB_INSTALL_DIR}"
           LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
           ARCHIVE DESTINATION "${LIB_INSTALL_DIR}")
Index: mariadb-connector-c-2.3.2-src/mariadb_config/mariadb_config.c.in
===================================================================
--- mariadb-connector-c-2.3.2-src.orig/mariadb_config/mariadb_config.c.in
+++ mariadb-connector-c-2.3.2-src/mariadb_config/mariadb_config.c.in
@@ -6,6 +6,8 @@
 #define INCLUDE "-I@INCLUDE_INSTALL_DIR@ -I@INCLUDE_INSTALL_DIR@/mariadb"
 #define LIBS    "-L@LIB_INSTALL_DIR@/mariadb -lmariadb" \
                 "@extra_dynamic_LDFLAGS@"
+#define PRIVATE_LIBS "-L@LIB_INSTALL_DIR@/mariadb -lmariadbprivate" \
+                "@extra_dynamic_LDFLAGS@"
 #define CFLAGS  INCLUDE " @CMAKE_C_FLAGS@"
 #define VERSION "@MYSQL_CLIENT_VERSION@"
 #define PLUGIN_DIR "@PLUGIN_INSTALL_DIR@"
@@ -22,6 +24,7 @@ static struct option long_options[]=
   {"version", no_argument, 0, 'f'},
   {"socket", no_argument, 0, 'g'},
   {"port", no_argument, 0, 'h'},
+  {"privatelibs", no_argument, 0, 'i'},
   {"plugindir", no_argument, 0, 'p'},
   {NULL, 0, 0, 0}
 };
@@ -36,6 +39,7 @@ static char *values[]=
   VERSION,
   SOCKET,
   PORT,
+  PRIVATE_LIBS,
   PLUGIN_DIR
 };
 
@@ -92,6 +96,9 @@ int main(int argc, char **argv)
     case 'h':
       puts(PORT);
       break;
+    case 'i':
+      puts(PRIVATE_LIBS);
+      break;
     case 'p':
       puts(PLUGIN_DIR);
       break;
Index: mariadb-connector-c-2.3.2-src/plugins/auth/CMakeLists.txt
===================================================================
--- mariadb-connector-c-2.3.2-src.orig/plugins/auth/CMakeLists.txt
+++ mariadb-connector-c-2.3.2-src/plugins/auth/CMakeLists.txt
@@ -10,7 +10,7 @@ IF(WIN32)
                    "FILE_DESCRIPTION:Authentication plugin")
   SET(DIALOG_SOURCES ${DIALOG_SOURCES} ${CMAKE_SOURCE_DIR}/plugins/plugin.def)
 ENDIF()
-ADD_LIBRARY(dialog SHARED ${dialog_RC} ${DIALOG_SOURCES})
+ADD_LIBRARY(dialog MODULE ${dialog_RC} ${DIALOG_SOURCES})
 TARGET_LINK_LIBRARIES(dialog dl)
 SET_TARGET_PROPERTIES(dialog PROPERTIES PREFIX "")
 SIGN_TARGET(dialog)
@@ -32,7 +32,7 @@ IF(WIN32)
                      "FILE_DESCRIPTION:Authentication plugin")
   SET(CTEXT_SOURCES ${CTEXT_SOURCES} ${CMAKE_SOURCE_DIR}/plugins/plugin.def)
 ENDIF()
-ADD_LIBRARY(mysql_clear_password SHARED ${mysql_clear_password_RC} ${CTEXT_SOURCES})
+ADD_LIBRARY(mysql_clear_password MODULE ${mysql_clear_password_RC} ${CTEXT_SOURCES})
 SET_TARGET_PROPERTIES(mysql_clear_password PROPERTIES PREFIX "")
 SIGN_TARGET(mysql_clear_password)