Tizen 2.1 base
[platform/upstream/gcd.git] / dispatch-1.0 / configure.ac
1 #
2 # When this file changes, rerun autogen.sh.
3 #
4
5 AC_PREREQ(2.59)
6 AC_INIT([libdispatch], [1.0], [libdispatch@macosforge.org], [libdispatch])
7 AC_REVISION([$$])
8 AC_CONFIG_AUX_DIR(config)
9 AC_CONFIG_HEADER([config/config.h])
10 AC_CONFIG_MACRO_DIR([m4])
11 AM_MAINTAINER_MODE
12
13 #
14 # On Mac OS X, some required header files come from other source packages;
15 # allow specifying where those are.
16 #
17 AC_ARG_WITH([apple-libc-source],
18   [AS_HELP_STRING([--with-apple-libc-source],
19     [Specify path to Apple Libc source])],
20   [apple_libc_source_path=${withval}/pthreads
21     APPLE_LIBC_SOURCE_PATH=-I$apple_libc_source_path
22     CPPFLAGS="$CPPFLAGS -I$apple_libc_source_path"],
23   [APPLE_LIBC_SOURCE_PATH=]
24 )
25 AC_SUBST([APPLE_LIBC_SOURCE_PATH])
26
27 AC_ARG_WITH([apple-xnu-source],
28   [AS_HELP_STRING([--with-apple-xnu-source],
29     [Specify path to Apple XNU source])],
30   [apple_xnu_source_path=${withval}/libkern
31     APPLE_XNU_SOURCE_PATH=-I$apple_xnu_source_path
32     CPPFLAGS="$CPPFLAGS -I$apple_xnu_source_path"],
33   [APPLE_XNU_SOURCE_PATH=]
34 )
35 AC_SUBST([APPLE_XNU_SOURCE_PATH])
36
37 AC_CACHE_CHECK([for System.framework/PrivateHeaders], dispatch_cv_system_privateheaders,
38   [AS_IF([test -d /System/Library/Frameworks/System.framework/PrivateHeaders],
39     [dispatch_cv_system_privateheaders=yes], [dispatch_cv_system_privateheaders=no])]
40 )
41 AS_IF([test "x$dispatch_cv_system_privateheaders" != "xno"],
42   [CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/System.framework/PrivateHeaders"]
43 )
44
45 #
46 # Try to build the legacy API only if specifically requested.
47 #
48 AC_ARG_ENABLE([legacy-api],
49   [AS_HELP_STRING([--enable-legacy-api], [Enable legacy (deprecated) API.])]
50 )
51
52 AS_IF([test "x$enable_legacy_api" != "xyes"],
53   [use_legacy_api=false
54     AC_DEFINE(DISPATCH_NO_LEGACY, 1,[Define to compile out legacy API])],
55   [use_legacy_api=true]
56 )
57 AM_CONDITIONAL(USE_LEGACY_API, $use_legacy_api)
58
59 #
60 # On Mac OS X Snow Leopard, libpispatch_init is automatically invoked during
61 # libsyscall process setup.  On other systems, it is tagged as a library
62 # constructor to be run by automatically by the runtime linker.
63 #
64 AC_ARG_ENABLE([libdispatch-init-constructor],
65   [AS_HELP_STRING([--disable-libdispatch-init-constructor],
66     [Disable libdispatch_init as a constructor])]
67 )
68
69 AS_IF([test "x$enable_libdispatch_init_constructor" != "xno"],
70   [AC_DEFINE(USE_LIBDISPATCH_INIT_CONSTRUCTOR, 1,
71     [Define to tag libdispatch_init as a constructor])]
72 )
73
74 #
75 # Whether or not to include/reference a crashreporter symbol.
76 #
77 AC_ARG_ENABLE([apple-crashreporter-info],
78   [AS_HELP_STRING([--enable-apple-crashreporter-info],
79     [Use Mac OS X crashreporter info])]
80 )
81
82 AS_IF([test "x$enable_apple_crashreporter_info" = "xyes"],
83   [AC_DEFINE(USE_APPLE_CRASHREPORTER_INFO, 1,
84     [Define to use Mac OS X crashreporter info])]
85 )
86
87 #
88 # libdispatch has micro-optimized and deeply personal knowledge of Mac OS
89 # implementation details.  Only enable this if explicitly requested, as it
90 # will lead to data corruption if applied on systems violating its
91 # expectations.
92 #
93 AC_ARG_ENABLE([apple-tsd-optimizations],
94   [AS_HELP_STRING([--enable-apple-tsd-optimizations],
95     [Use non-portable pthread TSD optimizations for Mac OS X.])]
96 )
97
98 AS_IF([test "x$enable_apple_tsd_optimizations" = "xyes"],
99   [AC_DEFINE(USE_APPLE_TSD_OPTIMIZATIONS, 1,
100     [Define to use non-portable pthread TSD optimizations for Mac OS X)])]
101 )
102
103 AC_ARG_ENABLE([apple-semaphore-optimizations],
104   [AS_HELP_STRING([--enable-apple-semaphore-optimizations],
105     [Use non-portable semaphore optimizations for Mac OS X.])]
106 )
107
108 AS_IF([test "x$enable_apple_semaphore_optimizations" = "xyes"],
109   [AC_DEFINE(USE_APPLE_SEMAPHORE_OPTIMIZATIONS, 1,
110     [Define to use non-portablesemaphore optimizations for Mac OS X])]
111 )
112
113 AC_USE_SYSTEM_EXTENSIONS
114 AC_PROG_CC
115 AC_PROG_CXX
116 AC_PROG_INSTALL
117 AC_PROG_LIBTOOL
118 AC_PATH_PROGS(MIG, mig)
119
120 AC_PATH_PROG(LEAKS, leaks)
121 AS_IF([test "x$LEAKS" != "x"],
122   [AC_DEFINE(HAVE_LEAKS, 1, [Define if Apple leaks program is present])]
123 )
124
125 AM_INIT_AUTOMAKE([foreign])
126
127 DISPATCH_C_ATOMIC_BUILTINS
128
129 case $dispatch_cv_atomic in
130   yes) ;;
131   -march*) MARCH_FLAGS="$dispatch_cv_atomic"
132          AC_SUBST([MARCH_FLAGS]) ;;
133   *) AC_MSG_ERROR([No gcc builtin atomic operations available]) ;;
134 esac
135
136 #
137 # Find libraries we will need
138 #
139 AC_SEARCH_LIBS(clock_gettime, rt)
140 AC_SEARCH_LIBS(pthread_create, pthread)
141
142 #
143 # Prefer native kqueue(2); otherwise use libkqueue if present.
144 #
145 AC_CHECK_HEADER(sys/event.h, [],
146   [PKG_CHECK_MODULES(KQUEUE, libkqueue)]
147 )
148
149 #
150 # Checks for header files.
151 #
152 AC_HEADER_STDC
153 AC_CHECK_HEADERS([TargetConditionals.h pthread_machdep.h pthread_np.h malloc/malloc.h libkern/OSCrossEndian.h libkern/OSAtomic.h sys/sysctl.h])
154
155 #
156 # Core Services is tested in one of the GCD regression tests, so test for its
157 # presence using its header file.
158 #
159 AC_CHECK_HEADER([CoreServices/CoreServices.h],
160   [have_coreservices=true],
161   [have_coreservices=false]
162 )
163 AM_CONDITIONAL(HAVE_CORESERVICES, $have_coreservices)
164
165 #
166 # We use the availability of mach.h to decide whether to compile in all sorts
167 # of Machisms, including using Mach ports as event sources, etc.
168 #
169 AC_CHECK_HEADER([mach/mach.h],
170   [AC_DEFINE(HAVE_MACH, 1,Define if mach is present)
171     have_mach=true],
172   [have_mach=false]
173 )
174 AM_CONDITIONAL(USE_MIG, $have_mach)
175
176 #
177 # We use the availability of pthread_workqueue.h to decide whether to compile
178 # in support for pthread work queues.
179 #
180 AC_CHECK_HEADER([pthread_workqueue.h],
181   [AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1,Define if pthread work queues are present)]
182 )
183
184 #
185 # Find functions and declarations we care about.
186 #
187 AC_CHECK_DECLS([CLOCK_UPTIME, CLOCK_MONOTONIC, CLOCK_REALTIME], [], [],
188   [[#include <time.h>]])
189 AC_CHECK_DECLS([EVFILT_LIO, EVFILT_SESSION, NOTE_NONE, NOTE_REAP, NOTE_REVOKE, NOTE_SIGNAL], [], [],
190   [[#include <sys/types.h>
191 #include <sys/event.h>]])
192 AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]])
193 AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]])
194 AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include <sys/mount.h>]])
195 AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
196 AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time malloc_create_zone sysconf getprogname])
197
198 AC_CHECK_DECLS([POSIX_SPAWN_START_SUSPENDED],
199   [have_posix_spawn_start_suspended=true],
200   [have_posix_spawn_start_suspended=false],
201   [[#include <sys/spawn.h>]]
202 )
203 AM_CONDITIONAL(HAVE_POSIX_SPAWN_START_SUSPENDED, $have_posix_spawn_start_suspended)
204
205 AC_CHECK_FUNC([sem_init],
206   [have_sem_init=true],
207   [have_sem_init=false]
208 )
209
210 #
211 # We support both Mach semaphores and POSIX semaphores; if the former are
212 # available, prefer them.
213 #
214 AC_MSG_CHECKING([what semaphore type to use]);
215 AS_IF([test "x$have_mach" = "xtrue"],
216   [AC_DEFINE(USE_MACH_SEM, 1,[Define to use Mach semaphores])
217     AC_MSG_RESULT([Mach semaphores])],
218   [test "x$have_sem_init" = "xtrue"],
219   [AC_DEFINE(USE_POSIX_SEM, 1,[Define to use POSIX semaphores])
220     AC_MSG_RESULT([POSIX semaphores])],
221   [AC_MSG_ERROR([no supported semaphore type])]
222 )
223
224 AC_CHECK_HEADERS([sys/cdefs.h], [], [],
225   [#ifdef HAVE_SYS_CDEFS_H
226    #include <sys/cdefs.h>
227    #endif])
228
229 DISPATCH_C_PRIVATE_EXTERN
230 DISPATCH_C_BLOCKS
231
232 #
233 # Temporary: some versions of clang do not mark __builtin_trap() as
234 # __attribute__((__noreturn__)).  Detect and add if required.
235 #
236 AC_COMPILE_IFELSE([
237   AC_LANG_PROGRAM([void __attribute__((__noreturn__)) temp(void) { __builtin_trap(); }], [])], [
238     AC_DEFINE(HAVE_NORETURN_BUILTIN_TRAP, 1,[Define if __builtin_trap marked noreturn])
239   ], [])
240
241 #
242 # Generate Makefiles.
243 #
244 AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile src/Makefile testing/Makefile])
245 AC_OUTPUT