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