|
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 // Note: no compilers before 1200 are supported |
|
113 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300) |
|
114 |
|
115 # ifdef UNDER_CE |
|
116 // vc6: |
|
117 # define BOOST_LIB_TOOLSET "evc4" |
|
118 # else |
|
119 // vc6: |
|
120 # define BOOST_LIB_TOOLSET "vc6" |
|
121 # endif |
|
122 |
|
123 #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1300) |
|
124 |
|
125 // vc7: |
|
126 # define BOOST_LIB_TOOLSET "vc7" |
|
127 |
|
128 #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1310) |
|
129 |
|
130 // vc71: |
|
131 # define BOOST_LIB_TOOLSET "vc71" |
|
132 |
|
133 #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1400) |
|
134 |
|
135 // vc80: |
|
136 # define BOOST_LIB_TOOLSET "vc80" |
|
137 |
|
138 #elif defined(BOOST_MSVC) && (BOOST_MSVC == 1500) |
|
139 |
|
140 // vc90: |
|
141 # define BOOST_LIB_TOOLSET "vc90" |
|
142 |
|
143 #elif defined(BOOST_MSVC) && (BOOST_MSVC >= 1600) |
|
144 |
|
145 // vc10: |
|
146 # define BOOST_LIB_TOOLSET "vc100" |
|
147 |
|
148 #elif defined(__BORLANDC__) |
|
149 |
|
150 // CBuilder 6: |
|
151 # define BOOST_LIB_TOOLSET "bcb" |
|
152 |
|
153 #elif defined(__ICL) |
|
154 |
|
155 // Intel C++, no version number: |
|
156 # define BOOST_LIB_TOOLSET "iw" |
|
157 |
|
158 #elif defined(__MWERKS__) && (__MWERKS__ <= 0x31FF ) |
|
159 |
|
160 // Metrowerks CodeWarrior 8.x |
|
161 # define BOOST_LIB_TOOLSET "cw8" |
|
162 |
|
163 #elif defined(__MWERKS__) && (__MWERKS__ <= 0x32FF ) |
|
164 |
|
165 // Metrowerks CodeWarrior 9.x |
|
166 # define BOOST_LIB_TOOLSET "cw9" |
|
167 |
|
168 #endif |
|
169 #endif // BOOST_LIB_TOOLSET |
|
170 |
|
171 // |
|
172 // select thread opt: |
|
173 // |
|
174 #if defined(_MT) || defined(__MT__) |
|
175 # define BOOST_LIB_THREAD_OPT "-mt" |
|
176 #else |
|
177 # define BOOST_LIB_THREAD_OPT |
|
178 #endif |
|
179 |
|
180 #if defined(_MSC_VER) || defined(__MWERKS__) |
|
181 |
|
182 # ifdef _DLL |
|
183 |
|
184 # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) |
|
185 |
|
186 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) |
|
187 # define BOOST_LIB_RT_OPT "-gdp" |
|
188 # elif defined(_DEBUG) |
|
189 # define BOOST_LIB_RT_OPT "-gdp" |
|
190 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") |
|
191 # error "Build options aren't compatible with pre-built libraries" |
|
192 # else |
|
193 # define BOOST_LIB_RT_OPT "-p" |
|
194 # endif |
|
195 |
|
196 # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) |
|
197 |
|
198 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) |
|
199 # define BOOST_LIB_RT_OPT "-gdpn" |
|
200 # elif defined(_DEBUG) |
|
201 # define BOOST_LIB_RT_OPT "-gdpn" |
|
202 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") |
|
203 # error "Build options aren't compatible with pre-built libraries" |
|
204 # else |
|
205 # define BOOST_LIB_RT_OPT "-pn" |
|
206 # endif |
|
207 |
|
208 # else |
|
209 |
|
210 # if defined(_DEBUG) |
|
211 # define BOOST_LIB_RT_OPT "-gd" |
|
212 # else |
|
213 # define BOOST_LIB_RT_OPT |
|
214 # endif |
|
215 |
|
216 # endif |
|
217 |
|
218 # else |
|
219 |
|
220 # if (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) && (defined(_STLP_OWN_IOSTREAMS) || defined(__STL_OWN_IOSTREAMS)) |
|
221 |
|
222 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) |
|
223 # define BOOST_LIB_RT_OPT "-sgdp" |
|
224 # elif defined(_DEBUG) |
|
225 # define BOOST_LIB_RT_OPT "-sgdp" |
|
226 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") |
|
227 # error "Build options aren't compatible with pre-built libraries" |
|
228 # else |
|
229 # define BOOST_LIB_RT_OPT "-sp" |
|
230 # endif |
|
231 |
|
232 # elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) |
|
233 |
|
234 # if defined(_DEBUG) && (defined(__STL_DEBUG) || defined(_STLP_DEBUG)) |
|
235 # define BOOST_LIB_RT_OPT "-sgdpn" |
|
236 # elif defined(_DEBUG) |
|
237 # define BOOST_LIB_RT_OPT "-sgdpn" |
|
238 # pragma message("warning: STLPort debug versions are built with /D_STLP_DEBUG=1") |
|
239 # error "Build options aren't compatible with pre-built libraries" |
|
240 # else |
|
241 # define BOOST_LIB_RT_OPT "-spn" |
|
242 # endif |
|
243 |
|
244 # else |
|
245 |
|
246 # if defined(_DEBUG) |
|
247 # define BOOST_LIB_RT_OPT "-sgd" |
|
248 # else |
|
249 # define BOOST_LIB_RT_OPT "-s" |
|
250 # endif |
|
251 |
|
252 # endif |
|
253 |
|
254 # endif |
|
255 |
|
256 #elif defined(__BORLANDC__) |
|
257 |
|
258 // |
|
259 // figure out whether we want the debug builds or not: |
|
260 // |
|
261 #if __BORLANDC__ > 0x561 |
|
262 #pragma defineonoption BOOST_BORLAND_DEBUG -v |
|
263 #endif |
|
264 // |
|
265 // sanity check: |
|
266 // |
|
267 #if defined(__STL_DEBUG) || defined(_STLP_DEBUG) |
|
268 #error "Pre-built versions of the Boost libraries are not provided in STLPort-debug form" |
|
269 #endif |
|
270 |
|
271 # ifdef _RTLDLL |
|
272 |
|
273 # ifdef BOOST_BORLAND_DEBUG |
|
274 # define BOOST_LIB_RT_OPT "-d" |
|
275 # else |
|
276 # define BOOST_LIB_RT_OPT |
|
277 # endif |
|
278 |
|
279 # else |
|
280 |
|
281 # ifdef BOOST_BORLAND_DEBUG |
|
282 # define BOOST_LIB_RT_OPT "-sd" |
|
283 # else |
|
284 # define BOOST_LIB_RT_OPT "-s" |
|
285 # endif |
|
286 |
|
287 # endif |
|
288 |
|
289 #endif |
|
290 |
|
291 // |
|
292 // select linkage opt: |
|
293 // |
|
294 #if (defined(_DLL) || defined(_RTLDLL)) && defined(BOOST_DYN_LINK) |
|
295 # define BOOST_LIB_PREFIX |
|
296 #elif defined(BOOST_DYN_LINK) |
|
297 # error "Mixing a dll boost library with a static runtime is a really bad idea..." |
|
298 #else |
|
299 # define BOOST_LIB_PREFIX "lib" |
|
300 #endif |
|
301 |
|
302 // |
|
303 // now include the lib: |
|
304 // |
|
305 #if defined(BOOST_LIB_NAME) \ |
|
306 && defined(BOOST_LIB_PREFIX) \ |
|
307 && defined(BOOST_LIB_TOOLSET) \ |
|
308 && defined(BOOST_LIB_THREAD_OPT) \ |
|
309 && defined(BOOST_LIB_RT_OPT) \ |
|
310 && defined(BOOST_LIB_VERSION) |
|
311 |
|
312 #ifndef BOOST_AUTO_LINK_NOMANGLE |
|
313 # 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") |
|
314 # ifdef BOOST_LIB_DIAGNOSTIC |
|
315 # 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") |
|
316 # endif |
|
317 #else |
|
318 # pragma comment(lib, BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib") |
|
319 # ifdef BOOST_LIB_DIAGNOSTIC |
|
320 # pragma message ("Linking to lib file: " BOOST_STRINGIZE(BOOST_LIB_NAME) ".lib") |
|
321 # endif |
|
322 #endif |
|
323 |
|
324 #else |
|
325 # error "some required macros where not defined (internal logic error)." |
|
326 #endif |
|
327 |
|
328 |
|
329 #endif // _MSC_VER || __BORLANDC__ |
|
330 |
|
331 // |
|
332 // finally undef any macros we may have set: |
|
333 // |
|
334 #ifdef BOOST_LIB_PREFIX |
|
335 # undef BOOST_LIB_PREFIX |
|
336 #endif |
|
337 #if defined(BOOST_LIB_NAME) |
|
338 # undef BOOST_LIB_NAME |
|
339 #endif |
|
340 // Don't undef this one: it can be set by the user and should be the |
|
341 // same for all libraries: |
|
342 //#if defined(BOOST_LIB_TOOLSET) |
|
343 //# undef BOOST_LIB_TOOLSET |
|
344 //#endif |
|
345 #if defined(BOOST_LIB_THREAD_OPT) |
|
346 # undef BOOST_LIB_THREAD_OPT |
|
347 #endif |
|
348 #if defined(BOOST_LIB_RT_OPT) |
|
349 # undef BOOST_LIB_RT_OPT |
|
350 #endif |
|
351 #if defined(BOOST_LIB_LINK_OPT) |
|
352 # undef BOOST_LIB_LINK_OPT |
|
353 #endif |
|
354 #if defined(BOOST_LIB_DEBUG_OPT) |
|
355 # undef BOOST_LIB_DEBUG_OPT |
|
356 #endif |
|
357 #if defined(BOOST_DYN_LINK) |
|
358 # undef BOOST_DYN_LINK |
|
359 #endif |
|
360 #if defined(BOOST_AUTO_LINK_NOMANGLE) |
|
361 # undef BOOST_AUTO_LINK_NOMANGLE |
|
362 #endif |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |