]>
Commit | Line | Data |
---|---|---|
1 | dnl | |
2 | dnl This file is part of Bakefile (http://bakefile.sourceforge.net) | |
3 | dnl | |
4 | dnl Copyright (C) 2003-2007 Vaclav Slavik and others | |
5 | dnl | |
6 | dnl Permission is hereby granted, free of charge, to any person obtaining a | |
7 | dnl copy of this software and associated documentation files (the "Software"), | |
8 | dnl to deal in the Software without restriction, including without limitation | |
9 | dnl the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
10 | dnl and/or sell copies of the Software, and to permit persons to whom the | |
11 | dnl Software is furnished to do so, subject to the following conditions: | |
12 | dnl | |
13 | dnl The above copyright notice and this permission notice shall be included in | |
14 | dnl all copies or substantial portions of the Software. | |
15 | dnl | |
16 | dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
19 | dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |
21 | dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |
22 | dnl DEALINGS IN THE SOFTWARE. | |
23 | dnl | |
24 | dnl $Id$ | |
25 | dnl | |
26 | dnl Support macros for makefiles generated by BAKEFILE. | |
27 | dnl | |
28 | ||
29 | ||
30 | dnl --------------------------------------------------------------------------- | |
31 | dnl Lots of compiler & linker detection code contained here was taken from | |
32 | dnl wxWidgets configure.in script (see http://www.wxwidgets.org) | |
33 | dnl --------------------------------------------------------------------------- | |
34 | ||
35 | ||
36 | ||
37 | dnl --------------------------------------------------------------------------- | |
38 | dnl AC_BAKEFILE_GNUMAKE | |
39 | dnl | |
40 | dnl Detects GNU make | |
41 | dnl --------------------------------------------------------------------------- | |
42 | ||
43 | AC_DEFUN([AC_BAKEFILE_GNUMAKE], | |
44 | [ | |
45 | dnl does make support "-include" (only GNU make does AFAIK)? | |
46 | AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu, | |
47 | [ | |
48 | if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null | | |
49 | egrep -s GNU > /dev/null); then | |
50 | bakefile_cv_prog_makeisgnu="yes" | |
51 | else | |
52 | bakefile_cv_prog_makeisgnu="no" | |
53 | fi | |
54 | ]) | |
55 | ||
56 | if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then | |
57 | IF_GNU_MAKE="" | |
58 | else | |
59 | IF_GNU_MAKE="#" | |
60 | fi | |
61 | AC_SUBST(IF_GNU_MAKE) | |
62 | ]) | |
63 | ||
64 | dnl --------------------------------------------------------------------------- | |
65 | dnl AC_BAKEFILE_PLATFORM | |
66 | dnl | |
67 | dnl Detects platform and sets PLATFORM_XXX variables accordingly | |
68 | dnl --------------------------------------------------------------------------- | |
69 | ||
70 | AC_DEFUN([AC_BAKEFILE_PLATFORM], | |
71 | [ | |
72 | PLATFORM_UNIX=0 | |
73 | PLATFORM_WIN32=0 | |
74 | PLATFORM_MSDOS=0 | |
75 | PLATFORM_MAC=0 | |
76 | PLATFORM_MACOS=0 | |
77 | PLATFORM_MACOSX=0 | |
78 | PLATFORM_OS2=0 | |
79 | PLATFORM_BEOS=0 | |
80 | ||
81 | if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then | |
82 | case "${BAKEFILE_HOST}" in | |
83 | *-*-mingw32* ) | |
84 | PLATFORM_WIN32=1 | |
85 | ;; | |
86 | *-pc-msdosdjgpp ) | |
87 | PLATFORM_MSDOS=1 | |
88 | ;; | |
89 | *-pc-os2_emx | *-pc-os2-emx ) | |
90 | PLATFORM_OS2=1 | |
91 | ;; | |
92 | *-*-darwin* ) | |
93 | PLATFORM_MAC=1 | |
94 | PLATFORM_MACOSX=1 | |
95 | ;; | |
96 | *-*-beos* ) | |
97 | PLATFORM_BEOS=1 | |
98 | ;; | |
99 | powerpc-apple-macos* ) | |
100 | PLATFORM_MAC=1 | |
101 | PLATFORM_MACOS=1 | |
102 | ;; | |
103 | * ) | |
104 | PLATFORM_UNIX=1 | |
105 | ;; | |
106 | esac | |
107 | else | |
108 | case "$BAKEFILE_FORCE_PLATFORM" in | |
109 | win32 ) | |
110 | PLATFORM_WIN32=1 | |
111 | ;; | |
112 | msdos ) | |
113 | PLATFORM_MSDOS=1 | |
114 | ;; | |
115 | os2 ) | |
116 | PLATFORM_OS2=1 | |
117 | ;; | |
118 | darwin ) | |
119 | PLATFORM_MAC=1 | |
120 | PLATFORM_MACOSX=1 | |
121 | ;; | |
122 | unix ) | |
123 | PLATFORM_UNIX=1 | |
124 | ;; | |
125 | beos ) | |
126 | PLATFORM_BEOS=1 | |
127 | ;; | |
128 | * ) | |
129 | dnl wxWidgets-specific: allow unknown Unix systems | |
130 | dnl AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM]) | |
131 | ;; | |
132 | esac | |
133 | fi | |
134 | ||
135 | AC_SUBST(PLATFORM_UNIX) | |
136 | AC_SUBST(PLATFORM_WIN32) | |
137 | AC_SUBST(PLATFORM_MSDOS) | |
138 | AC_SUBST(PLATFORM_MAC) | |
139 | AC_SUBST(PLATFORM_MACOS) | |
140 | AC_SUBST(PLATFORM_MACOSX) | |
141 | AC_SUBST(PLATFORM_OS2) | |
142 | AC_SUBST(PLATFORM_BEOS) | |
143 | ]) | |
144 | ||
145 | ||
146 | dnl --------------------------------------------------------------------------- | |
147 | dnl AC_BAKEFILE_PLATFORM_SPECIFICS | |
148 | dnl | |
149 | dnl Sets misc platform-specific settings | |
150 | dnl --------------------------------------------------------------------------- | |
151 | ||
152 | AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS], | |
153 | [ | |
154 | AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf], | |
155 | [use OMF object format (OS/2)]), | |
156 | [bk_os2_use_omf="$enableval"]) | |
157 | ||
158 | case "${BAKEFILE_HOST}" in | |
159 | *-*-darwin* ) | |
160 | dnl For Unix to MacOS X porting instructions, see: | |
161 | dnl http://fink.sourceforge.net/doc/porting/porting.html | |
162 | if test "x$GCC" = "xyes"; then | |
163 | CFLAGS="$CFLAGS -fno-common" | |
164 | CXXFLAGS="$CXXFLAGS -fno-common" | |
165 | fi | |
166 | if test "x$XLCC" = "xyes"; then | |
167 | CFLAGS="$CFLAGS -qnocommon" | |
168 | CXXFLAGS="$CXXFLAGS -qnocommon" | |
169 | fi | |
170 | ;; | |
171 | ||
172 | *-pc-os2_emx | *-pc-os2-emx ) | |
173 | if test "x$bk_os2_use_omf" = "xyes" ; then | |
174 | AR=emxomfar | |
175 | RANLIB=: | |
176 | LDFLAGS="-Zomf $LDFLAGS" | |
177 | CFLAGS="-Zomf $CFLAGS" | |
178 | CXXFLAGS="-Zomf $CXXFLAGS" | |
179 | OS2_LIBEXT="lib" | |
180 | else | |
181 | OS2_LIBEXT="a" | |
182 | fi | |
183 | ;; | |
184 | ||
185 | i*86-*-beos* ) | |
186 | LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS" | |
187 | ;; | |
188 | esac | |
189 | ]) | |
190 | ||
191 | dnl --------------------------------------------------------------------------- | |
192 | dnl AC_BAKEFILE_SUFFIXES | |
193 | dnl | |
194 | dnl Detects shared various suffixes for shared libraries, libraries, programs, | |
195 | dnl plugins etc. | |
196 | dnl --------------------------------------------------------------------------- | |
197 | ||
198 | AC_DEFUN([AC_BAKEFILE_SUFFIXES], | |
199 | [ | |
200 | SO_SUFFIX="so" | |
201 | SO_SUFFIX_MODULE="so" | |
202 | EXEEXT="" | |
203 | LIBPREFIX="lib" | |
204 | LIBEXT=".a" | |
205 | DLLPREFIX="lib" | |
206 | DLLPREFIX_MODULE="" | |
207 | DLLIMP_SUFFIX="" | |
208 | dlldir="$libdir" | |
209 | ||
210 | case "${BAKEFILE_HOST}" in | |
211 | *-hp-hpux* ) | |
212 | SO_SUFFIX="sl" | |
213 | SO_SUFFIX_MODULE="sl" | |
214 | ;; | |
215 | *-*-aix* ) | |
216 | dnl quoting from | |
217 | dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html: | |
218 | dnl Both archive libraries and shared libraries on AIX have an | |
219 | dnl .a extension. This will explain why you can't link with an | |
220 | dnl .so and why it works with the name changed to .a. | |
221 | SO_SUFFIX="a" | |
222 | SO_SUFFIX_MODULE="a" | |
223 | ;; | |
224 | *-*-cygwin* ) | |
225 | SO_SUFFIX="dll" | |
226 | SO_SUFFIX_MODULE="dll" | |
227 | DLLIMP_SUFFIX="dll.a" | |
228 | EXEEXT=".exe" | |
229 | DLLPREFIX="cyg" | |
230 | dlldir="$bindir" | |
231 | ;; | |
232 | *-*-mingw32* ) | |
233 | SO_SUFFIX="dll" | |
234 | SO_SUFFIX_MODULE="dll" | |
235 | DLLIMP_SUFFIX="dll.a" | |
236 | EXEEXT=".exe" | |
237 | DLLPREFIX="" | |
238 | dlldir="$bindir" | |
239 | ;; | |
240 | *-pc-msdosdjgpp ) | |
241 | EXEEXT=".exe" | |
242 | DLLPREFIX="" | |
243 | dlldir="$bindir" | |
244 | ;; | |
245 | *-pc-os2_emx | *-pc-os2-emx ) | |
246 | SO_SUFFIX="dll" | |
247 | SO_SUFFIX_MODULE="dll" | |
248 | DLLIMP_SUFFIX=$OS2_LIBEXT | |
249 | EXEEXT=".exe" | |
250 | DLLPREFIX="" | |
251 | LIBPREFIX="" | |
252 | LIBEXT=".$OS2_LIBEXT" | |
253 | dlldir="$bindir" | |
254 | ;; | |
255 | *-*-darwin* ) | |
256 | SO_SUFFIX="dylib" | |
257 | SO_SUFFIX_MODULE="bundle" | |
258 | ;; | |
259 | esac | |
260 | ||
261 | if test "x$DLLIMP_SUFFIX" = "x" ; then | |
262 | DLLIMP_SUFFIX="$SO_SUFFIX" | |
263 | fi | |
264 | ||
265 | AC_SUBST(SO_SUFFIX) | |
266 | AC_SUBST(SO_SUFFIX_MODULE) | |
267 | AC_SUBST(DLLIMP_SUFFIX) | |
268 | AC_SUBST(EXEEXT) | |
269 | AC_SUBST(LIBPREFIX) | |
270 | AC_SUBST(LIBEXT) | |
271 | AC_SUBST(DLLPREFIX) | |
272 | AC_SUBST(DLLPREFIX_MODULE) | |
273 | AC_SUBST(dlldir) | |
274 | ]) | |
275 | ||
276 | ||
277 | dnl --------------------------------------------------------------------------- | |
278 | dnl AC_BAKEFILE_SHARED_LD | |
279 | dnl | |
280 | dnl Detects command for making shared libraries, substitutes SHARED_LD_CC | |
281 | dnl and SHARED_LD_CXX. | |
282 | dnl --------------------------------------------------------------------------- | |
283 | ||
284 | AC_DEFUN([AC_BAKEFILE_SHARED_LD], | |
285 | [ | |
286 | dnl the extra compiler flags needed for compilation of shared library | |
287 | PIC_FLAG="" | |
288 | if test "x$GCC" = "xyes"; then | |
289 | dnl the switch for gcc is the same under all platforms | |
290 | PIC_FLAG="-fPIC" | |
291 | fi | |
292 | ||
293 | dnl Defaults for GCC and ELF .so shared libs: | |
294 | SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o" | |
295 | SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o" | |
296 | WINDOWS_IMPLIB=0 | |
297 | ||
298 | case "${BAKEFILE_HOST}" in | |
299 | *-hp-hpux* ) | |
300 | dnl default settings are good for gcc but not for the native HP-UX | |
301 | if test "x$GCC" != "xyes"; then | |
302 | dnl no idea why it wants it, but it does | |
303 | LDFLAGS="$LDFLAGS -L/usr/lib" | |
304 | ||
305 | SHARED_LD_CC="${CC} -b -o" | |
306 | SHARED_LD_CXX="${CXX} -b -o" | |
307 | PIC_FLAG="+Z" | |
308 | fi | |
309 | ;; | |
310 | ||
311 | *-*-linux* ) | |
312 | if test "$INTELCC" = "yes"; then | |
313 | PIC_FLAG="-KPIC" | |
314 | elif test "x$SUNCXX" = "xyes"; then | |
315 | SHARED_LD_CC="${CC} -G -o" | |
316 | SHARED_LD_CXX="${CXX} -G -o" | |
317 | PIC_FLAG="-KPIC" | |
318 | fi | |
319 | ;; | |
320 | ||
321 | *-*-solaris2* ) | |
322 | if test "x$SUNCXX" = xyes ; then | |
323 | SHARED_LD_CC="${CC} -G -o" | |
324 | SHARED_LD_CXX="${CXX} -G -o" | |
325 | PIC_FLAG="-KPIC" | |
326 | fi | |
327 | ;; | |
328 | ||
329 | *-*-darwin* ) | |
330 | AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH | |
331 | chmod +x shared-ld-sh | |
332 | ||
333 | SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o" | |
334 | SHARED_LD_MODULE_CXX="$SHARED_LD_MODULE_CC" | |
335 | ||
336 | dnl Most apps benefit from being fully binded (its faster and static | |
337 | dnl variables initialized at startup work). | |
338 | dnl This can be done either with the exe linker flag -Wl,-bind_at_load | |
339 | dnl or with a double stage link in order to create a single module | |
340 | dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved | |
341 | ||
342 | dnl If using newer dev tools then there is a -single_module flag that | |
343 | dnl we can use to do this for dylibs, otherwise we'll need to use a helper | |
344 | dnl script. Check the version of gcc to see which way we can go: | |
345 | AC_CACHE_CHECK([for gcc 3.1 or later], bakefile_cv_gcc31, [ | |
346 | AC_TRY_COMPILE([], | |
347 | [ | |
348 | #if (__GNUC__ < 3) || \ | |
349 | ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)) | |
350 | This is old gcc | |
351 | #endif | |
352 | ], | |
353 | [ | |
354 | bakefile_cv_gcc31=yes | |
355 | ], | |
356 | [ | |
357 | bakefile_cv_gcc31=no | |
358 | ] | |
359 | ) | |
360 | ]) | |
361 | if test "$bakefile_cv_gcc31" = "no"; then | |
362 | dnl Use the shared-ld-sh helper script | |
363 | SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o" | |
364 | SHARED_LD_CXX="$SHARED_LD_CC" | |
365 | else | |
366 | dnl Use the -single_module flag and let the linker do it for us | |
367 | SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o" | |
368 | SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o" | |
369 | fi | |
370 | ||
371 | if test "x$GCC" == "xyes"; then | |
372 | PIC_FLAG="-dynamic -fPIC" | |
373 | fi | |
374 | if test "x$XLCC" = "xyes"; then | |
375 | PIC_FLAG="-dynamic -DPIC" | |
376 | fi | |
377 | ;; | |
378 | ||
379 | *-*-aix* ) | |
380 | if test "x$GCC" = "xyes"; then | |
381 | dnl at least gcc 2.95 warns that -fPIC is ignored when | |
382 | dnl compiling each and every file under AIX which is annoying, | |
383 | dnl so don't use it there (it's useless as AIX runs on | |
384 | dnl position-independent architectures only anyhow) | |
385 | PIC_FLAG="" | |
386 | ||
387 | dnl -bexpfull is needed by AIX linker to export all symbols (by | |
388 | dnl default it doesn't export any and even with -bexpall it | |
389 | dnl doesn't export all C++ support symbols, e.g. vtable | |
390 | dnl pointers) but it's only available starting from 5.1 (with | |
391 | dnl maintenance pack 2, whatever this is), see | |
392 | dnl http://www-128.ibm.com/developerworks/eserver/articles/gnu.html | |
393 | case "${BAKEFILE_HOST}" in | |
394 | *-*-aix5* ) | |
395 | LD_EXPFULL="-Wl,-bexpfull" | |
396 | ;; | |
397 | esac | |
398 | ||
399 | SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o" | |
400 | SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o" | |
401 | else | |
402 | dnl FIXME: makeC++SharedLib is obsolete, what should we do for | |
403 | dnl recent AIX versions? | |
404 | AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib, | |
405 | makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib) | |
406 | SHARED_LD_CC="$AIX_CC_LD -p 0 -o" | |
407 | SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o" | |
408 | fi | |
409 | ;; | |
410 | ||
411 | *-*-beos* ) | |
412 | dnl can't use gcc under BeOS for shared library creation because it | |
413 | dnl complains about missing 'main' | |
414 | SHARED_LD_CC="${LD} -nostart -o" | |
415 | SHARED_LD_CXX="${LD} -nostart -o" | |
416 | ;; | |
417 | ||
418 | *-*-irix* ) | |
419 | dnl default settings are ok for gcc | |
420 | if test "x$GCC" != "xyes"; then | |
421 | PIC_FLAG="-KPIC" | |
422 | fi | |
423 | ;; | |
424 | ||
425 | *-*-cygwin* | *-*-mingw32* ) | |
426 | PIC_FLAG="" | |
427 | SHARED_LD_CC="\$(CC) -shared -o" | |
428 | SHARED_LD_CXX="\$(CXX) -shared -o" | |
429 | WINDOWS_IMPLIB=1 | |
430 | ;; | |
431 | ||
432 | *-pc-os2_emx | *-pc-os2-emx ) | |
433 | SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o" | |
434 | SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o" | |
435 | PIC_FLAG="" | |
436 | AC_BAKEFILE_CREATE_FILE_DLLAR_SH | |
437 | chmod +x dllar.sh | |
438 | ;; | |
439 | ||
440 | powerpc-apple-macos* | \ | |
441 | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \ | |
442 | *-*-mirbsd* | \ | |
443 | *-*-sunos4* | \ | |
444 | *-*-osf* | \ | |
445 | *-*-dgux5* | \ | |
446 | *-*-sysv5* | \ | |
447 | *-pc-msdosdjgpp ) | |
448 | dnl defaults are ok | |
449 | ;; | |
450 | ||
451 | *) | |
452 | AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.) | |
453 | esac | |
454 | ||
455 | if test "x$PIC_FLAG" != "x" ; then | |
456 | PIC_FLAG="$PIC_FLAG -DPIC" | |
457 | fi | |
458 | ||
459 | if test "x$SHARED_LD_MODULE_CC" = "x" ; then | |
460 | SHARED_LD_MODULE_CC="$SHARED_LD_CC" | |
461 | fi | |
462 | if test "x$SHARED_LD_MODULE_CXX" = "x" ; then | |
463 | SHARED_LD_MODULE_CXX="$SHARED_LD_CXX" | |
464 | fi | |
465 | ||
466 | AC_SUBST(SHARED_LD_CC) | |
467 | AC_SUBST(SHARED_LD_CXX) | |
468 | AC_SUBST(SHARED_LD_MODULE_CC) | |
469 | AC_SUBST(SHARED_LD_MODULE_CXX) | |
470 | AC_SUBST(PIC_FLAG) | |
471 | AC_SUBST(WINDOWS_IMPLIB) | |
472 | ]) | |
473 | ||
474 | ||
475 | dnl --------------------------------------------------------------------------- | |
476 | dnl AC_BAKEFILE_SHARED_VERSIONS | |
477 | dnl | |
478 | dnl Detects linker options for attaching versions (sonames) to shared libs. | |
479 | dnl --------------------------------------------------------------------------- | |
480 | ||
481 | AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS], | |
482 | [ | |
483 | USE_SOVERSION=0 | |
484 | USE_SOVERLINUX=0 | |
485 | USE_SOVERSOLARIS=0 | |
486 | USE_SOVERCYGWIN=0 | |
487 | USE_SOSYMLINKS=0 | |
488 | USE_MACVERSION=0 | |
489 | SONAME_FLAG= | |
490 | ||
491 | case "${BAKEFILE_HOST}" in | |
492 | *-*-linux* | *-*-freebsd* | *-*-k*bsd*-gnu ) | |
493 | if test "x$SUNCXX" = "xyes"; then | |
494 | SONAME_FLAG="-h " | |
495 | else | |
496 | SONAME_FLAG="-Wl,-soname," | |
497 | fi | |
498 | USE_SOVERSION=1 | |
499 | USE_SOVERLINUX=1 | |
500 | USE_SOSYMLINKS=1 | |
501 | ;; | |
502 | ||
503 | *-*-solaris2* ) | |
504 | SONAME_FLAG="-h " | |
505 | USE_SOVERSION=1 | |
506 | USE_SOVERSOLARIS=1 | |
507 | USE_SOSYMLINKS=1 | |
508 | ;; | |
509 | ||
510 | *-*-darwin* ) | |
511 | USE_MACVERSION=1 | |
512 | USE_SOVERSION=1 | |
513 | USE_SOSYMLINKS=1 | |
514 | ;; | |
515 | ||
516 | *-*-cygwin* ) | |
517 | USE_SOVERSION=1 | |
518 | USE_SOVERCYGWIN=1 | |
519 | ;; | |
520 | esac | |
521 | ||
522 | AC_SUBST(USE_SOVERSION) | |
523 | AC_SUBST(USE_SOVERLINUX) | |
524 | AC_SUBST(USE_SOVERSOLARIS) | |
525 | AC_SUBST(USE_SOVERCYGWIN) | |
526 | AC_SUBST(USE_MACVERSION) | |
527 | AC_SUBST(USE_SOSYMLINKS) | |
528 | AC_SUBST(SONAME_FLAG) | |
529 | ]) | |
530 | ||
531 | ||
532 | dnl --------------------------------------------------------------------------- | |
533 | dnl AC_BAKEFILE_DEPS | |
534 | dnl | |
535 | dnl Detects available C/C++ dependency tracking options | |
536 | dnl --------------------------------------------------------------------------- | |
537 | ||
538 | AC_DEFUN([AC_BAKEFILE_DEPS], | |
539 | [ | |
540 | AC_ARG_ENABLE([dependency-tracking], | |
541 | AS_HELP_STRING([--disable-dependency-tracking], | |
542 | [don't use dependency tracking even if the compiler can]), | |
543 | [bk_use_trackdeps="$enableval"]) | |
544 | ||
545 | AC_MSG_CHECKING([for dependency tracking method]) | |
546 | ||
547 | BK_DEPS="" | |
548 | if test "x$bk_use_trackdeps" = "xno" ; then | |
549 | DEPS_TRACKING=0 | |
550 | AC_MSG_RESULT([disabled]) | |
551 | else | |
552 | DEPS_TRACKING=1 | |
553 | ||
554 | if test "x$GCC" = "xyes"; then | |
555 | DEPSMODE=gcc | |
556 | case "${BAKEFILE_HOST}" in | |
557 | *-*-darwin* ) | |
558 | dnl -cpp-precomp (the default) conflicts with -MMD option | |
559 | dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html) | |
560 | DEPSFLAG="-no-cpp-precomp -MMD" | |
561 | ;; | |
562 | * ) | |
563 | DEPSFLAG="-MMD" | |
564 | ;; | |
565 | esac | |
566 | AC_MSG_RESULT([gcc]) | |
567 | elif test "x$MWCC" = "xyes"; then | |
568 | DEPSMODE=mwcc | |
569 | DEPSFLAG="-MM" | |
570 | AC_MSG_RESULT([mwcc]) | |
571 | elif test "x$SUNCC" = "xyes"; then | |
572 | DEPSMODE=unixcc | |
573 | DEPSFLAG="-xM1" | |
574 | AC_MSG_RESULT([Sun cc]) | |
575 | elif test "x$SGICC" = "xyes"; then | |
576 | DEPSMODE=unixcc | |
577 | DEPSFLAG="-M" | |
578 | AC_MSG_RESULT([SGI cc]) | |
579 | elif test "x$HPCC" = "xyes"; then | |
580 | DEPSMODE=unixcc | |
581 | DEPSFLAG="+make" | |
582 | AC_MSG_RESULT([HP cc]) | |
583 | elif test "x$COMPAQCC" = "xyes"; then | |
584 | DEPSMODE=gcc | |
585 | DEPSFLAG="-MD" | |
586 | AC_MSG_RESULT([Compaq cc]) | |
587 | else | |
588 | DEPS_TRACKING=0 | |
589 | AC_MSG_RESULT([none]) | |
590 | fi | |
591 | ||
592 | if test $DEPS_TRACKING = 1 ; then | |
593 | AC_BAKEFILE_CREATE_FILE_BK_DEPS | |
594 | chmod +x bk-deps | |
595 | dnl FIXME: make this $(top_builddir)/bk-deps once autoconf-2.60 | |
596 | dnl is required (and so top_builddir is never empty): | |
597 | BK_DEPS="`pwd`/bk-deps" | |
598 | fi | |
599 | fi | |
600 | ||
601 | AC_SUBST(DEPS_TRACKING) | |
602 | AC_SUBST(BK_DEPS) | |
603 | ]) | |
604 | ||
605 | dnl --------------------------------------------------------------------------- | |
606 | dnl AC_BAKEFILE_CHECK_BASIC_STUFF | |
607 | dnl | |
608 | dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib" | |
609 | dnl or "install" | |
610 | dnl --------------------------------------------------------------------------- | |
611 | ||
612 | AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF], | |
613 | [ | |
614 | AC_PROG_RANLIB | |
615 | AC_PROG_INSTALL | |
616 | AC_PROG_LN_S | |
617 | ||
618 | AC_PROG_MAKE_SET | |
619 | AC_SUBST(MAKE_SET) | |
620 | ||
621 | if test "x$SUNCXX" = "xyes"; then | |
622 | dnl Sun C++ compiler requires special way of creating static libs; | |
623 | dnl see here for more details: | |
624 | dnl https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1229751&group_id=9863 | |
625 | AR=$CXX | |
626 | AROPTIONS="-xar -o" | |
627 | AC_SUBST(AR) | |
628 | elif test "x$SGICC" = "xyes"; then | |
629 | dnl Almost the same as above for SGI mipsPro compiler | |
630 | AR=$CXX | |
631 | AROPTIONS="-ar -o" | |
632 | AC_SUBST(AR) | |
633 | else | |
634 | AC_CHECK_TOOL(AR, ar, ar) | |
635 | AROPTIONS=rcu | |
636 | fi | |
637 | AC_SUBST(AROPTIONS) | |
638 | ||
639 | AC_CHECK_TOOL(STRIP, strip, :) | |
640 | AC_CHECK_TOOL(NM, nm, :) | |
641 | ||
642 | case ${BAKEFILE_HOST} in | |
643 | *-hp-hpux* ) | |
644 | dnl HP-UX install doesn't handle the "-d" switch so don't | |
645 | dnl use it there | |
646 | INSTALL_DIR="mkdir -p" | |
647 | ;; | |
648 | * ) | |
649 | dnl we must refer to makefile's $(INSTALL) variable and not | |
650 | dnl current value of shell variable, hence the single quoting: | |
651 | INSTALL_DIR='$(INSTALL) -d' | |
652 | ;; | |
653 | esac | |
654 | AC_SUBST(INSTALL_DIR) | |
655 | ||
656 | LDFLAGS_GUI= | |
657 | case ${BAKEFILE_HOST} in | |
658 | *-*-cygwin* | *-*-mingw32* ) | |
659 | LDFLAGS_GUI="-mwindows" | |
660 | esac | |
661 | AC_SUBST(LDFLAGS_GUI) | |
662 | ]) | |
663 | ||
664 | ||
665 | dnl --------------------------------------------------------------------------- | |
666 | dnl AC_BAKEFILE_RES_COMPILERS | |
667 | dnl | |
668 | dnl Checks for presence of resource compilers for win32 or mac | |
669 | dnl --------------------------------------------------------------------------- | |
670 | ||
671 | AC_DEFUN([AC_BAKEFILE_RES_COMPILERS], | |
672 | [ | |
673 | case ${BAKEFILE_HOST} in | |
674 | *-*-cygwin* | *-*-mingw32* ) | |
675 | dnl Check for win32 resources compiler: | |
676 | AC_CHECK_TOOL(WINDRES, windres) | |
677 | ;; | |
678 | ||
679 | *-*-darwin* | powerpc-apple-macos* ) | |
680 | AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez) | |
681 | AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile) | |
682 | ;; | |
683 | esac | |
684 | ||
685 | AC_SUBST(WINDRES) | |
686 | AC_SUBST(REZ) | |
687 | AC_SUBST(SETFILE) | |
688 | ]) | |
689 | ||
690 | dnl --------------------------------------------------------------------------- | |
691 | dnl AC_BAKEFILE_PRECOMP_HEADERS | |
692 | dnl | |
693 | dnl Check for precompiled headers support (GCC >= 3.4) | |
694 | dnl --------------------------------------------------------------------------- | |
695 | ||
696 | AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS], | |
697 | [ | |
698 | ||
699 | AC_ARG_ENABLE([precomp-headers], | |
700 | AS_HELP_STRING([--disable-precomp-headers], | |
701 | [don't use precompiled headers even if compiler can]), | |
702 | [bk_use_pch="$enableval"]) | |
703 | ||
704 | GCC_PCH=0 | |
705 | ICC_PCH=0 | |
706 | USE_PCH=0 | |
707 | BK_MAKE_PCH="" | |
708 | ||
709 | case ${BAKEFILE_HOST} in | |
710 | *-*-cygwin* ) | |
711 | dnl PCH support is broken in cygwin gcc because of unportable | |
712 | dnl assumptions about mmap() in gcc code which make PCH generation | |
713 | dnl fail erratically; disable PCH completely until this is fixed | |
714 | bk_use_pch="no" | |
715 | ;; | |
716 | esac | |
717 | ||
718 | if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then | |
719 | if test "x$GCC" = "xyes"; then | |
720 | dnl test if we have gcc-3.4: | |
721 | AC_MSG_CHECKING([if the compiler supports precompiled headers]) | |
722 | AC_TRY_COMPILE([], | |
723 | [ | |
724 | #if !defined(__GNUC__) || !defined(__GNUC_MINOR__) | |
725 | There is no PCH support | |
726 | #endif | |
727 | #if (__GNUC__ < 3) | |
728 | There is no PCH support | |
729 | #endif | |
730 | #if (__GNUC__ == 3) && \ | |
731 | ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \ | |
732 | ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3))) || \ | |
733 | ( defined(__INTEL_COMPILER) ) | |
734 | There is no PCH support | |
735 | #endif | |
736 | ], | |
737 | [ | |
738 | AC_MSG_RESULT([yes]) | |
739 | GCC_PCH=1 | |
740 | ], | |
741 | [ | |
742 | AC_TRY_COMPILE([], | |
743 | [ | |
744 | #if !defined(__INTEL_COMPILER) || \ | |
745 | (__INTEL_COMPILER < 800) | |
746 | There is no PCH support | |
747 | #endif | |
748 | ], | |
749 | [ | |
750 | AC_MSG_RESULT([yes]) | |
751 | ICC_PCH=1 | |
752 | ], | |
753 | [ | |
754 | AC_MSG_RESULT([no]) | |
755 | ]) | |
756 | ]) | |
757 | if test $GCC_PCH = 1 -o $ICC_PCH = 1 ; then | |
758 | USE_PCH=1 | |
759 | AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH | |
760 | chmod +x bk-make-pch | |
761 | dnl FIXME: make this $(top_builddir)/bk-make-pch once | |
762 | dnl autoconf-2.60 is required (and so top_builddir is | |
763 | dnl never empty): | |
764 | BK_MAKE_PCH="`pwd`/bk-make-pch" | |
765 | fi | |
766 | fi | |
767 | fi | |
768 | ||
769 | AC_SUBST(GCC_PCH) | |
770 | AC_SUBST(ICC_PCH) | |
771 | AC_SUBST(BK_MAKE_PCH) | |
772 | ]) | |
773 | ||
774 | ||
775 | ||
776 | dnl --------------------------------------------------------------------------- | |
777 | dnl AC_BAKEFILE([autoconf_inc.m4 inclusion]) | |
778 | dnl | |
779 | dnl To be used in configure.in of any project using Bakefile-generated mks | |
780 | dnl | |
781 | dnl Behaviour can be modified by setting following variables: | |
782 | dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to | |
783 | dnl to perform check for basic tools like ranlib | |
784 | dnl BAKEFILE_HOST set this to override host detection, defaults | |
785 | dnl to ${host} | |
786 | dnl BAKEFILE_FORCE_PLATFORM set to override platform detection | |
787 | dnl | |
788 | dnl Example usage: | |
789 | dnl | |
790 | dnl AC_BAKEFILE([FOO(autoconf_inc.m4)]) | |
791 | dnl | |
792 | dnl (replace FOO with m4_include above, aclocal would die otherwise) | |
793 | dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing | |
794 | dnl we can do...) | |
795 | dnl --------------------------------------------------------------------------- | |
796 | ||
797 | AC_DEFUN([AC_BAKEFILE], | |
798 | [ | |
799 | AC_PREREQ([2.58]) | |
800 | ||
801 | if test "x$BAKEFILE_HOST" = "x"; then | |
802 | if test "x${host}" = "x" ; then | |
803 | AC_MSG_ERROR([You must call the autoconf "CANONICAL_HOST" macro in your configure.ac (or .in) file.]) | |
804 | fi | |
805 | ||
806 | BAKEFILE_HOST="${host}" | |
807 | fi | |
808 | ||
809 | if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then | |
810 | AC_BAKEFILE_CHECK_BASIC_STUFF | |
811 | fi | |
812 | AC_BAKEFILE_GNUMAKE | |
813 | AC_BAKEFILE_PLATFORM | |
814 | AC_BAKEFILE_PLATFORM_SPECIFICS | |
815 | AC_BAKEFILE_SUFFIXES | |
816 | AC_BAKEFILE_SHARED_LD | |
817 | AC_BAKEFILE_SHARED_VERSIONS | |
818 | AC_BAKEFILE_DEPS | |
819 | AC_BAKEFILE_RES_COMPILERS | |
820 | ||
821 | BAKEFILE_BAKEFILE_M4_VERSION="0.2.2" | |
822 | ||
823 | dnl includes autoconf_inc.m4: | |
824 | $1 | |
825 | ||
826 | if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then | |
827 | AC_MSG_ERROR([No version found in autoconf_inc.m4 - bakefile macro was changed to take additional argument, perhaps configure.in wasn't updated (see the documentation)?]) | |
828 | fi | |
829 | ||
830 | if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then | |
831 | AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.]) | |
832 | fi | |
833 | ]) | |
834 | ||
835 | ||
836 | dnl --------------------------------------------------------------------------- | |
837 | dnl Embedded copies of helper scripts follow: | |
838 | dnl --------------------------------------------------------------------------- | |
839 | ||
840 | AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS], | |
841 | [ | |
842 | dnl ===================== bk-deps begins here ===================== | |
843 | dnl (Created by merge-scripts.py from bk-deps | |
844 | dnl file do not edit here!) | |
845 | D='$' | |
846 | cat <<EOF >bk-deps | |
847 | #!/bin/sh | |
848 | ||
849 | # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf | |
850 | # script. It is used to track C/C++ files dependencies in portable way. | |
851 | # | |
852 | # Permission is given to use this file in any way. | |
853 | ||
854 | DEPSMODE=${DEPSMODE} | |
855 | DEPSDIR=.deps | |
856 | DEPSFLAG="${DEPSFLAG}" | |
857 | ||
858 | mkdir -p ${D}DEPSDIR | |
859 | ||
860 | if test ${D}DEPSMODE = gcc ; then | |
861 | ${D}* ${D}{DEPSFLAG} | |
862 | status=${D}? | |
863 | if test ${D}{status} != 0 ; then | |
864 | exit ${D}{status} | |
865 | fi | |
866 | # move created file to the location we want it in: | |
867 | while test ${D}# -gt 0; do | |
868 | case "${D}1" in | |
869 | -o ) | |
870 | shift | |
871 | objfile=${D}1 | |
872 | ;; | |
873 | -* ) | |
874 | ;; | |
875 | * ) | |
876 | srcfile=${D}1 | |
877 | ;; | |
878 | esac | |
879 | shift | |
880 | done | |
881 | depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\` | |
882 | depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\` | |
883 | if test -f ${D}depfile ; then | |
884 | sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d | |
885 | rm -f ${D}depfile | |
886 | else | |
887 | # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d | |
888 | depfile=\`basename ${D}objfile | sed -e 's/\\..*${D}/.d/g'\` | |
889 | if test ! -f ${D}depfile ; then | |
890 | # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++) | |
891 | depfile="${D}objfile.d" | |
892 | fi | |
893 | if test -f ${D}depfile ; then | |
894 | sed -e "/^${D}objfile/!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d | |
895 | rm -f ${D}depfile | |
896 | fi | |
897 | fi | |
898 | exit 0 | |
899 | elif test ${D}DEPSMODE = mwcc ; then | |
900 | ${D}* || exit ${D}? | |
901 | # Run mwcc again with -MM and redirect into the dep file we want | |
902 | # NOTE: We can't use shift here because we need ${D}* to be valid | |
903 | prevarg= | |
904 | for arg in ${D}* ; do | |
905 | if test "${D}prevarg" = "-o"; then | |
906 | objfile=${D}arg | |
907 | else | |
908 | case "${D}arg" in | |
909 | -* ) | |
910 | ;; | |
911 | * ) | |
912 | srcfile=${D}arg | |
913 | ;; | |
914 | esac | |
915 | fi | |
916 | prevarg="${D}arg" | |
917 | done | |
918 | ${D}* ${D}DEPSFLAG >${D}{DEPSDIR}/${D}{objfile}.d | |
919 | exit 0 | |
920 | elif test ${D}DEPSMODE = unixcc; then | |
921 | ${D}* || exit ${D}? | |
922 | # Run compiler again with deps flag and redirect into the dep file. | |
923 | # It doesn't work if the '-o FILE' option is used, but without it the | |
924 | # dependency file will contain the wrong name for the object. So it is | |
925 | # removed from the command line, and the dep file is fixed with sed. | |
926 | cmd="" | |
927 | while test ${D}# -gt 0; do | |
928 | case "${D}1" in | |
929 | -o ) | |
930 | shift | |
931 | objfile=${D}1 | |
932 | ;; | |
933 | * ) | |
934 | eval arg${D}#=\\${D}1 | |
935 | cmd="${D}cmd \\${D}arg${D}#" | |
936 | ;; | |
937 | esac | |
938 | shift | |
939 | done | |
940 | eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{DEPSDIR}/${D}{objfile}.d | |
941 | exit 0 | |
942 | else | |
943 | ${D}* | |
944 | exit ${D}? | |
945 | fi | |
946 | EOF | |
947 | dnl ===================== bk-deps ends here ===================== | |
948 | ]) | |
949 | ||
950 | AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH], | |
951 | [ | |
952 | dnl ===================== shared-ld-sh begins here ===================== | |
953 | dnl (Created by merge-scripts.py from shared-ld-sh | |
954 | dnl file do not edit here!) | |
955 | D='$' | |
956 | cat <<EOF >shared-ld-sh | |
957 | #!/bin/sh | |
958 | #----------------------------------------------------------------------------- | |
959 | #-- Name: distrib/mac/shared-ld-sh | |
960 | #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X | |
961 | #-- Author: Gilles Depeyrot | |
962 | #-- Copyright: (c) 2002 Gilles Depeyrot | |
963 | #-- Licence: any use permitted | |
964 | #----------------------------------------------------------------------------- | |
965 | ||
966 | verbose=0 | |
967 | args="" | |
968 | objects="" | |
969 | linking_flag="-dynamiclib" | |
970 | ldargs="-r -keep_private_externs -nostdlib" | |
971 | ||
972 | while test ${D}# -gt 0; do | |
973 | case ${D}1 in | |
974 | ||
975 | -v) | |
976 | verbose=1 | |
977 | ;; | |
978 | ||
979 | -o|-compatibility_version|-current_version|-framework|-undefined|-install_name) | |
980 | # collect these options and values | |
981 | args="${D}{args} ${D}1 ${D}2" | |
982 | shift | |
983 | ;; | |
984 | ||
985 | -s|-Wl,*) | |
986 | # collect these load args | |
987 | ldargs="${D}{ldargs} ${D}1" | |
988 | ;; | |
989 | ||
990 | -l*|-L*|-flat_namespace|-headerpad_max_install_names) | |
991 | # collect these options | |
992 | args="${D}{args} ${D}1" | |
993 | ;; | |
994 | ||
995 | -dynamiclib|-bundle) | |
996 | linking_flag="${D}1" | |
997 | ;; | |
998 | ||
999 | -*) | |
1000 | echo "shared-ld: unhandled option '${D}1'" | |
1001 | exit 1 | |
1002 | ;; | |
1003 | ||
1004 | *.o | *.a | *.dylib) | |
1005 | # collect object files | |
1006 | objects="${D}{objects} ${D}1" | |
1007 | ;; | |
1008 | ||
1009 | *) | |
1010 | echo "shared-ld: unhandled argument '${D}1'" | |
1011 | exit 1 | |
1012 | ;; | |
1013 | ||
1014 | esac | |
1015 | shift | |
1016 | done | |
1017 | ||
1018 | status=0 | |
1019 | ||
1020 | # | |
1021 | # Link one module containing all the others | |
1022 | # | |
1023 | if test ${D}{verbose} = 1; then | |
1024 | echo "c++ ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o" | |
1025 | fi | |
1026 | c++ ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o | |
1027 | status=${D}? | |
1028 | ||
1029 | # | |
1030 | # Link the shared library from the single module created, but only if the | |
1031 | # previous command didn't fail: | |
1032 | # | |
1033 | if test ${D}{status} = 0; then | |
1034 | if test ${D}{verbose} = 1; then | |
1035 | echo "c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args}" | |
1036 | fi | |
1037 | c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args} | |
1038 | status=${D}? | |
1039 | fi | |
1040 | ||
1041 | # | |
1042 | # Remove intermediate module | |
1043 | # | |
1044 | rm -f master.${D}${D}.o | |
1045 | ||
1046 | exit ${D}status | |
1047 | EOF | |
1048 | dnl ===================== shared-ld-sh ends here ===================== | |
1049 | ]) | |
1050 | ||
1051 | AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH], | |
1052 | [ | |
1053 | dnl ===================== bk-make-pch begins here ===================== | |
1054 | dnl (Created by merge-scripts.py from bk-make-pch | |
1055 | dnl file do not edit here!) | |
1056 | D='$' | |
1057 | cat <<EOF >bk-make-pch | |
1058 | #!/bin/sh | |
1059 | ||
1060 | # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf | |
1061 | # script. It is used to generated precompiled headers. | |
1062 | # | |
1063 | # Permission is given to use this file in any way. | |
1064 | ||
1065 | outfile="${D}{1}" | |
1066 | header="${D}{2}" | |
1067 | shift | |
1068 | shift | |
1069 | ||
1070 | compiler="" | |
1071 | headerfile="" | |
1072 | ||
1073 | while test ${D}{#} -gt 0; do | |
1074 | add_to_cmdline=1 | |
1075 | case "${D}{1}" in | |
1076 | -I* ) | |
1077 | incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\` | |
1078 | if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then | |
1079 | headerfile="${D}{incdir}/${D}{header}" | |
1080 | fi | |
1081 | ;; | |
1082 | -use-pch|-use_pch ) | |
1083 | shift | |
1084 | add_to_cmdline=0 | |
1085 | ;; | |
1086 | esac | |
1087 | if test ${D}add_to_cmdline = 1 ; then | |
1088 | compiler="${D}{compiler} ${D}{1}" | |
1089 | fi | |
1090 | shift | |
1091 | done | |
1092 | ||
1093 | if test "x${D}{headerfile}" = "x" ; then | |
1094 | echo "error: can't find header ${D}{header} in include paths" >&2 | |
1095 | else | |
1096 | if test -f ${D}{outfile} ; then | |
1097 | rm -f ${D}{outfile} | |
1098 | else | |
1099 | mkdir -p \`dirname ${D}{outfile}\` | |
1100 | fi | |
1101 | depsfile=".deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d" | |
1102 | mkdir -p .deps | |
1103 | if test "x${GCC_PCH}" = "x1" ; then | |
1104 | # can do this because gcc is >= 3.4: | |
1105 | ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}" | |
1106 | elif test "x${ICC_PCH}" = "x1" ; then | |
1107 | filename=pch_gen-${D}${D} | |
1108 | file=${D}{filename}.c | |
1109 | dfile=${D}{filename}.d | |
1110 | cat > ${D}file <<EOT | |
1111 | #include "${D}header" | |
1112 | EOT | |
1113 | # using -MF icc complains about differing command lines in creation/use | |
1114 | ${D}compiler -c -create_pch ${D}outfile -MMD ${D}file && \\ | |
1115 | sed -e "s,^.*:,${D}outfile:," -e "s, ${D}file,," < ${D}dfile > ${D}depsfile && \\ | |
1116 | rm -f ${D}file ${D}dfile ${D}{filename}.o | |
1117 | fi | |
1118 | exit ${D}{?} | |
1119 | fi | |
1120 | EOF | |
1121 | dnl ===================== bk-make-pch ends here ===================== | |
1122 | ]) |