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