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