Index: configure.ac =================================================================== --- configure.ac (revision 16) +++ configure.ac (working copy) @@ -19,8 +19,7 @@ ],[],[ use_legacy_api=false AC_DEFINE(DISPATCH_NO_LEGACY,,Define to compile out legacy API) - ] -) + ]) AM_CONDITIONAL(USE_LEGACY_API, $use_legacy_api) # @@ -34,22 +33,20 @@ [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) +AM_INIT_AUTOMAKE([foreign nostdinc]) # # Find libraries we will need @@ -59,8 +56,7 @@ use_libpthread=true ],[ use_libpthread=false - ] -) + ]) AM_CONDITIONAL(USE_LIBPTHREAD, $use_libpthread) # @@ -96,6 +92,23 @@ AC_DEFINE(HAVE_POSIX_SEM,,Define if POSIX semaphores implemented) ]) +if test "$GCC"="yes"; then + WARN_FLAGS="-Wall -Werror" + # If the user added -march flags, don't override them, otherwise + # set to i686 so that GCC will implement atomic builtins + case "$CC $CFLAGS $CPPFLAGS" in + *" -march="*) ;; + *) case $host_cpu in + i?86) EXTRA_FLAGS="-march=i686" ;; + x86_64|amd64) EXTRA_FLAGS="something else?" ;; + esac ;; + esac +else + AC_MSG_ERROR([GCC is currently required to build libdispatch]) +fi + +AC_SUBST(WARN_FLAGS) +AC_SUBST(EXTRA_FLAGS) # # Generate Makefiles. # Index: src/Makefile.am =================================================================== --- src/Makefile.am (revision 16) +++ src/Makefile.am (working copy) @@ -15,16 +15,8 @@ source.c \ time.c -libdispatch_la_CFLAGS=-Wall -Werror +AM_CFLAGS=$(WARN_FLAGS) $(EXTRA_FLAGS) -# -# 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 @@ -34,10 +26,4 @@ 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 +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir)/config