Revision
24
Author
robert@fledge.watson.org
Date
2009-09-14 09:32:24 -0700 (Mon, 14 Sep 2009)

Log Message

Add configure options to point the build at Apple libc and XNU source,
required to find private headers on Mac OS X.

Use AC_ARG_ENABLE instead of AC_ARG_WITH for functional frobs, such as
legacy API, libdispatch_init constructor tagging, Apple-specific TSD
and semaphore optimizations, as well as new settings such as the use of
crashreporter_info.

Locate MIG on Mac OS X, as we need it to build protocols.def.

Use pthread_workqueue.h to decide whether to define
HAVE_PTHREAD_WORKQUEUES.  We may want to offer a --disable frob for this
on Mac OS X.

Modified Paths

Diff

Modified: trunk/configure.ac (23 => 24)


--- trunk/configure.ac	2009-09-14 11:49:45 UTC (rev 23)
+++ trunk/configure.ac	2009-09-14 16:32:24 UTC (rev 24)
@@ -10,15 +10,37 @@
 AM_MAINTAINER_MODE
 
 #
+# On Mac OS X, some required header files come from other source packages;
+# allow specifying where those are.
+#
+AC_ARG_WITH([apple-libc-source],
+  [AS_HELP_STRING([--with-apple-libc-source],
+    [Specify path to Apple Libc source])],
+  [APPLE_LIBC_SOURCE_PATH=-I${withval}/pthreads],
+  [APPLE_LIBC_SOURCE_PATH=]
+)
+AC_SUBST([APPLE_LIBC_SOURCE_PATH])
+
+AC_ARG_WITH([apple-xnu-source],
+  [AS_HELP_STRING([--with-apple-xnu-source],
+    [Specify path to Apple XNU source])],
+  [APPLE_XNU_SOURCE_PATH=-I${withval}/libkern ],
+  [APPLE_XNU_SOURCE_PATH=]
+)
+AC_SUBST([APPLE_XNU_SOURCE_PATH])
+
+#
 # Try to build the legacy API only if specifically requested.
 #
-AC_ARG_WITH([legacy-api],
-  [AS_HELP_STRING([--with-legacy-api],
-    [Support historic (deprecated) Apple API in libdispatch.])
-  ],[],[
-    use_legacy_api=false
-    AC_DEFINE(DISPATCH_NO_LEGACY,,Define to compile out legacy API)
-  ])
+AC_ARG_ENABLE([legacy-api],
+  [AS_HELP_STRING([--enable-legacy-api], [Enable legacy (deprecated) API.])]
+)
+
+AS_IF([test "x$enable_legacy_api" != "xyes"],
+  [use_legacy_api=false
+    AC_DEFINE(DISPATCH_NO_LEGACY,,[Define to compile out legacy API])],
+  [use_legacy_api=true]
+)
 AM_CONDITIONAL(USE_LEGACY_API, $use_legacy_api)
 
 #
@@ -26,36 +48,59 @@
 # libsyscall process setup.  On other systems, it is tagged as a library
 # constructor to be run by automatically by the runtime linker.
 #
