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