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