2007-03-07 16:50:47 -05:00
dnl
2008-02-04 08:21:23 -05:00
dnl This file is part of Bakefile (http://www.bakefile.org)
2007-03-07 16:50:47 -05:00
dnl
dnl Copyright (C) 2003-2007 Vaclav Slavik and others
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the "Software"),
dnl to deal in the Software without restriction, including without limitation
dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
dnl and/or sell copies of the Software, and to permit persons to whom the
dnl Software is furnished to do so, subject to the following conditions:
dnl
dnl The above copyright notice and this permission notice shall be included in
dnl all copies or substantial portions of the Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
dnl DEALINGS IN THE SOFTWARE.
dnl
2009-10-31 16:52:55 -04:00
dnl $Id$
2007-03-07 16:50:47 -05:00
dnl
dnl Support macros for makefiles generated by BAKEFILE.
dnl
2005-09-18 09:24:14 -04:00
2007-03-07 16:50:47 -05:00
dnl ---------------------------------------------------------------------------
2005-09-18 09:24:14 -04:00
dnl Lots of compiler & linker detection code contained here was taken from
2007-03-07 16:50:47 -05:00
dnl wxWidgets configure.in script (see http://www.wxwidgets.org)
dnl ---------------------------------------------------------------------------
2005-09-18 09:24:14 -04:00
dnl ---------------------------------------------------------------------------
dnl AC_BAKEFILE_GNUMAKE
dnl
dnl Detects GNU make
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE_GNUMAKE],
[
dnl does make support "-include" (only GNU make does AFAIK)?
AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu,
[
if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
egrep -s GNU > /dev/null); then
bakefile_cv_prog_makeisgnu="yes"
else
bakefile_cv_prog_makeisgnu="no"
fi
])
if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then
IF_GNU_MAKE=""
else
IF_GNU_MAKE="#"
fi
AC_SUBST(IF_GNU_MAKE)
])
dnl ---------------------------------------------------------------------------
dnl AC_BAKEFILE_PLATFORM
dnl
dnl Detects platform and sets PLATFORM_XXX variables accordingly
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE_PLATFORM],
[
PLATFORM_UNIX=0
PLATFORM_WIN32=0
PLATFORM_MSDOS=0
PLATFORM_MAC=0
PLATFORM_MACOS=0
PLATFORM_MACOSX=0
PLATFORM_OS2=0
PLATFORM_BEOS=0
2007-03-07 16:50:47 -05:00
if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
2005-09-18 09:24:14 -04:00
case "${BAKEFILE_HOST}" in
*-*-mingw32* )
PLATFORM_WIN32=1
;;
*-pc-msdosdjgpp )
PLATFORM_MSDOS=1
;;
*-pc-os2_emx | *-pc-os2-emx )
PLATFORM_OS2=1
;;
*-*-darwin* )
PLATFORM_MAC=1
PLATFORM_MACOSX=1
2007-03-07 16:50:47 -05:00
;;
2005-09-18 09:24:14 -04:00
*-*-beos* )
PLATFORM_BEOS=1
;;
powerpc-apple-macos* )
PLATFORM_MAC=1
PLATFORM_MACOS=1
;;
* )
PLATFORM_UNIX=1
;;
esac
else
case "$BAKEFILE_FORCE_PLATFORM" in
win32 )
PLATFORM_WIN32=1
;;
msdos )
PLATFORM_MSDOS=1
;;
os2 )
PLATFORM_OS2=1
;;
darwin )
PLATFORM_MAC=1
PLATFORM_MACOSX=1
;;
unix )
PLATFORM_UNIX=1
;;
beos )
PLATFORM_BEOS=1
;;
* )
2009-10-31 16:52:55 -04:00
AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
2005-09-18 09:24:14 -04:00
;;
esac
fi
AC_SUBST(PLATFORM_UNIX)
AC_SUBST(PLATFORM_WIN32)
AC_SUBST(PLATFORM_MSDOS)
AC_SUBST(PLATFORM_MAC)
AC_SUBST(PLATFORM_MACOS)
AC_SUBST(PLATFORM_MACOSX)
AC_SUBST(PLATFORM_OS2)
AC_SUBST(PLATFORM_BEOS)
])
dnl ---------------------------------------------------------------------------
dnl AC_BAKEFILE_PLATFORM_SPECIFICS
dnl
dnl Sets misc platform-specific settings
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS],
[
AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf],
[use OMF object format (OS/2)]),
[bk_os2_use_omf="$enableval"])
2007-03-07 16:50:47 -05:00
2005-09-18 09:24:14 -04:00
case "${BAKEFILE_HOST}" in
*-*-darwin* )
dnl For Unix to MacOS X porting instructions, see:
dnl http://fink.sourceforge.net/doc/porting/porting.html
if test "x$GCC" = "xyes"; then
CFLAGS="$CFLAGS -fno-common"
CXXFLAGS="$CXXFLAGS -fno-common"
fi
if test "x$XLCC" = "xyes"; then
CFLAGS="$CFLAGS -qnocommon"
CXXFLAGS="$CXXFLAGS -qnocommon"
fi
;;
*-pc-os2_emx | *-pc-os2-emx )
if test "x$bk_os2_use_omf" = "xyes" ; then
AR=emxomfar
RANLIB=:
LDFLAGS="-Zomf $LDFLAGS"
CFLAGS="-Zomf $CFLAGS"
CXXFLAGS="-Zomf $CXXFLAGS"
OS2_LIBEXT="lib"
else
OS2_LIBEXT="a"
fi
;;
2007-03-07 16:50:47 -05:00
2005-09-18 09:24:14 -04:00
i*86-*-beos* )
LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
;;
esac
])
dnl ---------------------------------------------------------------------------
dnl AC_BAKEFILE_SUFFIXES
dnl
dnl Detects shared various suffixes for shared libraries, libraries, programs,
dnl plugins etc.
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE_SUFFIXES],
[
SO_SUFFIX="so"
SO_SUFFIX_MODULE="so"
EXEEXT=""
LIBPREFIX="lib"
LIBEXT=".a"
DLLPREFIX="lib"
DLLPREFIX_MODULE=""
DLLIMP_SUFFIX=""
dlldir="$libdir"
2007-03-07 16:50:47 -05:00
2005-09-18 09:24:14 -04:00
case "${BAKEFILE_HOST}" in
2008-11-12 10:37:01 -05:00
dnl PA-RISC HP systems used .sl but IA64 use ELF-64 and so use the
dnl standard .so extension
ia64-hp-hpux* )
;;
2005-09-18 09:24:14 -04:00
*-hp-hpux* )
SO_SUFFIX="sl"
SO_SUFFIX_MODULE="sl"
;;
*-*-aix* )
dnl quoting from
dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
dnl Both archive libraries and shared libraries on AIX have an
dnl .a extension. This will explain why you can't link with an
dnl .so and why it works with the name changed to .a.
SO_SUFFIX="a"
SO_SUFFIX_MODULE="a"
;;
*-*-cygwin* )
SO_SUFFIX="dll"
SO_SUFFIX_MODULE="dll"
DLLIMP_SUFFIX="dll.a"
EXEEXT=".exe"
DLLPREFIX="cyg"
dlldir="$bindir"
;;
*-*-mingw32* )
SO_SUFFIX="dll"
SO_SUFFIX_MODULE="dll"
DLLIMP_SUFFIX="dll.a"
EXEEXT=".exe"
DLLPREFIX=""
dlldir="$bindir"
;;
*-pc-msdosdjgpp )
EXEEXT=".exe"
DLLPREFIX=""
dlldir="$bindir"
;;
*-pc-os2_emx | *-pc-os2-emx )
SO_SUFFIX="dll"
SO_SUFFIX_MODULE="dll"
DLLIMP_SUFFIX=$OS2_LIBEXT
EXEEXT=".exe"
DLLPREFIX=""
LIBPREFIX=""
LIBEXT=".$OS2_LIBEXT"
dlldir="$bindir"
;;
*-*-darwin* )
SO_SUFFIX="dylib"
SO_SUFFIX_MODULE="bundle"
;;
esac
if test "x$DLLIMP_SUFFIX" = "x" ; then
DLLIMP_SUFFIX="$SO_SUFFIX"
fi
AC_SUBST(SO_SUFFIX)
AC_SUBST(SO_SUFFIX_MODULE)
AC_SUBST(DLLIMP_SUFFIX)
AC_SUBST(EXEEXT)
AC_SUBST(LIBPREFIX)
AC_SUBST(LIBEXT)
AC_SUBST(DLLPREFIX)
AC_SUBST(DLLPREFIX_MODULE)
AC_SUBST(dlldir)
])
dnl ---------------------------------------------------------------------------
dnl AC_BAKEFILE_SHARED_LD
dnl
dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
dnl and SHARED_LD_CXX.
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE_SHARED_LD],
[
dnl the extra compiler flags needed for compilation of shared library
PIC_FLAG=""
if test "x$GCC" = "xyes"; then
dnl the switch for gcc is the same under all platforms
PIC_FLAG="-fPIC"
fi
2007-03-07 16:50:47 -05:00
2005-09-18 09:24:14 -04:00
dnl Defaults for GCC and ELF .so shared libs:
SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o"
SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o"
WINDOWS_IMPLIB=0
case "${BAKEFILE_HOST}" in
*-hp-hpux* )
dnl default settings are good for gcc but not for the native HP-UX
if test "x$GCC" != "xyes"; then
dnl no idea why it wants it, but it does
LDFLAGS="$LDFLAGS -L/usr/lib"
SHARED_LD_CC="${CC} -b -o"
SHARED_LD_CXX="${CXX} -b -o"
PIC_FLAG="+Z"
fi
;;
*-*-linux* )
2008-11-17 17:29:05 -05:00
dnl newer icc versions use -fPIC just as gcc does and, in fact, the
dnl newest (v10+) ones don't even understand -KPIC any longer
if test "$INTELCC" = "yes" -a "$INTELCC8" != "yes"; then
2007-06-22 13:15:33 -04:00
PIC_FLAG="-KPIC"
elif test "x$SUNCXX" = "xyes"; then
SHARED_LD_CC="${CC} -G -o"
SHARED_LD_CXX="${CXX} -G -o"
PIC_FLAG="-KPIC"
2005-09-18 09:24:14 -04:00
fi
;;
*-*-solaris2* )
2007-06-22 13:15:33 -04:00
if test "x$SUNCXX" = xyes ; then
2005-09-18 09:24:14 -04:00
SHARED_LD_CC="${CC} -G -o"
SHARED_LD_CXX="${CXX} -G -o"
PIC_FLAG="-KPIC"
fi
;;
*-*-darwin* )
2005-10-10 08:48:40 -04:00
AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
chmod +x shared-ld-sh
SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
2009-10-22 12:53:10 -04:00
SHARED_LD_MODULE_CXX="CXX=\"\$(CXX)\" $SHARED_LD_MODULE_CC"
2005-10-10 08:48:40 -04:00
2005-09-18 09:24:14 -04:00
dnl Most apps benefit from being fully binded (its faster and static
dnl variables initialized at startup work).
dnl This can be done either with the exe linker flag -Wl,-bind_at_load
dnl or with a double stage link in order to create a single module
dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
dnl If using newer dev tools then there is a -single_module flag that
2005-10-09 08:49:09 -04:00
dnl we can use to do this for dylibs, otherwise we'll need to use a helper
2005-09-18 09:24:14 -04:00
dnl script. Check the version of gcc to see which way we can go:
2005-10-08 11:33:10 -04:00
AC_CACHE_CHECK([for gcc 3.1 or later], bakefile_cv_gcc31, [
2005-09-18 09:24:14 -04:00
AC_TRY_COMPILE([],
[
#if (__GNUC__ < 3) || \
((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
2006-02-12 08:55:19 -05:00
This is old gcc
2005-09-18 09:24:14 -04:00
#endif
],
[
2005-10-08 11:33:10 -04:00
bakefile_cv_gcc31=yes
2005-09-18 09:24:14 -04:00
],
[
2005-10-08 11:33:10 -04:00
bakefile_cv_gcc31=no
2005-09-18 09:24:14 -04:00
]
)
])
2005-10-08 11:33:10 -04:00
if test "$bakefile_cv_gcc31" = "no"; then
2005-09-18 09:24:14 -04:00
dnl Use the shared-ld-sh helper script
SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
SHARED_LD_CXX="$SHARED_LD_CC"
else
dnl Use the -single_module flag and let the linker do it for us
SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o"
SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
fi
if test "x$GCC" == "xyes"; then
PIC_FLAG="-dynamic -fPIC"
fi
if test "x$XLCC" = "xyes"; then
PIC_FLAG="-dynamic -DPIC"
fi
;;
*-*-aix* )
if test "x$GCC" = "xyes"; then
2005-10-10 08:48:40 -04:00
dnl at least gcc 2.95 warns that -fPIC is ignored when
dnl compiling each and every file under AIX which is annoying,
dnl so don't use it there (it's useless as AIX runs on
dnl position-independent architectures only anyhow)
PIC_FLAG=""
dnl -bexpfull is needed by AIX linker to export all symbols (by
dnl default it doesn't export any and even with -bexpall it
dnl doesn't export all C++ support symbols, e.g. vtable
dnl pointers) but it's only available starting from 5.1 (with
dnl maintenance pack 2, whatever this is), see
dnl http://www-128.ibm.com/developerworks/eserver/articles/gnu.html
case "${BAKEFILE_HOST}" in
*-*-aix5* )
LD_EXPFULL="-Wl,-bexpfull"
;;
esac
SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o"
SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o"
else
dnl FIXME: makeC++SharedLib is obsolete, what should we do for
dnl recent AIX versions?
2005-09-18 09:24:14 -04:00
AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
fi
;;
*-*-beos* )
dnl can't use gcc under BeOS for shared library creation because it
dnl complains about missing 'main'
SHARED_LD_CC="${LD} -nostart -o"
SHARED_LD_CXX="${LD} -nostart -o"
;;
*-*-irix* )
dnl default settings are ok for gcc
if test "x$GCC" != "xyes"; then
PIC_FLAG="-KPIC"
fi
;;
2005-10-10 08:48:40 -04:00
2005-09-18 09:24:14 -04:00
*-*-cygwin* | *-*-mingw32* )
PIC_FLAG=""
SHARED_LD_CC="\$(CC) -shared -o"
SHARED_LD_CXX="\$(CXX) -shared -o"
WINDOWS_IMPLIB=1
;;
*-pc-os2_emx | *-pc-os2-emx )
SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
PIC_FLAG=""
AC_BAKEFILE_CREATE_FILE_DLLAR_SH
chmod +x dllar.sh
;;
2005-10-10 08:48:40 -04:00
2005-09-18 09:24:14 -04:00
powerpc-apple-macos* | \
*-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-k*bsd*-gnu | \
2006-11-04 15:21:49 -05:00
*-*-mirbsd* | \
2005-09-18 09:24:14 -04:00
*-*-sunos4* | \
*-*-osf* | \
*-*-dgux5* | \
*-*-sysv5* | \
*-pc-msdosdjgpp )
dnl defaults are ok
;;
*)
2007-03-07 16:50:47 -05:00
AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
2005-09-18 09:24:14 -04:00
esac
if test "x$PIC_FLAG" != "x" ; then
PIC_FLAG="$PIC_FLAG -DPIC"
fi
if test "x$SHARED_LD_MODULE_CC" = "x" ; then
SHARED_LD_MODULE_CC="$SHARED_LD_CC"
fi
if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
fi
AC_SUBST(SHARED_LD_CC)
AC_SUBST(SHARED_LD_CXX)
AC_SUBST(SHARED_LD_MODULE_CC)
AC_SUBST(SHARED_LD_MODULE_CXX)
AC_SUBST(PIC_FLAG)
AC_SUBST(WINDOWS_IMPLIB)
])
dnl ---------------------------------------------------------------------------
dnl AC_BAKEFILE_SHARED_VERSIONS
dnl
dnl Detects linker options for attaching versions (sonames) to shared libs.
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
[
USE_SOVERSION=0
USE_SOVERLINUX=0
USE_SOVERSOLARIS=0
USE_SOVERCYGWIN=0
2009-10-07 09:54:44 -04:00
USE_SOTWOSYMLINKS=0
2005-09-18 09:24:14 -04:00
USE_MACVERSION=0
SONAME_FLAG=
case "${BAKEFILE_HOST}" in
2008-02-04 08:21:23 -05:00
*-*-linux* | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
*-*-k*bsd*-gnu | *-*-mirbsd* )
2007-06-22 13:15:33 -04:00
if test "x$SUNCXX" = "xyes"; then
SONAME_FLAG="-h "
else
SONAME_FLAG="-Wl,-soname,"
fi
2005-09-18 09:24:14 -04:00
USE_SOVERSION=1
USE_SOVERLINUX=1
2009-10-07 09:54:44 -04:00
USE_SOTWOSYMLINKS=1
2005-09-18 09:24:14 -04:00
;;
*-*-solaris2* )
SONAME_FLAG="-h "
USE_SOVERSION=1
USE_SOVERSOLARIS=1
;;
*-*-darwin* )
USE_MACVERSION=1
USE_SOVERSION=1
2009-10-07 09:54:44 -04:00
USE_SOTWOSYMLINKS=1
2005-09-18 09:24:14 -04:00
;;
*-*-cygwin* )
USE_SOVERSION=1
USE_SOVERCYGWIN=1
;;
esac
AC_SUBST(USE_SOVERSION)
AC_SUBST(USE_SOVERLINUX)
AC_SUBST(USE_SOVERSOLARIS)
AC_SUBST(USE_SOVERCYGWIN)
AC_SUBST(USE_MACVERSION)
2009-10-07 09:54:44 -04:00
AC_SUBST(USE_SOTWOSYMLINKS)
2005-09-18 09:24:14 -04:00
AC_SUBST(SONAME_FLAG)
])
dnl ---------------------------------------------------------------------------
dnl AC_BAKEFILE_DEPS
dnl
dnl Detects available C/C++ dependency tracking options
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE_DEPS],
[
2006-02-10 15:15:08 -05:00
AC_ARG_ENABLE([dependency-tracking],
AS_HELP_STRING([--disable-dependency-tracking],
[don't use dependency tracking even if the compiler can]),
[bk_use_trackdeps="$enableval"])
2007-03-07 16:50:47 -05:00
2005-09-18 09:24:14 -04:00
AC_MSG_CHECKING([for dependency tracking method])
2006-11-04 15:15:51 -05:00
BK_DEPS=""
2006-02-10 15:15:08 -05:00
if test "x$bk_use_trackdeps" = "xno" ; then
2005-10-07 11:39:34 -04:00
DEPS_TRACKING=0
2006-02-10 15:15:08 -05:00
AC_MSG_RESULT([disabled])
else
DEPS_TRACKING=1
if test "x$GCC" = "xyes"; then
DEPSMODE=gcc
case "${BAKEFILE_HOST}" in
*-*-darwin* )
dnl -cpp-precomp (the default) conflicts with -MMD option
dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
DEPSFLAG="-no-cpp-precomp -MMD"
;;
* )
DEPSFLAG="-MMD"
;;
esac
AC_MSG_RESULT([gcc])
elif test "x$MWCC" = "xyes"; then
DEPSMODE=mwcc
DEPSFLAG="-MM"
AC_MSG_RESULT([mwcc])
elif test "x$SUNCC" = "xyes"; then
DEPSMODE=unixcc
DEPSFLAG="-xM1"
AC_MSG_RESULT([Sun cc])
elif test "x$SGICC" = "xyes"; then
DEPSMODE=unixcc
DEPSFLAG="-M"
AC_MSG_RESULT([SGI cc])
elif test "x$HPCC" = "xyes"; then
DEPSMODE=unixcc
DEPSFLAG="+make"
AC_MSG_RESULT([HP cc])
elif test "x$COMPAQCC" = "xyes"; then
DEPSMODE=gcc
DEPSFLAG="-MD"
AC_MSG_RESULT([Compaq cc])
else
DEPS_TRACKING=0
AC_MSG_RESULT([none])
fi
2005-09-18 09:24:14 -04:00
2006-02-10 15:15:08 -05:00
if test $DEPS_TRACKING = 1 ; then
AC_BAKEFILE_CREATE_FILE_BK_DEPS
chmod +x bk-deps
2006-11-04 15:15:51 -05:00
dnl FIXME: make this $(top_builddir)/bk-deps once autoconf-2.60
dnl is required (and so top_builddir is never empty):
BK_DEPS="`pwd`/bk-deps"
2006-02-10 15:15:08 -05:00
fi
2005-09-18 09:24:14 -04:00
fi
2005-10-07 11:39:34 -04:00
2005-09-18 09:24:14 -04:00
AC_SUBST(DEPS_TRACKING)
2006-11-04 15:15:51 -05:00
AC_SUBST(BK_DEPS)
2005-09-18 09:24:14 -04:00
])
dnl ---------------------------------------------------------------------------
dnl AC_BAKEFILE_CHECK_BASIC_STUFF
dnl
dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
dnl or "install"
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
[
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_SUBST(MAKE_SET)
2007-03-07 16:50:47 -05:00
2006-11-04 15:15:51 -05:00
if test "x$SUNCXX" = "xyes"; then
dnl Sun C++ compiler requires special way of creating static libs;
dnl see here for more details:
dnl https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1229751&group_id=9863
2007-03-07 16:50:47 -05:00
AR=$CXX
AROPTIONS="-xar -o"
AC_SUBST(AR)
elif test "x$SGICC" = "xyes"; then
dnl Almost the same as above for SGI mipsPro compiler
AR=$CXX
AROPTIONS="-ar -o"
2006-11-04 15:15:51 -05:00
AC_SUBST(AR)
else
AC_CHECK_TOOL(AR, ar, ar)
AROPTIONS=rcu
fi
AC_SUBST(AROPTIONS)
2005-09-18 09:24:14 -04:00
AC_CHECK_TOOL(STRIP, strip, :)
AC_CHECK_TOOL(NM, nm, :)
2008-02-04 08:21:23 -05:00
dnl This check is necessary because "install -d" doesn't exist on
dnl all platforms (e.g. HP/UX), see http://www.bakefile.org/ticket/80
AC_MSG_CHECKING([for command to install directories])
INSTALL_TEST_DIR=acbftest$$
$INSTALL -d $INSTALL_TEST_DIR > /dev/null 2>&1
if test $? = 0 -a -d $INSTALL_TEST_DIR; then
rmdir $INSTALL_TEST_DIR
dnl we must refer to makefile's $(INSTALL) variable and not
dnl current value of shell variable, hence the single quoting:
INSTALL_DIR='$(INSTALL) -d'
AC_MSG_RESULT([$INSTALL -d])
else
INSTALL_DIR="mkdir -p"
AC_MSG_RESULT([mkdir -p])
fi
2005-09-18 09:24:14 -04:00
AC_SUBST(INSTALL_DIR)
LDFLAGS_GUI=
case ${BAKEFILE_HOST} in
*-*-cygwin* | *-*-mingw32* )
LDFLAGS_GUI="-mwindows"
esac
AC_SUBST(LDFLAGS_GUI)
])
dnl ---------------------------------------------------------------------------
dnl AC_BAKEFILE_RES_COMPILERS
dnl
dnl Checks for presence of resource compilers for win32 or mac
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
[
2007-03-07 16:50:47 -05:00
case ${BAKEFILE_HOST} in
2005-09-18 09:24:14 -04:00
*-*-cygwin* | *-*-mingw32* )
dnl Check for win32 resources compiler:
2005-11-24 23:51:08 -05:00
AC_CHECK_TOOL(WINDRES, windres)
2005-09-18 09:24:14 -04:00
;;
2007-03-07 16:50:47 -05:00
2005-09-18 09:24:14 -04:00
*-*-darwin* | powerpc-apple-macos* )
2005-11-24 23:51:08 -05:00
AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez)
2005-09-18 09:24:14 -04:00
AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
;;
esac
2005-11-24 23:51:08 -05:00
AC_SUBST(WINDRES)
AC_SUBST(REZ)
2005-09-18 09:24:14 -04:00
AC_SUBST(SETFILE)
])
dnl ---------------------------------------------------------------------------
dnl AC_BAKEFILE_PRECOMP_HEADERS
dnl
dnl Check for precompiled headers support (GCC >= 3.4)
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
[
AC_ARG_ENABLE([precomp-headers],
AS_HELP_STRING([--disable-precomp-headers],
[don't use precompiled headers even if compiler can]),
[bk_use_pch="$enableval"])
GCC_PCH=0
2006-02-10 15:15:08 -05:00
ICC_PCH=0
USE_PCH=0
2006-11-04 15:15:51 -05:00
BK_MAKE_PCH=""
2005-09-18 09:24:14 -04:00
2007-03-07 16:50:47 -05:00
case ${BAKEFILE_HOST} in
2005-10-31 14:59:52 -05:00
*-*-cygwin* )
dnl PCH support is broken in cygwin gcc because of unportable
dnl assumptions about mmap() in gcc code which make PCH generation
dnl fail erratically; disable PCH completely until this is fixed
bk_use_pch="no"
;;
esac
2005-09-18 09:24:14 -04:00
if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
if test "x$GCC" = "xyes"; then
dnl test if we have gcc-3.4:
AC_MSG_CHECKING([if the compiler supports precompiled headers])
AC_TRY_COMPILE([],
[
#if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
2006-02-12 08:55:19 -05:00
There is no PCH support
2005-09-18 09:24:14 -04:00
#endif
#if (__GNUC__ < 3)
2006-02-12 08:55:19 -05:00
There is no PCH support
2005-09-18 09:24:14 -04:00
#endif
#if (__GNUC__ == 3) && \
((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
2006-02-10 15:15:08 -05:00
( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3))) || \
( defined(__INTEL_COMPILER) )
2006-02-12 08:55:19 -05:00
There is no PCH support
2005-09-18 09:24:14 -04:00
#endif
],
[
AC_MSG_RESULT([yes])
GCC_PCH=1
],
[
2008-11-17 17:29:05 -05:00
if test "$INTELCXX8" = "yes"; then
AC_MSG_RESULT([yes])
ICC_PCH=1
if test "$INTELCXX10" = "yes"; then
ICC_PCH_CREATE_SWITCH="-pch-create"
ICC_PCH_USE_SWITCH="-pch-use"
else
ICC_PCH_CREATE_SWITCH="-create-pch"
ICC_PCH_USE_SWITCH="-use-pch"
fi
else
AC_MSG_RESULT([no])
fi
2005-09-18 09:24:14 -04:00
])
2006-02-10 15:15:08 -05:00
if test $GCC_PCH = 1 -o $ICC_PCH = 1 ; then
USE_PCH=1
2005-09-18 09:24:14 -04:00
AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
chmod +x bk-make-pch
2006-11-04 15:15:51 -05:00
dnl FIXME: make this $(top_builddir)/bk-make-pch once
dnl autoconf-2.60 is required (and so top_builddir is
dnl never empty):
BK_MAKE_PCH="`pwd`/bk-make-pch"
2005-09-18 09:24:14 -04:00
fi
fi
fi
AC_SUBST(GCC_PCH)
2006-02-10 15:15:08 -05:00
AC_SUBST(ICC_PCH)
2008-11-17 17:29:05 -05:00
AC_SUBST(ICC_PCH_CREATE_SWITCH)
AC_SUBST(ICC_PCH_USE_SWITCH)
2006-11-04 15:15:51 -05:00
AC_SUBST(BK_MAKE_PCH)
2005-09-18 09:24:14 -04:00
])
dnl ---------------------------------------------------------------------------
dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
dnl
dnl To be used in configure.in of any project using Bakefile-generated mks
dnl
dnl Behaviour can be modified by setting following variables:
dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
dnl to perform check for basic tools like ranlib
dnl BAKEFILE_HOST set this to override host detection, defaults
dnl to ${host}
dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
dnl
dnl Example usage:
dnl
dnl AC_BAKEFILE([FOO(autoconf_inc.m4)])
dnl
dnl (replace FOO with m4_include above, aclocal would die otherwise)
dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
dnl we can do...)
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE],
[
2006-11-04 15:15:51 -05:00
AC_PREREQ([2.58])
2005-09-18 09:24:14 -04:00
2008-02-04 08:21:23 -05:00
dnl We need to always run C/C++ compiler tests, but it's also possible
dnl for the user to call these macros manually, hence this instead of
dnl simply calling these macros. See http://www.bakefile.org/ticket/64
AC_REQUIRE([AC_BAKEFILE_PROG_CC])
AC_REQUIRE([AC_BAKEFILE_PROG_CXX])
2005-09-18 09:24:14 -04:00
if test "x$BAKEFILE_HOST" = "x"; then
2006-02-10 15:15:08 -05:00
if test "x${host}" = "x" ; then
AC_MSG_ERROR([You must call the autoconf "CANONICAL_HOST" macro in your configure.ac (or .in) file.])
fi
2005-09-18 09:24:14 -04:00
BAKEFILE_HOST="${host}"
fi
if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
AC_BAKEFILE_CHECK_BASIC_STUFF
fi
AC_BAKEFILE_GNUMAKE
AC_BAKEFILE_PLATFORM
AC_BAKEFILE_PLATFORM_SPECIFICS
AC_BAKEFILE_SUFFIXES
AC_BAKEFILE_SHARED_LD
AC_BAKEFILE_SHARED_VERSIONS
AC_BAKEFILE_DEPS
AC_BAKEFILE_RES_COMPILERS
2008-10-08 12:32:41 -04:00
dnl OBJCFLAGS is set by Autoconf, but OBJCXXFLAGS is not:
AC_SUBST(OBJCXXFLAGS)
2011-02-03 10:02:45 -05:00
BAKEFILE_BAKEFILE_M4_VERSION="0.2.9"
2007-03-07 16:50:47 -05:00
2005-09-18 09:24:14 -04:00
dnl includes autoconf_inc.m4:
$1
2007-03-07 16:50:47 -05:00
2005-09-18 09:24:14 -04:00
if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then
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)?])
fi
2007-03-07 16:50:47 -05:00
2005-09-18 09:24:14 -04:00
if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
fi
])
2007-03-07 16:50:47 -05:00
2005-09-18 09:24:14 -04:00
dnl ---------------------------------------------------------------------------
dnl Embedded copies of helper scripts follow:
dnl ---------------------------------------------------------------------------
AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
[
dnl ===================== bk-deps begins here =====================
dnl (Created by merge-scripts.py from bk-deps
dnl file do not edit here!)
D='$'
cat <<EOF >bk-deps
#!/bin/sh
2008-02-04 08:21:23 -05:00
# This script is part of Bakefile (http://www.bakefile.org) autoconf
2005-09-18 09:24:14 -04:00
# script. It is used to track C/C++ files dependencies in portable way.
#
# Permission is given to use this file in any way.
DEPSMODE=${DEPSMODE}
DEPSFLAG="${DEPSFLAG}"
2008-10-08 12:32:41 -04:00
DEPSDIRBASE=.deps
2005-09-18 09:24:14 -04:00
if test ${D}DEPSMODE = gcc ; then
${D}* ${D}{DEPSFLAG}
status=${D}?
2008-02-04 08:21:23 -05:00
# determine location of created files:
2005-09-18 09:24:14 -04:00
while test ${D}# -gt 0; do
case "${D}1" in
-o )
shift
objfile=${D}1
;;
-* )
;;
* )
srcfile=${D}1
;;
esac
shift
done
2008-10-08 12:32:41 -04:00
objfilebase=\`basename ${D}objfile\`
builddir=\`dirname ${D}objfile\`
2005-09-18 09:24:14 -04:00
depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
2008-10-08 12:32:41 -04:00
depsdir=${D}builddir/${D}DEPSDIRBASE
mkdir -p ${D}depsdir
2008-02-04 08:21:23 -05:00
# if the compiler failed, we're done:
if test ${D}{status} != 0 ; then
rm -f ${D}depfile
exit ${D}{status}
fi
# move created file to the location we want it in:
2005-09-18 09:24:14 -04:00
if test -f ${D}depfile ; then
2008-10-08 12:32:41 -04:00
sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
2005-09-18 09:24:14 -04:00
rm -f ${D}depfile
else
2005-10-08 11:33:10 -04:00
# "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d
2008-10-08 12:32:41 -04:00
depfile=\`echo "${D}objfile" | sed -e 's/\\..*${D}/.d/g'\`
2005-10-08 11:33:10 -04:00
if test ! -f ${D}depfile ; then
# "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++)
depfile="${D}objfile.d"
fi
2005-09-18 09:24:14 -04:00
if test -f ${D}depfile ; then
2008-10-08 12:32:41 -04:00
sed -e "\\,^${D}objfile,!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
2005-09-18 09:24:14 -04:00
rm -f ${D}depfile
fi
fi
exit 0
2008-10-08 12:32:41 -04:00
2005-09-18 09:24:14 -04:00
elif test ${D}DEPSMODE = mwcc ; then
2005-09-18 20:26:53 -04:00
${D}* || exit ${D}?
2005-09-18 09:24:14 -04:00
# Run mwcc again with -MM and redirect into the dep file we want
# NOTE: We can't use shift here because we need ${D}* to be valid
prevarg=
for arg in ${D}* ; do
if test "${D}prevarg" = "-o"; then
objfile=${D}arg
else
case "${D}arg" in
-* )
;;
* )
srcfile=${D}arg
;;
esac
fi
prevarg="${D}arg"
done
2008-11-17 17:29:05 -05:00
2008-10-08 12:32:41 -04:00
objfilebase=\`basename ${D}objfile\`
builddir=\`dirname ${D}objfile\`
depsdir=${D}builddir/${D}DEPSDIRBASE
mkdir -p ${D}depsdir
${D}* ${D}DEPSFLAG >${D}{depsdir}/${D}{objfilebase}.d
2005-09-18 09:24:14 -04:00
exit 0
2008-10-08 12:32:41 -04:00
2005-09-18 09:24:14 -04:00
elif test ${D}DEPSMODE = unixcc; then
2005-09-18 20:26:53 -04:00
${D}* || exit ${D}?
2005-09-18 09:24:14 -04:00
# Run compiler again with deps flag and redirect into the dep file.
# It doesn't work if the '-o FILE' option is used, but without it the
# dependency file will contain the wrong name for the object. So it is
# removed from the command line, and the dep file is fixed with sed.
cmd=""
while test ${D}# -gt 0; do
case "${D}1" in
-o )
shift
objfile=${D}1
;;
* )
eval arg${D}#=\\${D}1
cmd="${D}cmd \\${D}arg${D}#"
;;
esac
shift
done
2008-11-17 17:29:05 -05:00
2008-10-08 12:32:41 -04:00
objfilebase=\`basename ${D}objfile\`
builddir=\`dirname ${D}objfile\`
depsdir=${D}builddir/${D}DEPSDIRBASE
mkdir -p ${D}depsdir
2008-11-17 17:29:05 -05:00
2008-11-12 06:54:41 -05:00
eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{depsdir}/${D}{objfilebase}.d
2005-09-18 09:24:14 -04:00
exit 0
2008-10-08 12:32:41 -04:00
2005-09-18 09:24:14 -04:00
else
${D}*
exit ${D}?
fi
EOF
dnl ===================== bk-deps ends here =====================
])
AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
[
dnl ===================== shared-ld-sh begins here =====================
dnl (Created by merge-scripts.py from shared-ld-sh
dnl file do not edit here!)
D='$'
cat <<EOF >shared-ld-sh
#!/bin/sh
#-----------------------------------------------------------------------------
#-- Name: distrib/mac/shared-ld-sh
#-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
#-- Author: Gilles Depeyrot
#-- Copyright: (c) 2002 Gilles Depeyrot
#-- Licence: any use permitted
#-----------------------------------------------------------------------------
verbose=0
args=""
objects=""
linking_flag="-dynamiclib"
ldargs="-r -keep_private_externs -nostdlib"
2008-02-04 08:21:23 -05:00
if test "x${D}CXX" = "x"; then
CXX="c++"
fi
2005-09-18 09:24:14 -04:00
while test ${D}# -gt 0; do
case ${D}1 in
-v)
verbose=1
;;
-o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
# collect these options and values
args="${D}{args} ${D}1 ${D}2"
shift
;;
2008-02-04 08:21:23 -05:00
-arch|-isysroot)
# collect these options and values
ldargs="${D}{ldargs} ${D}1 ${D}2"
shift
;;
2007-03-07 16:50:47 -05:00
2005-09-18 09:24:14 -04:00
-s|-Wl,*)
# collect these load args
ldargs="${D}{ldargs} ${D}1"
;;
-l*|-L*|-flat_namespace|-headerpad_max_install_names)
# collect these options
args="${D}{args} ${D}1"
;;
-dynamiclib|-bundle)
linking_flag="${D}1"
;;
-*)
echo "shared-ld: unhandled option '${D}1'"
exit 1
;;
*.o | *.a | *.dylib)
# collect object files
objects="${D}{objects} ${D}1"
;;
*)
echo "shared-ld: unhandled argument '${D}1'"
exit 1
;;
esac
shift
done
status=0
#
# Link one module containing all the others
#
if test ${D}{verbose} = 1; then
2008-02-04 08:21:23 -05:00
echo "${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o"
2005-09-18 09:24:14 -04:00
fi
2008-02-04 08:21:23 -05:00
${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o
2005-09-18 09:24:14 -04:00
status=${D}?
#
# Link the shared library from the single module created, but only if the
# previous command didn't fail:
#
if test ${D}{status} = 0; then
if test ${D}{verbose} = 1; then
2008-02-04 08:21:23 -05:00
echo "${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
2005-09-18 09:24:14 -04:00
fi
2008-02-04 08:21:23 -05:00
${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}
2005-09-18 09:24:14 -04:00
status=${D}?
fi
#
# Remove intermediate module
#
rm -f master.${D}${D}.o
exit ${D}status
EOF
dnl ===================== shared-ld-sh ends here =====================
])
AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
[
dnl ===================== bk-make-pch begins here =====================
dnl (Created by merge-scripts.py from bk-make-pch
dnl file do not edit here!)
D='$'
cat <<EOF >bk-make-pch
#!/bin/sh
2008-02-04 08:21:23 -05:00
# This script is part of Bakefile (http://www.bakefile.org) autoconf
2005-09-18 09:24:14 -04:00
# script. It is used to generated precompiled headers.
#
# Permission is given to use this file in any way.
outfile="${D}{1}"
header="${D}{2}"
shift
shift
2008-10-08 12:32:41 -04:00
builddir=\`echo ${D}outfile | sed -e 's,/\\.pch/.*${D},,g'\`
2006-02-10 15:15:08 -05:00
compiler=""
headerfile=""
2005-09-18 09:24:14 -04:00
while test ${D}{#} -gt 0; do
2006-02-10 15:15:08 -05:00
add_to_cmdline=1
2005-09-18 09:24:14 -04:00
case "${D}{1}" in
-I* )
incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
headerfile="${D}{incdir}/${D}{header}"
fi
;;
2008-11-17 17:29:05 -05:00
-use-pch|-use_pch|-pch-use )
2006-02-10 15:15:08 -05:00
shift
add_to_cmdline=0
;;
2005-09-18 09:24:14 -04:00
esac
2006-02-10 15:15:08 -05:00
if test ${D}add_to_cmdline = 1 ; then
compiler="${D}{compiler} ${D}{1}"
fi
2005-09-18 09:24:14 -04:00
shift
done
if test "x${D}{headerfile}" = "x" ; then
2006-02-10 15:15:08 -05:00
echo "error: can't find header ${D}{header} in include paths" >&2
2005-09-18 09:24:14 -04:00
else
if test -f ${D}{outfile} ; then
rm -f ${D}{outfile}
else
mkdir -p \`dirname ${D}{outfile}\`
fi
2008-10-08 12:32:41 -04:00
depsfile="${D}{builddir}/.deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
mkdir -p ${D}{builddir}/.deps
2006-02-10 15:15:08 -05:00
if test "x${GCC_PCH}" = "x1" ; then
# can do this because gcc is >= 3.4:
${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
elif test "x${ICC_PCH}" = "x1" ; then
filename=pch_gen-${D}${D}
file=${D}{filename}.c
dfile=${D}{filename}.d
cat > ${D}file <<EOT
#include "${D}header"
EOT
# using -MF icc complains about differing command lines in creation/use
2008-11-17 17:29:05 -05:00
${D}compiler -c ${ICC_PCH_CREATE_SWITCH} ${D}outfile -MMD ${D}file && \\
2006-02-10 15:15:08 -05:00
sed -e "s,^.*:,${D}outfile:," -e "s, ${D}file,," < ${D}dfile > ${D}depsfile && \\
rm -f ${D}file ${D}dfile ${D}{filename}.o
fi
2005-09-18 09:24:14 -04:00
exit ${D}{?}
fi
EOF
dnl ===================== bk-make-pch ends here =====================
])