Revision: 15 http://trac.macosforge.org/projects/libdispatch/changeset/15 Author: robert@fledge.watson.org Date: 2009-09-12 16:19:33 -0700 (Sat, 12 Sep 2009) Log Message: ----------- Add a first cut at an autoconf/automake/libtool-based build system for libdispatch. Test for various Mac OS X and FreeBSD features and define config.h variables as needed. Note: this commit does not include source code changes to use these variables. Added Paths: ----------- trunk/Makefile.am trunk/autogen.sh trunk/config/ trunk/configure.ac trunk/src/Makefile.am Added: trunk/Makefile.am =================================================================== --- trunk/Makefile.am (rev 0) +++ trunk/Makefile.am 2009-09-12 23:19:33 UTC (rev 15) @@ -0,0 +1,6 @@ +# +# +# + +SUBDIRS= \ + src Added: trunk/autogen.sh =================================================================== --- trunk/autogen.sh (rev 0) +++ trunk/autogen.sh 2009-09-12 23:19:33 UTC (rev 15) @@ -0,0 +1,10 @@ +#!/bin/sh +# +# +# +libtoolize --copy --force +aclocal +autoheader +automake -a -c --foreign +autoconf + Added: trunk/configure.ac =================================================================== --- trunk/configure.ac (rev 0) +++ trunk/configure.ac 2009-09-12 23:19:33 UTC (rev 15) @@ -0,0 +1,103 @@ +# +# When this file changes, rerun autogen.sh. +# + +AC_PREREQ(2.59) +AC_INIT([libdispatch], [1.0], [libdispatch-dev@lists.macosforge.org], + [libdispatch]) +AC_REVISION([$$]) +AC_CONFIG_AUX_DIR(config) +AC_CONFIG_HEADER([config/config.h]) +AM_MAINTAINER_MODE + +# +# 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) + ] +) +AM_CONDITIONAL(USE_LEGACY_API, $use_legacy_api) + +# +# libdispatch has micro-optimized and deeply personal knowledge of the 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_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) + ],[] +) + +AC_PROG_CC +AC_PROG_INSTALL +AC_PROG_LIBTOOL + +AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) + +# +# Find libraries we will need +# +AC_SEARCH_LIBS(clock_gettime, rt) +AC_SEARCH_LIBS(pthread_create, pthread, [ + use_libpthread=true + ],[ + use_libpthread=false + ] +) +AM_CONDITIONAL(USE_LIBPTHREAD, $use_libpthread) + +# +# Checks for header files. +# +AC_HEADER_STDC +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) +]) + +# +# Find functions we care about. +# +AC_CHECK_FUNC([pthread_key_init_np],[ + AC_DEFINE(HAVE_PTHREAD_KEY_INIT_NP,,Define if can use preinitialized keys) +]) +AC_CHECK_FUNC([mach_absolute_time],[ + AC_DEFINE(HAVE_MACH_ABSOLUTE_TIME,,Define if mach_absolute_time present) +]) +AC_CHECK_FUNC([pthread_workqueue_attr_init_np],[ + AC_DEFINE(HAVE_PTHREAD_WORKQUEUE,,Define if pthread workqueues implemented) +]) +AC_CHECK_FUNC([malloc_create_zone],[ + AC_DEFINE(HAVE_MALLOC_ZONES,,Define if malloc zones implemented) +]) +AC_CHECK_FUNC([sem_init],[ + AC_DEFINE(HAVE_POSIX_SEM,,Define if POSIX semaphores implemented) +]) + +# +# Generate Makefiles. +# +AC_CONFIG_FILES([Makefile src/Makefile]) +AC_OUTPUT Added: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am (rev 0) +++ trunk/src/Makefile.am 2009-09-12 23:19:33 UTC (rev 15) @@ -0,0 +1,44 @@ +# +# +# + +lib_LTLIBRARIES=libdispatch.la + +libdispatch_la_SOURCES= \ + apply.c \ + benchmark.c \ + object.c \ + once.c \ + queue.c \ + semaphore.c \ + shims.c \ + source.c \ + time.c + +libdispatch_la_CFLAGS=-Wall -Werror + +# +# This will need some refinement: gcc requires a minimum of -march=i486 on +# x86 in order to implement built-in atomic operations. But when should we +# define this optional argument? We need appropriate configure parts to make +# this conditional. +# +libdispatch_la_CFLAGS+=-march=i686 + +if USE_LEGACY_API +libdispatch_la_SOURCES+= \ + legacy.c +libdispatch_la_CFLAGS+=-DDISPATCH_NO_LEGACY +endif + +if USE_LIBPTHREAD +libdispatch_la_LIBADD=-lpthread +endif + +# +# This hack is needed because the default include line from automake will add +# -I. to compiler commands. That leads to the local semaphore.h overriding +# the one in /usr/local on systems using POSIX semaphores. We can remove +# this hack once header files are moved to their own directory. +# +DEFAULT_INCLUDES = @am__isrc@ -I.. -I$(top_builddir)/config