-AC_ARG_WITH([libdispatch-init-constructor],
-  [AS_HELP_STRING([--without-libdispatch-init-constructor],
-    [Don't tag libdispatch_init as a constructor])
-  ],[],[
-    AC_DEFINE(USE_LIBDISPATCH_INIT_CONSTRUCTOR,,Define to tag libdispatch_init as a constructor)
-  ])
+AC_ARG_ENABLE([libdispatch-init-constructor],
+  [AS_HELP_STRING([--disable-libdispatch-init-constructor],
+    [Disable libdispatch_init as a constructor])]
+)
 
+AS_IF([test "x$enable_libdispatch_init_constructor" != "xno"],
+  [AC_DEFINE(USE_LIBDISPATCH_INIT_CONSTRUCTOR,,
+    [Define to tag libdispatch_init as a constructor])]
+)
+
 #
-# libdispatch has micro-optimized and deeply personal knowledge of the Mac OS
+# Whether or not to include/reference a crashreporter symbol.
+#
+AC_ARG_ENABLE([apple-crashreporter-info],
+  [AS_HELP_STRING([--enable-apple-crashreporter-info],
+    [Use Mac OS X crashreporter info])]
+)
+
+AS_IF([test "x$enable_apple_crashreporter_info" = "xyes"],
+  [AC_DEFINE(USE_APPLE_CRASHREPORTER_INFO,,
+    [Define to use Mac OS X crashreporter info])]
+)
+
+#
+# libdispatch has micro-optimized and deeply personal knowledge of Mac OS
 # implementation details.  Only enable this if explicitly requested, as it
 # will lead to data corruption if applied on systems violating its
 # expectations.
 #
-AC_ARG_WITH([apple-tsd-optimizations],
-  [AS_HELP_STRING([--with-apple-tsd-optimizations],
-    [Use less portable pthread TSD optimizations for Mac OS X.])
-  ],[
-    AC_DEFINE(USE_APPLE_TSD_OPTIMIZATIONS,,Define to compile in tsd optimizations)
-  ],[])
+AC_ARG_ENABLE([apple-tsd-optimizations],
+  [AS_HELP_STRING([--enable-apple-tsd-optimizations],
+    [Use non-portable pthread TSD optimizations for Mac OS X.])]
+)
 
-AC_ARG_WITH([apple-semaphore-optimizations],
-  [AS_HELP_STRING([--with-apple-semaphore-optimizations],
-    [Use less portable semaphore optimizations for Mac OS X.])
-  ],[
-    AC_DEFINE(USE_APPLE_SEMAPHORE_OPTIMIZATIONS,,Define to compile in semaphore optimizations)
-  ],[])
+AS_IF([test "x$enable_apple_tsd_optimizations" = "xyes"],
+  [AC_DEFINE(USE_APPLE_TSD_OPTIMIZATIONS,,
+    [Define to use non-portable pthread TSD optimizations for Mac OS X)])]
+)
 
+AC_ARG_ENABLE([apple-semaphore-optimizations],
+  [AS_HELP_STRING([--enable-apple-semaphore-optimizations],
+    [Use non-portable semaphore optimizations for Mac OS X.])]
+)
+
+AS_IF([test "x$enable_apple_semaphore_optimizations" = "xyes"],
+  [AC_DEFINE(USE_APPLE_SEMAPHORE_OPTIMIZATIONS,,
+    [Define to use non-portablesemaphore optimizations for Mac OS X])]
+)
+
 AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
+AC_PATH_PROGS(MIG, mig)
 
 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
 
@@ -63,11 +108,9 @@
 # Find libraries we will need
 #
 AC_SEARCH_LIBS(clock_gettime, rt)
-AC_SEARCH_LIBS(pthread_create, pthread, [
-    use_libpthread=true
-  ],[
-    use_libpthread=false
-  ]
+AC_SEARCH_LIBS(pthread_create, pthread,
+  [use_libpthread=true],
+  [use_libpthread=false]
 )
 AM_CONDITIONAL(USE_LIBPTHREAD, $use_libpthread)
 
@@ -75,23 +118,34 @@
 # Checks for header files.
 #
 AC_HEADER_STDC
-AC_CHECK_HEADERS([Availability.h pthread_np.h pthread_workqueue.h malloc/malloc.h])
+AC_CHECK_HEADERS([Availability.h pthread_np.h malloc/malloc.h])
 
 #
 # We use the availability of mach.h to decide whether to compile in all sorts
 # of Machisms, including using Mach ports as event sources, etc.
 #
-AC_CHECK_HEADER([mach/mach.h],[
-  AC_DEFINE(HAVE_MACH,,Define if mach is present)
-])
+AC_CHECK_HEADER([mach/mach.h],
+  [AC_DEFINE(HAVE_MACH,,Define if mach is present)
+    use_mig=true],
+  [use_mig=false]
+)
+AM_CONDITIONAL(USE_MIG, $use_mig)
 
 #
+# We use the availability of pthread_workqueue.h to decide whether to compile
+# in support for pthread work queues.
+#
+AC_CHECK_HEADER([pthread_workqueue.h],
+  [AC_DEFINE(HAVE_PTHREAD_WORKQUEUES,,Define if pthread work queues are present)]
+)
+
+#
 # Find functions and declarations we care about.
 #
 AC_CHECK_DECLS([EVFILT_SESSION, NOTE_NONE, NOTE_REAP, NOTE_SIGNAL], [], [],
   [[#include <sys/event.h>]])
 AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include <sys/mount.h>]])
-AC_CHECK_FUNCS([pthread_key_init_np mach_absolute_time pthread_workqueue_attr_init_np malloc_create_zone sem_init])
+AC_CHECK_FUNCS([pthread_key_init_np mach_absolute_time malloc_create_zone sem_init])
 
 #
 # Generate Makefiles.