dnl $Id$
builtin(include,m4/tcl.m4)
builtin(include,m4/objc.m4)
builtin(include,m4/pthread.m4)
builtin(include,m4/foundation.m4)
#------------------------------------------------------------------------
# MP_CHECK_FRAMEWORK_COREFOUNDATION --
#
# Check if CoreFoundation framework is available, define HAVE_FRAMEWORK_COREFOUNDATION if so.
#
# Arguments:
# None.
#
# Requires:
# None.
#
# Depends:
# AC_LANG_PROGRAM
#
# Results:
# Result is cached.
#
# If CoreFoundation framework is available, defines the following variables:
# HAVE_FRAMEWORK_COREFOUNDATION
#
#------------------------------------------------------------------------
AC_DEFUN(MP_CHECK_FRAMEWORK_COREFOUNDATION, [
FRAMEWORK_LIBS="-framework CoreFoundation"
AC_MSG_CHECKING([for CoreFoundation framework])
AC_CACHE_VAL(mp_cv_have_framework_corefoundation, [
ac_save_LIBS="$LIBS"
LIBS="$FRAMEWORK_LIBS $LIBS"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include <CoreFoundation/CoreFoundation.h>
], [
CFURLRef url = CFURLCreateWithFileSystemPath(NULL, CFSTR("/testing"), kCFURLPOSIXPathStyle, 1);
CFArrayRef bundles = CFBundleCreateBundlesFromDirectory(NULL, url, CFSTR("pkg"));
])
], [
mp_cv_have_framework_corefoundation="yes"
], [
mp_cv_have_framework_corefoundation="no"
]
)
LIBS="$ac_save_LIBS"
])
AC_MSG_RESULT(${mp_cv_have_framework_corefoundation})
if test x"${mp_cv_have_framework_corefoundation}" = "xyes"; then
AC_DEFINE([HAVE_FRAMEWORK_COREFOUNDATION], [], [Define if CoreFoundation framework is available])
fi
AC_SUBST(HAVE_FRAMEWORK_COREFOUNDATION)
])
#------------------------------------------------------------------------
# MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER --
#
# Check if if the routine CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER
# is available in CoreFoundation.
#
# Arguments:
# None.
#
# Requires:
# None.
#
# Depends:
# AC_LANG_PROGRAM
#
# Results:
# Result is cached.
#
# If function CFNotificationCenterGetDarwinNotifyCenter is in the CoreFoundation framework, defines the following variables:
# HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER
#
#------------------------------------------------------------------------
AC_DEFUN(MP_CHECK_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER, [
FRAMEWORK_LIBS="-framework CoreFoundation"
AC_MSG_CHECKING([for CFNotificationCenterGetDarwinNotifyCenter])
AC_CACHE_VAL(mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter, [
ac_save_LIBS="$LIBS"
LIBS="$FRAMEWORK_LIBS $LIBS"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include <CoreFoundation/CoreFoundation.h>
], [
CFNotificationCenterRef ref = CFNotificationCenterGetDarwinNotifyCenter();
])
], [
mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter="yes"
], [
mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter="no"
]
)
LIBS="$ac_save_LIBS"
])
AC_MSG_RESULT(${mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter})
if test x"${mp_cv_have_function_cfnotificationcentergetdarwinnotifycenter}" = "xyes"; then
AC_DEFINE([HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER], [], [Define if function CFNotificationCenterGetDarwinNotifyCenter in CoreFoundation framework])
fi
AC_SUBST(HAVE_FUNCTION_CFNOTIFICATIONCENTERGETDARWINNOTIFYCENTER)
])
#------------------------------------------------------------------------
# MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION --
#
# Check if SystemConfiguration framework is available, define HAVE_FRAMEWORK_SYSTEMCONFIGURATION if so.
#
# Arguments:
# None.
#
# Requires:
# None.
#
# Depends:
# AC_LANG_PROGRAM
#
# Results:
# Result is cached.
#
# If SystemConfiguration framework is available, defines the following variables:
# HAVE_FRAMEWORK_SYSTEMCONFIGURATION
#
#------------------------------------------------------------------------
AC_DEFUN(MP_CHECK_FRAMEWORK_SYSTEMCONFIGURATION, [
FRAMEWORK_LIBS="-framework SystemConfiguration"
AC_MSG_CHECKING([for SystemConfiguration framework])
AC_CACHE_VAL(mp_cv_have_framework_systemconfiguration, [
ac_save_LIBS="$LIBS"
LIBS="$FRAMEWORK_LIBS $LIBS"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include <SystemConfiguration/SystemConfiguration.h>
], [
int err = SCError();
SCDynamicStoreRef dsRef = SCDynamicStoreCreate(NULL, NULL, NULL, NULL);
])
], [
mp_cv_have_framework_systemconfiguration="yes"
], [
mp_cv_have_framework_systemconfiguration="no"
]
)
LIBS="$ac_save_LIBS"
])
AC_MSG_RESULT(${mp_cv_have_framework_systemconfiguration})
if test x"${mp_cv_have_framework_systemconfiguration}" = "xyes"; then
AC_DEFINE([HAVE_FRAMEWORK_SYSTEMCONFIGURATION], [], [Define if SystemConfiguration framework is available])
fi
AC_SUBST(HAVE_FRAMEWORK_SYSTEMCONFIGURATION)
])
#------------------------------------------------------------------------
# MP_CHECK_FRAMEWORK_IOKIT --
#
# Check if IOKit framework is available, define HAVE_FRAMEWORK_IOKIT if so.
#
# Arguments:
# None.
#
# Requires:
# None.
#
# Depends:
# AC_LANG_PROGRAM
#
# Results:
# Result is cached.
#
# If IOKit framework is available, defines the following variables:
# HAVE_FRAMEWORK_IOKIT
#
#------------------------------------------------------------------------
AC_DEFUN(MP_CHECK_FRAMEWORK_IOKIT, [
FRAMEWORK_LIBS="-framework IOKit"
AC_MSG_CHECKING([for IOKit framework])
AC_CACHE_VAL(mp_cv_have_framework_iokit, [
ac_save_LIBS="$LIBS"
LIBS="$FRAMEWORK_LIBS $LIBS"
AC_LINK_IFELSE([
AC_LANG_PROGRAM([
#include <IOKit/IOKitLib.h>
], [
IOCreateReceivePort(0, NULL);
IORegisterForSystemPower(0, NULL, NULL, NULL);
])
], [
mp_cv_have_framework_iokit="yes"
], [
mp_cv_have_framework_iokit="no"
]
)
LIBS="$ac_save_LIBS"
])
AC_MSG_RESULT(${mp_cv_have_framework_iokit})
if test x"${mp_cv_have_framework_iokit}" = "xyes"; then
AC_DEFINE([HAVE_FRAMEWORK_IOKIT], [], [Define if IOKit framework is available])
fi
AC_SUBST(HAVE_FRAMEWORK_IOKIT)
])
dnl This macro checks if the user specified a ports tree
dnl explicitly. If not, search for it
# MP_PATH_PORTSDIR(DEFAULT_PORTSDIR)
#---------------------------------------
AC_DEFUN([MP_PATH_PORTSDIR],[
dnl For ease of reading, run after gcc has been found/configured
AC_REQUIRE([AC_PROG_CC])
AC_ARG_WITH(ports-dir, [AC_HELP_STRING([--with-ports-dir=DIR], [Specify alternate ports directory])], [ portsdir="$withval" ] )
AC_MSG_CHECKING([for ports tree])
if test "x$portsdir" != "x" ; then
if test -d "$portsdir" -a -e "$portsdir/PortIndex" ; then
:
else
AC_MSG_ERROR([$portsdir not a valid ports tree])
fi
else
dnl If the user didn't give a path, look for default
if test "x$1" != "x" ; then
if test -d "$1" -a -e "$1/PortIndex" ; then
portsdir=$1
fi
fi
fi
if test "x$portsdir" != "x" ; then
AC_MSG_RESULT($portsdir)
PORTSDIR="$portsdir"
AC_SUBST(PORTSDIR)
else
AC_MSG_WARN([No ports tree found])
fi
])
# MP_PATH_MPCONFIGDIR
#---------------------------------------
AC_DEFUN([MP_PATH_MPCONFIGDIR],[
dnl if the user actually specified --prefix, shift
dnl mpconfigdir to $prefix/etc/macports
dnl AC_REQUIRE([MP_PATH_PORTSDIR])
AC_MSG_CHECKING([for MacPorts config directory])
mpconfigdir='${sysconfdir}/macports'
AC_MSG_RESULT([$mpconfigdir])
MPCONFIGDIR="$mpconfigdir"
AC_SUBST(MPCONFIGDIR)
])
# MP_CHECK_INSTALLUSER
#-------------------------------------------------
AC_DEFUN([MP_CHECK_INSTALLUSER],[
dnl if with user specifies --with-install-user,
dnl use it. otherwise default to platform defaults
AC_REQUIRE([MP_PATH_MPCONFIGDIR])
AC_ARG_WITH(install-user, [AC_HELP_STRING([--with-install-user=USER], [Specify user ownership of installed files])], [ DSTUSR=$withval ] )
AC_MSG_CHECKING([for install user])
if test "x$DSTUSR" = "x" ; then
DSTUSR=root
fi
AC_MSG_RESULT([$DSTUSR])
AC_SUBST(DSTUSR)
])
# MP_CHECK_INSTALLGROUP
#-------------------------------------------------
AC_DEFUN([MP_CHECK_INSTALLGROUP],[
dnl if with user specifies --with-install-group,
dnl use it. otherwise default to platform defaults
AC_REQUIRE([MP_CHECK_INSTALLUSER])
AC_ARG_WITH(install-group, [AC_HELP_STRING([--with-install-group=GROUP], [Specify group ownership of installed files])], [ DSTGRP=$withval ] )
AC_MSG_CHECKING([for install group])
if test "x$DSTGRP" = "x" ; then
case $host_os in
darwin*)
DSTGRP="admin"
;;
freebsd*)
DSTGRP="wheel"
;;
linux*)
DSTGRP="root"
;;
*)
DSTGRP="wheel"
;;
esac
fi
AC_MSG_RESULT([$DSTGRP])
AC_SUBST(DSTGRP)
])
# MP_DIRECTORY_MODE
#-------------------------------------------------
AC_DEFUN([MP_DIRECTORY_MODE],[
dnl if with user specifies --with-directory-mode,
dnl use the specified permissions for ${prefix} directories
dnl otherwise use 0755
AC_REQUIRE([MP_PATH_MPCONFIGDIR])
AC_ARG_WITH(directory-mode, [AC_HELP_STRING([--with-directory-mode=MODE], [Specify directory mode of installed directories])], [ DSTMODE=$withval ] )
AC_MSG_CHECKING([what permissions to use for installation directories])
if test "x$DSTMODE" = "x" ; then
DSTMODE=0755
fi
AC_MSG_RESULT([$DSTMODE])
AC_SUBST(DSTMODE)
])
# MP_PATH_APPLICATIONS
#---------------------------------------
AC_DEFUN([MP_PATH_APPLICATIONS],[
AC_REQUIRE([MP_CHECK_INSTALLUSER])
AC_ARG_WITH(applications-dir,[AC_HELP_STRING([--with-applications-dir], [Applications installation directory.])], MPAPPLICATIONSDIR=${withval})
AC_MSG_CHECKING([for Applications installation directory])
if test "x$MPAPPLICATIONSDIR" = "x" ; then
if test "$DSTUSR" = "root" ; then
MPAPPLICATIONSDIR="/Applications/MacPorts"
else
MPAPPLICATIONSDIR="~$DSTUSR/Applications/MacPorts"
fi
fi
AC_MSG_RESULT([$MPAPPLICATIONSDIR])
AC_SUBST(MPAPPLICATIONSDIR)
])
# MP_PATH_FRAMEWORKS
#---------------------------------------
AC_DEFUN([MP_PATH_FRAMEWORKS],[
AC_REQUIRE([MP_CHECK_INSTALLUSER])
AC_ARG_WITH(frameworks-dir,[AC_HELP_STRING([--with-frameworks-dir], [Frameworks installation directory.])], MPFRAMEWORKSDIR=${withval})
AC_MSG_CHECKING([for Frameworks installation directory])
if test "x$MPFRAMEWORKSDIR" = "x" ; then
if test "$DSTUSR" = "root" ; then
MPFRAMEWORKSDIR="/Library/Frameworks"
else
MPFRAMEWORKSDIR="~$DSTUSR/Library/Frameworks"
fi
fi
AC_MSG_RESULT([$MPFRAMEWORKSDIR])
AC_SUBST(MPFRAMEWORKSDIR)
])
# MP_UNIVERSAL_OPTIONS
#---------------------------------------
AC_DEFUN([MP_UNIVERSAL_OPTIONS],[
AC_ARG_WITH(universal-target,[AC_HELP_STRING([--with-universal-target=MDT], [Universal MACOSX_DEPLOYMENT_TARGET version])], UNIVERSAL_TARGET=${withval})
AC_ARG_WITH(universal-sysroot,[AC_HELP_STRING([--with-universal-sysroot=SDK], [Universal SDK sysroot (with complete path)])], UNIVERSAL_SYSROOT=${withval})
AC_ARG_WITH(universal-archs,[AC_HELP_STRING([--with-universal-archs="CPU"], [Universal CPU architectures (space separated)])], UNIVERSAL_ARCHS=${withval})
if test "x$UNIVERSAL_TARGET" = "x"; then
if [test -d /Developer/SDKs/MacOSX10.5.sdk]; then
UNIVERSAL_TARGET=10.5
UNIVERSAL_SYSROOT=/Developer/SDKs/MacOSX10.5.sdk
else
UNIVERSAL_TARGET=10.4
UNIVERSAL_SYSROOT=/Developer/SDKs/MacOSX10.4u.sdk
fi
else
if test "x$UNIVERSAL_SYSROOT" = "x"; then
UNIVERSAL_SYSROOT=/Developer/SDKs/MacOSX${UNIVERSAL_TARGET}.sdk
fi
fi
if test "x$UNIVERSAL_ARCHS" = "x"; then
#UNIVERSAL_ARCHS="ppc ppc64 i386 x86_64"
UNIVERSAL_ARCHS="ppc i386"
fi
AC_MSG_CHECKING([for Universal MDT version])
AC_MSG_RESULT([$UNIVERSAL_TARGET])
AC_SUBST(UNIVERSAL_TARGET)
AC_MSG_CHECKING([for Universal SDK sysroot])
AC_MSG_RESULT([$UNIVERSAL_SYSROOT])
AC_SUBST(UNIVERSAL_SYSROOT)
AC_MSG_CHECKING([for Universal CPU architectures])
AC_MSG_RESULT([$UNIVERSAL_ARCHS])
AC_SUBST(UNIVERSAL_ARCHS)
])
# MP_LIB_MD5
#---------------------------------------
# Check for an md5 implementation
AC_DEFUN([MP_LIB_MD5],[
# Check for libmd, which is prefered
AC_CHECK_LIB([md], [MD5Update],[
AC_CHECK_HEADERS([md5.h], ,[
case $host_os in
darwin*)
AC_MSG_NOTICE([Please install the BSD SDK package from the Xcode Developer Tools CD.])
;;
*)
AC_MSG_NOTICE([Please install the libmd developer headers for your platform.])
;;
esac
AC_MSG_ERROR([libmd was found, but md5.h is missing.])
])
AC_DEFINE([HAVE_LIBMD], ,[Define if you have the `md' library (-lmd).])
MD5_LIBS="-lmd"]
)
if test "x$MD5_LIBS" = "x" ; then
# If libmd is not found, check for libcrypto from OpenSSL
AC_CHECK_LIB([crypto], [MD5_Update],[
AC_CHECK_HEADERS([openssl/md5.h],,[
case $host_os in
darwin*)
AC_MSG_NOTICE([Please install the BSD SDK package from the Xcode Developer Tools CD.])
;;
*)
AC_MSG_NOTICE([Please install the libmd developer headers for your platform.])
;;
esac
AC_MSG_ERROR([libcrypt was found, but header file openssl/md5.h is missing.])
])
AC_DEFINE([HAVE_LIBCRYPTO],,[Define if you have the `crypto' library (-lcrypto).])
MD5_LIBS="-lcrypto"
], [
AC_MSG_ERROR([Neither OpenSSL or libmd were found. A working md5 implementation is required.])
])
fi
if test "x$MD5_LIBS" = "x"; then
AC_MSG_ERROR([Neither OpenSSL or libmd were found. A working md5 implementation is required.])
fi
AC_SUBST([MD5_LIBS])
])
dnl This macro checks for X11 presence. If the libraries are
dnl present, so must the headers be. If nothing is present,
dnl print a warning
# MP_CHECK_X11
# ---------------------
AC_DEFUN([MP_CHECK_X11], [
# work around symbolic X11 link in /usr/include by providing explicit defaults
case "$host" in
*-*-darwin9*)
if test "x$x_includes" = xNONE && test "x$x_libraries" = xNONE; then
x_includes="/usr/X11/include"
x_libraries="/usr/X11/lib"