]> git.saurik.com Git - wxWidgets.git/blame - build/aclocal/bakefile.m4
preserve TAB characters when copying HTML <pre> content to clipboard
[wxWidgets.git] / build / aclocal / bakefile.m4
CommitLineData
2e91a01a 1dnl
5b8deaba 2dnl This file is part of Bakefile (http://www.bakefile.org)
2e91a01a
VZ
3dnl
4dnl Copyright (C) 2003-2007 Vaclav Slavik and others
5dnl
6dnl Permission is hereby granted, free of charge, to any person obtaining a
7dnl copy of this software and associated documentation files (the "Software"),
8dnl to deal in the Software without restriction, including without limitation
9dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
10dnl and/or sell copies of the Software, and to permit persons to whom the
11dnl Software is furnished to do so, subject to the following conditions:
12dnl
13dnl The above copyright notice and this permission notice shall be included in
14dnl all copies or substantial portions of the Software.
15dnl
16dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22dnl DEALINGS IN THE SOFTWARE.
23dnl
24dnl $Id$
25dnl
26dnl Support macros for makefiles generated by BAKEFILE.
27dnl
948b08e2 28
2e91a01a
VZ
29
30dnl ---------------------------------------------------------------------------
948b08e2 31dnl Lots of compiler & linker detection code contained here was taken from
2e91a01a
VZ
32dnl wxWidgets configure.in script (see http://www.wxwidgets.org)
33dnl ---------------------------------------------------------------------------
948b08e2
VZ
34
35
36
37dnl ---------------------------------------------------------------------------
38dnl AC_BAKEFILE_GNUMAKE
39dnl
40dnl Detects GNU make
41dnl ---------------------------------------------------------------------------
42
43AC_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
64dnl ---------------------------------------------------------------------------
65dnl AC_BAKEFILE_PLATFORM
66dnl
67dnl Detects platform and sets PLATFORM_XXX variables accordingly
68dnl ---------------------------------------------------------------------------
69
70AC_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
2e91a01a 81 if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
948b08e2
VZ
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
2e91a01a 95 ;;
948b08e2
VZ
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 * )
5b8deaba 129 dnl wxWidgets-specific: allow unknown Unix systems
2e91a01a 130 dnl AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
948b08e2
VZ
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
146dnl ---------------------------------------------------------------------------
147dnl AC_BAKEFILE_PLATFORM_SPECIFICS
148dnl
149dnl Sets misc platform-specific settings
150dnl ---------------------------------------------------------------------------
151
152AC_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"])
2e91a01a 157
948b08e2
VZ
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 ;;
2e91a01a 184
948b08e2
VZ
185 i*86-*-beos* )
186 LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
187 ;;
188 esac
189])
190
191dnl ---------------------------------------------------------------------------
192dnl AC_BAKEFILE_SUFFIXES
193dnl
194dnl Detects shared various suffixes for shared libraries, libraries, programs,
195dnl plugins etc.
196dnl ---------------------------------------------------------------------------
197
198AC_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"
2e91a01a 209
948b08e2
VZ
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
277dnl ---------------------------------------------------------------------------
278dnl AC_BAKEFILE_SHARED_LD
279dnl
280dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
281dnl and SHARED_LD_CXX.
282dnl ---------------------------------------------------------------------------
283
284AC_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
2e91a01a 292
948b08e2
VZ
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* )
9435c35e
VZ
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"
948b08e2
VZ
318 fi
319 ;;
320
321 *-*-solaris2* )
9435c35e 322 if test "x$SUNCXX" = xyes ; then
948b08e2
VZ
323 SHARED_LD_CC="${CC} -G -o"
324 SHARED_LD_CXX="${CXX} -G -o"
325 PIC_FLAG="-KPIC"
326 fi
327 ;;
328
329 *-*-darwin* )
89ec5d14
VZ
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"
5b8deaba 334 SHARED_LD_MODULE_CXX="CXX=\$(CXX) $SHARED_LD_MODULE_CC"
89ec5d14 335
948b08e2
VZ
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
2eef8513 343 dnl we can use to do this for dylibs, otherwise we'll need to use a helper
948b08e2 344 dnl script. Check the version of gcc to see which way we can go:
a1aa0349 345 AC_CACHE_CHECK([for gcc 3.1 or later], bakefile_cv_gcc31, [
948b08e2
VZ
346 AC_TRY_COMPILE([],
347 [
348 #if (__GNUC__ < 3) || \
349 ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
27237c37 350 This is old gcc
948b08e2
VZ
351 #endif
352 ],
353 [
a1aa0349 354 bakefile_cv_gcc31=yes
948b08e2
VZ
355 ],
356 [
a1aa0349 357 bakefile_cv_gcc31=no
948b08e2
VZ
358 ]
359 )
360 ])
a1aa0349 361 if test "$bakefile_cv_gcc31" = "no"; then
948b08e2
VZ
362 dnl Use the shared-ld-sh helper script
363 SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
948b08e2 364 SHARED_LD_CXX="$SHARED_LD_CC"
948b08e2
VZ
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"
948b08e2 368 SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
948b08e2
VZ
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* )
948b08e2 380 if test "x$GCC" = "xyes"; then
89ec5d14
VZ
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?
948b08e2
VZ
404 AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
405 makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
948b08e2
VZ
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 ;;
89ec5d14 424
948b08e2
VZ
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 ;;
89ec5d14 439
948b08e2
VZ
440 powerpc-apple-macos* | \
441 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \
c3e7509c 442 *-*-mirbsd* | \
948b08e2
VZ
443 *-*-sunos4* | \
444 *-*-osf* | \
445 *-*-dgux5* | \
446 *-*-sysv5* | \
447 *-pc-msdosdjgpp )
448 dnl defaults are ok
449 ;;
450
451 *)
2e91a01a 452 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
948b08e2
VZ
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
475dnl ---------------------------------------------------------------------------
476dnl AC_BAKEFILE_SHARED_VERSIONS
477dnl
478dnl Detects linker options for attaching versions (sonames) to shared libs.
479dnl ---------------------------------------------------------------------------
480
481AC_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
5b8deaba
VZ
492 *-*-linux* | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
493 *-*-k*bsd*-gnu | *-*-mirbsd* )
9435c35e
VZ
494 if test "x$SUNCXX" = "xyes"; then
495 SONAME_FLAG="-h "
496 else
497 SONAME_FLAG="-Wl,-soname,"
498 fi
948b08e2
VZ
499 USE_SOVERSION=1
500 USE_SOVERLINUX=1
501 USE_SOSYMLINKS=1
502 ;;
503
504 *-*-solaris2* )
505 SONAME_FLAG="-h "
506 USE_SOVERSION=1
507 USE_SOVERSOLARIS=1
508 USE_SOSYMLINKS=1
509 ;;
510
511 *-*-darwin* )
512 USE_MACVERSION=1
513 USE_SOVERSION=1
514 USE_SOSYMLINKS=1
515 ;;
516
517 *-*-cygwin* )
518 USE_SOVERSION=1
519 USE_SOVERCYGWIN=1
520 ;;
521 esac
522
523 AC_SUBST(USE_SOVERSION)
524 AC_SUBST(USE_SOVERLINUX)
525 AC_SUBST(USE_SOVERSOLARIS)
526 AC_SUBST(USE_SOVERCYGWIN)
527 AC_SUBST(USE_MACVERSION)
528 AC_SUBST(USE_SOSYMLINKS)
529 AC_SUBST(SONAME_FLAG)
530])
531
532
533dnl ---------------------------------------------------------------------------
534dnl AC_BAKEFILE_DEPS
535dnl
536dnl Detects available C/C++ dependency tracking options
537dnl ---------------------------------------------------------------------------
538
539AC_DEFUN([AC_BAKEFILE_DEPS],
540[
bd73e184
VZ
541 AC_ARG_ENABLE([dependency-tracking],
542 AS_HELP_STRING([--disable-dependency-tracking],
543 [don't use dependency tracking even if the compiler can]),
544 [bk_use_trackdeps="$enableval"])
2e91a01a 545
948b08e2 546 AC_MSG_CHECKING([for dependency tracking method])
948b08e2 547
97d28c6f 548 BK_DEPS=""
bd73e184 549 if test "x$bk_use_trackdeps" = "xno" ; then
14cde513 550 DEPS_TRACKING=0
bd73e184
VZ
551 AC_MSG_RESULT([disabled])
552 else
553 DEPS_TRACKING=1
554
555 if test "x$GCC" = "xyes"; then
556 DEPSMODE=gcc
557 case "${BAKEFILE_HOST}" in
558 *-*-darwin* )
559 dnl -cpp-precomp (the default) conflicts with -MMD option
560 dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
561 DEPSFLAG="-no-cpp-precomp -MMD"
562 ;;
563 * )
564 DEPSFLAG="-MMD"
565 ;;
566 esac
567 AC_MSG_RESULT([gcc])
568 elif test "x$MWCC" = "xyes"; then
569 DEPSMODE=mwcc
570 DEPSFLAG="-MM"
571 AC_MSG_RESULT([mwcc])
572 elif test "x$SUNCC" = "xyes"; then
573 DEPSMODE=unixcc
574 DEPSFLAG="-xM1"
575 AC_MSG_RESULT([Sun cc])
576 elif test "x$SGICC" = "xyes"; then
577 DEPSMODE=unixcc
578 DEPSFLAG="-M"
579 AC_MSG_RESULT([SGI cc])
580 elif test "x$HPCC" = "xyes"; then
581 DEPSMODE=unixcc
582 DEPSFLAG="+make"
583 AC_MSG_RESULT([HP cc])
584 elif test "x$COMPAQCC" = "xyes"; then
585 DEPSMODE=gcc
586 DEPSFLAG="-MD"
587 AC_MSG_RESULT([Compaq cc])
588 else
589 DEPS_TRACKING=0
590 AC_MSG_RESULT([none])
591 fi
948b08e2 592
bd73e184
VZ
593 if test $DEPS_TRACKING = 1 ; then
594 AC_BAKEFILE_CREATE_FILE_BK_DEPS
595 chmod +x bk-deps
97d28c6f
VZ
596 dnl FIXME: make this $(top_builddir)/bk-deps once autoconf-2.60
597 dnl is required (and so top_builddir is never empty):
598 BK_DEPS="`pwd`/bk-deps"
bd73e184 599 fi
948b08e2 600 fi
14cde513 601
948b08e2 602 AC_SUBST(DEPS_TRACKING)
97d28c6f 603 AC_SUBST(BK_DEPS)
948b08e2
VZ
604])
605
606dnl ---------------------------------------------------------------------------
607dnl AC_BAKEFILE_CHECK_BASIC_STUFF
608dnl
609dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
610dnl or "install"
611dnl ---------------------------------------------------------------------------
612
613AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
614[
615 AC_PROG_RANLIB
616 AC_PROG_INSTALL
617 AC_PROG_LN_S
618
619 AC_PROG_MAKE_SET
620 AC_SUBST(MAKE_SET)
2e91a01a 621
97d28c6f
VZ
622 if test "x$SUNCXX" = "xyes"; then
623 dnl Sun C++ compiler requires special way of creating static libs;
624 dnl see here for more details:
625 dnl https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1229751&group_id=9863
2e91a01a
VZ
626 AR=$CXX
627 AROPTIONS="-xar -o"
628 AC_SUBST(AR)
629 elif test "x$SGICC" = "xyes"; then
630 dnl Almost the same as above for SGI mipsPro compiler
631 AR=$CXX
632 AROPTIONS="-ar -o"
97d28c6f 633 AC_SUBST(AR)
97d28c6f
VZ
634 else
635 AC_CHECK_TOOL(AR, ar, ar)
636 AROPTIONS=rcu
637 fi
638 AC_SUBST(AROPTIONS)
639
948b08e2
VZ
640 AC_CHECK_TOOL(STRIP, strip, :)
641 AC_CHECK_TOOL(NM, nm, :)
642
5b8deaba
VZ
643 dnl This check is necessary because "install -d" doesn't exist on
644 dnl all platforms (e.g. HP/UX), see http://www.bakefile.org/ticket/80
645 AC_MSG_CHECKING([for command to install directories])
646 INSTALL_TEST_DIR=acbftest$$
647 $INSTALL -d $INSTALL_TEST_DIR > /dev/null 2>&1
648 if test $? = 0 -a -d $INSTALL_TEST_DIR; then
649 rmdir $INSTALL_TEST_DIR
650 dnl we must refer to makefile's $(INSTALL) variable and not
651 dnl current value of shell variable, hence the single quoting:
652 INSTALL_DIR='$(INSTALL) -d'
653 AC_MSG_RESULT([$INSTALL -d])
654 else
655 INSTALL_DIR="mkdir -p"
656 AC_MSG_RESULT([mkdir -p])
657 fi
948b08e2
VZ
658 AC_SUBST(INSTALL_DIR)
659
660 LDFLAGS_GUI=
661 case ${BAKEFILE_HOST} in
662 *-*-cygwin* | *-*-mingw32* )
663 LDFLAGS_GUI="-mwindows"
664 esac
665 AC_SUBST(LDFLAGS_GUI)
666])
667
668
669dnl ---------------------------------------------------------------------------
670dnl AC_BAKEFILE_RES_COMPILERS
671dnl
672dnl Checks for presence of resource compilers for win32 or mac
673dnl ---------------------------------------------------------------------------
674
675AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
676[
2e91a01a 677 case ${BAKEFILE_HOST} in
948b08e2
VZ
678 *-*-cygwin* | *-*-mingw32* )
679 dnl Check for win32 resources compiler:
891ace05 680 AC_CHECK_TOOL(WINDRES, windres)
948b08e2 681 ;;
2e91a01a 682
948b08e2 683 *-*-darwin* | powerpc-apple-macos* )
891ace05 684 AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez)
948b08e2
VZ
685 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
686 ;;
687 esac
688
891ace05
DE
689 AC_SUBST(WINDRES)
690 AC_SUBST(REZ)
948b08e2
VZ
691 AC_SUBST(SETFILE)
692])
693
694dnl ---------------------------------------------------------------------------
695dnl AC_BAKEFILE_PRECOMP_HEADERS
696dnl
697dnl Check for precompiled headers support (GCC >= 3.4)
698dnl ---------------------------------------------------------------------------
699
700AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
701[
702
703 AC_ARG_ENABLE([precomp-headers],
704 AS_HELP_STRING([--disable-precomp-headers],
705 [don't use precompiled headers even if compiler can]),
706 [bk_use_pch="$enableval"])
707
708 GCC_PCH=0
bd73e184
VZ
709 ICC_PCH=0
710 USE_PCH=0
97d28c6f 711 BK_MAKE_PCH=""
948b08e2 712
2e91a01a 713 case ${BAKEFILE_HOST} in
91a1ee86
VZ
714 *-*-cygwin* )
715 dnl PCH support is broken in cygwin gcc because of unportable
716 dnl assumptions about mmap() in gcc code which make PCH generation
717 dnl fail erratically; disable PCH completely until this is fixed
718 bk_use_pch="no"
719 ;;
720 esac
721
948b08e2
VZ
722 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
723 if test "x$GCC" = "xyes"; then
724 dnl test if we have gcc-3.4:
725 AC_MSG_CHECKING([if the compiler supports precompiled headers])
726 AC_TRY_COMPILE([],
727 [
728 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
27237c37 729 There is no PCH support
948b08e2
VZ
730 #endif
731 #if (__GNUC__ < 3)
27237c37 732 There is no PCH support
948b08e2
VZ
733 #endif
734 #if (__GNUC__ == 3) && \
735 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
bd73e184
VZ
736 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3))) || \
737 ( defined(__INTEL_COMPILER) )
27237c37 738 There is no PCH support
948b08e2
VZ
739 #endif
740 ],
741 [
742 AC_MSG_RESULT([yes])
743 GCC_PCH=1
744 ],
745 [
bd73e184
VZ
746 AC_TRY_COMPILE([],
747 [
748 #if !defined(__INTEL_COMPILER) || \
749 (__INTEL_COMPILER < 800)
27237c37 750 There is no PCH support
bd73e184
VZ
751 #endif
752 ],
753 [
754 AC_MSG_RESULT([yes])
755 ICC_PCH=1
756 ],
757 [
758 AC_MSG_RESULT([no])
759 ])
948b08e2 760 ])
bd73e184
VZ
761 if test $GCC_PCH = 1 -o $ICC_PCH = 1 ; then
762 USE_PCH=1
948b08e2
VZ
763 AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
764 chmod +x bk-make-pch
97d28c6f
VZ
765 dnl FIXME: make this $(top_builddir)/bk-make-pch once
766 dnl autoconf-2.60 is required (and so top_builddir is
767 dnl never empty):
768 BK_MAKE_PCH="`pwd`/bk-make-pch"
948b08e2
VZ
769 fi
770 fi
771 fi
772
773 AC_SUBST(GCC_PCH)
bd73e184 774 AC_SUBST(ICC_PCH)
97d28c6f 775 AC_SUBST(BK_MAKE_PCH)
948b08e2
VZ
776])
777
778
779
780dnl ---------------------------------------------------------------------------
781dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
782dnl
783dnl To be used in configure.in of any project using Bakefile-generated mks
784dnl
785dnl Behaviour can be modified by setting following variables:
786dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
787dnl to perform check for basic tools like ranlib
788dnl BAKEFILE_HOST set this to override host detection, defaults
789dnl to ${host}
790dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
791dnl
792dnl Example usage:
793dnl
794dnl AC_BAKEFILE([FOO(autoconf_inc.m4)])
795dnl
796dnl (replace FOO with m4_include above, aclocal would die otherwise)
797dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
798dnl we can do...)
799dnl ---------------------------------------------------------------------------
800
801AC_DEFUN([AC_BAKEFILE],
802[
97d28c6f 803 AC_PREREQ([2.58])
948b08e2 804
5b8deaba
VZ
805 dnl We need to always run C/C++ compiler tests, but it's also possible
806 dnl for the user to call these macros manually, hence this instead of
807 dnl simply calling these macros. See http://www.bakefile.org/ticket/64
808 AC_REQUIRE([AC_BAKEFILE_PROG_CC])
809 AC_REQUIRE([AC_BAKEFILE_PROG_CXX])
810
948b08e2 811 if test "x$BAKEFILE_HOST" = "x"; then
bd73e184
VZ
812 if test "x${host}" = "x" ; then
813 AC_MSG_ERROR([You must call the autoconf "CANONICAL_HOST" macro in your configure.ac (or .in) file.])
814 fi
815
948b08e2
VZ
816 BAKEFILE_HOST="${host}"
817 fi
818
819 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
820 AC_BAKEFILE_CHECK_BASIC_STUFF
821 fi
822 AC_BAKEFILE_GNUMAKE
823 AC_BAKEFILE_PLATFORM
824 AC_BAKEFILE_PLATFORM_SPECIFICS
825 AC_BAKEFILE_SUFFIXES
826 AC_BAKEFILE_SHARED_LD
827 AC_BAKEFILE_SHARED_VERSIONS
828 AC_BAKEFILE_DEPS
829 AC_BAKEFILE_RES_COMPILERS
830
5b8deaba 831 BAKEFILE_BAKEFILE_M4_VERSION="0.2.3"
2e91a01a 832
948b08e2
VZ
833 dnl includes autoconf_inc.m4:
834 $1
2e91a01a 835
948b08e2
VZ
836 if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then
837 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)?])
838 fi
2e91a01a 839
948b08e2
VZ
840 if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
841 AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
842 fi
843])
2e91a01a 844
948b08e2
VZ
845
846dnl ---------------------------------------------------------------------------
847dnl Embedded copies of helper scripts follow:
848dnl ---------------------------------------------------------------------------
849
948b08e2
VZ
850AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
851[
852dnl ===================== bk-deps begins here =====================
853dnl (Created by merge-scripts.py from bk-deps
854dnl file do not edit here!)
855D='$'
856cat <<EOF >bk-deps
857#!/bin/sh
858
5b8deaba 859# This script is part of Bakefile (http://www.bakefile.org) autoconf
948b08e2
VZ
860# script. It is used to track C/C++ files dependencies in portable way.
861#
862# Permission is given to use this file in any way.
863
864DEPSMODE=${DEPSMODE}
865DEPSDIR=.deps
866DEPSFLAG="${DEPSFLAG}"
867
868mkdir -p ${D}DEPSDIR
869
870if test ${D}DEPSMODE = gcc ; then
871 ${D}* ${D}{DEPSFLAG}
872 status=${D}?
5b8deaba
VZ
873
874 # determine location of created files:
948b08e2
VZ
875 while test ${D}# -gt 0; do
876 case "${D}1" in
877 -o )
878 shift
879 objfile=${D}1
880 ;;
881 -* )
882 ;;
883 * )
884 srcfile=${D}1
885 ;;
886 esac
887 shift
888 done
889 depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
890 depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
5b8deaba
VZ
891
892 # if the compiler failed, we're done:
893 if test ${D}{status} != 0 ; then
894 rm -f ${D}depfile
895 exit ${D}{status}
896 fi
897
898 # move created file to the location we want it in:
948b08e2
VZ
899 if test -f ${D}depfile ; then
900 sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
901 rm -f ${D}depfile
902 else
a1aa0349 903 # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d
948b08e2 904 depfile=\`basename ${D}objfile | sed -e 's/\\..*${D}/.d/g'\`
a1aa0349
VZ
905 if test ! -f ${D}depfile ; then
906 # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++)
907 depfile="${D}objfile.d"
908 fi
948b08e2
VZ
909 if test -f ${D}depfile ; then
910 sed -e "/^${D}objfile/!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
911 rm -f ${D}depfile
912 fi
913 fi
914 exit 0
915elif test ${D}DEPSMODE = mwcc ; then
4171f4c1 916 ${D}* || exit ${D}?
948b08e2
VZ
917 # Run mwcc again with -MM and redirect into the dep file we want
918 # NOTE: We can't use shift here because we need ${D}* to be valid
919 prevarg=
920 for arg in ${D}* ; do
921 if test "${D}prevarg" = "-o"; then
922 objfile=${D}arg
923 else
924 case "${D}arg" in
925 -* )
926 ;;
927 * )
928 srcfile=${D}arg
929 ;;
930 esac
931 fi
932 prevarg="${D}arg"
933 done
934 ${D}* ${D}DEPSFLAG >${D}{DEPSDIR}/${D}{objfile}.d
935 exit 0
936elif test ${D}DEPSMODE = unixcc; then
4171f4c1 937 ${D}* || exit ${D}?
948b08e2
VZ
938 # Run compiler again with deps flag and redirect into the dep file.
939 # It doesn't work if the '-o FILE' option is used, but without it the
940 # dependency file will contain the wrong name for the object. So it is
941 # removed from the command line, and the dep file is fixed with sed.
942 cmd=""
943 while test ${D}# -gt 0; do
944 case "${D}1" in
945 -o )
946 shift
947 objfile=${D}1
948 ;;
949 * )
950 eval arg${D}#=\\${D}1
951 cmd="${D}cmd \\${D}arg${D}#"
952 ;;
953 esac
954 shift
955 done
956 eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{DEPSDIR}/${D}{objfile}.d
957 exit 0
958else
959 ${D}*
960 exit ${D}?
961fi
962EOF
963dnl ===================== bk-deps ends here =====================
964])
965
966AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
967[
968dnl ===================== shared-ld-sh begins here =====================
969dnl (Created by merge-scripts.py from shared-ld-sh
970dnl file do not edit here!)
971D='$'
972cat <<EOF >shared-ld-sh
973#!/bin/sh
974#-----------------------------------------------------------------------------
975#-- Name: distrib/mac/shared-ld-sh
976#-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
977#-- Author: Gilles Depeyrot
978#-- Copyright: (c) 2002 Gilles Depeyrot
979#-- Licence: any use permitted
980#-----------------------------------------------------------------------------
981
982verbose=0
983args=""
984objects=""
985linking_flag="-dynamiclib"
986ldargs="-r -keep_private_externs -nostdlib"
987
5b8deaba
VZ
988if test "x${D}CXX" = "x"; then
989 CXX="c++"
990fi
991
948b08e2
VZ
992while test ${D}# -gt 0; do
993 case ${D}1 in
994
995 -v)
996 verbose=1
997 ;;
998
999 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1000 # collect these options and values
1001 args="${D}{args} ${D}1 ${D}2"
1002 shift
1003 ;;
5b8deaba
VZ
1004
1005 -arch|-isysroot)
1006 # collect these options and values
1007 ldargs="${D}{ldargs} ${D}1 ${D}2"
1008 shift
1009 ;;
2e91a01a 1010
948b08e2
VZ
1011 -s|-Wl,*)
1012 # collect these load args
1013 ldargs="${D}{ldargs} ${D}1"
1014 ;;
1015
1016 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
1017 # collect these options
1018 args="${D}{args} ${D}1"
1019 ;;
1020
1021 -dynamiclib|-bundle)
1022 linking_flag="${D}1"
1023 ;;
1024
1025 -*)
1026 echo "shared-ld: unhandled option '${D}1'"
1027 exit 1
1028 ;;
1029
1030 *.o | *.a | *.dylib)
1031 # collect object files
1032 objects="${D}{objects} ${D}1"
1033 ;;
1034
1035 *)
1036 echo "shared-ld: unhandled argument '${D}1'"
1037 exit 1
1038 ;;
1039
1040 esac
1041 shift
1042done
1043
1044status=0
1045
1046#
1047# Link one module containing all the others
1048#
1049if test ${D}{verbose} = 1; then
5b8deaba 1050 echo "${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o"
948b08e2 1051fi
5b8deaba 1052${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o
948b08e2
VZ
1053status=${D}?
1054
1055#
1056# Link the shared library from the single module created, but only if the
1057# previous command didn't fail:
1058#
1059if test ${D}{status} = 0; then
1060 if test ${D}{verbose} = 1; then
5b8deaba 1061 echo "${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
948b08e2 1062 fi
5b8deaba 1063 ${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}
948b08e2
VZ
1064 status=${D}?
1065fi
1066
1067#
1068# Remove intermediate module
1069#
1070rm -f master.${D}${D}.o
1071
1072exit ${D}status
1073EOF
1074dnl ===================== shared-ld-sh ends here =====================
1075])
1076
1077AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
1078[
1079dnl ===================== bk-make-pch begins here =====================
1080dnl (Created by merge-scripts.py from bk-make-pch
1081dnl file do not edit here!)
1082D='$'
1083cat <<EOF >bk-make-pch
1084#!/bin/sh
1085
5b8deaba 1086# This script is part of Bakefile (http://www.bakefile.org) autoconf
948b08e2
VZ
1087# script. It is used to generated precompiled headers.
1088#
1089# Permission is given to use this file in any way.
1090
1091outfile="${D}{1}"
1092header="${D}{2}"
1093shift
1094shift
1095
bd73e184
VZ
1096compiler=""
1097headerfile=""
1098
948b08e2 1099while test ${D}{#} -gt 0; do
bd73e184 1100 add_to_cmdline=1
948b08e2
VZ
1101 case "${D}{1}" in
1102 -I* )
1103 incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
1104 if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
1105 headerfile="${D}{incdir}/${D}{header}"
1106 fi
1107 ;;
bd73e184
VZ
1108 -use-pch|-use_pch )
1109 shift
1110 add_to_cmdline=0
1111 ;;
948b08e2 1112 esac
bd73e184
VZ
1113 if test ${D}add_to_cmdline = 1 ; then
1114 compiler="${D}{compiler} ${D}{1}"
1115 fi
948b08e2
VZ
1116 shift
1117done
1118
1119if test "x${D}{headerfile}" = "x" ; then
bd73e184 1120 echo "error: can't find header ${D}{header} in include paths" >&2
948b08e2
VZ
1121else
1122 if test -f ${D}{outfile} ; then
1123 rm -f ${D}{outfile}
1124 else
1125 mkdir -p \`dirname ${D}{outfile}\`
1126 fi
1127 depsfile=".deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
1128 mkdir -p .deps
bd73e184
VZ
1129 if test "x${GCC_PCH}" = "x1" ; then
1130 # can do this because gcc is >= 3.4:
1131 ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
1132 elif test "x${ICC_PCH}" = "x1" ; then
1133 filename=pch_gen-${D}${D}
1134 file=${D}{filename}.c
1135 dfile=${D}{filename}.d
1136 cat > ${D}file <<EOT
1137#include "${D}header"
1138EOT
1139 # using -MF icc complains about differing command lines in creation/use
1140 ${D}compiler -c -create_pch ${D}outfile -MMD ${D}file && \\
1141 sed -e "s,^.*:,${D}outfile:," -e "s, ${D}file,," < ${D}dfile > ${D}depsfile && \\
1142 rm -f ${D}file ${D}dfile ${D}{filename}.o
1143 fi
948b08e2
VZ
1144 exit ${D}{?}
1145fi
1146EOF
1147dnl ===================== bk-make-pch ends here =====================
1148])