| 1 | //  (C) Copyright John Maddock 2003. | 
|---|
| 2 | //  Use, modification and distribution are subject to the | 
|---|
| 3 | //  Boost Software License, Version 1.0. (See accompanying file | 
|---|
| 4 | //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | 
|---|
| 5 |  | 
|---|
| 6 |  /* | 
|---|
| 7 |   *   LOCATION:    see http://www.boost.org for most recent version. | 
|---|
| 8 |   *   FILE         auto_link.hpp | 
|---|
| 9 |   *   VERSION      see <boost/version.hpp> | 
|---|
| 10 |   *   DESCRIPTION: Automatic library inclusion for Borland/Microsoft compilers. | 
|---|
| 11 |   */ | 
|---|
| 12 |  | 
|---|
| 13 | /************************************************************************* | 
|---|
| 14 |  | 
|---|
| 15 | USAGE: | 
|---|
| 16 | ~~~~~~ | 
|---|
| 17 |  | 
|---|
| 18 | Before including this header you must define one or more of define the following macros: | 
|---|
| 19 |  | 
|---|
| 20 | BOOST_LIB_NAME:           Required: A string containing the basename of the library, | 
|---|
| 21 |                           for example boost_regex. | 
|---|
| 22 | BOOST_LIB_TOOLSET:        Optional: the base name of the toolset. | 
|---|
| 23 | BOOST_DYN_LINK:           Optional: when set link to dll rather than static library. | 
|---|
| 24 | BOOST_LIB_DIAGNOSTIC:     Optional: when set the header will print out the name | 
|---|
| 25 |                           of the library selected (useful for debugging). | 
|---|
| 26 | BOOST_AUTO_LINK_NOMANGLE: Specifies that we should link to BOOST_LIB_NAME.lib, | 
|---|
| 27 |                           rather than a mangled-name version. | 
|---|
| 28 |  | 
|---|
| 29 | These macros will be undef'ed at the end of the header, further this header | 
|---|
| 30 | has no include guards - so be sure to include it only once from your library! | 
|---|
| 31 |  | 
|---|
| 32 | Algorithm: | 
|---|
| 33 | ~~~~~~~~~~ | 
|---|
| 34 |  | 
|---|
| 35 | Libraries for Borland and Microsoft compilers are automatically | 
|---|
| 36 | selected here, the name of the lib is selected according to the following | 
|---|
| 37 | formula: | 
|---|
| 38 |  | 
|---|
| 39 | BOOST_LIB_PREFIX | 
|---|
| 40 |    + BOOST_LIB_NAME | 
|---|
| 41 |    + "_" | 
|---|
| 42 |    + BOOST_LIB_TOOLSET | 
|---|
| 43 |    + BOOST_LIB_THREAD_OPT | 
|---|
| 44 |    + BOOST_LIB_RT_OPT | 
|---|
| 45 |    "-" | 
|---|
| 46 |    + BOOST_LIB_VERSION | 
|---|
| 47 |  | 
|---|
| 48 | These are defined as: | 
|---|
| 49 |  | 
|---|
| 50 | BOOST_LIB_PREFIX:     "lib" for static libraries otherwise "". | 
|---|
| 51 |  | 
|---|
| 52 | BOOST_LIB_NAME:       The base name of the lib ( for example boost_regex). | 
|---|
| 53 |  | 
|---|
| 54 | BOOST_LIB_TOOLSET:    The compiler toolset name (vc6, vc7, bcb5 etc). | 
|---|
| 55 |  | 
|---|
| 56 | BOOST_LIB_THREAD_OPT: "-mt" for multithread builds, otherwise nothing. | 
|---|
| 57 |  | 
|---|
| 58 | BOOST_LIB_RT_OPT:     A suffix that indicates the runtime library used, | 
|---|
| 59 |                       contains one or more of the following letters after | 
|---|
| 60 |                       a hiphen: | 
|---|
| 61 |  | 
|---|
| 62 |                       s      static runtime (dynamic if not present). | 
|---|
| 63 |                       d      debug build (release if not present). | 
|---|
| 64 |                       g      debug/diagnostic runtime (release if not present). | 
|---|
| 65 |                       p      STLPort Build. | 
|---|
| 66 |  | 
|---|
| 67 | BOOST_LIB_VERSION:    The Boost version, in the form x_y, for Boost version x.y. | 
|---|
| 68 |  | 
|---|
| 69 |  | 
|---|
| 70 | ***************************************************************************/ | 
|---|
| 71 |  | 
|---|
| 72 | #ifdef __cplusplus | 
|---|
| 73 | #  ifndef BOOST_CONFIG_HPP | 
|---|
| 74 | #     include <boost/config.hpp> | 
|---|
| 75 | #  endif | 
|---|
| 76 | #elif defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__EDG_VERSION__) | 
|---|
| 77 | // | 
|---|
| 78 | // C language compatability (no, honestly) | 
|---|
| 79 | // | 
|---|
| 80 | #  define BOOST_MSVC _MSC_VER | 
|---|
| 81 | #  define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X) | 
|---|
| 82 | #  define BOOST_DO_STRINGIZE(X) #X | 
|---|
| 83 | #endif | 
|---|
| 84 | // | 
|---|
| 85 | // Only include what follows for known and supported compilers: | 
|---|
| 86 | // | 
|---|
| 87 | #if defined(BOOST_MSVC) \ | 
|---|
| 88 |     || defined(__BORLANDC__) \ | 
|---|
| 89 |     || (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) \ | 
|---|
| 90 |     || (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200)) | 
|---|
| 91 |  | 
|---|
| 92 | #ifndef BOOST_VERSION_HPP | 
|---|
| 93 | #  include <boost/version.hpp> | 
|---|
| 94 | #endif | 
|---|
| 95 |  | 
|---|
| 96 | #ifndef BOOST_LIB_NAME | 
|---|
| 97 | #  error "Macro BOOST_LIB_NAME not set (internal error)" | 
|---|
| 98 | #endif | 
|---|
| 99 |  | 
|---|
| 100 | // | 
|---|
| 101 | // error check: | 
|---|
| 102 | // | 
|---|
| 103 | #if defined(__MSVC_RUNTIME_CHECKS) && !defined(_DEBUG) | 
|---|
| 104 | #  pragma message("Using the /RTC option without specifying a debug runtime will lead to linker errors") | 
|---|
| 105 | #  pragma message("Hint: go to the code generation options and switch to one of the debugging runtimes") | 
|---|
| 106 | #  error "Incompatible build options" | 
|---|
| 107 | #endif | 
|---|
| 108 | // | 
|---|
| 109 | // select toolset if not defined already: | 
|---|
| 110 | // | 
|---|
| 111 | #ifndef BOOST_LIB_TOOLSET | 
|---|
| 112 | #if defined(BOOST_MSVC) && (BOOST_MSVC == 1200) | 
|---|
| 113 |  | 
|---|
| 114 |    // vc6: | 
|---|
| 115 | #  define BOOST_LIB_TOOLSET "vc6" | 
|---|
| 116 |  | 
|---|
| 117 | #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1300) | 
|---|
| 118 |  | 
|---|
| 119 |    // vc7: | 
|---|
| 120 | #  define BOOST_LIB_TOOLSET "vc7" | 
|---|
| 121 |  | 
|---|
| 122 | #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1310) | 
|---|
| 123 |  | 
|---|
| 124 |    // vc71: | 
|---|
| 125 | #  define BOOST_LIB_TOOLSET "vc71" | 
|---|
| 126 |  | 
|---|
| 127 | #elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1400) | 
|---|
| 128 |  | 
|---|
| 129 |    // vc80: | 
|---|
| 130 | #  define BOOST_LIB_TOOLSET "vc80" | 
|---|
| 131 |  | 
|---|
| 132 | #elif defined(__BORLANDC__) | 
|---|
| 133 |  | 
|---|
| 134 |    // CBuilder 6: | 
|---|
| 135 | #  define BOOST_LIB_TOOLSET "bcb" | 
|---|
| 136 |  | 
|---|
| 137 | #elif defined(__ICL) | 
|---|
| 138 |  | 
|---|
| 139 |    // Intel C++, no version number: | 
|---|
| 140 | #  define BOOST_LIB_TOOLSET "iw" | 
|---|
| 141 |  | 
|---|
| 142 | #elif defined(__MWERKS__) && (__MWERKS__ <= 0x31FF ) | 
|---|
| 143 |  | 
|---|
| 144 |    // Metrowerks CodeWarrior 8.x | 
|---|
| 145 | #  define BOOST_LIB_TOOLSET "cw8" | 
|---|
| 146 |  | 
|---|
| 147 | #elif defined(__MWERKS__) && (__MWERKS__ <= 0x32FF ) | 
|---|
| 148 |  | 
|---|
| 149 |    // Metrowerks CodeWarrior 9.x | 
|---|
| 150 | #  define BOOST_LIB_TOOLSET "cw9" | 
|---|
| 151 |  | 
|---|
| 152 | #endif | 
|---|
| 153 | #endif // BOOST_LIB_TOOLSET | 
|---|
| 154 |  | 
|---|
| 155 | // | 
|---|
| 156 | // select thread opt: | 
|---|
| 157 | // | 
|---|
| 158 | #if defined(_MT) || defined(__MT__) | 
|---|
| 159 | #  define BOOST_LIB_THREAD_OPT "-mt" | 
|---|
| 160 | #else | 
|---|
| 161 | #  define BOOST_LIB_THREAD_OPT | 
|---|
| 162 | #endif | 
|---|
| 163 |  | 
|---|
| 164 | #if defined(_MSC_VER) || defined(__MWERKS__) | 
|---|
| 165 |  | 
|---|
| 166 | #  ifdef _DLL | 
|---|
| 167 |  | 
|---|
| 168 | #     if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) | 
|---|
| 169 |  | 
|---|
| 170 | #        if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) | 
|---|
| 171 | #            define BOOST_LIB_RT_OPT "-gdp" | 
|---|
| 172 | #        elif defined(_DEBUG) | 
|---|
| 173 | #            define BOOST_LIB_RT_OPT "-gdp" | 
|---|
| 174 | #            pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") | 
|---|
| 175 | #            error "Build options aren't compatible with pre-built libraries" | 
|---|
| 176 | #        else | 
|---|
| 177 | #            define BOOST_LIB_RT_OPT "-p" | 
|---|
| 178 | #        endif | 
|---|
| 179 |  | 
|---|
| 180 | #     elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) | 
|---|
| 181 |  | 
|---|
| 182 | #        if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) | 
|---|
| 183 | #            define BOOST_LIB_RT_OPT "-gdpn" | 
|---|
| 184 | #        elif defined(_DEBUG) | 
|---|
| 185 | #            define BOOST_LIB_RT_OPT "-gdpn" | 
|---|
| 186 | #            pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") | 
|---|
| 187 | #            error "Build options aren't compatible with pre-built libraries" | 
|---|
| 188 | #        else | 
|---|
| 189 | #            define BOOST_LIB_RT_OPT "-pn" | 
|---|
| 190 | #        endif | 
|---|
| 191 |  | 
|---|
| 192 | #     else | 
|---|
| 193 |  | 
|---|
| 194 | #        if defined(_DEBUG) | 
|---|
| 195 | #            define BOOST_LIB_RT_OPT "-gd" | 
|---|
| 196 | #        else | 
|---|
| 197 | #            define BOOST_LIB_RT_OPT | 
|---|
| 198 | #        endif | 
|---|
| 199 |  | 
|---|
| 200 | #     endif | 
|---|
| 201 |  | 
|---|
| 202 | #  else | 
|---|
| 203 |  | 
|---|
| 204 | #     if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) | 
|---|
| 205 |  | 
|---|
| 206 | #        if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) | 
|---|
| 207 | #            define BOOST_LIB_RT_OPT "-sgdp" | 
|---|
| 208 | #        elif defined(_DEBUG) | 
|---|
| 209 | #             define BOOST_LIB_RT_OPT "-sgdp" | 
|---|
| 210 | #            pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") | 
|---|
| 211 | #            error "Build options aren't compatible with pre-built libraries" | 
|---|
| 212 | #        else | 
|---|
| 213 | #            define BOOST_LIB_RT_OPT "-sp" | 
|---|
| 214 | #        endif | 
|---|
| 215 |  | 
|---|
| 216 | #     elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) | 
|---|
| 217 |  | 
|---|
| 218 | #        if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) | 
|---|
| 219 | #            define BOOST_LIB_RT_OPT "-sgdpn" | 
|---|
| 220 | #        elif defined(_DEBUG) | 
|---|
| 221 | #             define BOOST_LIB_RT_OPT "-sgdpn" | 
|---|
| 222 | #            pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") | 
|---|
| 223 | #            error "Build options aren't compatible with pre-built libraries" | 
|---|
| 224 | #        else | 
|---|
| 225 | #            define BOOST_LIB_RT_OPT "-spn" | 
|---|
| 226 | #        endif | 
|---|
| 227 |  | 
|---|
| 228 | #     else | 
|---|
| 229 |  | 
|---|
| 230 | #        if defined(_DEBUG) | 
|---|
| 231 | #             define BOOST_LIB_RT_OPT "-sgd" | 
|---|
| 232 | #        else | 
|---|
| 233 | #            define BOOST_LIB_RT_OPT "-s" | 
|---|
| 234 | #        endif | 
|---|
| 235 |  | 
|---|
| 236 | #     endif | 
|---|
| 237 |  | 
|---|
| 238 | #  endif | 
|---|
| 239 |  | 
|---|
| 240 | #elif defined(__BORLANDC__) | 
|---|
| 241 |  | 
|---|
| 242 | // | 
|---|
| 243 | // figure out whether we want the debug builds or not: | 
|---|
| 244 | // | 
|---|
| 245 | #if __BORLANDC__ > 0x561 | 
|---|
| 246 | #pragma defineonoption BOOST_BORLAND_DEBUG -v | 
|---|
| 247 | #endif | 
|---|
| 248 | // | 
|---|
| 249 | // sanity check: | 
|---|
| 250 | // | 
|---|
| 251 | #if defined(__STL_DEBUG) || defined(_STLP_DEBUG) | 
|---|
| 252 | #error "Pre-built versions of the Boost libraries are not provided in STLPort-debug form" | 
|---|
| 253 | #endif | 
|---|
| 254 |  | 
|---|
| 255 | #  ifdef _RTLDLL | 
|---|
| 256 |  | 
|---|
| 257 | #     ifdef BOOST_BORLAND_DEBUG | 
|---|
| 258 | #         define BOOST_LIB_RT_OPT "-d" | 
|---|
| 259 | #     else | 
|---|
| 260 | #         define BOOST_LIB_RT_OPT | 
|---|
| 261 | #     endif | 
|---|
| 262 |  | 
|---|
| 263 | #  else | 
|---|
| 264 |  | 
|---|
| 265 | #     ifdef BOOST_BORLAND_DEBUG | 
|---|
| 266 | #         define BOOST_LIB_RT_OPT "-sd" | 
|---|
| 267 | #     else | 
|---|
| 268 | #         define BOOST_LIB_RT_OPT "-s" | 
|---|
| 269 | #     endif | 
|---|
| 270 |  | 
|---|
| 271 | #  endif | 
|---|
| 272 |  | 
|---|
| 273 | #endif | 
|---|
| 274 |  | 
|---|
| 275 | // | 
|---|
| 276 | // select linkage opt: | 
|---|
| 277 | // | 
|---|
| 278 | #if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_DYN_LINK) | 
|---|
| 279 | #  define BOOST_LIB_PREFIX | 
|---|
| 280 | #elif defined(BOOST_DYN_LINK) | 
|---|
| 281 | #  error "Mixing a dll boost library with a static runtime is a really bad idea..." | 
|---|
| 282 | #else | 
|---|
| 283 | #  define BOOST_LIB_PREFIX "lib" | 
|---|
| 284 | #endif | 
|---|
| 285 |  | 
|---|
| 286 | // | 
|---|
| 287 | // now include the lib: | 
|---|
| 288 | // | 
|---|
| 289 | #if defined(BOOST_LIB_NAME) \ | 
|---|
| 290 |       && defined(BOOST_LIB_PREFIX) \ | 
|---|
| 291 |       && defined(BOOST_LIB_TOOLSET) \ | 
|---|
| 292 |       && defined(BOOST_LIB_THREAD_OPT) \ | 
|---|
| 293 |       && defined(BOOST_LIB_RT_OPT) \ | 
|---|
| 294 |       && defined(BOOST_LIB_VERSION) | 
|---|
| 295 |  | 
|---|
| 296 | #ifndef BOOST_AUTO_LINK_NOMANGLE | 
|---|
| 297 | #  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") | 
|---|
| 298 | #  ifdef BOOST_LIB_DIAGNOSTIC | 
|---|
| 299 | #     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") | 
|---|
| 300 | #  endif | 
|---|
| 301 | #else | 
|---|
| 302 | #  pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib") | 
|---|
| 303 | #  ifdef BOOST_LIB_DIAGNOSTIC | 
|---|
| 304 | #     pragma message ("Linking to lib file: " BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib") | 
|---|
| 305 | #  endif | 
|---|
| 306 | #endif | 
|---|
| 307 |  | 
|---|
| 308 | #else | 
|---|
| 309 | #  error "some required macros where not defined (internal logic error)." | 
|---|
| 310 | #endif | 
|---|
| 311 |  | 
|---|
| 312 |  | 
|---|
| 313 | #endif // _MSC_VER || __BORLANDC__ | 
|---|
| 314 |  | 
|---|
| 315 | // | 
|---|
| 316 | // finally undef any macros we may have set: | 
|---|
| 317 | // | 
|---|
| 318 | #ifdef BOOST_LIB_PREFIX | 
|---|
| 319 | #  undef BOOST_LIB_PREFIX | 
|---|
| 320 | #endif | 
|---|
| 321 | #if defined(BOOST_LIB_NAME) | 
|---|
| 322 | #  undef BOOST_LIB_NAME | 
|---|
| 323 | #endif | 
|---|
| 324 | // Don't undef this one: it can be set by the user and should be the  | 
|---|
| 325 | // same for all libraries: | 
|---|
| 326 | //#if defined(BOOST_LIB_TOOLSET) | 
|---|
| 327 | //#  undef BOOST_LIB_TOOLSET | 
|---|
| 328 | //#endif | 
|---|
| 329 | #if defined(BOOST_LIB_THREAD_OPT) | 
|---|
| 330 | #  undef BOOST_LIB_THREAD_OPT | 
|---|
| 331 | #endif | 
|---|
| 332 | #if defined(BOOST_LIB_RT_OPT) | 
|---|
| 333 | #  undef BOOST_LIB_RT_OPT | 
|---|
| 334 | #endif | 
|---|
| 335 | #if defined(BOOST_LIB_LINK_OPT) | 
|---|
| 336 | #  undef BOOST_LIB_LINK_OPT | 
|---|
| 337 | #endif | 
|---|
| 338 | #if defined(BOOST_LIB_DEBUG_OPT) | 
|---|
| 339 | #  undef BOOST_LIB_DEBUG_OPT | 
|---|
| 340 | #endif | 
|---|
| 341 | #if defined(BOOST_DYN_LINK) | 
|---|
| 342 | #  undef BOOST_DYN_LINK | 
|---|
| 343 | #endif | 
|---|
| 344 | #if defined(BOOST_AUTO_LINK_NOMANGLE) | 
|---|
| 345 | #  undef BOOST_AUTO_LINK_NOMANGLE | 
|---|
| 346 | #endif | 
|---|
| 347 |  | 
|---|
| 348 |  | 
|---|
| 349 |  | 
|---|
| 350 |  | 
|---|
| 351 |  | 
|---|
| 352 |  | 
|---|
| 353 |  | 
|---|
| 354 |  | 
|---|
| 355 |  | 
|---|
| 356 |  | 
|---|
| 357 |  | 
|---|