2 dnl This file is part of Bakefile (http://www.bakefile.org)
4 dnl Copyright (C) 2003-2007 Vaclav Slavik and others
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:
13 dnl The above copyright notice and this permission notice shall be included in
14 dnl all copies or substantial portions of the Software.
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.
26 dnl Support macros for makefiles generated by BAKEFILE.
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 ---------------------------------------------------------------------------
37 dnl ---------------------------------------------------------------------------
38 dnl AC_BAKEFILE_GNUMAKE
41 dnl ---------------------------------------------------------------------------
43 AC_DEFUN([AC_BAKEFILE_GNUMAKE],
45 dnl does make support "-include" (only GNU make does AFAIK)?
46 AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu,
48 if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
49 egrep -s GNU > /dev/null); then
50 bakefile_cv_prog_makeisgnu="yes"
52 bakefile_cv_prog_makeisgnu="no"
56 if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then
64 dnl ---------------------------------------------------------------------------
65 dnl AC_BAKEFILE_PLATFORM
67 dnl Detects platform and sets PLATFORM_XXX variables accordingly
68 dnl ---------------------------------------------------------------------------
70 AC_DEFUN([AC_BAKEFILE_PLATFORM],
81 if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
82 case "${BAKEFILE_HOST}" in
89 *-pc-os2_emx | *-pc-os2-emx )
99 powerpc-apple-macos* )
108 case "$BAKEFILE_FORCE_PLATFORM" in
129 dnl wxWidgets-specific: allow unknown Unix systems
130 dnl AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
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)
146 dnl ---------------------------------------------------------------------------
147 dnl AC_BAKEFILE_PLATFORM_SPECIFICS
149 dnl Sets misc platform-specific settings
150 dnl ---------------------------------------------------------------------------
152 AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS],
154 AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf],
155 [use OMF object format (OS/2)]),
156 [bk_os2_use_omf="$enableval"])
158 case "${BAKEFILE_HOST}" in
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"
166 if test "x$XLCC" = "xyes"; then
167 CFLAGS="$CFLAGS -qnocommon"
168 CXXFLAGS="$CXXFLAGS -qnocommon"
172 *-pc-os2_emx | *-pc-os2-emx )
173 if test "x$bk_os2_use_omf" = "xyes" ; then
176 LDFLAGS="-Zomf $LDFLAGS"
177 CFLAGS="-Zomf $CFLAGS"
178 CXXFLAGS="-Zomf $CXXFLAGS"
186 LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
191 dnl ---------------------------------------------------------------------------
192 dnl AC_BAKEFILE_SUFFIXES
194 dnl Detects shared various suffixes for shared libraries, libraries, programs,
196 dnl ---------------------------------------------------------------------------
198 AC_DEFUN([AC_BAKEFILE_SUFFIXES],
201 SO_SUFFIX_MODULE="so"
210 case "${BAKEFILE_HOST}" in
213 SO_SUFFIX_MODULE="sl"
217 dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
218 dnl Both archive libraries and shared libraries on AIX have an
219 dnl .a extension. This will explain why you can't link with an
220 dnl .so and why it works with the name changed to .a.
226 SO_SUFFIX_MODULE="dll"
227 DLLIMP_SUFFIX="dll.a"
234 SO_SUFFIX_MODULE="dll"
235 DLLIMP_SUFFIX="dll.a"
245 *-pc-os2_emx | *-pc-os2-emx )
247 SO_SUFFIX_MODULE="dll"
248 DLLIMP_SUFFIX=$OS2_LIBEXT
252 LIBEXT=".$OS2_LIBEXT"
257 SO_SUFFIX_MODULE="bundle"
261 if test "x$DLLIMP_SUFFIX" = "x" ; then
262 DLLIMP_SUFFIX="$SO_SUFFIX"
266 AC_SUBST(SO_SUFFIX_MODULE)
267 AC_SUBST(DLLIMP_SUFFIX)
272 AC_SUBST(DLLPREFIX_MODULE)
277 dnl ---------------------------------------------------------------------------
278 dnl AC_BAKEFILE_SHARED_LD
280 dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
281 dnl and SHARED_LD_CXX.
282 dnl ---------------------------------------------------------------------------
284 AC_DEFUN([AC_BAKEFILE_SHARED_LD],
286 dnl the extra compiler flags needed for compilation of shared library
288 if test "x$GCC" = "xyes"; then
289 dnl the switch for gcc is the same under all platforms
293 dnl Defaults for GCC and ELF .so shared libs:
294 SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o"
295 SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o"
298 case "${BAKEFILE_HOST}" in
300 dnl default settings are good for gcc but not for the native HP-UX
301 if test "x$GCC" != "xyes"; then
302 dnl no idea why it wants it, but it does
303 LDFLAGS="$LDFLAGS -L/usr/lib"
305 SHARED_LD_CC="${CC} -b -o"
306 SHARED_LD_CXX="${CXX} -b -o"
312 if test "$INTELCC" = "yes"; then
314 elif test "x$SUNCXX" = "xyes"; then
315 SHARED_LD_CC="${CC} -G -o"
316 SHARED_LD_CXX="${CXX} -G -o"
322 if test "x$SUNCXX" = xyes ; then
323 SHARED_LD_CC="${CC} -G -o"
324 SHARED_LD_CXX="${CXX} -G -o"
330 AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
331 chmod +x shared-ld-sh
333 SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
334 SHARED_LD_MODULE_CXX="CXX=\$(CXX) $SHARED_LD_MODULE_CC"
336 dnl Most apps benefit from being fully binded (its faster and static
337 dnl variables initialized at startup work).
338 dnl This can be done either with the exe linker flag -Wl,-bind_at_load
339 dnl or with a double stage link in order to create a single module
340 dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
342 dnl If using newer dev tools then there is a -single_module flag that
343 dnl we can use to do this for dylibs, otherwise we'll need to use a helper
344 dnl script. Check the version of gcc to see which way we can go:
345 AC_CACHE_CHECK([for gcc 3.1 or later], bakefile_cv_gcc31, [
348 #if (__GNUC__ < 3) || \
349 ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
354 bakefile_cv_gcc31=yes
361 if test "$bakefile_cv_gcc31" = "no"; then
362 dnl Use the shared-ld-sh helper script
363 SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
364 SHARED_LD_CXX="$SHARED_LD_CC"
366 dnl Use the -single_module flag and let the linker do it for us
367 SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o"
368 SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
371 if test "x$GCC" == "xyes"; then
372 PIC_FLAG="-dynamic -fPIC"
374 if test "x$XLCC" = "xyes"; then
375 PIC_FLAG="-dynamic -DPIC"
380 if test "x$GCC" = "xyes"; then
381 dnl at least gcc 2.95 warns that -fPIC is ignored when
382 dnl compiling each and every file under AIX which is annoying,
383 dnl so don't use it there (it's useless as AIX runs on
384 dnl position-independent architectures only anyhow)
387 dnl -bexpfull is needed by AIX linker to export all symbols (by
388 dnl default it doesn't export any and even with -bexpall it
389 dnl doesn't export all C++ support symbols, e.g. vtable
390 dnl pointers) but it's only available starting from 5.1 (with
391 dnl maintenance pack 2, whatever this is), see
392 dnl http://www-128.ibm.com/developerworks/eserver/articles/gnu.html
393 case "${BAKEFILE_HOST}" in
395 LD_EXPFULL="-Wl,-bexpfull"
399 SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o"
400 SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o"
402 dnl FIXME: makeC++SharedLib is obsolete, what should we do for
403 dnl recent AIX versions?
404 AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
405 makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
406 SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
407 SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
412 dnl can't use gcc under BeOS for shared library creation because it
413 dnl complains about missing 'main'
414 SHARED_LD_CC="${LD} -nostart -o"
415 SHARED_LD_CXX="${LD} -nostart -o"
419 dnl default settings are ok for gcc
420 if test "x$GCC" != "xyes"; then
425 *-*-cygwin* | *-*-mingw32* )
427 SHARED_LD_CC="\$(CC) -shared -o"
428 SHARED_LD_CXX="\$(CXX) -shared -o"
432 *-pc-os2_emx | *-pc-os2-emx )
433 SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
434 SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
436 AC_BAKEFILE_CREATE_FILE_DLLAR_SH
440 powerpc-apple-macos* | \
441 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \
452 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
455 if test "x$PIC_FLAG" != "x" ; then
456 PIC_FLAG="$PIC_FLAG -DPIC"
459 if test "x$SHARED_LD_MODULE_CC" = "x" ; then
460 SHARED_LD_MODULE_CC="$SHARED_LD_CC"
462 if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
463 SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
466 AC_SUBST(SHARED_LD_CC)
467 AC_SUBST(SHARED_LD_CXX)
468 AC_SUBST(SHARED_LD_MODULE_CC)
469 AC_SUBST(SHARED_LD_MODULE_CXX)
471 AC_SUBST(WINDOWS_IMPLIB)
475 dnl ---------------------------------------------------------------------------
476 dnl AC_BAKEFILE_SHARED_VERSIONS
478 dnl Detects linker options for attaching versions (sonames) to shared libs.
479 dnl ---------------------------------------------------------------------------
481 AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
491 case "${BAKEFILE_HOST}" in
492 *-*-linux* | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
493 *-*-k*bsd*-gnu | *-*-mirbsd* )
494 if test "x$SUNCXX" = "xyes"; then
497 SONAME_FLAG="-Wl,-soname,"
523 AC_SUBST(USE_SOVERSION)
524 AC_SUBST(USE_SOVERLINUX)
525 AC_SUBST(USE_SOVERSOLARIS)
526 AC_SUBST(USE_SOVERCYGWIN)
527 AC_SUBST(USE_MACVERSION)
528 AC_SUBST(USE_SOSYMLINKS)
529 AC_SUBST(SONAME_FLAG)
533 dnl ---------------------------------------------------------------------------
536 dnl Detects available C/C++ dependency tracking options
537 dnl ---------------------------------------------------------------------------
539 AC_DEFUN([AC_BAKEFILE_DEPS],
541 AC_ARG_ENABLE([dependency-tracking],
542 AS_HELP_STRING([--disable-dependency-tracking],
543 [don't use dependency tracking even if the compiler can]),
544 [bk_use_trackdeps="$enableval"])
546 AC_MSG_CHECKING([for dependency tracking method])
549 if test "x$bk_use_trackdeps" = "xno" ; then
551 AC_MSG_RESULT([disabled])
555 if test "x$GCC" = "xyes"; then
557 case "${BAKEFILE_HOST}" in
559 dnl -cpp-precomp (the default) conflicts with -MMD option
560 dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
561 DEPSFLAG="-no-cpp-precomp -MMD"
568 elif test "x$MWCC" = "xyes"; then
571 AC_MSG_RESULT([mwcc])
572 elif test "x$SUNCC" = "xyes"; then
575 AC_MSG_RESULT([Sun cc])
576 elif test "x$SGICC" = "xyes"; then
579 AC_MSG_RESULT([SGI cc])
580 elif test "x$HPCC" = "xyes"; then
583 AC_MSG_RESULT([HP cc])
584 elif test "x$COMPAQCC" = "xyes"; then
587 AC_MSG_RESULT([Compaq cc])
590 AC_MSG_RESULT([none])
593 if test $DEPS_TRACKING = 1 ; then
594 AC_BAKEFILE_CREATE_FILE_BK_DEPS
596 dnl FIXME: make this $(top_builddir)/bk-deps once autoconf-2.60
597 dnl is required (and so top_builddir is never empty):
598 BK_DEPS="`pwd`/bk-deps"
602 AC_SUBST(DEPS_TRACKING)
606 dnl ---------------------------------------------------------------------------
607 dnl AC_BAKEFILE_CHECK_BASIC_STUFF
609 dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
611 dnl ---------------------------------------------------------------------------
613 AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
622 if test "x$SUNCXX" = "xyes"; then
623 dnl Sun C++ compiler requires special way of creating static libs;
624 dnl see here for more details:
625 dnl https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1229751&group_id=9863
629 elif test "x$SGICC" = "xyes"; then
630 dnl Almost the same as above for SGI mipsPro compiler
635 AC_CHECK_TOOL(AR, ar, ar)
640 AC_CHECK_TOOL(STRIP, strip, :)
641 AC_CHECK_TOOL(NM, nm, :)
643 dnl This check is necessary because "install -d" doesn't exist on
644 dnl all platforms (e.g. HP/UX), see http://www.bakefile.org/ticket/80
645 AC_MSG_CHECKING([for command to install directories])
646 INSTALL_TEST_DIR=acbftest$$
647 $INSTALL -d $INSTALL_TEST_DIR > /dev/null 2>&1
648 if test $? = 0 -a -d $INSTALL_TEST_DIR; then
649 rmdir $INSTALL_TEST_DIR
650 dnl we must refer to makefile's $(INSTALL) variable and not
651 dnl current value of shell variable, hence the single quoting:
652 INSTALL_DIR='$(INSTALL) -d'
653 AC_MSG_RESULT([$INSTALL -d])
655 INSTALL_DIR="mkdir -p"
656 AC_MSG_RESULT([mkdir -p])
658 AC_SUBST(INSTALL_DIR)
661 case ${BAKEFILE_HOST} in
662 *-*-cygwin* | *-*-mingw32* )
663 LDFLAGS_GUI="-mwindows"
665 AC_SUBST(LDFLAGS_GUI)
669 dnl ---------------------------------------------------------------------------
670 dnl AC_BAKEFILE_RES_COMPILERS
672 dnl Checks for presence of resource compilers for win32 or mac
673 dnl ---------------------------------------------------------------------------
675 AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
677 case ${BAKEFILE_HOST} in
678 *-*-cygwin* | *-*-mingw32* )
679 dnl Check for win32 resources compiler:
680 AC_CHECK_TOOL(WINDRES, windres)
683 *-*-darwin* | powerpc-apple-macos* )
684 AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez)
685 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
694 dnl ---------------------------------------------------------------------------
695 dnl AC_BAKEFILE_PRECOMP_HEADERS
697 dnl Check for precompiled headers support (GCC >= 3.4)
698 dnl ---------------------------------------------------------------------------
700 AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
703 AC_ARG_ENABLE([precomp-headers],
704 AS_HELP_STRING([--disable-precomp-headers],
705 [don't use precompiled headers even if compiler can]),
706 [bk_use_pch="$enableval"])
713 case ${BAKEFILE_HOST} in
715 dnl PCH support is broken in cygwin gcc because of unportable
716 dnl assumptions about mmap() in gcc code which make PCH generation
717 dnl fail erratically; disable PCH completely until this is fixed
722 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
723 if test "x$GCC" = "xyes"; then
724 dnl test if we have gcc-3.4:
725 AC_MSG_CHECKING([if the compiler supports precompiled headers])
728 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
729 There is no PCH support
732 There is no PCH support
734 #if (__GNUC__ == 3) && \
735 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
736 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3))) || \
737 ( defined(__INTEL_COMPILER) )
738 There is no PCH support
748 #if !defined(__INTEL_COMPILER) || \
749 (__INTEL_COMPILER < 800)
750 There is no PCH support
761 if test $GCC_PCH = 1 -o $ICC_PCH = 1 ; then
763 AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
765 dnl FIXME: make this $(top_builddir)/bk-make-pch once
766 dnl autoconf-2.60 is required (and so top_builddir is
768 BK_MAKE_PCH="`pwd`/bk-make-pch"
775 AC_SUBST(BK_MAKE_PCH)
780 dnl ---------------------------------------------------------------------------
781 dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
783 dnl To be used in configure.in of any project using Bakefile-generated mks
785 dnl Behaviour can be modified by setting following variables:
786 dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
787 dnl to perform check for basic tools like ranlib
788 dnl BAKEFILE_HOST set this to override host detection, defaults
790 dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
794 dnl AC_BAKEFILE([FOO(autoconf_inc.m4)])
796 dnl (replace FOO with m4_include above, aclocal would die otherwise)
797 dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
799 dnl ---------------------------------------------------------------------------
801 AC_DEFUN([AC_BAKEFILE],
805 dnl We need to always run C/C++ compiler tests, but it's also possible
806 dnl for the user to call these macros manually, hence this instead of
807 dnl simply calling these macros. See http://www.bakefile.org/ticket/64
808 AC_REQUIRE([AC_BAKEFILE_PROG_CC])
809 AC_REQUIRE([AC_BAKEFILE_PROG_CXX])
811 if test "x$BAKEFILE_HOST" = "x"; then
812 if test "x${host}" = "x" ; then
813 AC_MSG_ERROR([You must call the autoconf "CANONICAL_HOST" macro in your configure.ac (or .in) file.])
816 BAKEFILE_HOST="${host}"
819 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
820 AC_BAKEFILE_CHECK_BASIC_STUFF
824 AC_BAKEFILE_PLATFORM_SPECIFICS
826 AC_BAKEFILE_SHARED_LD
827 AC_BAKEFILE_SHARED_VERSIONS
829 AC_BAKEFILE_RES_COMPILERS
831 BAKEFILE_BAKEFILE_M4_VERSION="0.2.3"
833 dnl includes autoconf_inc.m4:
836 if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then
837 AC_MSG_ERROR([No version found in autoconf_inc.m4 - bakefile macro was changed to take additional argument, perhaps configure.in wasn't updated (see the documentation)?])
840 if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
841 AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
846 dnl ---------------------------------------------------------------------------
847 dnl Embedded copies of helper scripts follow:
848 dnl ---------------------------------------------------------------------------
850 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
852 dnl ===================== bk-deps begins here =====================
853 dnl (Created by merge-scripts.py from bk-deps
854 dnl file do not edit here!)
859 # This script is part of Bakefile (http://www.bakefile.org) autoconf
860 # script. It is used to track C/C++ files dependencies in portable way.
862 # Permission is given to use this file in any way.
866 DEPSFLAG="${DEPSFLAG}"
870 if test ${D}DEPSMODE = gcc ; then
874 # determine location of created files:
875 while test ${D}# -gt 0; do
889 depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
890 depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
892 # if the compiler failed, we're done:
893 if test ${D}{status} != 0 ; then
898 # move created file to the location we want it in:
899 if test -f ${D}depfile ; then
900 sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
903 # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d
904 depfile=\`basename ${D}objfile | sed -e 's/\\..*${D}/.d/g'\`
905 if test ! -f ${D}depfile ; then
906 # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++)
907 depfile="${D}objfile.d"
909 if test -f ${D}depfile ; then
910 sed -e "/^${D}objfile/!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
915 elif test ${D}DEPSMODE = mwcc ; then
917 # Run mwcc again with -MM and redirect into the dep file we want
918 # NOTE: We can't use shift here because we need ${D}* to be valid
920 for arg in ${D}* ; do
921 if test "${D}prevarg" = "-o"; then
934 ${D}* ${D}DEPSFLAG >${D}{DEPSDIR}/${D}{objfile}.d
936 elif test ${D}DEPSMODE = unixcc; then
938 # Run compiler again with deps flag and redirect into the dep file.
939 # It doesn't work if the '-o FILE' option is used, but without it the
940 # dependency file will contain the wrong name for the object. So it is
941 # removed from the command line, and the dep file is fixed with sed.
943 while test ${D}# -gt 0; do
950 eval arg${D}#=\\${D}1
951 cmd="${D}cmd \\${D}arg${D}#"
956 eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{DEPSDIR}/${D}{objfile}.d
963 dnl ===================== bk-deps ends here =====================
966 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
968 dnl ===================== shared-ld-sh begins here =====================
969 dnl (Created by merge-scripts.py from shared-ld-sh
970 dnl file do not edit here!)
972 cat <<EOF >shared-ld-sh
974 #-----------------------------------------------------------------------------
975 #-- Name: distrib/mac/shared-ld-sh
976 #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
977 #-- Author: Gilles Depeyrot
978 #-- Copyright: (c) 2002 Gilles Depeyrot
979 #-- Licence: any use permitted
980 #-----------------------------------------------------------------------------
985 linking_flag="-dynamiclib"
986 ldargs="-r -keep_private_externs -nostdlib"
988 if test "x${D}CXX" = "x"; then
992 while test ${D}# -gt 0; do
999 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1000 # collect these options and values
1001 args="${D}{args} ${D}1 ${D}2"
1006 # collect these options and values
1007 ldargs="${D}{ldargs} ${D}1 ${D}2"
1012 # collect these load args
1013 ldargs="${D}{ldargs} ${D}1"
1016 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
1017 # collect these options
1018 args="${D}{args} ${D}1"
1021 -dynamiclib|-bundle)
1022 linking_flag="${D}1"
1026 echo "shared-ld: unhandled option '${D}1'"
1030 *.o | *.a | *.dylib)
1031 # collect object files
1032 objects="${D}{objects} ${D}1"
1036 echo "shared-ld: unhandled argument '${D}1'"
1047 # Link one module containing all the others
1049 if test ${D}{verbose} = 1; then
1050 echo "${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o"
1052 ${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o
1056 # Link the shared library from the single module created, but only if the
1057 # previous command didn't fail:
1059 if test ${D}{status} = 0; then
1060 if test ${D}{verbose} = 1; then
1061 echo "${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
1063 ${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}
1068 # Remove intermediate module
1070 rm -f master.${D}${D}.o
1074 dnl ===================== shared-ld-sh ends here =====================
1077 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
1079 dnl ===================== bk-make-pch begins here =====================
1080 dnl (Created by merge-scripts.py from bk-make-pch
1081 dnl file do not edit here!)
1083 cat <<EOF >bk-make-pch
1086 # This script is part of Bakefile (http://www.bakefile.org) autoconf
1087 # script. It is used to generated precompiled headers.
1089 # Permission is given to use this file in any way.
1099 while test ${D}{#} -gt 0; do
1103 incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
1104 if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
1105 headerfile="${D}{incdir}/${D}{header}"
1113 if test ${D}add_to_cmdline = 1 ; then
1114 compiler="${D}{compiler} ${D}{1}"
1119 if test "x${D}{headerfile}" = "x" ; then
1120 echo "error: can't find header ${D}{header} in include paths" >&2
1122 if test -f ${D}{outfile} ; then
1125 mkdir -p \`dirname ${D}{outfile}\`
1127 depsfile=".deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
1129 if test "x${GCC_PCH}" = "x1" ; then
1130 # can do this because gcc is >= 3.4:
1131 ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
1132 elif test "x${ICC_PCH}" = "x1" ; then
1133 filename=pch_gen-${D}${D}
1134 file=${D}{filename}.c
1135 dfile=${D}{filename}.d
1136 cat > ${D}file <<EOT
1137 #include "${D}header"
1139 # using -MF icc complains about differing command lines in creation/use
1140 ${D}compiler -c -create_pch ${D}outfile -MMD ${D}file && \\
1141 sed -e "s,^.*:,${D}outfile:," -e "s, ${D}file,," < ${D}dfile > ${D}depsfile && \\
1142 rm -f ${D}file ${D}dfile ${D}{filename}.o
1147 dnl ===================== bk-make-pch ends here =====================