From 547d1dd2da9c9b2b010da6d167ac88959342a634 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 30 Aug 2010 15:49:05 +0200 Subject: Support for automake and VC++ builds --- configure.ac | 90 +++++++++--------------------------------------- libodb-vc9.sln | 2 +- libodb.pc.in | 2 +- m4/disable-rpath.m4 | 26 ++++++++++++++ m4/libodb.m4 | 83 ++++++++++++++++++++++++++++++++++++++++++++ m4/libtool-link.m4 | 31 +++++++++++++++++ m4/pkgconfig.m4 | 13 +++++++ m4/threads.m4 | 41 ++++++++++++++++++++++ makefile | 1 - odb/compilers/vc/pre.hxx | 7 +++- odb/libodb-vc10.vcxproj | 16 ++++----- odb/libodb-vc9.vcproj | 8 ++--- 12 files changed, 231 insertions(+), 89 deletions(-) create mode 100644 m4/disable-rpath.m4 create mode 100644 m4/libodb.m4 create mode 100644 m4/libtool-link.m4 create mode 100644 m4/pkgconfig.m4 create mode 100644 m4/threads.m4 diff --git a/configure.ac b/configure.ac index 932b47c..cad1e36 100644 --- a/configure.ac +++ b/configure.ac @@ -20,82 +20,33 @@ AC_CANONICAL_HOST AC_PROG_CXX AC_LANG(C++) -# Check for threads. +# Required by subdir-objects. # -AC_ARG_ENABLE( - [threads], - AS_HELP_STRING([--disable-threads], [disable threads (enabled by default)]), - [AS_IF([test x"$enableval" = xno], [threads=none], [threads=check])], - [threads=check]) +AM_PROG_CC_C_O -# If thread support is not disabled by the user, figure out what we -# can use. +# Create the libtool executable so that we can use it in further tests. # -AS_IF( - [test x$threads = xcheck], - [ - case $host_os in - windows* | mingw*) - AC_DEFINE([ODB_THREADS_WIN32], [1], [Have Win32 threads.]) - case $host_os in - mingw*) - CXXFLAGS="$CXXFLAGS -mthreads" - ;; - esac - threads=win32 - ;; - *) - ACX_PTHREAD - AS_IF( - [test x$acx_pthread_ok = xyes], - [ - threads=posix - LIBS="$LIBS $PTHREAD_LIBS" - CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" - AC_DEFINE([ODB_THREADS_POSIX], [1], [Have POSIX threads.]) - ]) - ;; - esac - ], - [AC_DEFINE([ODB_THREADS_NONE], [1], [Have no threads.])]) - -AM_CONDITIONAL([ODB_THREADS_NONE], [test x"$threads" = xnone]) -AM_CONDITIONAL([ODB_THREADS_WIN32], [test x"$threads" = xwin32]) -AM_CONDITIONAL([ODB_THREADS_POSIX], [test x"$threads" = xposix]) +LT_OUTPUT -# Check if we should disable rpath. +# Check for threads. # -AC_MSG_CHECKING([whether to use rpath]) -AC_ARG_ENABLE( - [rpath], - [AC_HELP_STRING([--disable-rpath], [patch libtool to not use rpath])], - [libtool_rpath="$enable_rpath"], - [libtool_rpath="yes"]) -AC_MSG_RESULT($libtool_rpath) +THREADS -# Allow the user to specify the pkgconfig directory. -# -AC_ARG_WITH( - [pkgconfigdir], - [AC_HELP_STRING([--with-pkgconfigdir=DIR],[location of pkgconfig dir (default is libdir/pkgconfig)])], - [pkgconfigdir=${withval}], - [pkgconfigdir='${libdir}/pkgconfig']) -AC_SUBST([pkgconfigdir]) +AM_CONDITIONAL([ODB_THREADS_NONE], [test x$threads = xnone]) +AM_CONDITIONAL([ODB_THREADS_WIN32], [test x$threads = xwin32]) +AM_CONDITIONAL([ODB_THREADS_POSIX], [test x$threads = xposix]) -# Required by subdir-objects. +AS_IF([test x$threads = xnone], AC_DEFINE([ODB_THREADS_NONE], [1], [Have no threads.])) +AS_IF([test x$threads = xwin32], AC_DEFINE([ODB_THREADS_WIN32], [1], [Have Win32 threads.])) +AS_IF([test x$threads = xposix], AC_DEFINE([ODB_THREADS_POSIX], [1], [Have POSIX threads.])) + +# Allow the user to specify the pkgconfig directory. # -AM_PROG_CC_C_O +PKGCONFIG -# Patch libtool to not use rpath if requested. +# Check if we should disable rpath. # -AC_CONFIG_COMMANDS( - [libtool-rpath-patch], - [if test "$libtool_use_rpath" = "no"; then - sed < libtool > libtool-2 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_NO_RPATH__ "/' - mv libtool-2 libtool - chmod 755 libtool - fi], - [libtool_use_rpath=$libtool_rpath]) +DISABLE_RPATH # Output. # @@ -104,10 +55,3 @@ AC_CONFIG_FILES([ __path__(config_files) ]) AC_OUTPUT - -AS_IF( - [test x$threads = xcheck], - [ - AC_MSG_NOTICE - AC_MSG_NOTICE([warning: thread support not available, building single-threaded]) - ]) diff --git a/libodb-vc9.sln b/libodb-vc9.sln index ff293ae..2ca5e34 100644 --- a/libodb-vc9.sln +++ b/libodb-vc9.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb", "odb/libodb-vc9.vcproj", "{513E5721-D318-46B0-8CFB-054042DF87A7}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libodb", "odb\libodb-vc9.vcproj", "{513E5721-D318-46B0-8CFB-054042DF87A7}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/libodb.pc.in b/libodb.pc.in index a4bcba5..145bbb0 100644 --- a/libodb.pc.in +++ b/libodb.pc.in @@ -9,7 +9,7 @@ libdir=@libdir@ includedir=@includedir@ Name: libodb -Description: Object persistence compiler for C++, runtime library +Description: Object persistence compiler for C++, common runtime library URL: http://www.codesynthesis.com/products/odb/ Version: @VERSION@ Libs: -L${libdir} -lodb diff --git a/m4/disable-rpath.m4 b/m4/disable-rpath.m4 new file mode 100644 index 0000000..da77bbe --- /dev/null +++ b/m4/disable-rpath.m4 @@ -0,0 +1,26 @@ +dnl file : m4/disable-rpath.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +AC_DEFUN([DISABLE_RPATH],[ + +AC_MSG_CHECKING([whether to use rpath]) +AC_ARG_ENABLE( + [rpath], + [AC_HELP_STRING([--disable-rpath], [patch libtool to not use rpath])], + [libtool_rpath="$enable_rpath"], + [libtool_rpath="yes"]) +AC_MSG_RESULT($libtool_rpath) + +# Patch libtool to not use rpath if requested. +# +AC_CONFIG_COMMANDS( + [libtool-rpath-patch], + [if test "$libtool_use_rpath" = "no"; then + sed < libtool > libtool-2 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_NO_RPATH__ "/' + mv libtool-2 libtool + chmod 755 libtool + fi], + [libtool_use_rpath=$libtool_rpath]) +])dnl diff --git a/m4/libodb.m4 b/m4/libodb.m4 new file mode 100644 index 0000000..a205afd --- /dev/null +++ b/m4/libodb.m4 @@ -0,0 +1,83 @@ +dnl file : m4/libodb.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +dnl LIBODB([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +dnl +dnl +AC_DEFUN([LIBODB], [ +libodb_found=no + +AC_ARG_WITH( + [libodb], + [AC_HELP_STRING([--with-libodb=DIR],[location of libodb build directory])], + [libodb_dir=${withval}], + [libodb_dir=]) + +AC_MSG_CHECKING([for libodb]) + +# If libodb_dir was given, add the necessary preprocessor and linker flags. +# +if test x"$libodb_dir" != x; then + save_CPPFLAGS="$CPPFLAGS" + save_LDFLAGS="$LDFLAGS" + + AS_SET_CATFILE([abs_libodb_dir], [$ac_pwd], [$libodb_dir]) + + CPPFLAGS="$CPPFLAGS -I$abs_libodb_dir" + LDFLAGS="$LDFLAGS -L$abs_libodb_dir/odb" +fi + +save_LIBS="$LIBS" +LIBS="-lodb $LIBS" + +CXX_LIBTOOL_LINK_IFELSE( +AC_LANG_SOURCE([[ +#include + +void +f () +{ +} + +const char* +g () +{ + try + { + f (); + } + catch (const odb::exception& e) + { + return e.what (); + } + return 0; +} + +int +main () +{ + const char* m (g ()); + return m != 0; +} +]]), +[libodb_found=yes]) + +if test x"$libodb_found" = xno; then + LIBS="$save_LIBS" + + if test x"$libodb_dir" != x; then + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + fi +fi + +if test x"$libodb_found" = xyes; then + AC_MSG_RESULT([yes]) + $1 +else + AC_MSG_RESULT([no]) + $2 +fi +])dnl diff --git a/m4/libtool-link.m4 b/m4/libtool-link.m4 new file mode 100644 index 0000000..229b270 --- /dev/null +++ b/m4/libtool-link.m4 @@ -0,0 +1,31 @@ +dnl file : m4/libtool-link.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +dnl +dnl CXX_LIBTOOL_LINK_IFELSE (input, [action-if-true], [action-if-false]) +dnl +dnl Similar to AC_LINK_IFELSE except it uses libtool to perform the +dnl linking and it does this using the C++ compiler. +dnl +AC_DEFUN([CXX_LIBTOOL_LINK_IFELSE],[ +AC_LANG_SAVE +save_CXX="$CXX" +CXX="./libtool --tag=CXX --mode=link $CXX -no-install" +AC_LANG(C++) + +if test -d .libs; then + delete_libs_dir=no +else + delete_libs_dir=yes +fi + +AC_LINK_IFELSE([$1], [$2], [$3]) + +if test x"$delete_libs_dir" != xyes; then + rm -rf .libs +fi + +CXX="$save_CXX" +AC_LANG_RESTORE])dnl diff --git a/m4/pkgconfig.m4 b/m4/pkgconfig.m4 new file mode 100644 index 0000000..ef48ee8 --- /dev/null +++ b/m4/pkgconfig.m4 @@ -0,0 +1,13 @@ +dnl file : m4/pkgconfig.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +AC_DEFUN([PKGCONFIG],[ +AC_ARG_WITH( + [pkgconfigdir], + [AC_HELP_STRING([--with-pkgconfigdir=DIR],[location of pkgconfig dir (default is libdir/pkgconfig)])], + [pkgconfigdir=${withval}], + [pkgconfigdir='${libdir}/pkgconfig']) +AC_SUBST([pkgconfigdir]) +])dnl diff --git a/m4/threads.m4 b/m4/threads.m4 new file mode 100644 index 0000000..7c32abe --- /dev/null +++ b/m4/threads.m4 @@ -0,0 +1,41 @@ +dnl file : m4/threads.m4 +dnl author : Boris Kolpackov +dnl copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +dnl license : GNU GPL v2; see accompanying LICENSE file +dnl +AC_DEFUN([THREADS],[ + +AC_ARG_ENABLE( + [threads], + AS_HELP_STRING([--disable-threads], [disable threads (enabled by default)]), + [AS_IF([test x"$enableval" = xno], [threads=none], [threads=check])], + [threads=check]) + +# If thread support is not disabled by the user, figure out what we can use. +# +if test x$threads = xcheck; then + case $host_os in + windows* | mingw*) + case $host_os in + mingw*) + CXXFLAGS="$CXXFLAGS -mthreads" + ;; + esac + threads=win32 + ;; + *) + ACX_PTHREAD + + if test x$acx_pthread_ok = xyes; then + threads=posix + LIBS="$LIBS $PTHREAD_LIBS" + CXXFLAGS="$CXXFLAGS $PTHREAD_CXXFLAGS" + fi + ;; + esac +fi + +if test x$threads = xcheck; then + AC_MSG_ERROR([thread support not available; use --disable-threads to force single-threaded mode]) +fi +])dnl diff --git a/makefile b/makefile index c69fe3d..e03a047 100644 --- a/makefile +++ b/makefile @@ -15,7 +15,6 @@ $(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs))) $(dist): export dirs := $(dirs) $(dist): export docs := GPLv2 LICENSE README version -$(dist): export docs := GPLv2 LICENSE README version $(dist): data_dist := libodb-vc9.sln libodb-vc10.sln $(dist): exec_dist := bootstrap $(dist): export extra_dist := $(data_dist) $(exec_dist) diff --git a/odb/compilers/vc/pre.hxx b/odb/compilers/vc/pre.hxx index cdcb527..13a006b 100644 --- a/odb/compilers/vc/pre.hxx +++ b/odb/compilers/vc/pre.hxx @@ -19,10 +19,15 @@ #pragma warning (disable:4355) // passing 'this' to a member #pragma warning (disable:4800) // forcing value to bool #pragma warning (disable:4290) // exception specification ignored + //#pragma warning (disable:4275) // non dll-interface base -//#pragma warning (disable:4251) // base needs to have dll-interface //#pragma warning (disable:4224) // nonstandard extension (/Za option) +// VC++ 10.0 (2010) +// +#if (_MSC_VER == 1600) +# pragma warning (disable:4251) // needs to have DLL-interface +#endif // Elevated warnings. // diff --git a/odb/libodb-vc10.vcxproj b/odb/libodb-vc10.vcxproj index 5047a56..81f1a2a 100644 --- a/odb/libodb-vc10.vcxproj +++ b/odb/libodb-vc10.vcxproj @@ -65,12 +65,12 @@ true ..\bin\ - odb_d-__value__(interface_version)-vc10 + odb-d-__value__(interface_version)-vc10 true ..\bin64\ - odb_d-__value__(interface_version)-vc10 + odb-d-__value__(interface_version)-vc10 false @@ -90,13 +90,13 @@ Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_DYNAMIC_LIB;%(PreprocessorDefinitions) .. - 4355;4800;4290;%(DisableSpecificWarnings) + 4355;4800;4290;4251;%(DisableSpecificWarnings) Windows true $(TargetPath) - ..\lib\odb_d.lib + ..\lib\odb-d.lib @@ -107,13 +107,13 @@ Disabled WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBODB_DYNAMIC_LIB;%(PreprocessorDefinitions) .. - 4355;4800;4290;%(DisableSpecificWarnings) + 4355;4800;4290;4251;%(DisableSpecificWarnings) Windows true $(TargetPath) - ..\lib64\odb_d.lib + ..\lib64\odb-d.lib @@ -126,7 +126,7 @@ true WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_DYNAMIC_LIB;%(PreprocessorDefinitions) .. - 4355;4800;4290;%(DisableSpecificWarnings) + 4355;4800;4290;4251;%(DisableSpecificWarnings) Windows @@ -147,7 +147,7 @@ true WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBODB_DYNAMIC_LIB;%(PreprocessorDefinitions) .. - 4355;4800;4290;%(DisableSpecificWarnings) + 4355;4800;4290;4251;%(DisableSpecificWarnings) Windows diff --git a/odb/libodb-vc9.vcproj b/odb/libodb-vc9.vcproj index ac970db..3877c89 100644 --- a/odb/libodb-vc9.vcproj +++ b/odb/libodb-vc9.vcproj @@ -66,11 +66,11 @@ />