]> git.saurik.com Git - apple/libdispatch.git/blob - configure.ac
libdispatch-187.5.tar.gz
[apple/libdispatch.git] / configure.ac
1 #
2 # When this file changes, rerun autogen.sh.
3 #
4
5 AC_PREREQ(2.59)
6 AC_INIT([libdispatch], [1.1], [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-libclosure-source],
28 [AS_HELP_STRING([--with-apple-libclosure-source],
29 [Specify path to Apple libclosure source])],
30 [apple_libclosure_source_path=${withval}
31 APPLE_LIBCLOSURE_SOURCE_PATH=-I$apple_libclosure_source_path
32 CPPFLAGS="$CPPFLAGS -I$apple_libclosure_source_path"],
33 [APPLE_LIBCLOSURE_SOURCE_PATH=]
34 )
35 AC_SUBST([APPLE_LIBCLOSURE_SOURCE_PATH])
36
37 AC_ARG_WITH([apple-xnu-source],
38 [AS_HELP_STRING([--with-apple-xnu-source],
39 [Specify path to Apple XNU source])],
40 [apple_xnu_source_path=${withval}/libkern
41 APPLE_XNU_SOURCE_PATH=-I$apple_xnu_source_path
42 CPPFLAGS="$CPPFLAGS -I$apple_xnu_source_path"
43 apple_xnu_source_system_path=${withval}/osfmk
44 APPLE_XNU_SOURCE_SYSTEM_PATH=$apple_xnu_source_system_path],
45 [APPLE_XNU_SOURCE_PATH=]
46 )
47 AC_SUBST([APPLE_XNU_SOURCE_PATH])
48 AC_SUBST([APPLE_XNU_SOURCE_SYSTEM_PATH])
49 AM_CONDITIONAL(USE_XNU_SOURCE, [test -n "$apple_xnu_source_system_path"])
50
51 AC_CACHE_CHECK([for System.framework/PrivateHeaders], dispatch_cv_system_privateheaders,
52 [AS_IF([test -d /System/Library/Frameworks/System.framework/PrivateHeaders],
53 [dispatch_cv_system_privateheaders=yes], [dispatch_cv_system_privateheaders=no])]
54 )
55 AS_IF([test "x$dispatch_cv_system_privateheaders" != "xno"],
56 [CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/System.framework/PrivateHeaders"]
57 )
58
59 #
60 # On Mac OS X, libpispatch_init is automatically invoked during libSystem
61 # process initialization. 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 # On Mac OS X libdispatch can use the non-portable direct pthread TSD functions
76 #
77 AC_ARG_ENABLE([apple-tsd-optimizations],
78 [AS_HELP_STRING([--enable-apple-tsd-optimizations],
79 [Use non-portable pthread TSD optimizations for Mac OS X.])]
80 )
81
82 AS_IF([test "x$enable_apple_tsd_optimizations" = "xyes"],
83 [AC_DEFINE(USE_APPLE_TSD_OPTIMIZATIONS, 1,
84 [Define to use non-portable pthread TSD optimizations for Mac OS X)])]
85 )
86
87 AC_USE_SYSTEM_EXTENSIONS
88 AC_PROG_CC
89 AC_PROG_CXX
90 AC_PROG_INSTALL
91 AC_PROG_LIBTOOL
92 AC_PATH_PROGS(MIG, mig)
93
94 AC_PATH_PROG(LEAKS, leaks)
95 AS_IF([test "x$LEAKS" != "x"],
96 [AC_DEFINE(HAVE_LEAKS, 1, [Define if Apple leaks program is present])]
97 )
98
99 AM_INIT_AUTOMAKE([foreign])
100
101 DISPATCH_C_ATOMIC_BUILTINS
102
103 case $dispatch_cv_atomic in
104 yes) ;;
105 -march*) MARCH_FLAGS="$dispatch_cv_atomic"
106 AC_SUBST([MARCH_FLAGS]) ;;
107 *) AC_MSG_ERROR([No gcc builtin atomic operations available]) ;;
108 esac
109
110 #
111 # Find libraries we will need
112 #
113 AC_SEARCH_LIBS(clock_gettime, rt)
114 AC_SEARCH_LIBS(pthread_create, pthread)
115
116 #
117 # Prefer native kqueue(2); otherwise use libkqueue if present.
118 #
119 AC_CHECK_HEADER(sys/event.h, [],
120 [PKG_CHECK_MODULES(KQUEUE, libkqueue)]
121 )
122
123 #
124 # Checks for header files.
125 #
126 AC_HEADER_STDC
127 AC_CHECK_HEADERS([TargetConditionals.h pthread_np.h malloc/malloc.h libkern/OSCrossEndian.h libkern/OSAtomic.h])
128
129 # hack for pthread_machdep.h's #include <System/machine/cpu_capabilities.h>
130 AS_IF([test -n "$apple_xnu_source_system_path"], [
131 saveCPPFLAGS="$CPPFLAGS"
132 CPPFLAGS="$CPPFLAGS -I."
133 ln -fsh "$apple_xnu_source_system_path" System
134 ])
135 AC_CHECK_HEADERS([pthread_machdep.h])
136 AS_IF([test -n "$apple_xnu_source_system_path"], [
137 rm -f System
138 CPPFLAGS="$saveCPPFLAGS"
139 ])
140
141 #
142 # Core Services is tested in one of the GCD regression tests, so test for its
143 # presence using its header file.
144 #
145 AC_CHECK_HEADER([CoreServices/CoreServices.h],
146 [have_coreservices=true],
147 [have_coreservices=false]
148 )
149 AM_CONDITIONAL(HAVE_CORESERVICES, $have_coreservices)
150
151 #
152 # We use the availability of mach.h to decide whether to compile in all sorts
153 # of Machisms, including using Mach ports as event sources, etc.
154 #
155 AC_CHECK_HEADER([mach/mach.h], [
156 AC_DEFINE(HAVE_MACH, 1, [Define if mach is present])
157 AC_DEFINE(__DARWIN_NON_CANCELABLE, 1, [Define if using Darwin $NOCANCEL])
158 have_mach=true],
159 [have_mach=false]
160 )
161 AM_CONDITIONAL(USE_MIG, $have_mach)
162
163 #
164 # We use the availability of pthread_workqueue.h to decide whether to compile
165 # in support for pthread work queues.
166 #
167 AC_CHECK_HEADER([pthread_workqueue.h],
168 [AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present])]
169 )
170
171 #
172 # Find functions and declarations we care about.
173 #
174 AC_CHECK_DECLS([CLOCK_UPTIME, CLOCK_MONOTONIC], [], [],
175 [[#include <time.h>]])
176 AC_CHECK_DECLS([NOTE_NONE, NOTE_REAP, NOTE_SIGNAL], [], [],
177 [[#include <sys/event.h>]])
178 AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]])
179 AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]])
180 AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK], [], [], [[#include <sys/mount.h>]])
181 AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
182 AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time malloc_create_zone sysconf getprogname])
183
184 AC_CHECK_DECLS([POSIX_SPAWN_START_SUSPENDED],
185 [have_posix_spawn_start_suspended=true],
186 [have_posix_spawn_start_suspended=false],
187 [[#include <sys/spawn.h>]]
188 )
189 AM_CONDITIONAL(HAVE_POSIX_SPAWN_START_SUSPENDED, $have_posix_spawn_start_suspended)
190
191 AC_CHECK_FUNC([sem_init],
192 [have_sem_init=true],
193 [have_sem_init=false]
194 )
195
196 #
197 # We support both Mach semaphores and POSIX semaphores; if the former are
198 # available, prefer them.
199 #
200 AC_MSG_CHECKING([what semaphore type to use]);
201 AS_IF([test "x$have_mach" = "xtrue"],
202 [AC_DEFINE(USE_MACH_SEM, 1, [Define to use Mach semaphores])
203 AC_MSG_RESULT([Mach semaphores])],
204 [test "x$have_sem_init" = "xtrue"],
205 [AC_DEFINE(USE_POSIX_SEM, 1, [Define to use POSIX semaphores])
206 AC_MSG_RESULT([POSIX semaphores])],
207 [AC_MSG_ERROR([no supported semaphore type])]
208 )
209
210 AC_CHECK_HEADERS([sys/cdefs.h], [], [],
211 [#ifdef HAVE_SYS_CDEFS_H
212 #include <sys/cdefs.h>
213 #endif])
214
215 DISPATCH_C_BLOCKS
216
217 AC_CACHE_CHECK([for -fvisibility=hidden], [dispatch_cv_cc_visibility_hidden], [
218 saveCFLAGS="$CFLAGS"
219 CFLAGS="$CFLAGS -fvisibility=hidden"
220 AC_LINK_IFELSE([AC_LANG_PROGRAM([
221 extern __attribute__ ((visibility ("default"))) int foo; int foo;], [foo = 0;])],
222 [dispatch_cv_cc_visibility_hidden="yes"], [dispatch_cv_cc_visibility_hidden="no"])
223 CFLAGS="$saveCFLAGS"
224 ])
225 AS_IF([test "x$dispatch_cv_cc_visibility_hidden" != "xno"], [
226 VISIBILITY_FLAGS="-fvisibility=hidden"
227 ])
228 AC_SUBST([VISIBILITY_FLAGS])
229
230 AC_CACHE_CHECK([for -momit-leaf-frame-pointer], [dispatch_cv_cc_omit_leaf_fp], [
231 saveCFLAGS="$CFLAGS"
232 CFLAGS="$CFLAGS -momit-leaf-frame-pointer"
233 AC_LINK_IFELSE([AC_LANG_PROGRAM([
234 extern int foo(void); int foo(void) {return 1;}], [foo();])],
235 [dispatch_cv_cc_omit_leaf_fp="yes"], [dispatch_cv_cc_omit_leaf_fp="no"])
236 CFLAGS="$saveCFLAGS"
237 ])
238 AS_IF([test "x$dispatch_cv_cc_omit_leaf_fp" != "xno"], [
239 OMIT_LEAF_FP_FLAGS="-momit-leaf-frame-pointer"
240 ])
241 AC_SUBST([OMIT_LEAF_FP_FLAGS])
242
243 AC_CACHE_CHECK([for darwin linker], [dispatch_cv_ld_darwin], [
244 saveLDFLAGS="$LDFLAGS"
245 LDFLAGS="$LDFLAGS -dynamiclib -compatibility_version 1.2.3 -current_version 4.5.6"
246 AC_LINK_IFELSE([AC_LANG_PROGRAM([
247 extern int foo; int foo;], [foo = 0;])],
248 [dispatch_cv_ld_darwin="yes"], [dispatch_cv_ld_darwin="no"])
249 LDFLAGS="$saveLDFLAGS"
250 ])
251 AM_CONDITIONAL(HAVE_DARWIN_LD, [test "x$dispatch_cv_ld_darwin" != "xno"])
252
253 #
254 # Temporary: some versions of clang do not mark __builtin_trap() as
255 # __attribute__((__noreturn__)). Detect and add if required.
256 #
257 AC_COMPILE_IFELSE([
258 AC_LANG_PROGRAM([void __attribute__((__noreturn__)) temp(void) { __builtin_trap(); }], [])], [
259 AC_DEFINE(HAVE_NORETURN_BUILTIN_TRAP, 1, [Define if __builtin_trap marked noreturn])
260 ], [])
261
262 #
263 # Generate Makefiles.
264 #
265 AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile private/Makefile src/Makefile])
266 AC_OUTPUT