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 AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
134 AC_SUBST(PLATFORM_UNIX)
135 AC_SUBST(PLATFORM_WIN32)
136 AC_SUBST(PLATFORM_MSDOS)
137 AC_SUBST(PLATFORM_MAC)
138 AC_SUBST(PLATFORM_MACOS)
139 AC_SUBST(PLATFORM_MACOSX)
140 AC_SUBST(PLATFORM_OS2)
141 AC_SUBST(PLATFORM_BEOS)
145 dnl ---------------------------------------------------------------------------
146 dnl AC_BAKEFILE_PLATFORM_SPECIFICS
148 dnl Sets misc platform-specific settings
149 dnl ---------------------------------------------------------------------------
151 AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS],
153 AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf],
154 [use OMF object format (OS/2)]),
155 [bk_os2_use_omf="$enableval"])
157 case "${BAKEFILE_HOST}" in
159 dnl For Unix to MacOS X porting instructions, see:
160 dnl http://fink.sourceforge.net/doc/porting/porting.html
161 if test "x$GCC" = "xyes"; then
162 CFLAGS="$CFLAGS -fno-common"
163 CXXFLAGS="$CXXFLAGS -fno-common"
165 if test "x$XLCC" = "xyes"; then
166 CFLAGS="$CFLAGS -qnocommon"
167 CXXFLAGS="$CXXFLAGS -qnocommon"
171 *-pc-os2_emx | *-pc-os2-emx )
172 if test "x$bk_os2_use_omf" = "xyes" ; then
175 LDFLAGS="-Zomf $LDFLAGS"
176 CFLAGS="-Zomf $CFLAGS"
177 CXXFLAGS="-Zomf $CXXFLAGS"
185 LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
190 dnl ---------------------------------------------------------------------------
191 dnl AC_BAKEFILE_SUFFIXES
193 dnl Detects shared various suffixes for shared libraries, libraries, programs,
195 dnl ---------------------------------------------------------------------------
197 AC_DEFUN([AC_BAKEFILE_SUFFIXES],
200 SO_SUFFIX_MODULE="so"
209 case "${BAKEFILE_HOST}" in
210 dnl PA-RISC HP systems used .sl but IA64 use ELF-64 and so use the
211 dnl standard .so extension
216 SO_SUFFIX_MODULE="sl"
220 dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
221 dnl Both archive libraries and shared libraries on AIX have an
222 dnl .a extension. This will explain why you can't link with an
223 dnl .so and why it works with the name changed to .a.
229 SO_SUFFIX_MODULE="dll"
230 DLLIMP_SUFFIX="dll.a"
237 SO_SUFFIX_MODULE="dll"
238 DLLIMP_SUFFIX="dll.a"
248 *-pc-os2_emx | *-pc-os2-emx )
250 SO_SUFFIX_MODULE="dll"
251 DLLIMP_SUFFIX=$OS2_LIBEXT
255 LIBEXT=".$OS2_LIBEXT"
260 SO_SUFFIX_MODULE="bundle"
264 if test "x$DLLIMP_SUFFIX" = "x" ; then
265 DLLIMP_SUFFIX="$SO_SUFFIX"
269 AC_SUBST(SO_SUFFIX_MODULE)
270 AC_SUBST(DLLIMP_SUFFIX)
275 AC_SUBST(DLLPREFIX_MODULE)
280 dnl ---------------------------------------------------------------------------
281 dnl AC_BAKEFILE_SHARED_LD
283 dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
284 dnl and SHARED_LD_CXX.
285 dnl ---------------------------------------------------------------------------
287 AC_DEFUN([AC_BAKEFILE_SHARED_LD],
289 dnl the extra compiler flags needed for compilation of shared library
291 if test "x$GCC" = "xyes"; then
292 dnl the switch for gcc is the same under all platforms
296 dnl Defaults for GCC and ELF .so shared libs:
297 SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o"
298 SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o"
301 case "${BAKEFILE_HOST}" in
303 dnl default settings are good for gcc but not for the native HP-UX
304 if test "x$GCC" != "xyes"; then
305 dnl no idea why it wants it, but it does
306 LDFLAGS="$LDFLAGS -L/usr/lib"
308 SHARED_LD_CC="${CC} -b -o"
309 SHARED_LD_CXX="${CXX} -b -o"
315 dnl newer icc versions use -fPIC just as gcc does and, in fact, the
316 dnl newest (v10+) ones don't even understand -KPIC any longer
317 if test "$INTELCC" = "yes" -a "$INTELCC8" != "yes"; then
319 elif test "x$SUNCXX" = "xyes"; then
320 SHARED_LD_CC="${CC} -G -o"
321 SHARED_LD_CXX="${CXX} -G -o"
327 if test "x$SUNCXX" = xyes ; then
328 SHARED_LD_CC="${CC} -G -o"
329 SHARED_LD_CXX="${CXX} -G -o"
335 AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
336 chmod +x shared-ld-sh
338 SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
339 SHARED_LD_MODULE_CXX="CXX=\"\$(CXX)\" $SHARED_LD_MODULE_CC"
341 dnl Most apps benefit from being fully binded (its faster and static
342 dnl variables initialized at startup work).
343 dnl This can be done either with the exe linker flag -Wl,-bind_at_load
344 dnl or with a double stage link in order to create a single module
345 dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
347 dnl If using newer dev tools then there is a -single_module flag that
348 dnl we can use to do this for dylibs, otherwise we'll need to use a helper
349 dnl script. Check the version of gcc to see which way we can go:
350 AC_CACHE_CHECK([for gcc 3.1 or later], bakefile_cv_gcc31, [
353 #if (__GNUC__ < 3) || \
354 ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
359 bakefile_cv_gcc31=yes
366 if test "$bakefile_cv_gcc31" = "no"; then
367 dnl Use the shared-ld-sh helper script
368 SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
369 SHARED_LD_CXX="$SHARED_LD_CC"
371 dnl Use the -single_module flag and let the linker do it for us
372 SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o"
373 SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
376 if test "x$GCC" == "xyes"; then
377 PIC_FLAG="-dynamic -fPIC"
379 if test "x$XLCC" = "xyes"; then
380 PIC_FLAG="-dynamic -DPIC"
385 if test "x$GCC" = "xyes"; then
386 dnl at least gcc 2.95 warns that -fPIC is ignored when
387 dnl compiling each and every file under AIX which is annoying,
388 dnl so don't use it there (it's useless as AIX runs on
389 dnl position-independent architectures only anyhow)
392 dnl -bexpfull is needed by AIX linker to export all symbols (by
393 dnl default it doesn't export any and even with -bexpall it
394 dnl doesn't export all C++ support symbols, e.g. vtable
395 dnl pointers) but it's only available starting from 5.1 (with
396 dnl maintenance pack 2, whatever this is), see
397 dnl http://www-128.ibm.com/developerworks/eserver/articles/gnu.html
398 case "${BAKEFILE_HOST}" in
400 LD_EXPFULL="-Wl,-bexpfull"
404 SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o"
405 SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o"
407 dnl FIXME: makeC++SharedLib is obsolete, what should we do for
408 dnl recent AIX versions?
409 AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
410 makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
411 SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
412 SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
417 dnl can't use gcc under BeOS for shared library creation because it
418 dnl complains about missing 'main'
419 SHARED_LD_CC="${LD} -nostart -o"
420 SHARED_LD_CXX="${LD} -nostart -o"
424 dnl default settings are ok for gcc
425 if test "x$GCC" != "xyes"; then
430 *-*-cygwin* | *-*-mingw32* )
432 SHARED_LD_CC="\$(CC) -shared -o"
433 SHARED_LD_CXX="\$(CXX) -shared -o"
437 *-pc-os2_emx | *-pc-os2-emx )
438 SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
439 SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
441 AC_BAKEFILE_CREATE_FILE_DLLAR_SH
445 powerpc-apple-macos* | \
446 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \
457 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
460 if test "x$PIC_FLAG" != "x" ; then
461 PIC_FLAG="$PIC_FLAG -DPIC"
464 if test "x$SHARED_LD_MODULE_CC" = "x" ; then
465 SHARED_LD_MODULE_CC="$SHARED_LD_CC"
467 if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
468 SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
471 AC_SUBST(SHARED_LD_CC)
472 AC_SUBST(SHARED_LD_CXX)
473 AC_SUBST(SHARED_LD_MODULE_CC)
474 AC_SUBST(SHARED_LD_MODULE_CXX)
476 AC_SUBST(WINDOWS_IMPLIB)
480 dnl ---------------------------------------------------------------------------
481 dnl AC_BAKEFILE_SHARED_VERSIONS
483 dnl Detects linker options for attaching versions (sonames) to shared libs.
484 dnl ---------------------------------------------------------------------------
486 AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
496 case "${BAKEFILE_HOST}" in
497 *-*-linux* | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
498 *-*-k*bsd*-gnu | *-*-mirbsd* )
499 if test "x$SUNCXX" = "xyes"; then
502 SONAME_FLAG="-Wl,-soname,"
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_SOTWOSYMLINKS)
533 AC_SUBST(SONAME_FLAG)
537 dnl ---------------------------------------------------------------------------
540 dnl Detects available C/C++ dependency tracking options
541 dnl ---------------------------------------------------------------------------
543 AC_DEFUN([AC_BAKEFILE_DEPS],
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"])
550 AC_MSG_CHECKING([for dependency tracking method])
553 if test "x$bk_use_trackdeps" = "xno" ; then
555 AC_MSG_RESULT([disabled])
559 if test "x$GCC" = "xyes"; then
563 elif test "x$MWCC" = "xyes"; then
566 AC_MSG_RESULT([mwcc])
567 elif test "x$SUNCC" = "xyes"; then
570 AC_MSG_RESULT([Sun cc])
571 elif test "x$SGICC" = "xyes"; then
574 AC_MSG_RESULT([SGI cc])
575 elif test "x$HPCC" = "xyes"; then
578 AC_MSG_RESULT([HP cc])
579 elif test "x$COMPAQCC" = "xyes"; then
582 AC_MSG_RESULT([Compaq cc])
585 AC_MSG_RESULT([none])
588 if test $DEPS_TRACKING = 1 ; then
589 AC_BAKEFILE_CREATE_FILE_BK_DEPS
591 dnl FIXME: make this $(top_builddir)/bk-deps once autoconf-2.60
592 dnl is required (and so top_builddir is never empty):
593 BK_DEPS="`pwd`/bk-deps"
597 AC_SUBST(DEPS_TRACKING)
601 dnl ---------------------------------------------------------------------------
602 dnl AC_BAKEFILE_CHECK_BASIC_STUFF
604 dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
606 dnl ---------------------------------------------------------------------------
608 AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
617 if test "x$SUNCXX" = "xyes"; then
618 dnl Sun C++ compiler requires special way of creating static libs;
619 dnl see here for more details:
620 dnl https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1229751&group_id=9863
624 elif test "x$SGICC" = "xyes"; then
625 dnl Almost the same as above for SGI mipsPro compiler
630 AC_CHECK_TOOL(AR, ar, ar)
635 AC_CHECK_TOOL(STRIP, strip, :)
636 AC_CHECK_TOOL(NM, nm, :)
638 dnl Don't use `install -d`, see http://trac.wxwidgets.org/ticket/13452
639 INSTALL_DIR="mkdir -p"
640 AC_SUBST(INSTALL_DIR)
643 case ${BAKEFILE_HOST} in
644 *-*-cygwin* | *-*-mingw32* )
645 LDFLAGS_GUI="-mwindows"
647 AC_SUBST(LDFLAGS_GUI)
651 dnl ---------------------------------------------------------------------------
652 dnl AC_BAKEFILE_RES_COMPILERS
654 dnl Checks for presence of resource compilers for win32 or mac
655 dnl ---------------------------------------------------------------------------
657 AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
659 case ${BAKEFILE_HOST} in
660 *-*-cygwin* | *-*-mingw32* )
661 dnl Check for win32 resources compiler:
662 AC_CHECK_TOOL(WINDRES, windres)
665 *-*-darwin* | powerpc-apple-macos* )
666 AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez)
667 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
676 dnl ---------------------------------------------------------------------------
677 dnl AC_BAKEFILE_PRECOMP_HEADERS
679 dnl Check for precompiled headers support (GCC >= 3.4)
680 dnl ---------------------------------------------------------------------------
682 AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
685 AC_ARG_ENABLE([precomp-headers],
686 AS_HELP_STRING([--disable-precomp-headers],
687 [don't use precompiled headers even if compiler can]),
688 [bk_use_pch="$enableval"])
695 case ${BAKEFILE_HOST} in
697 dnl PCH support is broken in cygwin gcc because of unportable
698 dnl assumptions about mmap() in gcc code which make PCH generation
699 dnl fail erratically; disable PCH completely until this is fixed
704 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
705 if test "x$GCC" = "xyes"; then
706 dnl test if we have gcc-3.4:
707 AC_MSG_CHECKING([if the compiler supports precompiled headers])
710 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
711 There is no PCH support
714 There is no PCH support
716 #if (__GNUC__ == 3) && \
717 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
718 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3))) || \
719 ( defined(__INTEL_COMPILER) )
720 There is no PCH support
728 if test "$INTELCXX8" = "yes"; then
731 if test "$INTELCXX10" = "yes"; then
732 ICC_PCH_CREATE_SWITCH="-pch-create"
733 ICC_PCH_USE_SWITCH="-pch-use"
735 ICC_PCH_CREATE_SWITCH="-create-pch"
736 ICC_PCH_USE_SWITCH="-use-pch"
742 if test $GCC_PCH = 1 -o $ICC_PCH = 1 ; then
744 AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
746 dnl FIXME: make this $(top_builddir)/bk-make-pch once
747 dnl autoconf-2.60 is required (and so top_builddir is
749 BK_MAKE_PCH="`pwd`/bk-make-pch"
756 AC_SUBST(ICC_PCH_CREATE_SWITCH)
757 AC_SUBST(ICC_PCH_USE_SWITCH)
758 AC_SUBST(BK_MAKE_PCH)
763 dnl ---------------------------------------------------------------------------
764 dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
766 dnl To be used in configure.in of any project using Bakefile-generated mks
768 dnl Behaviour can be modified by setting following variables:
769 dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
770 dnl to perform check for basic tools like ranlib
771 dnl BAKEFILE_HOST set this to override host detection, defaults
773 dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
777 dnl AC_BAKEFILE([FOO(autoconf_inc.m4)])
779 dnl (replace FOO with m4_include above, aclocal would die otherwise)
780 dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
782 dnl ---------------------------------------------------------------------------
784 AC_DEFUN([AC_BAKEFILE],
788 dnl We need to always run C/C++ compiler tests, but it's also possible
789 dnl for the user to call these macros manually, hence this instead of
790 dnl simply calling these macros. See http://www.bakefile.org/ticket/64
791 AC_REQUIRE([AC_BAKEFILE_PROG_CC])
792 AC_REQUIRE([AC_BAKEFILE_PROG_CXX])
794 if test "x$BAKEFILE_HOST" = "x"; then
795 if test "x${host}" = "x" ; then
796 AC_MSG_ERROR([You must call the autoconf "CANONICAL_HOST" macro in your configure.ac (or .in) file.])
799 BAKEFILE_HOST="${host}"
802 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
803 AC_BAKEFILE_CHECK_BASIC_STUFF
807 AC_BAKEFILE_PLATFORM_SPECIFICS
809 AC_BAKEFILE_SHARED_LD
810 AC_BAKEFILE_SHARED_VERSIONS
812 AC_BAKEFILE_RES_COMPILERS
814 dnl OBJCFLAGS is set by Autoconf, but OBJCXXFLAGS is not:
815 AC_SUBST(OBJCXXFLAGS)
818 BAKEFILE_BAKEFILE_M4_VERSION="0.2.9"
820 dnl includes autoconf_inc.m4:
823 if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then
824 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)?])
827 if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
828 AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
833 dnl ---------------------------------------------------------------------------
834 dnl Embedded copies of helper scripts follow:
835 dnl ---------------------------------------------------------------------------
837 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
839 dnl ===================== bk-deps begins here =====================
840 dnl (Created by merge-scripts.py from bk-deps
841 dnl file do not edit here!)
846 # This script is part of Bakefile (http://www.bakefile.org) autoconf
847 # script. It is used to track C/C++ files dependencies in portable way.
849 # Permission is given to use this file in any way.
852 DEPSFLAG="${DEPSFLAG}"
855 if test ${D}DEPSMODE = gcc ; then
859 # determine location of created files:
860 while test ${D}# -gt 0; do
874 objfilebase=\`basename ${D}objfile\`
875 builddir=\`dirname ${D}objfile\`
876 depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
877 depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
878 depsdir=${D}builddir/${D}DEPSDIRBASE
881 # if the compiler failed, we're done:
882 if test ${D}{status} != 0 ; then
887 # move created file to the location we want it in:
888 if test -f ${D}depfile ; then
889 sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
892 # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d
893 depfile=\`echo "${D}objfile" | sed -e 's/\\..*${D}/.d/g'\`
894 if test ! -f ${D}depfile ; then
895 # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++)
896 depfile="${D}objfile.d"
898 if test -f ${D}depfile ; then
899 sed -e "\\,^${D}objfile,!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
905 elif test ${D}DEPSMODE = mwcc ; then
907 # Run mwcc again with -MM and redirect into the dep file we want
908 # NOTE: We can't use shift here because we need ${D}* to be valid
910 for arg in ${D}* ; do
911 if test "${D}prevarg" = "-o"; then
925 objfilebase=\`basename ${D}objfile\`
926 builddir=\`dirname ${D}objfile\`
927 depsdir=${D}builddir/${D}DEPSDIRBASE
930 ${D}* ${D}DEPSFLAG >${D}{depsdir}/${D}{objfilebase}.d
933 elif test ${D}DEPSMODE = unixcc; then
935 # Run compiler again with deps flag and redirect into the dep file.
936 # It doesn't work if the '-o FILE' option is used, but without it the
937 # dependency file will contain the wrong name for the object. So it is
938 # removed from the command line, and the dep file is fixed with sed.
940 while test ${D}# -gt 0; do
947 eval arg${D}#=\\${D}1
948 cmd="${D}cmd \\${D}arg${D}#"
954 objfilebase=\`basename ${D}objfile\`
955 builddir=\`dirname ${D}objfile\`
956 depsdir=${D}builddir/${D}DEPSDIRBASE
959 eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{depsdir}/${D}{objfilebase}.d
967 dnl ===================== bk-deps ends here =====================
970 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
972 dnl ===================== shared-ld-sh begins here =====================
973 dnl (Created by merge-scripts.py from shared-ld-sh
974 dnl file do not edit here!)
976 cat <<EOF >shared-ld-sh
978 #-----------------------------------------------------------------------------
979 #-- Name: distrib/mac/shared-ld-sh
980 #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
981 #-- Author: Gilles Depeyrot
982 #-- Copyright: (c) 2002 Gilles Depeyrot
983 #-- Licence: any use permitted
984 #-----------------------------------------------------------------------------
989 linking_flag="-dynamiclib"
990 ldargs="-r -keep_private_externs -nostdlib"
992 if test "x${D}CXX" = "x"; then
996 while test ${D}# -gt 0; do
1003 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1004 # collect these options and values
1005 args="${D}{args} ${D}1 ${D}2"
1010 # collect these options and values
1011 ldargs="${D}{ldargs} ${D}1 ${D}2"
1016 # collect these load args
1017 ldargs="${D}{ldargs} ${D}1"
1020 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
1021 # collect these options
1022 args="${D}{args} ${D}1"
1025 -dynamiclib|-bundle)
1026 linking_flag="${D}1"
1030 echo "shared-ld: unhandled option '${D}1'"
1034 *.o | *.a | *.dylib)
1035 # collect object files
1036 objects="${D}{objects} ${D}1"
1040 echo "shared-ld: unhandled argument '${D}1'"
1051 # Link one module containing all the others
1053 if test ${D}{verbose} = 1; then
1054 echo "${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o"
1056 ${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o
1060 # Link the shared library from the single module created, but only if the
1061 # previous command didn't fail:
1063 if test ${D}{status} = 0; then
1064 if test ${D}{verbose} = 1; then
1065 echo "${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
1067 ${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}
1072 # Remove intermediate module
1074 rm -f master.${D}${D}.o
1078 dnl ===================== shared-ld-sh ends here =====================
1081 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
1083 dnl ===================== bk-make-pch begins here =====================
1084 dnl (Created by merge-scripts.py from bk-make-pch
1085 dnl file do not edit here!)
1087 cat <<EOF >bk-make-pch
1090 # This script is part of Bakefile (http://www.bakefile.org) autoconf
1091 # script. It is used to generated precompiled headers.
1093 # Permission is given to use this file in any way.
1100 builddir=\`echo ${D}outfile | sed -e 's,/\\.pch/.*${D},,g'\`
1105 while test ${D}{#} -gt 0; do
1109 incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
1110 if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
1111 headerfile="${D}{incdir}/${D}{header}"
1114 -use-pch|-use_pch|-pch-use )
1119 if test ${D}add_to_cmdline = 1 ; then
1120 compiler="${D}{compiler} ${D}{1}"
1125 if test "x${D}{headerfile}" = "x" ; then
1126 echo "error: can't find header ${D}{header} in include paths" >&2
1128 if test -f ${D}{outfile} ; then
1131 mkdir -p \`dirname ${D}{outfile}\`
1133 depsfile="${D}{builddir}/.deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
1134 mkdir -p ${D}{builddir}/.deps
1135 if test "x${GCC_PCH}" = "x1" ; then
1136 # can do this because gcc is >= 3.4:
1137 ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
1138 elif test "x${ICC_PCH}" = "x1" ; then
1139 filename=pch_gen-${D}${D}
1140 file=${D}{filename}.c
1141 dfile=${D}{filename}.d
1142 cat > ${D}file <<EOT
1143 #include "${D}header"
1145 # using -MF icc complains about differing command lines in creation/use
1146 ${D}compiler -c ${ICC_PCH_CREATE_SWITCH} ${D}outfile -MMD ${D}file && \\
1147 sed -e "s,^.*:,${D}outfile:," -e "s, ${D}file,," < ${D}dfile > ${D}depsfile && \\
1148 rm -f ${D}file ${D}dfile ${D}{filename}.o
1153 dnl ===================== bk-make-pch ends here =====================