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
211 dnl PA-RISC HP systems used .sl but IA64 use ELF-64 and so use the
212 dnl standard .so extension
217 SO_SUFFIX_MODULE="sl"
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.
230 SO_SUFFIX_MODULE="dll"
231 DLLIMP_SUFFIX="dll.a"
238 SO_SUFFIX_MODULE="dll"
239 DLLIMP_SUFFIX="dll.a"
249 *-pc-os2_emx | *-pc-os2-emx )
251 SO_SUFFIX_MODULE="dll"
252 DLLIMP_SUFFIX=$OS2_LIBEXT
256 LIBEXT=".$OS2_LIBEXT"
261 SO_SUFFIX_MODULE="bundle"
265 if test "x$DLLIMP_SUFFIX" = "x" ; then
266 DLLIMP_SUFFIX="$SO_SUFFIX"
270 AC_SUBST(SO_SUFFIX_MODULE)
271 AC_SUBST(DLLIMP_SUFFIX)
276 AC_SUBST(DLLPREFIX_MODULE)
281 dnl ---------------------------------------------------------------------------
282 dnl AC_BAKEFILE_SHARED_LD
284 dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
285 dnl and SHARED_LD_CXX.
286 dnl ---------------------------------------------------------------------------
288 AC_DEFUN([AC_BAKEFILE_SHARED_LD],
290 dnl the extra compiler flags needed for compilation of shared library
292 if test "x$GCC" = "xyes"; then
293 dnl the switch for gcc is the same under all platforms
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"
302 case "${BAKEFILE_HOST}" in
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"
309 SHARED_LD_CC="${CC} -b -o"
310 SHARED_LD_CXX="${CXX} -b -o"
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
320 elif test "x$SUNCXX" = "xyes"; then
321 SHARED_LD_CC="${CC} -G -o"
322 SHARED_LD_CXX="${CXX} -G -o"
328 if test "x$SUNCXX" = xyes ; then
329 SHARED_LD_CC="${CC} -G -o"
330 SHARED_LD_CXX="${CXX} -G -o"
336 AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
337 chmod +x shared-ld-sh
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"
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
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, [
354 #if (__GNUC__ < 3) || \
355 ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
360 bakefile_cv_gcc31=yes
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"
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"
377 if test "x$GCC" == "xyes"; then
378 PIC_FLAG="-dynamic -fPIC"
380 if test "x$XLCC" = "xyes"; then
381 PIC_FLAG="-dynamic -DPIC"
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)
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
401 LD_EXPFULL="-Wl,-bexpfull"
405 SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o"
406 SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o"
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"
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"
425 dnl default settings are ok for gcc
426 if test "x$GCC" != "xyes"; then
431 *-*-cygwin* | *-*-mingw32* )
433 SHARED_LD_CC="\$(CC) -shared -o"
434 SHARED_LD_CXX="\$(CXX) -shared -o"
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"
442 AC_BAKEFILE_CREATE_FILE_DLLAR_SH
446 powerpc-apple-macos* | \
447 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \
458 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
461 if test "x$PIC_FLAG" != "x" ; then
462 PIC_FLAG="$PIC_FLAG -DPIC"
465 if test "x$SHARED_LD_MODULE_CC" = "x" ; then
466 SHARED_LD_MODULE_CC="$SHARED_LD_CC"
468 if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
469 SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
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)
477 AC_SUBST(WINDOWS_IMPLIB)
481 dnl ---------------------------------------------------------------------------
482 dnl AC_BAKEFILE_SHARED_VERSIONS
484 dnl Detects linker options for attaching versions (sonames) to shared libs.
485 dnl ---------------------------------------------------------------------------
487 AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
497 case "${BAKEFILE_HOST}" in
498 *-*-linux* | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
499 *-*-k*bsd*-gnu | *-*-mirbsd* )
500 if test "x$SUNCXX" = "xyes"; then
503 SONAME_FLAG="-Wl,-soname,"
529 AC_SUBST(USE_SOVERSION)
530 AC_SUBST(USE_SOVERLINUX)
531 AC_SUBST(USE_SOVERSOLARIS)
532 AC_SUBST(USE_SOVERCYGWIN)
533 AC_SUBST(USE_MACVERSION)
534 AC_SUBST(USE_SOSYMLINKS)
535 AC_SUBST(SONAME_FLAG)
539 dnl ---------------------------------------------------------------------------
542 dnl Detects available C/C++ dependency tracking options
543 dnl ---------------------------------------------------------------------------
545 AC_DEFUN([AC_BAKEFILE_DEPS],
547 AC_ARG_ENABLE([dependency-tracking],
548 AS_HELP_STRING([--disable-dependency-tracking],
549 [don't use dependency tracking even if the compiler can]),
550 [bk_use_trackdeps="$enableval"])
552 AC_MSG_CHECKING([for dependency tracking method])
555 if test "x$bk_use_trackdeps" = "xno" ; then
557 AC_MSG_RESULT([disabled])
561 if test "x$GCC" = "xyes"; then
563 case "${BAKEFILE_HOST}" in
565 dnl -cpp-precomp (the default) conflicts with -MMD option
566 dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
567 DEPSFLAG="-no-cpp-precomp -MMD"
574 elif test "x$MWCC" = "xyes"; then
577 AC_MSG_RESULT([mwcc])
578 elif test "x$SUNCC" = "xyes"; then
581 AC_MSG_RESULT([Sun cc])
582 elif test "x$SGICC" = "xyes"; then
585 AC_MSG_RESULT([SGI cc])
586 elif test "x$HPCC" = "xyes"; then
589 AC_MSG_RESULT([HP cc])
590 elif test "x$COMPAQCC" = "xyes"; then
593 AC_MSG_RESULT([Compaq cc])
596 AC_MSG_RESULT([none])
599 if test $DEPS_TRACKING = 1 ; then
600 AC_BAKEFILE_CREATE_FILE_BK_DEPS
602 dnl FIXME: make this $(top_builddir)/bk-deps once autoconf-2.60
603 dnl is required (and so top_builddir is never empty):
604 BK_DEPS="`pwd`/bk-deps"
608 AC_SUBST(DEPS_TRACKING)
612 dnl ---------------------------------------------------------------------------
613 dnl AC_BAKEFILE_CHECK_BASIC_STUFF
615 dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
617 dnl ---------------------------------------------------------------------------
619 AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
628 if test "x$SUNCXX" = "xyes"; then
629 dnl Sun C++ compiler requires special way of creating static libs;
630 dnl see here for more details:
631 dnl https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1229751&group_id=9863
635 elif test "x$SGICC" = "xyes"; then
636 dnl Almost the same as above for SGI mipsPro compiler
641 AC_CHECK_TOOL(AR, ar, ar)
646 AC_CHECK_TOOL(STRIP, strip, :)
647 AC_CHECK_TOOL(NM, nm, :)
649 dnl This check is necessary because "install -d" doesn't exist on
650 dnl all platforms (e.g. HP/UX), see http://www.bakefile.org/ticket/80
651 AC_MSG_CHECKING([for command to install directories])
652 INSTALL_TEST_DIR=acbftest$$
653 $INSTALL -d $INSTALL_TEST_DIR > /dev/null 2>&1
654 if test $? = 0 -a -d $INSTALL_TEST_DIR; then
655 rmdir $INSTALL_TEST_DIR
656 dnl we must refer to makefile's $(INSTALL) variable and not
657 dnl current value of shell variable, hence the single quoting:
658 INSTALL_DIR='$(INSTALL) -d'
659 AC_MSG_RESULT([$INSTALL -d])
661 INSTALL_DIR="mkdir -p"
662 AC_MSG_RESULT([mkdir -p])
664 AC_SUBST(INSTALL_DIR)
667 case ${BAKEFILE_HOST} in
668 *-*-cygwin* | *-*-mingw32* )
669 LDFLAGS_GUI="-mwindows"
671 AC_SUBST(LDFLAGS_GUI)
675 dnl ---------------------------------------------------------------------------
676 dnl AC_BAKEFILE_RES_COMPILERS
678 dnl Checks for presence of resource compilers for win32 or mac
679 dnl ---------------------------------------------------------------------------
681 AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
683 case ${BAKEFILE_HOST} in
684 *-*-cygwin* | *-*-mingw32* )
685 dnl Check for win32 resources compiler:
686 AC_CHECK_TOOL(WINDRES, windres)
689 *-*-darwin* | powerpc-apple-macos* )
690 AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez)
691 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
700 dnl ---------------------------------------------------------------------------
701 dnl AC_BAKEFILE_PRECOMP_HEADERS
703 dnl Check for precompiled headers support (GCC >= 3.4)
704 dnl ---------------------------------------------------------------------------
706 AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
709 AC_ARG_ENABLE([precomp-headers],
710 AS_HELP_STRING([--disable-precomp-headers],
711 [don't use precompiled headers even if compiler can]),
712 [bk_use_pch="$enableval"])
719 case ${BAKEFILE_HOST} in
721 dnl PCH support is broken in cygwin gcc because of unportable
722 dnl assumptions about mmap() in gcc code which make PCH generation
723 dnl fail erratically; disable PCH completely until this is fixed
728 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
729 if test "x$GCC" = "xyes"; then
730 dnl test if we have gcc-3.4:
731 AC_MSG_CHECKING([if the compiler supports precompiled headers])
734 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
735 There is no PCH support
738 There is no PCH support
740 #if (__GNUC__ == 3) && \
741 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
742 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3))) || \
743 ( defined(__INTEL_COMPILER) )
744 There is no PCH support
752 if test "$INTELCXX8" = "yes"; then
755 if test "$INTELCXX10" = "yes"; then
756 ICC_PCH_CREATE_SWITCH="-pch-create"
757 ICC_PCH_USE_SWITCH="-pch-use"
759 ICC_PCH_CREATE_SWITCH="-create-pch"
760 ICC_PCH_USE_SWITCH="-use-pch"
766 if test $GCC_PCH = 1 -o $ICC_PCH = 1 ; then
768 AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
770 dnl FIXME: make this $(top_builddir)/bk-make-pch once
771 dnl autoconf-2.60 is required (and so top_builddir is
773 BK_MAKE_PCH="`pwd`/bk-make-pch"
780 AC_SUBST(ICC_PCH_CREATE_SWITCH)
781 AC_SUBST(ICC_PCH_USE_SWITCH)
782 AC_SUBST(BK_MAKE_PCH)
787 dnl ---------------------------------------------------------------------------
788 dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
790 dnl To be used in configure.in of any project using Bakefile-generated mks
792 dnl Behaviour can be modified by setting following variables:
793 dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
794 dnl to perform check for basic tools like ranlib
795 dnl BAKEFILE_HOST set this to override host detection, defaults
797 dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
801 dnl AC_BAKEFILE([FOO(autoconf_inc.m4)])
803 dnl (replace FOO with m4_include above, aclocal would die otherwise)
804 dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
806 dnl ---------------------------------------------------------------------------
808 AC_DEFUN([AC_BAKEFILE],
812 dnl We need to always run C/C++ compiler tests, but it's also possible
813 dnl for the user to call these macros manually, hence this instead of
814 dnl simply calling these macros. See http://www.bakefile.org/ticket/64
815 AC_REQUIRE([AC_BAKEFILE_PROG_CC])
816 AC_REQUIRE([AC_BAKEFILE_PROG_CXX])
818 if test "x$BAKEFILE_HOST" = "x"; then
819 if test "x${host}" = "x" ; then
820 AC_MSG_ERROR([You must call the autoconf "CANONICAL_HOST" macro in your configure.ac (or .in) file.])
823 BAKEFILE_HOST="${host}"
826 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
827 AC_BAKEFILE_CHECK_BASIC_STUFF
831 AC_BAKEFILE_PLATFORM_SPECIFICS
833 AC_BAKEFILE_SHARED_LD
834 AC_BAKEFILE_SHARED_VERSIONS
836 AC_BAKEFILE_RES_COMPILERS
838 dnl OBJCFLAGS is set by Autoconf, but OBJCXXFLAGS is not:
839 AC_SUBST(OBJCXXFLAGS)
842 BAKEFILE_BAKEFILE_M4_VERSION="0.2.6"
844 dnl includes autoconf_inc.m4:
847 if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then
848 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)?])
851 if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
852 AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
857 dnl ---------------------------------------------------------------------------
858 dnl Embedded copies of helper scripts follow:
859 dnl ---------------------------------------------------------------------------
861 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
863 dnl ===================== bk-deps begins here =====================
864 dnl (Created by merge-scripts.py from bk-deps
865 dnl file do not edit here!)
870 # This script is part of Bakefile (http://www.bakefile.org) autoconf
871 # script. It is used to track C/C++ files dependencies in portable way.
873 # Permission is given to use this file in any way.
876 DEPSFLAG="${DEPSFLAG}"
879 if test ${D}DEPSMODE = gcc ; then
883 # determine location of created files:
884 while test ${D}# -gt 0; do
898 objfilebase=\`basename ${D}objfile\`
899 builddir=\`dirname ${D}objfile\`
900 depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
901 depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
902 depsdir=${D}builddir/${D}DEPSDIRBASE
905 # if the compiler failed, we're done:
906 if test ${D}{status} != 0 ; then
911 # move created file to the location we want it in:
912 if test -f ${D}depfile ; then
913 sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
916 # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d
917 depfile=\`echo "${D}objfile" | sed -e 's/\\..*${D}/.d/g'\`
918 if test ! -f ${D}depfile ; then
919 # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++)
920 depfile="${D}objfile.d"
922 if test -f ${D}depfile ; then
923 sed -e "\\,^${D}objfile,!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
929 elif test ${D}DEPSMODE = mwcc ; then
931 # Run mwcc again with -MM and redirect into the dep file we want
932 # NOTE: We can't use shift here because we need ${D}* to be valid
934 for arg in ${D}* ; do
935 if test "${D}prevarg" = "-o"; then
949 objfilebase=\`basename ${D}objfile\`
950 builddir=\`dirname ${D}objfile\`
951 depsdir=${D}builddir/${D}DEPSDIRBASE
954 ${D}* ${D}DEPSFLAG >${D}{depsdir}/${D}{objfilebase}.d
957 elif test ${D}DEPSMODE = unixcc; then
959 # Run compiler again with deps flag and redirect into the dep file.
960 # It doesn't work if the '-o FILE' option is used, but without it the
961 # dependency file will contain the wrong name for the object. So it is
962 # removed from the command line, and the dep file is fixed with sed.
964 while test ${D}# -gt 0; do
971 eval arg${D}#=\\${D}1
972 cmd="${D}cmd \\${D}arg${D}#"
978 objfilebase=\`basename ${D}objfile\`
979 builddir=\`dirname ${D}objfile\`
980 depsdir=${D}builddir/${D}DEPSDIRBASE
983 eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{depsdir}/${D}{objfilebase}.d
991 dnl ===================== bk-deps ends here =====================
994 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
996 dnl ===================== shared-ld-sh begins here =====================
997 dnl (Created by merge-scripts.py from shared-ld-sh
998 dnl file do not edit here!)
1000 cat <<EOF >shared-ld-sh
1002 #-----------------------------------------------------------------------------
1003 #-- Name: distrib/mac/shared-ld-sh
1004 #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
1005 #-- Author: Gilles Depeyrot
1006 #-- Copyright: (c) 2002 Gilles Depeyrot
1007 #-- Licence: any use permitted
1008 #-----------------------------------------------------------------------------
1013 linking_flag="-dynamiclib"
1014 ldargs="-r -keep_private_externs -nostdlib"
1016 if test "x${D}CXX" = "x"; then
1020 while test ${D}# -gt 0; do
1027 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1028 # collect these options and values
1029 args="${D}{args} ${D}1 ${D}2"
1034 # collect these options and values
1035 ldargs="${D}{ldargs} ${D}1 ${D}2"
1040 # collect these load args
1041 ldargs="${D}{ldargs} ${D}1"
1044 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
1045 # collect these options
1046 args="${D}{args} ${D}1"
1049 -dynamiclib|-bundle)
1050 linking_flag="${D}1"
1054 echo "shared-ld: unhandled option '${D}1'"
1058 *.o | *.a | *.dylib)
1059 # collect object files
1060 objects="${D}{objects} ${D}1"
1064 echo "shared-ld: unhandled argument '${D}1'"
1075 # Link one module containing all the others
1077 if test ${D}{verbose} = 1; then
1078 echo "${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o"
1080 ${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o
1084 # Link the shared library from the single module created, but only if the
1085 # previous command didn't fail:
1087 if test ${D}{status} = 0; then
1088 if test ${D}{verbose} = 1; then
1089 echo "${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
1091 ${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}
1096 # Remove intermediate module
1098 rm -f master.${D}${D}.o
1102 dnl ===================== shared-ld-sh ends here =====================
1105 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
1107 dnl ===================== bk-make-pch begins here =====================
1108 dnl (Created by merge-scripts.py from bk-make-pch
1109 dnl file do not edit here!)
1111 cat <<EOF >bk-make-pch
1114 # This script is part of Bakefile (http://www.bakefile.org) autoconf
1115 # script. It is used to generated precompiled headers.
1117 # Permission is given to use this file in any way.
1124 builddir=\`echo ${D}outfile | sed -e 's,/\\.pch/.*${D},,g'\`
1129 while test ${D}{#} -gt 0; do
1133 incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
1134 if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
1135 headerfile="${D}{incdir}/${D}{header}"
1138 -use-pch|-use_pch|-pch-use )
1143 if test ${D}add_to_cmdline = 1 ; then
1144 compiler="${D}{compiler} ${D}{1}"
1149 if test "x${D}{headerfile}" = "x" ; then
1150 echo "error: can't find header ${D}{header} in include paths" >&2
1152 if test -f ${D}{outfile} ; then
1155 mkdir -p \`dirname ${D}{outfile}\`
1157 depsfile="${D}{builddir}/.deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
1158 mkdir -p ${D}{builddir}/.deps
1159 if test "x${GCC_PCH}" = "x1" ; then
1160 # can do this because gcc is >= 3.4:
1161 ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
1162 elif test "x${ICC_PCH}" = "x1" ; then
1163 filename=pch_gen-${D}${D}
1164 file=${D}{filename}.c
1165 dfile=${D}{filename}.d
1166 cat > ${D}file <<EOT
1167 #include "${D}header"
1169 # using -MF icc complains about differing command lines in creation/use
1170 ${D}compiler -c ${ICC_PCH_CREATE_SWITCH} ${D}outfile -MMD ${D}file && \\
1171 sed -e "s,^.*:,${D}outfile:," -e "s, ${D}file,," < ${D}dfile > ${D}depsfile && \\
1172 rm -f ${D}file ${D}dfile ${D}{filename}.o
1177 dnl ===================== bk-make-pch ends here =====================