diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2010-09-03 16:21:31 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2010-09-03 16:21:31 +0200 |
commit | 7e8e8aba7cc49bd26393c8f2cb07d99df9fec8dd (patch) | |
tree | cbbef7278026edf6ee1d9d93c9ef3df2e50bd001 | |
parent | ab9911fc1ed97bcfcb013c202c610a950609f979 (diff) |
Add support for MinGW build
-rw-r--r-- | configure.ac | 16 | ||||
-rw-r--r-- | m4/libmysqlclient.m4 | 35 | ||||
-rw-r--r-- | m4/static-lib.m4 | 19 | ||||
-rw-r--r-- | odb/mysql/Makefile.am | 5 | ||||
-rw-r--r-- | odb/mysql/connection-factory.cxx | 11 | ||||
-rw-r--r-- | odb/mysql/connection.hxx | 7 | ||||
-rw-r--r-- | odb/mysql/database.hxx | 7 | ||||
-rw-r--r-- | odb/mysql/details/config.h.in | 17 | ||||
-rw-r--r-- | odb/mysql/details/config.hxx | 8 | ||||
-rw-r--r-- | odb/mysql/details/export.hxx | 20 | ||||
-rw-r--r-- | odb/mysql/exceptions.cxx | 7 | ||||
-rw-r--r-- | odb/mysql/exceptions.hxx | 7 | ||||
-rw-r--r-- | odb/mysql/makefile | 2 | ||||
-rw-r--r-- | odb/mysql/query.hxx | 7 | ||||
-rw-r--r-- | odb/mysql/statement.cxx | 7 | ||||
-rw-r--r-- | odb/mysql/statement.hxx | 7 | ||||
-rw-r--r-- | odb/mysql/traits.hxx | 7 | ||||
-rw-r--r-- | odb/mysql/transaction-impl.cxx | 7 |
18 files changed, 155 insertions, 41 deletions
diff --git a/configure.ac b/configure.ac index 39fb278..484a443 100644 --- a/configure.ac +++ b/configure.ac @@ -35,10 +35,24 @@ LIBMYSQLCLIENT( [], [AC_MSG_ERROR([lib$libmysqlclient_name is not found; consider using CPPFLAGS/LDFLAGS to specify its location])]) +case $libmysqlclient_include in + short) + AC_DEFINE([LIBODB_MYSQL_INCLUDE_SHORT], [1], ["Short MySQL include."]) + ;; + long) + AC_DEFINE([LIBODB_MYSQL_INCLUDE_LONG], [1], ["Long MySQL include."]) + ;; +esac + # Check for libodb. # LIBODB([],[AC_MSG_ERROR([libodb is not found; consider using --with-libodb=DIR])]) +# Define LIBODB_MYSQL_STATIC_LIB if we are build static library on certain +# platforms. +# +STATIC_LIB([LIBODB_MYSQL_STATIC_LIB], [Static library interface.]) + # Allow the user to specify the pkgconfig directory. # PKGCONFIG @@ -49,7 +63,7 @@ DISABLE_RPATH # Output. # -AC_CONFIG_HEADERS([odb/mysql/config.h]) +AC_CONFIG_HEADERS([odb/mysql/config.h odb/mysql/details/config.h]) AC_CONFIG_FILES([ __path__(config_files) ]) diff --git a/m4/libmysqlclient.m4 b/m4/libmysqlclient.m4 index 3f607a2..bacb765 100644 --- a/m4/libmysqlclient.m4 +++ b/m4/libmysqlclient.m4 @@ -24,6 +24,9 @@ LIBS="-l$libmysqlclient_name $LIBS" CXX_LIBTOOL_LINK_IFELSE( AC_LANG_SOURCE([[ +#ifdef _WIN32 +# include <winsock2.h> +#endif #include <mysql/mysql.h> int @@ -37,7 +40,37 @@ main () mysql_close (&handle); } ]]), -[libmysqlclient_found=yes]) +[ +libmysqlclient_found=yes +libmysqlclient_include=long +]) + +if test x"$libmysqlclient_found" = xno; then + +CXX_LIBTOOL_LINK_IFELSE( +AC_LANG_SOURCE([[ +#ifdef _WIN32 +# include <winsock2.h> +#endif +#include <mysql.h> + +int +main () +{ + MYSQL handle; + mysql_init (&handle); + mysql_real_connect (&handle, 0, 0, 0, 0, 0, 0, 0); + MYSQL_STMT* stmt = mysql_stmt_init (&handle); + mysql_stmt_close (stmt); + mysql_close (&handle); +} +]]), +[ +libmysqlclient_found=yes +libmysqlclient_include=short +]) + +fi if test x"$libmysqlclient_found" = xno; then LIBS="$save_LIBS" diff --git a/m4/static-lib.m4 b/m4/static-lib.m4 new file mode 100644 index 0000000..1c0af42 --- /dev/null +++ b/m4/static-lib.m4 @@ -0,0 +1,19 @@ +dnl file : m4/static-lib.m4 +dnl author : Boris Kolpackov <boris@codesynthesis.com> +dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +dnl STATIC_LIB(MACRO, DESCRIPTION) +dnl +dnl Define MACRO if we are on MinGW and are only building static library. +dnl +AC_DEFUN([STATIC_LIB], +[ +if test x$enable_shared = xno; then + case $host_os in + mingw*) + AC_DEFINE([$1], [1], [$2]) + ;; + esac +fi +])dnl diff --git a/odb/mysql/Makefile.am b/odb/mysql/Makefile.am index 3d5c2b3..25059a9 100644 --- a/odb/mysql/Makefile.am +++ b/odb/mysql/Makefile.am @@ -8,8 +8,9 @@ libodb_mysql_la_SOURCES = __path__(sources) odbmysqlincludedir = $(includedir)/odb/mysql/ nobase_odbmysqlinclude_HEADERS = __path__(headers) +nobase_nodist_odbmysqlinclude_HEADERS = details/config.h EXTRA_DIST = __file__(extra_dist) -AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -libodb_mysql_la_LDFLAGS = -release __value__(interface_version) +libodb_mysql_la_CPPFLAGS= -I$(top_builddir) -I$(top_srcdir) -DLIBODB_MYSQL_DYNAMIC_LIB +libodb_mysql_la_LDFLAGS = -release __value__(interface_version) -no-undefined diff --git a/odb/mysql/connection-factory.cxx b/odb/mysql/connection-factory.cxx index c490048..2bfd566 100644 --- a/odb/mysql/connection-factory.cxx +++ b/odb/mysql/connection-factory.cxx @@ -5,10 +5,11 @@ #include <odb/mysql/details/config.hxx> +#ifdef _WIN32 +# include <winsock2.h> +#endif + #ifdef LIBODB_MYSQL_INCLUDE_SHORT -# ifdef _WIN32 -# include <winsock2.h> -# endif # include <mysql.h> # include <errmsg.h> // CR_UNKNOWN_ERROR #else @@ -38,7 +39,7 @@ namespace odb #ifndef ODB_THREADS_NONE mysql_init () { - if (my_thread_init ()) + if (mysql_thread_init ()) { throw database_exception ( CR_UNKNOWN_ERROR, "?????", "thread initialization failed"); @@ -47,7 +48,7 @@ namespace odb ~mysql_init () { - my_thread_end (); + mysql_thread_end (); } #endif }; diff --git a/odb/mysql/connection.hxx b/odb/mysql/connection.hxx index 9cbd5c5..b00be75 100644 --- a/odb/mysql/connection.hxx +++ b/odb/mysql/connection.hxx @@ -10,10 +10,11 @@ #include <odb/mysql/details/config.hxx> +#ifdef _WIN32 +# include <winsock2.h> +#endif + #ifdef LIBODB_MYSQL_INCLUDE_SHORT -# ifdef _WIN32 -# include <winsock2.h> -# endif # include <mysql.h> #else # include <mysql/mysql.h> diff --git a/odb/mysql/database.hxx b/odb/mysql/database.hxx index 0344f3c..b10b037 100644 --- a/odb/mysql/database.hxx +++ b/odb/mysql/database.hxx @@ -10,10 +10,11 @@ #include <odb/mysql/details/config.hxx> +#ifdef _WIN32 +# include <winsock2.h> +#endif + #ifdef LIBODB_MYSQL_INCLUDE_SHORT -# ifdef _WIN32 -# include <winsock2.h> -# endif # include <mysql.h> #else # include <mysql/mysql.h> diff --git a/odb/mysql/details/config.h.in b/odb/mysql/details/config.h.in new file mode 100644 index 0000000..81c308a --- /dev/null +++ b/odb/mysql/details/config.h.in @@ -0,0 +1,17 @@ +/* file : odb/mysql/details/config.h.in + * author : Boris Kolpackov <boris@codesynthesis.com> + * copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC + * license : GNU GPL v2; see accompanying LICENSE file + */ + +/* This file is automatically processed by configure. */ + +#ifndef ODB_MYSQL_DETAILS_CONFIG_H +#define ODB_MYSQL_DETAILS_CONFIG_H + +#undef LIBODB_MYSQL_STATIC_LIB + +#undef LIBODB_MYSQL_INCLUDE_SHORT +#undef LIBODB_MYSQL_INCLUDE_LONG + +#endif /* ODB_MYSQL_DETAILS_CONFIG_H */ diff --git a/odb/mysql/details/config.hxx b/odb/mysql/details/config.hxx index f8418c6..957f623 100644 --- a/odb/mysql/details/config.hxx +++ b/odb/mysql/details/config.hxx @@ -8,9 +8,15 @@ // no pre -#ifndef LIBODB_MYSQL_INCLUDE_SHORT +#ifdef HAVE_CONFIG_H +# include <odb/mysql/details/config.h> +#endif + +#if !defined(LIBODB_MYSQL_INCLUDE_SHORT) && !defined (LIBODB_MYSQL_INCLUDE_LONG) #ifdef _WIN32 #define LIBODB_MYSQL_INCLUDE_SHORT 1 + #else + #define LIBODB_MYSQL_INCLUDE_LONG 1 #endif #endif diff --git a/odb/mysql/details/export.hxx b/odb/mysql/details/export.hxx index bb3bac5..410f6d3 100644 --- a/odb/mysql/details/export.hxx +++ b/odb/mysql/details/export.hxx @@ -8,14 +8,28 @@ #include <odb/pre.hxx> +#include <odb/mysql/details/config.hxx> + #ifdef LIBODB_MYSQL_STATIC_LIB # define LIBODB_MYSQL_EXPORT #else # ifdef _WIN32 -# ifdef LIBODB_MYSQL_DYNAMIC_LIB -# define LIBODB_MYSQL_EXPORT __declspec(dllexport) +# ifdef _MSC_VER +# ifdef LIBODB_MYSQL_DYNAMIC_LIB +# define LIBODB_MYSQL_EXPORT __declspec(dllexport) +# else +# define LIBODB_MYSQL_EXPORT __declspec(dllimport) +# endif # else -# define LIBODB_MYSQL_EXPORT __declspec(dllimport) +# ifdef LIBODB_MYSQL_DYNAMIC_LIB +# ifdef DLL_EXPORT +# define LIBODB_MYSQL_EXPORT __declspec(dllexport) +# else +# define LIBODB_MYSQL_EXPORT +# endif +# else +# define LIBODB_MYSQL_EXPORT __declspec(dllimport) +# endif # endif # else # define LIBODB_MYSQL_EXPORT diff --git a/odb/mysql/exceptions.cxx b/odb/mysql/exceptions.cxx index b857fb6..636c223 100644 --- a/odb/mysql/exceptions.cxx +++ b/odb/mysql/exceptions.cxx @@ -5,10 +5,11 @@ #include <odb/mysql/details/config.hxx> +#ifdef _WIN32 +# include <winsock2.h> +#endif + #ifdef LIBODB_MYSQL_INCLUDE_SHORT -# ifdef _WIN32 -# include <winsock2.h> -# endif # include <errmsg.h> // CR_OUT_OF_MEMORY #else # include <mysql/errmsg.h> diff --git a/odb/mysql/exceptions.hxx b/odb/mysql/exceptions.hxx index 6be2d80..834a4d6 100644 --- a/odb/mysql/exceptions.hxx +++ b/odb/mysql/exceptions.hxx @@ -10,10 +10,11 @@ #include <odb/mysql/details/config.hxx> +#ifdef _WIN32 +# include <winsock2.h> +#endif + #ifdef LIBODB_MYSQL_INCLUDE_SHORT -# ifdef _WIN32 -# include <winsock2.h> -# endif # include <mysql.h> #else # include <mysql/mysql.h> diff --git a/odb/mysql/makefile b/odb/mysql/makefile index 49d42a7..94495ac 100644 --- a/odb/mysql/makefile +++ b/odb/mysql/makefile @@ -66,7 +66,7 @@ $(dist): export interface_version = $(shell sed -e \ 's/^\([0-9]*\.[0-9]*\).*/\1/' $(src_root)/version) $(dist): - $(call dist-data,$(sources) $(headers)) + $(call dist-data,$(sources) $(headers) details/config.h.in) $(call meta-vc9proj,$(src_base)/libodb-mysql-vc9.vcproj) $(call meta-vc10proj,$(src_base)/libodb-mysql-vc10.vcxproj) $(call meta-automake) diff --git a/odb/mysql/query.hxx b/odb/mysql/query.hxx index 5dd4339..8e1d241 100644 --- a/odb/mysql/query.hxx +++ b/odb/mysql/query.hxx @@ -10,10 +10,11 @@ #include <odb/mysql/details/config.hxx> +#ifdef _WIN32 +# include <winsock2.h> +#endif + #ifdef LIBODB_MYSQL_INCLUDE_SHORT -# ifdef _WIN32 -# include <winsock2.h> -# endif # include <mysql.h> #else # include <mysql/mysql.h> diff --git a/odb/mysql/statement.cxx b/odb/mysql/statement.cxx index 9cacc4f..95edbbd 100644 --- a/odb/mysql/statement.cxx +++ b/odb/mysql/statement.cxx @@ -5,10 +5,11 @@ #include <odb/mysql/details/config.hxx> +#ifdef _WIN32 +# include <winsock2.h> +#endif + #ifdef LIBODB_MYSQL_INCLUDE_SHORT -# ifdef _WIN32 -# include <winsock2.h> -# endif # include <mysqld_error.h> // ER_DUP_ENTRY, ER_LOCK_DEADLOCK #else # include <mysql/mysqld_error.h> diff --git a/odb/mysql/statement.hxx b/odb/mysql/statement.hxx index 7ac9c61..78681a2 100644 --- a/odb/mysql/statement.hxx +++ b/odb/mysql/statement.hxx @@ -10,10 +10,11 @@ #include <odb/mysql/details/config.hxx> +#ifdef _WIN32 +# include <winsock2.h> +#endif + #ifdef LIBODB_MYSQL_INCLUDE_SHORT -# ifdef _WIN32 -# include <winsock2.h> -# endif # include <mysql.h> #else # include <mysql/mysql.h> diff --git a/odb/mysql/traits.hxx b/odb/mysql/traits.hxx index bf52d78..a520d1b 100644 --- a/odb/mysql/traits.hxx +++ b/odb/mysql/traits.hxx @@ -10,10 +10,11 @@ #include <odb/mysql/details/config.hxx> +#ifdef _WIN32 +# include <winsock2.h> +#endif + #ifdef LIBODB_MYSQL_INCLUDE_SHORT -# ifdef _WIN32 -# include <winsock2.h> -# endif # include <mysql.h> // MYSQL_TIME, used in custom specializations. #else # include <mysql/mysql.h> diff --git a/odb/mysql/transaction-impl.cxx b/odb/mysql/transaction-impl.cxx index 946ea23..04493e6 100644 --- a/odb/mysql/transaction-impl.cxx +++ b/odb/mysql/transaction-impl.cxx @@ -5,10 +5,11 @@ #include <odb/mysql/details/config.hxx> +#ifdef _WIN32 +# include <winsock2.h> +#endif + #ifdef LIBODB_MYSQL_INCLUDE_SHORT -# ifdef _WIN32 -# include <winsock2.h> -# endif # include <mysql.h> #else # include <mysql/mysql.h> |