sl@0: // (C) Copyright John Maddock 2003. sl@0: // Use, modification and distribution are subject to the sl@0: // Boost Software License, Version 1.0. (See accompanying file sl@0: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: /* sl@0: * LOCATION: see http://www.boost.org for most recent version. sl@0: * FILE auto_link.hpp sl@0: * VERSION see sl@0: * DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers. sl@0: */ sl@0: sl@0: /************************************************************************* sl@0: sl@0: USAGE: sl@0: ~~~~~~ sl@0: sl@0: Before including this header you must define one or more of define the following macros: sl@0: sl@0: BOOST_LIB_NAME: Required: A string containing the basename of the library, sl@0: for example boost_regex. sl@0: BOOST_LIB_TOOLSET: Optional: the base name of the toolset. sl@0: BOOST_DYN_LINK: Optional: when set link to dll rather than static library. sl@0: BOOST_LIB_DIAGNOSTIC: Optional: when set the header will print out the name sl@0: of the library selected (useful for debugging). sl@0: BOOST_AUTO_LINK_NOMANGLE: Specifies that we should link to BOOST_LIB_NAME.lib, sl@0: rather than a mangled-name version. sl@0: sl@0: These macros will be undef'ed at the end of the header, further this header sl@0: has no include guards - so be sure to include it only once from your library! sl@0: sl@0: Algorithm: sl@0: ~~~~~~~~~~ sl@0: sl@0: Libraries for Borland and Microsoft compilers are automatically sl@0: selected here, the name of the lib is selected according to the following sl@0: formula: sl@0: sl@0: BOOST_LIB_PREFIX sl@0: + BOOST_LIB_NAME sl@0: + "_" sl@0: + BOOST_LIB_TOOLSET sl@0: + BOOST_LIB_THREAD_OPT sl@0: + BOOST_LIB_RT_OPT sl@0: "-" sl@0: + BOOST_LIB_VERSION sl@0: sl@0: These are defined as: sl@0: sl@0: BOOST_LIB_PREFIX: "lib" for static libraries otherwise "". sl@0: sl@0: BOOST_LIB_NAME: The base name of the lib ( for example boost_regex). sl@0: sl@0: BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc). sl@0: sl@0: BOOST_LIB_THREAD_OPT: "-mt" for multithread builds, otherwise nothing. sl@0: sl@0: BOOST_LIB_RT_OPT: A suffix that indicates the runtime library used, sl@0: contains one or more of the following letters after sl@0: a hiphen: sl@0: sl@0: s static runtime (dynamic if not present). sl@0: d debug build (release if not present). sl@0: g debug/diagnostic runtime (release if not present). sl@0: p STLPort Build. sl@0: sl@0: BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y. sl@0: sl@0: sl@0: ***************************************************************************/ sl@0: sl@0: #ifdef __cplusplus sl@0: # ifndef BOOST_CONFIG_HPP sl@0: # include sl@0: # endif sl@0: #elif defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__EDG_VERSION__) sl@0: // sl@0: // C language compatability (no, honestly) sl@0: // sl@0: # define BOOST_MSVC _MSC_VER sl@0: # define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X) sl@0: # define BOOST_DO_STRINGIZE(X) #X sl@0: #endif sl@0: // sl@0: // Only include what follows for known and supported compilers: sl@0: // sl@0: #if defined(BOOST_MSVC) \ sl@0: || defined(__BORLANDC__) \ sl@0: || (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) \ sl@0: || (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200)) sl@0: sl@0: #ifndef BOOST_VERSION_HPP sl@0: # include sl@0: #endif sl@0: sl@0: #ifndef BOOST_LIB_NAME sl@0: # error "Macro BOOST_LIB_NAME not set (internal error)" sl@0: #endif sl@0: sl@0: // sl@0: // error check: sl@0: // sl@0: #if defined(__MSVC_RUNTIME_CHECKS) && !defined(_DEBUG) sl@0: # pragma message("Using the /RTC option without specifying a debug runtime will lead to linker errors") sl@0: # pragma message("Hint: go to the code generation options and switch to one of the debugging runtimes") sl@0: # error "Incompatible build options" sl@0: #endif sl@0: // sl@0: // select toolset if not defined already: sl@0: // sl@0: #ifndef BOOST_LIB_TOOLSET sl@0: // Note: no compilers before 1200 are supported sl@0: #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) sl@0: sl@0: # ifdef UNDER_CE sl@0: // vc6: sl@0: # define BOOST_LIB_TOOLSET "evc4" sl@0: # else sl@0: // vc6: sl@0: # define BOOST_LIB_TOOLSET "vc6" sl@0: # endif sl@0: sl@0: #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1300) sl@0: sl@0: // vc7: sl@0: # define BOOST_LIB_TOOLSET "vc7" sl@0: sl@0: #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1310) sl@0: sl@0: // vc71: sl@0: # define BOOST_LIB_TOOLSET "vc71" sl@0: sl@0: #elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1400) sl@0: sl@0: // vc80: sl@0: # define BOOST_LIB_TOOLSET "vc80" sl@0: sl@0: #elif defined(__BORLANDC__) sl@0: sl@0: // CBuilder 6: sl@0: # define BOOST_LIB_TOOLSET "bcb" sl@0: sl@0: #elif defined(__ICL) sl@0: sl@0: // Intel C++, no version number: sl@0: # define BOOST_LIB_TOOLSET "iw" sl@0: sl@0: #elif defined(__MWERKS__) && (__MWERKS__ <= 0x31FF ) sl@0: sl@0: // Metrowerks CodeWarrior 8.x sl@0: # define BOOST_LIB_TOOLSET "cw8" sl@0: sl@0: #elif defined(__MWERKS__) && (__MWERKS__ <= 0x32FF ) sl@0: sl@0: // Metrowerks CodeWarrior 9.x sl@0: # define BOOST_LIB_TOOLSET "cw9" sl@0: sl@0: #endif sl@0: #endif // BOOST_LIB_TOOLSET sl@0: sl@0: // sl@0: // select thread opt: sl@0: // sl@0: #if defined(_MT) || defined(__MT__) sl@0: # define BOOST_LIB_THREAD_OPT "-mt" sl@0: #else sl@0: # define BOOST_LIB_THREAD_OPT sl@0: #endif sl@0: sl@0: #if defined(_MSC_VER) || defined(__MWERKS__) sl@0: sl@0: # ifdef _DLL sl@0: sl@0: # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) sl@0: sl@0: # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) sl@0: # define BOOST_LIB_RT_OPT "-gdp" sl@0: # elif defined(_DEBUG) sl@0: # define BOOST_LIB_RT_OPT "-gdp" sl@0: # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") sl@0: # error "Build options aren't compatible with pre-built libraries" sl@0: # else sl@0: # define BOOST_LIB_RT_OPT "-p" sl@0: # endif sl@0: sl@0: # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) sl@0: sl@0: # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) sl@0: # define BOOST_LIB_RT_OPT "-gdpn" sl@0: # elif defined(_DEBUG) sl@0: # define BOOST_LIB_RT_OPT "-gdpn" sl@0: # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") sl@0: # error "Build options aren't compatible with pre-built libraries" sl@0: # else sl@0: # define BOOST_LIB_RT_OPT "-pn" sl@0: # endif sl@0: sl@0: # else sl@0: sl@0: # if defined(_DEBUG) sl@0: # define BOOST_LIB_RT_OPT "-gd" sl@0: # else sl@0: # define BOOST_LIB_RT_OPT sl@0: # endif sl@0: sl@0: # endif sl@0: sl@0: # else sl@0: sl@0: # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) sl@0: sl@0: # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) sl@0: # define BOOST_LIB_RT_OPT "-sgdp" sl@0: # elif defined(_DEBUG) sl@0: # define BOOST_LIB_RT_OPT "-sgdp" sl@0: # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") sl@0: # error "Build options aren't compatible with pre-built libraries" sl@0: # else sl@0: # define BOOST_LIB_RT_OPT "-sp" sl@0: # endif sl@0: sl@0: # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) sl@0: sl@0: # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) sl@0: # define BOOST_LIB_RT_OPT "-sgdpn" sl@0: # elif defined(_DEBUG) sl@0: # define BOOST_LIB_RT_OPT "-sgdpn" sl@0: # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") sl@0: # error "Build options aren't compatible with pre-built libraries" sl@0: # else sl@0: # define BOOST_LIB_RT_OPT "-spn" sl@0: # endif sl@0: sl@0: # else sl@0: sl@0: # if defined(_DEBUG) sl@0: # define BOOST_LIB_RT_OPT "-sgd" sl@0: # else sl@0: # define BOOST_LIB_RT_OPT "-s" sl@0: # endif sl@0: sl@0: # endif sl@0: sl@0: # endif sl@0: sl@0: #elif defined(__BORLANDC__) sl@0: sl@0: // sl@0: // figure out whether we want the debug builds or not: sl@0: // sl@0: #if __BORLANDC__ > 0x561 sl@0: #pragma defineonoption BOOST_BORLAND_DEBUG -v sl@0: #endif sl@0: // sl@0: // sanity check: sl@0: // sl@0: #if defined(__STL_DEBUG) || defined(_STLP_DEBUG) sl@0: #error "Pre-built versions of the Boost libraries are not provided in STLPort-debug form" sl@0: #endif sl@0: sl@0: # ifdef _RTLDLL sl@0: sl@0: # ifdef BOOST_BORLAND_DEBUG sl@0: # define BOOST_LIB_RT_OPT "-d" sl@0: # else sl@0: # define BOOST_LIB_RT_OPT sl@0: # endif sl@0: sl@0: # else sl@0: sl@0: # ifdef BOOST_BORLAND_DEBUG sl@0: # define BOOST_LIB_RT_OPT "-sd" sl@0: # else sl@0: # define BOOST_LIB_RT_OPT "-s" sl@0: # endif sl@0: sl@0: # endif sl@0: sl@0: #endif sl@0: sl@0: // sl@0: // select linkage opt: sl@0: // sl@0: #if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_DYN_LINK) sl@0: # define BOOST_LIB_PREFIX sl@0: #elif defined(BOOST_DYN_LINK) sl@0: # error "Mixing a dll boost library with a static runtime is a really bad idea..." sl@0: #else sl@0: # define BOOST_LIB_PREFIX "lib" sl@0: #endif sl@0: sl@0: // sl@0: // now include the lib: sl@0: // sl@0: #if defined(BOOST_LIB_NAME) \ sl@0: && defined(BOOST_LIB_PREFIX) \ sl@0: && defined(BOOST_LIB_TOOLSET) \ sl@0: && defined(BOOST_LIB_THREAD_OPT) \ sl@0: && defined(BOOST_LIB_RT_OPT) \ sl@0: && defined(BOOST_LIB_VERSION) sl@0: sl@0: #ifndef BOOST_AUTO_LINK_NOMANGLE sl@0: # pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib") sl@0: # ifdef BOOST_LIB_DIAGNOSTIC sl@0: # pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT "-" BOOST_LIB_VERSION ".lib") sl@0: # endif sl@0: #else sl@0: # pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib") sl@0: # ifdef BOOST_LIB_DIAGNOSTIC sl@0: # pragma message ("Linking to lib file: " BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib") sl@0: # endif sl@0: #endif sl@0: sl@0: #else sl@0: # error "some required macros where not defined (internal logic error)." sl@0: #endif sl@0: sl@0: sl@0: #endif // _MSC_VER || __BORLANDC__ sl@0: sl@0: // sl@0: // finally undef any macros we may have set: sl@0: // sl@0: #ifdef BOOST_LIB_PREFIX sl@0: # undef BOOST_LIB_PREFIX sl@0: #endif sl@0: #if defined(BOOST_LIB_NAME) sl@0: # undef BOOST_LIB_NAME sl@0: #endif sl@0: // Don't undef this one: it can be set by the user and should be the sl@0: // same for all libraries: sl@0: //#if defined(BOOST_LIB_TOOLSET) sl@0: //# undef BOOST_LIB_TOOLSET sl@0: //#endif sl@0: #if defined(BOOST_LIB_THREAD_OPT) sl@0: # undef BOOST_LIB_THREAD_OPT sl@0: #endif sl@0: #if defined(BOOST_LIB_RT_OPT) sl@0: # undef BOOST_LIB_RT_OPT sl@0: #endif sl@0: #if defined(BOOST_LIB_LINK_OPT) sl@0: # undef BOOST_LIB_LINK_OPT sl@0: #endif sl@0: #if defined(BOOST_LIB_DEBUG_OPT) sl@0: # undef BOOST_LIB_DEBUG_OPT sl@0: #endif sl@0: #if defined(BOOST_DYN_LINK) sl@0: # undef BOOST_DYN_LINK sl@0: #endif sl@0: #if defined(BOOST_AUTO_LINK_NOMANGLE) sl@0: # undef BOOST_AUTO_LINK_NOMANGLE sl@0: #endif sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: