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.
24 dnl Support macros for makefiles generated by BAKEFILE.
28 dnl ---------------------------------------------------------------------------
29 dnl Lots of compiler & linker detection code contained here was taken from
30 dnl wxWidgets configure.in script (see http://www.wxwidgets.org)
31 dnl ---------------------------------------------------------------------------
35 dnl ---------------------------------------------------------------------------
36 dnl AC_BAKEFILE_GNUMAKE
39 dnl ---------------------------------------------------------------------------
41 AC_DEFUN([AC_BAKEFILE_GNUMAKE],
43 dnl does make support "-include" (only GNU make does AFAIK)?
44 AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu,
46 if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
47 egrep -s GNU > /dev/null); then
48 bakefile_cv_prog_makeisgnu="yes"
50 bakefile_cv_prog_makeisgnu="no"
54 if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then
62 dnl ---------------------------------------------------------------------------
63 dnl AC_BAKEFILE_PLATFORM
65 dnl Detects platform and sets PLATFORM_XXX variables accordingly
66 dnl ---------------------------------------------------------------------------
68 AC_DEFUN([AC_BAKEFILE_PLATFORM],
79 if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
80 case "${BAKEFILE_HOST}" in
87 *-pc-os2_emx | *-pc-os2-emx )
97 powerpc-apple-macos* )
106 case "$BAKEFILE_FORCE_PLATFORM" in
127 AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
132 AC_SUBST(PLATFORM_UNIX)
133 AC_SUBST(PLATFORM_WIN32)
134 AC_SUBST(PLATFORM_MSDOS)
135 AC_SUBST(PLATFORM_MAC)
136 AC_SUBST(PLATFORM_MACOS)
137 AC_SUBST(PLATFORM_MACOSX)
138 AC_SUBST(PLATFORM_OS2)
139 AC_SUBST(PLATFORM_BEOS)
143 dnl ---------------------------------------------------------------------------
144 dnl AC_BAKEFILE_PLATFORM_SPECIFICS
146 dnl Sets misc platform-specific settings
147 dnl ---------------------------------------------------------------------------
149 AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS],
151 AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf],
152 [use OMF object format (OS/2)]),
153 [bk_os2_use_omf="$enableval"])
155 case "${BAKEFILE_HOST}" in
157 dnl For Unix to MacOS X porting instructions, see:
158 dnl http://fink.sourceforge.net/doc/porting/porting.html
159 if test "x$GCC" = "xyes"; then
160 CFLAGS="$CFLAGS -fno-common"
161 CXXFLAGS="$CXXFLAGS -fno-common"
163 if test "x$XLCC" = "xyes"; then
164 CFLAGS="$CFLAGS -qnocommon"
165 CXXFLAGS="$CXXFLAGS -qnocommon"
169 *-pc-os2_emx | *-pc-os2-emx )
170 if test "x$bk_os2_use_omf" = "xyes" ; then
173 LDFLAGS="-Zomf $LDFLAGS"
174 CFLAGS="-Zomf $CFLAGS"
175 CXXFLAGS="-Zomf $CXXFLAGS"
183 LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
188 dnl ---------------------------------------------------------------------------
189 dnl AC_BAKEFILE_SUFFIXES
191 dnl Detects shared various suffixes for shared libraries, libraries, programs,
193 dnl ---------------------------------------------------------------------------
195 AC_DEFUN([AC_BAKEFILE_SUFFIXES],
198 SO_SUFFIX_MODULE="so"
207 case "${BAKEFILE_HOST}" in
208 dnl PA-RISC HP systems used .sl but IA64 use ELF-64 and so use the
209 dnl standard .so extension
214 SO_SUFFIX_MODULE="sl"
218 dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
219 dnl Both archive libraries and shared libraries on AIX have an
220 dnl .a extension. This will explain why you can't link with an
221 dnl .so and why it works with the name changed to .a.
227 SO_SUFFIX_MODULE="dll"
228 DLLIMP_SUFFIX="dll.a"
235 SO_SUFFIX_MODULE="dll"
236 DLLIMP_SUFFIX="dll.a"
246 *-pc-os2_emx | *-pc-os2-emx )
248 SO_SUFFIX_MODULE="dll"
249 DLLIMP_SUFFIX=$OS2_LIBEXT
253 LIBEXT=".$OS2_LIBEXT"
258 SO_SUFFIX_MODULE="bundle"
262 if test "x$DLLIMP_SUFFIX" = "x" ; then
263 DLLIMP_SUFFIX="$SO_SUFFIX"
267 AC_SUBST(SO_SUFFIX_MODULE)
268 AC_SUBST(DLLIMP_SUFFIX)
273 AC_SUBST(DLLPREFIX_MODULE)
278 dnl ---------------------------------------------------------------------------
279 dnl AC_BAKEFILE_SHARED_LD
281 dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
282 dnl and SHARED_LD_CXX.
283 dnl ---------------------------------------------------------------------------
285 AC_DEFUN([AC_BAKEFILE_SHARED_LD],
287 dnl the extra compiler flags needed for compilation of shared library
289 if test "x$GCC" = "xyes"; then
290 dnl the switch for gcc is the same under all platforms
294 dnl Defaults for GCC and ELF .so shared libs:
295 SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o"
296 SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o"
299 case "${BAKEFILE_HOST}" in
301 dnl default settings are good for gcc but not for the native HP-UX
302 if test "x$GCC" != "xyes"; then
303 dnl no idea why it wants it, but it does
304 LDFLAGS="$LDFLAGS -L/usr/lib"
306 SHARED_LD_CC="${CC} -b -o"
307 SHARED_LD_CXX="${CXX} -b -o"
313 dnl newer icc versions use -fPIC just as gcc does and, in fact, the
314 dnl newest (v10+) ones don't even understand -KPIC any longer
315 if test "$INTELCC" = "yes" -a "$INTELCC8" != "yes"; then
317 elif test "x$SUNCXX" = "xyes"; then
318 SHARED_LD_CC="${CC} -G -o"
319 SHARED_LD_CXX="${CXX} -G -o"
325 if test "x$SUNCXX" = xyes ; then
326 SHARED_LD_CC="${CC} -G -o"
327 SHARED_LD_CXX="${CXX} -G -o"
333 AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
334 chmod +x shared-ld-sh
336 SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
337 SHARED_LD_MODULE_CXX="CXX=\"\$(CXX)\" $SHARED_LD_MODULE_CC"
339 dnl Most apps benefit from being fully binded (its faster and static
340 dnl variables initialized at startup work).
341 dnl This can be done either with the exe linker flag -Wl,-bind_at_load
342 dnl or with a double stage link in order to create a single module
343 dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
345 dnl If using newer dev tools then there is a -single_module flag that
346 dnl we can use to do this for dylibs, otherwise we'll need to use a helper
347 dnl script. Check the version of gcc to see which way we can go:
348 AC_CACHE_CHECK([for gcc 3.1 or later], bakefile_cv_gcc31, [
351 #if (__GNUC__ < 3) || \
352 ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
357 bakefile_cv_gcc31=yes
364 if test "$bakefile_cv_gcc31" = "no"; then
365 dnl Use the shared-ld-sh helper script
366 SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
367 SHARED_LD_CXX="$SHARED_LD_CC"
369 dnl Use the -single_module flag and let the linker do it for us
370 SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o"
371 SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
374 if test "x$GCC" == "xyes"; then
375 PIC_FLAG="-dynamic -fPIC"
377 if test "x$XLCC" = "xyes"; then
378 PIC_FLAG="-dynamic -DPIC"
383 if test "x$GCC" = "xyes"; then
384 dnl at least gcc 2.95 warns that -fPIC is ignored when
385 dnl compiling each and every file under AIX which is annoying,
386 dnl so don't use it there (it's useless as AIX runs on
387 dnl position-independent architectures only anyhow)
390 dnl -bexpfull is needed by AIX linker to export all symbols (by
391 dnl default it doesn't export any and even with -bexpall it
392 dnl doesn't export all C++ support symbols, e.g. vtable
393 dnl pointers) but it's only available starting from 5.1 (with
394 dnl maintenance pack 2, whatever this is), see
395 dnl http://www-128.ibm.com/developerworks/eserver/articles/gnu.html
396 case "${BAKEFILE_HOST}" in
398 LD_EXPFULL="-Wl,-bexpfull"
402 SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o"
403 SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o"
405 dnl FIXME: makeC++SharedLib is obsolete, what should we do for
406 dnl recent AIX versions?
407 AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
408 makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
409 SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
410 SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
415 dnl can't use gcc under BeOS for shared library creation because it
416 dnl complains about missing 'main'
417 SHARED_LD_CC="${LD} -nostart -o"
418 SHARED_LD_CXX="${LD} -nostart -o"
422 dnl default settings are ok for gcc
423 if test "x$GCC" != "xyes"; then
428 *-*-cygwin* | *-*-mingw32* )
430 SHARED_LD_CC="\$(CC) -shared -o"
431 SHARED_LD_CXX="\$(CXX) -shared -o"
435 *-pc-os2_emx | *-pc-os2-emx )
436 SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
437 SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
439 AC_BAKEFILE_CREATE_FILE_DLLAR_SH
443 powerpc-apple-macos* | \
444 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-gnu* | *-*-k*bsd*-gnu | \
455 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
458 if test "x$PIC_FLAG" != "x" ; then
459 PIC_FLAG="$PIC_FLAG -DPIC"
462 if test "x$SHARED_LD_MODULE_CC" = "x" ; then
463 SHARED_LD_MODULE_CC="$SHARED_LD_CC"
465 if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
466 SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
469 AC_SUBST(SHARED_LD_CC)
470 AC_SUBST(SHARED_LD_CXX)
471 AC_SUBST(SHARED_LD_MODULE_CC)
472 AC_SUBST(SHARED_LD_MODULE_CXX)
474 AC_SUBST(WINDOWS_IMPLIB)
478 dnl ---------------------------------------------------------------------------
479 dnl AC_BAKEFILE_SHARED_VERSIONS
481 dnl Detects linker options for attaching versions (sonames) to shared libs.
482 dnl ---------------------------------------------------------------------------
484 AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
494 case "${BAKEFILE_HOST}" in
495 *-*-linux* | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
496 *-*-k*bsd*-gnu | *-*-mirbsd* | *-*-gnu* )
497 if test "x$SUNCXX" = "xyes"; then
500 SONAME_FLAG="-Wl,-soname,"
525 AC_SUBST(USE_SOVERSION)
526 AC_SUBST(USE_SOVERLINUX)
527 AC_SUBST(USE_SOVERSOLARIS)
528 AC_SUBST(USE_SOVERCYGWIN)
529 AC_SUBST(USE_MACVERSION)
530 AC_SUBST(USE_SOTWOSYMLINKS)
531 AC_SUBST(SONAME_FLAG)
535 dnl ---------------------------------------------------------------------------
538 dnl Detects available C/C++ dependency tracking options
539 dnl ---------------------------------------------------------------------------
541 AC_DEFUN([AC_BAKEFILE_DEPS],
543 AC_ARG_ENABLE([dependency-tracking],
544 AS_HELP_STRING([--disable-dependency-tracking],
545 [don't use dependency tracking even if the compiler can]),
546 [bk_use_trackdeps="$enableval"])
548 AC_MSG_CHECKING([for dependency tracking method])
551 if test "x$bk_use_trackdeps" = "xno" ; then
553 AC_MSG_RESULT([disabled])
557 if test "x$GCC" = "xyes"; then
561 elif test "x$MWCC" = "xyes"; then
564 AC_MSG_RESULT([mwcc])
565 elif test "x$SUNCC" = "xyes"; then
568 AC_MSG_RESULT([Sun cc])
569 elif test "x$SGICC" = "xyes"; then
572 AC_MSG_RESULT([SGI cc])
573 elif test "x$HPCC" = "xyes"; then
576 AC_MSG_RESULT([HP cc])
577 elif test "x$COMPAQCC" = "xyes"; then
580 AC_MSG_RESULT([Compaq cc])
583 AC_MSG_RESULT([none])
586 if test $DEPS_TRACKING = 1 ; then
587 AC_BAKEFILE_CREATE_FILE_BK_DEPS
589 dnl FIXME: make this $(top_builddir)/bk-deps once autoconf-2.60
590 dnl is required (and so top_builddir is never empty):
591 BK_DEPS="`pwd`/bk-deps"
595 AC_SUBST(DEPS_TRACKING)
599 dnl ---------------------------------------------------------------------------
600 dnl AC_BAKEFILE_CHECK_BASIC_STUFF
602 dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
604 dnl ---------------------------------------------------------------------------
606 AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
615 if test "x$SUNCXX" = "xyes"; then
616 dnl Sun C++ compiler requires special way of creating static libs;
617 dnl see here for more details:
618 dnl https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1229751&group_id=9863
622 elif test "x$SGICC" = "xyes"; then
623 dnl Almost the same as above for SGI mipsPro compiler
628 AC_CHECK_TOOL(AR, ar, ar)
633 AC_CHECK_TOOL(STRIP, strip, :)
634 AC_CHECK_TOOL(NM, nm, :)
636 dnl Don't use `install -d`, see http://trac.wxwidgets.org/ticket/13452
637 INSTALL_DIR="mkdir -p"
638 AC_SUBST(INSTALL_DIR)
641 case ${BAKEFILE_HOST} in
642 *-*-cygwin* | *-*-mingw32* )
643 LDFLAGS_GUI="-mwindows"
645 AC_SUBST(LDFLAGS_GUI)
649 dnl ---------------------------------------------------------------------------
650 dnl AC_BAKEFILE_RES_COMPILERS
652 dnl Checks for presence of resource compilers for win32 or mac
653 dnl ---------------------------------------------------------------------------
655 AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
657 case ${BAKEFILE_HOST} in
658 *-*-cygwin* | *-*-mingw32* )
659 dnl Check for win32 resources compiler:
660 AC_CHECK_TOOL(WINDRES, windres)
663 *-*-darwin* | powerpc-apple-macos* )
664 AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez)
665 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
674 dnl ---------------------------------------------------------------------------
675 dnl AC_BAKEFILE_PRECOMP_HEADERS
677 dnl Check for precompiled headers support (GCC >= 3.4)
678 dnl ---------------------------------------------------------------------------
680 AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
683 AC_ARG_ENABLE([precomp-headers],
684 AS_HELP_STRING([--disable-precomp-headers],
685 [don't use precompiled headers even if compiler can]),
686 [bk_use_pch="$enableval"])
693 case ${BAKEFILE_HOST} in
695 dnl PCH support is broken in cygwin gcc because of unportable
696 dnl assumptions about mmap() in gcc code which make PCH generation
697 dnl fail erratically; disable PCH completely until this is fixed
702 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
703 if test "x$GCC" = "xyes"; then
704 dnl test if we have gcc-3.4:
705 AC_MSG_CHECKING([if the compiler supports precompiled headers])
708 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
709 There is no PCH support
712 There is no PCH support
714 #if (__GNUC__ == 3) && \
715 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
716 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3))) || \
717 ( defined(__INTEL_COMPILER) )
718 There is no PCH support
726 if test "$INTELCXX8" = "yes"; then
729 if test "$INTELCXX10" = "yes"; then
730 ICC_PCH_CREATE_SWITCH="-pch-create"
731 ICC_PCH_USE_SWITCH="-pch-use"
733 ICC_PCH_CREATE_SWITCH="-create-pch"
734 ICC_PCH_USE_SWITCH="-use-pch"
740 if test $GCC_PCH = 1 -o $ICC_PCH = 1 ; then
742 AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
744 dnl FIXME: make this $(top_builddir)/bk-make-pch once
745 dnl autoconf-2.60 is required (and so top_builddir is
747 BK_MAKE_PCH="`pwd`/bk-make-pch"
754 AC_SUBST(ICC_PCH_CREATE_SWITCH)
755 AC_SUBST(ICC_PCH_USE_SWITCH)
756 AC_SUBST(BK_MAKE_PCH)
761 dnl ---------------------------------------------------------------------------
762 dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
764 dnl To be used in configure.in of any project using Bakefile-generated mks
766 dnl Behaviour can be modified by setting following variables:
767 dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
768 dnl to perform check for basic tools like ranlib
769 dnl BAKEFILE_HOST set this to override host detection, defaults
771 dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
775 dnl AC_BAKEFILE([FOO(autoconf_inc.m4)])
777 dnl (replace FOO with m4_include above, aclocal would die otherwise)
778 dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
780 dnl ---------------------------------------------------------------------------
782 AC_DEFUN([AC_BAKEFILE],
786 dnl We need to always run C/C++ compiler tests, but it's also possible
787 dnl for the user to call these macros manually, hence this instead of
788 dnl simply calling these macros. See http://www.bakefile.org/ticket/64
789 AC_REQUIRE([AC_BAKEFILE_PROG_CC])
790 AC_REQUIRE([AC_BAKEFILE_PROG_CXX])
792 if test "x$BAKEFILE_HOST" = "x"; then
793 if test "x${host}" = "x" ; then
794 AC_MSG_ERROR([You must call the autoconf "CANONICAL_HOST" macro in your configure.ac (or .in) file.])
797 BAKEFILE_HOST="${host}"
800 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
801 AC_BAKEFILE_CHECK_BASIC_STUFF
805 AC_BAKEFILE_PLATFORM_SPECIFICS
807 AC_BAKEFILE_SHARED_LD
808 AC_BAKEFILE_SHARED_VERSIONS
810 AC_BAKEFILE_RES_COMPILERS
812 dnl OBJCFLAGS is set by Autoconf, but OBJCXXFLAGS is not:
813 AC_SUBST(OBJCXXFLAGS)
816 BAKEFILE_BAKEFILE_M4_VERSION="0.2.9"
818 dnl includes autoconf_inc.m4:
821 if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then
822 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)?])
825 if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
826 AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
831 dnl ---------------------------------------------------------------------------
832 dnl Embedded copies of helper scripts follow:
833 dnl ---------------------------------------------------------------------------
835 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
837 dnl ===================== bk-deps begins here =====================
838 dnl (Created by merge-scripts.py from bk-deps
839 dnl file do not edit here!)
844 # This script is part of Bakefile (http://www.bakefile.org) autoconf
845 # script. It is used to track C/C++ files dependencies in portable way.
847 # Permission is given to use this file in any way.
850 DEPSFLAG="${DEPSFLAG}"
853 if test ${D}DEPSMODE = gcc ; then
857 # determine location of created files:
858 while test ${D}# -gt 0; do
872 objfilebase=\`basename ${D}objfile\`
873 builddir=\`dirname ${D}objfile\`
874 depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
875 depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
876 depsdir=${D}builddir/${D}DEPSDIRBASE
879 # if the compiler failed, we're done:
880 if test ${D}{status} != 0 ; then
885 # move created file to the location we want it in:
886 if test -f ${D}depfile ; then
887 sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
890 # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d
891 depfile=\`echo "${D}objfile" | sed -e 's/\\..*${D}/.d/g'\`
892 if test ! -f ${D}depfile ; then
893 # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++)
894 depfile="${D}objfile.d"
896 if test -f ${D}depfile ; then
897 sed -e "\\,^${D}objfile,!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
903 elif test ${D}DEPSMODE = mwcc ; then
905 # Run mwcc again with -MM and redirect into the dep file we want
906 # NOTE: We can't use shift here because we need ${D}* to be valid
908 for arg in ${D}* ; do
909 if test "${D}prevarg" = "-o"; then
923 objfilebase=\`basename ${D}objfile\`
924 builddir=\`dirname ${D}objfile\`
925 depsdir=${D}builddir/${D}DEPSDIRBASE
928 ${D}* ${D}DEPSFLAG >${D}{depsdir}/${D}{objfilebase}.d
931 elif test ${D}DEPSMODE = unixcc; then
933 # Run compiler again with deps flag and redirect into the dep file.
934 # It doesn't work if the '-o FILE' option is used, but without it the
935 # dependency file will contain the wrong name for the object. So it is
936 # removed from the command line, and the dep file is fixed with sed.
938 while test ${D}# -gt 0; do
945 eval arg${D}#=\\${D}1
946 cmd="${D}cmd \\${D}arg${D}#"
952 objfilebase=\`basename ${D}objfile\`
953 builddir=\`dirname ${D}objfile\`
954 depsdir=${D}builddir/${D}DEPSDIRBASE
957 eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{depsdir}/${D}{objfilebase}.d
965 dnl ===================== bk-deps ends here =====================
968 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
970 dnl ===================== shared-ld-sh begins here =====================
971 dnl (Created by merge-scripts.py from shared-ld-sh
972 dnl file do not edit here!)
974 cat <<EOF >shared-ld-sh
976 #-----------------------------------------------------------------------------
977 #-- Name: distrib/mac/shared-ld-sh
978 #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
979 #-- Author: Gilles Depeyrot
980 #-- Copyright: (c) 2002 Gilles Depeyrot
981 #-- Licence: any use permitted
982 #-----------------------------------------------------------------------------
987 linking_flag="-dynamiclib"
988 ldargs="-r -keep_private_externs -nostdlib"
990 if test "x${D}CXX" = "x"; then
994 while test ${D}# -gt 0; do
1001 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1002 # collect these options and values
1003 args="${D}{args} ${D}1 ${D}2"
1008 # collect these options and values
1009 ldargs="${D}{ldargs} ${D}1 ${D}2"
1014 # collect these load args
1015 ldargs="${D}{ldargs} ${D}1"
1018 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
1019 # collect these options
1020 args="${D}{args} ${D}1"
1023 -dynamiclib|-bundle)
1024 linking_flag="${D}1"
1028 echo "shared-ld: unhandled option '${D}1'"
1032 *.o | *.a | *.dylib)
1033 # collect object files
1034 objects="${D}{objects} ${D}1"
1038 echo "shared-ld: unhandled argument '${D}1'"
1049 # Link one module containing all the others
1051 if test ${D}{verbose} = 1; then
1052 echo "${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o"
1054 ${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o
1058 # Link the shared library from the single module created, but only if the
1059 # previous command didn't fail:
1061 if test ${D}{status} = 0; then
1062 if test ${D}{verbose} = 1; then
1063 echo "${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
1065 ${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}
1070 # Remove intermediate module
1072 rm -f master.${D}${D}.o
1076 dnl ===================== shared-ld-sh ends here =====================
1079 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
1081 dnl ===================== bk-make-pch begins here =====================
1082 dnl (Created by merge-scripts.py from bk-make-pch
1083 dnl file do not edit here!)
1085 cat <<EOF >bk-make-pch
1088 # This script is part of Bakefile (http://www.bakefile.org) autoconf
1089 # script. It is used to generated precompiled headers.
1091 # Permission is given to use this file in any way.
1098 builddir=\`echo ${D}outfile | sed -e 's,/\\.pch/.*${D},,g'\`
1103 while test ${D}{#} -gt 0; do
1107 incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
1108 if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
1109 headerfile="${D}{incdir}/${D}{header}"
1112 -use-pch|-use_pch|-pch-use )
1117 if test ${D}add_to_cmdline = 1 ; then
1118 compiler="${D}{compiler} ${D}{1}"
1123 if test "x${D}{headerfile}" = "x" ; then
1124 echo "error: can't find header ${D}{header} in include paths" >&2
1126 if test -f ${D}{outfile} ; then
1129 mkdir -p \`dirname ${D}{outfile}\`
1131 depsfile="${D}{builddir}/.deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
1132 mkdir -p ${D}{builddir}/.deps
1133 if test "x${GCC_PCH}" = "x1" ; then
1134 # can do this because gcc is >= 3.4:
1135 ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
1136 elif test "x${ICC_PCH}" = "x1" ; then
1137 filename=pch_gen-${D}${D}
1138 file=${D}{filename}.c
1139 dfile=${D}{filename}.d
1140 cat > ${D}file <<EOT
1141 #include "${D}header"
1143 # using -MF icc complains about differing command lines in creation/use
1144 ${D}compiler -c ${ICC_PCH_CREATE_SWITCH} ${D}outfile -MMD ${D}file && \\
1145 sed -e "s,^.*:,${D}outfile:," -e "s, ${D}file,," < ${D}dfile > ${D}depsfile && \\
1146 rm -f ${D}file ${D}dfile ${D}{filename}.o
1151 dnl ===================== bk-make-pch ends here =====================