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
15USAGE:
16~~~~~~
17
18Before including this header you must define one or more of define the following macros:
19
20BOOST_LIB_NAME: Required: A string containing the basename of the library,
21 for example boost_regex.
22BOOST_LIB_TOOLSET: Optional: the base name of the toolset.
23BOOST_DYN_LINK: Optional: when set link to dll rather than static library.
24BOOST_LIB_DIAGNOSTIC: Optional: when set the header will print out the name
25 of the library selected (useful for debugging).
26BOOST_AUTO_LINK_NOMANGLE: Specifies that we should link to BOOST_LIB_NAME.lib,
27 rather than a mangled-name version.
28BOOST_AUTO_LINK_TAGGED: Specifies that we link to libraries built with the --layout=tagged option.
29 This is essentially the same as the default name-mangled version, but without
30 the compiler name and version, or the Boost version. Just the build options.
31BOOST_AUTO_LINK_SYSTEM: Specifies that we link to libraries built with the --layout=system option.
32 This is essentially the same as the non-name-mangled version, but with
33 the prefix to differentiate static and dll builds
34
35These macros will be undef'ed at the end of the header, further this header
36has no include guards - so be sure to include it only once from your library!
37
38Algorithm:
39~~~~~~~~~~
40
41Libraries for Borland and Microsoft compilers are automatically
42selected here, the name of the lib is selected according to the following
43formula:
44
45BOOST_LIB_PREFIX
46 + BOOST_LIB_NAME
47 + "_"
48 + BOOST_LIB_TOOLSET
49 + BOOST_LIB_THREAD_OPT
50 + BOOST_LIB_RT_OPT
51 + BOOST_LIB_ARCH_AND_MODEL_OPT
52 "-"
53 + BOOST_LIB_VERSION
54
55These are defined as:
56
57BOOST_LIB_PREFIX: "lib" for static libraries otherwise "".
58
59BOOST_LIB_NAME: The base name of the lib ( for example boost_regex).
60
61BOOST_LIB_TOOLSET: The compiler toolset name (vc6, vc7, bcb5 etc).
62
63BOOST_LIB_THREAD_OPT: "-mt" for multithread builds, otherwise nothing.
64
65BOOST_LIB_RT_OPT: A suffix that indicates the runtime library used,
66 contains one or more of the following letters after
67 a hyphen:
68
69 s static runtime (dynamic if not present).
70 g debug/diagnostic runtime (release if not present).
71 y Python debug/diagnostic runtime (release if not present).
72 d debug build (release if not present).
73 p STLport build.
74 n STLport build without its IOStreams.
75
76BOOST_LIB_ARCH_AND_MODEL_OPT: The architecture and address model
77 (-x32 or -x64 for x86/32 and x86/64 respectively)
78
79BOOST_LIB_VERSION: The Boost version, in the form x_y, for Boost version x.y.
80
81
82***************************************************************************/
83
84#ifdef __cplusplus
85# ifndef BOOST_CONFIG_HPP
86# include <boost/config.hpp>
87# endif
88#elif defined(_MSC_VER) && !defined(__MWERKS__) && !defined(__EDG_VERSION__)
89//
90// C language compatability (no, honestly)
91//
92# define BOOST_MSVC _MSC_VER
93# define BOOST_STRINGIZE(X) BOOST_DO_STRINGIZE(X)
94# define BOOST_DO_STRINGIZE(X) #X
95#endif
96//
97// Only include what follows for known and supported compilers:
98//
99#if defined(BOOST_MSVC) \
100 || defined(__BORLANDC__) \
101 || (defined(__MWERKS__) && defined(_WIN32) && (__MWERKS__ >= 0x3000)) \
102 || (defined(__ICL) && defined(_MSC_EXTENSIONS) && (_MSC_VER >= 1200))
103
104#ifndef BOOST_VERSION_HPP
105# include <boost/version.hpp>
106#endif
107
108#ifndef BOOST_LIB_NAME
109# error "Macro BOOST_LIB_NAME not set (internal error)"
110#endif
111
112//
113// error check:
114//
115#if defined(__MSVC_RUNTIME_CHECKS) && !defined(_DEBUG)
116# pragma message("Using the /RTC option without specifying a debug runtime will lead to linker errors")
117# pragma message("Hint: go to the code generation options and switch to one of the debugging runtimes")
118# error "Incompatible build options"
119#endif
120//
121// select toolset if not defined already:
122//
123#ifndef BOOST_LIB_TOOLSET
124# if defined(BOOST_MSVC) && (BOOST_MSVC < 1200)
125 // Note: no compilers before 1200 are supported
126# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
127
128# ifdef UNDER_CE
129 // eVC4:
130# define BOOST_LIB_TOOLSET "evc4"
131# else
132 // vc6:
133# define BOOST_LIB_TOOLSET "vc6"
134# endif
135
136# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1310)
137
138 // vc7:
139# define BOOST_LIB_TOOLSET "vc7"
140
141# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1400)
142
143 // vc71:
144# define BOOST_LIB_TOOLSET "vc71"
145
146# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1500)
147
148 // vc80:
149# define BOOST_LIB_TOOLSET "vc80"
150
151# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1600)
152
153 // vc90:
154# define BOOST_LIB_TOOLSET "vc90"
155
156# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1700)
157
158 // vc10:
159# define BOOST_LIB_TOOLSET "vc100"
160
161# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1800)
162
163 // vc11:
164# define BOOST_LIB_TOOLSET "vc110"
165
166# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1900)
167
168 // vc12:
169# define BOOST_LIB_TOOLSET "vc120"
170
171# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1910)
172
173 // vc14:
174# define BOOST_LIB_TOOLSET "vc140"
175
176# elif defined(BOOST_MSVC) && (BOOST_MSVC < 1920)
177
178 // vc14.1:
179# define BOOST_LIB_TOOLSET "vc141"
180
181# elif defined(BOOST_MSVC)
182
183 // vc14.2:
184# define BOOST_LIB_TOOLSET "vc142"
185
186# elif defined(__BORLANDC__)
187
188 // CBuilder 6:
189# define BOOST_LIB_TOOLSET "bcb"
190
191# elif defined(__ICL)
192
193 // Intel C++, no version number:
194# define BOOST_LIB_TOOLSET "iw"
195
196# elif defined(__MWERKS__) && (__MWERKS__ <= 0x31FF )
197
198 // Metrowerks CodeWarrior 8.x
199# define BOOST_LIB_TOOLSET "cw8"
200
201# elif defined(__MWERKS__) && (__MWERKS__ <= 0x32FF )
202
203 // Metrowerks CodeWarrior 9.x
204# define BOOST_LIB_TOOLSET "cw9"
205
206# endif
207#endif // BOOST_LIB_TOOLSET
208
209//
210// select thread opt:
211//
212#if defined(_MT) || defined(__MT__)
213# define BOOST_LIB_THREAD_OPT "-mt"
214#else
215# define BOOST_LIB_THREAD_OPT
216#endif
217
218#if defined(_MSC_VER) || defined(__MWERKS__)
219
220# ifdef _DLL
221
222# if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS))
223
224# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
225 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
226# define BOOST_LIB_RT_OPT "-gydp"
227# elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
228# define BOOST_LIB_RT_OPT "-gdp"
229# elif defined(_DEBUG)\
230 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
231# define BOOST_LIB_RT_OPT "-gydp"
232# pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
233# error "Build options aren't compatible with pre-built libraries"
234# elif defined(_DEBUG)
235# define BOOST_LIB_RT_OPT "-gdp"
236# pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
237# error "Build options aren't compatible with pre-built libraries"
238# else
239# define BOOST_LIB_RT_OPT "-p"
240# endif
241
242# elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
243
244# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
245 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
246# define BOOST_LIB_RT_OPT "-gydpn"
247# elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
248# define BOOST_LIB_RT_OPT "-gdpn"
249# elif defined(_DEBUG)\
250 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
251# define BOOST_LIB_RT_OPT "-gydpn"
252# pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
253# error "Build options aren't compatible with pre-built libraries"
254# elif defined(_DEBUG)
255# define BOOST_LIB_RT_OPT "-gdpn"
256# pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
257# error "Build options aren't compatible with pre-built libraries"
258# else
259# define BOOST_LIB_RT_OPT "-pn"
260# endif
261
262# else
263
264# if defined(_DEBUG) && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
265# define BOOST_LIB_RT_OPT "-gyd"
266# elif defined(_DEBUG)
267# define BOOST_LIB_RT_OPT "-gd"
268# else
269# define BOOST_LIB_RT_OPT
270# endif
271
272# endif
273
274# else
275
276# if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS))
277
278# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
279 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
280# define BOOST_LIB_RT_OPT "-sgydp"
281# elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
282# define BOOST_LIB_RT_OPT "-sgdp"
283# elif defined(_DEBUG)\
284 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
285# define BOOST_LIB_RT_OPT "-sgydp"
286# pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
287# error "Build options aren't compatible with pre-built libraries"
288# elif defined(_DEBUG)
289# define BOOST_LIB_RT_OPT "-sgdp"
290# pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
291# error "Build options aren't compatible with pre-built libraries"
292# else
293# define BOOST_LIB_RT_OPT "-sp"
294# endif
295
296# elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
297
298# if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))\
299 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
300# define BOOST_LIB_RT_OPT "-sgydpn"
301# elif defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG))
302# define BOOST_LIB_RT_OPT "-sgdpn"
303# elif defined(_DEBUG)\
304 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
305# define BOOST_LIB_RT_OPT "-sgydpn"
306# pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
307# error "Build options aren't compatible with pre-built libraries"
308# elif defined(_DEBUG)
309# define BOOST_LIB_RT_OPT "-sgdpn"
310# pragma message("warning: STLport debug versions are built with /D_STLP_DEBUG=1")
311# error "Build options aren't compatible with pre-built libraries"
312# else
313# define BOOST_LIB_RT_OPT "-spn"
314# endif
315
316# else
317
318# if defined(_DEBUG)\
319 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
320# define BOOST_LIB_RT_OPT "-sgyd"
321# elif defined(_DEBUG)
322# define BOOST_LIB_RT_OPT "-sgd"
323# else
324# define BOOST_LIB_RT_OPT "-s"
325# endif
326
327# endif
328
329# endif
330
331#elif defined(__BORLANDC__)
332
333//
334// figure out whether we want the debug builds or not:
335//
336#if __BORLANDC__ > 0x561
337#pragma defineonoption BOOST_BORLAND_DEBUG -v
338#endif
339//
340// sanity check:
341//
342#if defined(__STL_DEBUG) || defined(_STLP_DEBUG)
343#error "Pre-built versions of the Boost libraries are not provided in STLport-debug form"
344#endif
345
346# ifdef _RTLDLL
347
348# if defined(BOOST_BORLAND_DEBUG)\
349 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
350# define BOOST_LIB_RT_OPT "-yd"
351# elif defined(BOOST_BORLAND_DEBUG)
352# define BOOST_LIB_RT_OPT "-d"
353# elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
354# define BOOST_LIB_RT_OPT -y
355# else
356# define BOOST_LIB_RT_OPT
357# endif
358
359# else
360
361# if defined(BOOST_BORLAND_DEBUG)\
362 && defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
363# define BOOST_LIB_RT_OPT "-syd"
364# elif defined(BOOST_BORLAND_DEBUG)
365# define BOOST_LIB_RT_OPT "-sd"
366# elif defined(BOOST_DEBUG_PYTHON) && defined(BOOST_LINKING_PYTHON)
367# define BOOST_LIB_RT_OPT "-sy"
368# else
369# define BOOST_LIB_RT_OPT "-s"
370# endif
371
372# endif
373
374#endif
375
376//
377// BOOST_LIB_ARCH_AND_MODEL_OPT
378//
379
380#if defined( _M_IX86 )
381# define BOOST_LIB_ARCH_AND_MODEL_OPT "-x32"
382#elif defined( _M_X64 )
383# define BOOST_LIB_ARCH_AND_MODEL_OPT "-x64"
384#elif defined( _M_ARM )
385# define BOOST_LIB_ARCH_AND_MODEL_OPT "-a32"
386#elif defined( _M_ARM64 )
387# define BOOST_LIB_ARCH_AND_MODEL_OPT "-a64"
388#endif
389
390//
391// select linkage opt:
392//
393#if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_DYN_LINK)
394# define BOOST_LIB_PREFIX
395#elif defined(BOOST_DYN_LINK)
396# error "Mixing a dll boost library with a static runtime is a really bad idea..."
397#else
398# define BOOST_LIB_PREFIX "lib"
399#endif
400
401//
402// now include the lib:
403//
404#if defined(BOOST_LIB_NAME) \
405 && defined(BOOST_LIB_PREFIX) \
406 && defined(BOOST_LIB_TOOLSET) \
407 && defined(BOOST_LIB_THREAD_OPT) \
408 && defined(BOOST_LIB_RT_OPT) \
409 && defined(BOOST_LIB_ARCH_AND_MODEL_OPT) \
410 && defined(BOOST_LIB_VERSION)
411
412#ifdef BOOST_AUTO_LINK_TAGGED
413# pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT ".lib")
414# ifdef BOOST_LIB_DIAGNOSTIC
415# pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT ".lib")
416# endif
417#elif defined(BOOST_AUTO_LINK_SYSTEM)
418# pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
419# ifdef BOOST_LIB_DIAGNOSTIC
420# pragma message ("Linking to lib file: " BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
421# endif
422#elif defined(BOOST_AUTO_LINK_NOMANGLE)
423# pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
424# ifdef BOOST_LIB_DIAGNOSTIC
425# pragma message ("Linking to lib file: " BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib")
426# endif
427#elif defined(BOOST_LIB_BUILDID)
428# pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION "-" BOOST_STRINGIZE(BOOST_LIB_BUILDID) ".lib")
429# ifdef BOOST_LIB_DIAGNOSTIC
430# 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_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION "-" BOOST_STRINGIZE(BOOST_LIB_BUILDID) ".lib")
431# endif
432#else
433# pragma comment(lib, BOOST_LIB_PREFIX BOOST_STRINGIZE(BOOST_LIB_NAME) "-" BOOST_LIB_TOOLSET BOOST_LIB_THREAD_OPT BOOST_LIB_RT_OPT BOOST_LIB_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION ".lib")
434# ifdef BOOST_LIB_DIAGNOSTIC
435# 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_ARCH_AND_MODEL_OPT "-" BOOST_LIB_VERSION ".lib")
436# endif
437#endif
438
439#else
440# error "some required macros where not defined (internal logic error)."
441#endif
442
443
444#endif // _MSC_VER || __BORLANDC__
445
446//
447// finally undef any macros we may have set:
448//
449#ifdef BOOST_LIB_PREFIX
450# undef BOOST_LIB_PREFIX
451#endif
452#if defined(BOOST_LIB_NAME)
453# undef BOOST_LIB_NAME
454#endif
455// Don't undef this one: it can be set by the user and should be the
456// same for all libraries:
457//#if defined(BOOST_LIB_TOOLSET)
458//# undef BOOST_LIB_TOOLSET
459//#endif
460#if defined(BOOST_LIB_THREAD_OPT)
461# undef BOOST_LIB_THREAD_OPT
462#endif
463#if defined(BOOST_LIB_RT_OPT)
464# undef BOOST_LIB_RT_OPT
465#endif
466#if defined(BOOST_LIB_ARCH_AND_MODEL_OPT)
467# undef BOOST_LIB_ARCH_AND_MODEL_OPT
468#endif
469#if defined(BOOST_LIB_LINK_OPT)
470# undef BOOST_LIB_LINK_OPT
471#endif
472#if defined(BOOST_LIB_DEBUG_OPT)
473# undef BOOST_LIB_DEBUG_OPT
474#endif
475#if defined(BOOST_DYN_LINK)
476# undef BOOST_DYN_LINK
477#endif
478
479
480