]>
Commit | Line | Data |
---|---|---|
e85f4437 A |
1 | # |
2 | # When this file changes, rerun autogen.sh. | |
3 | # | |
4 | ||
beb15981 | 5 | AC_PREREQ(2.69) |
fa22f35b | 6 | AC_INIT([libdispatch], [1.3], [https://bugs.swift.org], [libdispatch], [https://github.com/apple/swift-corelibs-libdispatch]) |
e85f4437 A |
7 | AC_REVISION([$$]) |
8 | AC_CONFIG_AUX_DIR(config) | |
beb15981 | 9 | AC_CONFIG_HEADER([config/config_ac.h]) |
e85f4437 | 10 | AC_CONFIG_MACRO_DIR([m4]) |
c093abd6 | 11 | ac_clean_files=a.out.dSYM |
e85f4437 A |
12 | AM_MAINTAINER_MODE |
13 | ||
6b746eb4 A |
14 | AC_CANONICAL_BUILD |
15 | AC_CANONICAL_HOST | |
16 | AC_CANONICAL_TARGET | |
17 | ||
fa22f35b A |
18 | # |
19 | # Command line argument to specify build variant (default to release). | |
20 | # Impacts default value of CFLAGS et al. so must come before AC_PROG_CC | |
21 | # | |
22 | AC_ARG_WITH([build-variant], | |
23 | [AS_HELP_STRING([--with-build-variant=release|debug|releaseassert|releasedebuginfo], [Specify build variant [default=release]])], | |
24 | [dispatch_build_variant=${withval}], | |
25 | [dispatch_build_variant=release] | |
26 | ) | |
27 | AS_CASE([$dispatch_build_variant], | |
28 | [debug], [ | |
29 | default_compiler_flags="-g -O0" | |
30 | dispatch_enable_asserts=true | |
31 | dispatch_enable_optimization=false | |
32 | ], | |
33 | [release], [ | |
34 | default_compiler_flags="-O2" | |
35 | dispatch_enable_asserts=false | |
36 | dispatch_enable_optimization=true | |
37 | ], | |
38 | [releaseassert], [ | |
39 | default_compiler_flags="-O2" | |
40 | dispatch_enable_asserts=true | |
41 | dispatch_enable_optimization=true | |
42 | ], | |
43 | [releasedebuginfo], [ | |
44 | default_compiler_flags="-g -O2" | |
45 | dispatch_enable_asserts=false | |
46 | dispatch_enable_optimization=true | |
47 | ], | |
48 | [AC_MSG_ERROR("invalid build-variant $dispatch_build_variant")] | |
49 | ) | |
50 | AM_CONDITIONAL(DISPATCH_ENABLE_ASSERTS, $dispatch_enable_asserts) | |
51 | AM_CONDITIONAL(DISPATCH_ENABLE_OPTIMIZATION, $dispatch_enable_optimization) | |
52 | ||
53 | : ${CFLAGS=$default_compiler_flags} | |
54 | : ${CXXFLAGS=$default_compiler_flags} | |
55 | : ${OBJCFLAGS=$default_compiler_flags} | |
56 | : ${OBJCXXFLAGS=$default_compiler_flags} | |
57 | ||
c093abd6 A |
58 | AC_PROG_CC([clang gcc cc]) |
59 | AC_PROG_CXX([clang++ g++ c++]) | |
60 | AC_PROG_OBJC([clang gcc cc]) | |
beb15981 | 61 | AC_PROG_OBJCXX([clang++ g++ c++]) |
c093abd6 | 62 | |
6b746eb4 A |
63 | # |
64 | # Android cross-compilation support | |
65 | # | |
66 | AC_ARG_WITH([android-ndk], | |
67 | [AS_HELP_STRING([--with-android-ndk], | |
68 | [Android NDK location])], [ | |
69 | android_ndk=${withval} | |
70 | ]) | |
71 | AC_ARG_WITH([android-ndk-gcc-version], | |
72 | [AS_HELP_STRING([--with-android-ndk-gcc-version], | |
73 | [Android NDK GCC version [defaults=4.9]])], | |
74 | [android_ndk_gcc_version=${withval}], [android_ndk_gcc_version=4.9]) | |
75 | AC_ARG_WITH([android-api-level], | |
76 | [AS_HELP_STRING([--with-android-api-level], | |
77 | [Android API level to link with])], [ | |
78 | android_api_level=${withval} | |
79 | ]) | |
80 | AC_ARG_ENABLE([android], | |
81 | [AS_HELP_STRING([--enable-android], | |
82 | [Compile for Android])], [ | |
83 | android=true | |
84 | ||
85 | # Override values until there's real support for multiple Android platforms | |
86 | host=armv7-none-linux-androideabi | |
87 | host_alias=arm-linux-androideabi | |
88 | host_cpu=armv7 | |
89 | host_os=linux-androideabi | |
90 | host_vendor=unknown | |
91 | arch=arm | |
92 | ||
93 | sysroot=${android_ndk}/platforms/android-${android_api_level}/arch-${arch} | |
94 | toolchain=${android_ndk}/toolchains/${host_alias}-${android_ndk_gcc_version}/prebuilt/linux-${build_cpu} | |
95 | ||
96 | CFLAGS="$CFLAGS -target ${host_alias} --sysroot=${sysroot} -B${toolchain}/${host_alias}/bin" | |
97 | CXXFLAGS="$CXXFLAGS -target ${host_alias} --sysroot=${sysroot} -B${toolchain}/${host_alias}/bin" | |
98 | SWIFTC_FLAGS="-target ${host} -sdk ${sysroot} -L${toolchain}/lib/gcc/${host_alias}/${android_ndk_gcc_version}.x" | |
99 | LIBS="$LIBS -L${toolchain}/lib/gcc/${host_alias}/${android_ndk_gcc_version}.x" | |
100 | LDFLAGS="$LDFLAGS -Wc,'-target','${host_alias}','-B${toolchain}/${host_alias}/bin'" | |
101 | ||
102 | # FIXME: empty CFLAGS and CXXFLAGS are assumed for this to work. | |
103 | # FIXME: there should be a more elegant way to do this | |
104 | ac_configure_args=`echo $ac_configure_args | sed -e "s/ 'CFLAGS='//" -e "s/ 'CXXFLAGS='//"` | |
105 | # CFLAGS, CXXFLAGS and LIBS needs to be passed to libkqueue and libpwq | |
106 | ac_configure_args="$ac_configure_args --enable-bionic-libc 'CFLAGS=$CFLAGS' 'CXXFLAGS=$CXXFLAGS' 'LIBS=$LIBS'" | |
107 | ], [android=false]) | |
108 | AM_CONDITIONAL(ANDROID, $android) | |
109 | ||
e85f4437 A |
110 | # |
111 | # On Mac OS X, some required header files come from other source packages; | |
112 | # allow specifying where those are. | |
113 | # | |
beb15981 A |
114 | AC_ARG_WITH([apple-libpthread-source], |
115 | [AS_HELP_STRING([--with-apple-libpthread-source], | |
116 | [Specify path to Apple libpthread source])], [ | |
117 | apple_libpthread_source_path=${withval} | |
118 | CPPFLAGS="$CPPFLAGS -isystem $apple_libpthread_source_path" | |
119 | ]) | |
120 | ||
121 | AC_ARG_WITH([apple-libplatform-source], | |
122 | [AS_HELP_STRING([--with-apple-libplatform-source], | |
123 | [Specify path to Apple libplatform source])], [ | |
124 | apple_libplatform_source_include_path=${withval}/include | |
125 | CPPFLAGS="$CPPFLAGS -isystem $apple_libplatform_source_include_path" | |
c093abd6 | 126 | ]) |
e85f4437 | 127 | |
e85f4437 A |
128 | AC_ARG_WITH([apple-xnu-source], |
129 | [AS_HELP_STRING([--with-apple-xnu-source], | |
c093abd6 | 130 | [Specify path to Apple XNU source])], [ |
beb15981 A |
131 | apple_xnu_source_libsyscall_path=${withval}/libsyscall |
132 | apple_xnu_source_libproc_path=${withval}/libsyscall/wrappers/libproc | |
c093abd6 | 133 | apple_xnu_source_libkern_path=${withval}/libkern |
fe4ce08b | 134 | apple_xnu_source_bsd_path=${withval}/bsd |
c093abd6 | 135 | apple_xnu_source_osfmk_path=${withval}/osfmk |
beb15981 | 136 | CPPFLAGS="$CPPFLAGS -idirafter $apple_xnu_source_libkern_path -isystem $apple_xnu_source_bsd_path -isystem $apple_xnu_source_libsyscall_path -isystem $apple_xnu_source_libproc_path " |
fe4ce08b A |
137 | ]) |
138 | ||
e85f4437 A |
139 | AC_CACHE_CHECK([for System.framework/PrivateHeaders], dispatch_cv_system_privateheaders, |
140 | [AS_IF([test -d /System/Library/Frameworks/System.framework/PrivateHeaders], | |
141 | [dispatch_cv_system_privateheaders=yes], [dispatch_cv_system_privateheaders=no])] | |
142 | ) | |
143 | AS_IF([test "x$dispatch_cv_system_privateheaders" != "xno"], | |
beb15981 | 144 | [CPPFLAGS="$CPPFLAGS -isystem /System/Library/Frameworks/System.framework/PrivateHeaders"] |
e85f4437 A |
145 | ) |
146 | ||
147 | # | |
c093abd6 | 148 | # On Mac OS X, libdispatch_init is automatically invoked during libSystem |
e85f4437 A |
149 | # process initialization. On other systems, it is tagged as a library |
150 | # constructor to be run by automatically by the runtime linker. | |
151 | # | |
152 | AC_ARG_ENABLE([libdispatch-init-constructor], | |
153 | [AS_HELP_STRING([--disable-libdispatch-init-constructor], | |
c093abd6 A |
154 | [Disable libdispatch_init as a constructor])],, |
155 | [AS_IF([test -f /usr/lib/system/libdispatch.dylib], | |
156 | [enable_libdispatch_init_constructor=no])] | |
e85f4437 | 157 | ) |
e85f4437 A |
158 | AS_IF([test "x$enable_libdispatch_init_constructor" != "xno"], |
159 | [AC_DEFINE(USE_LIBDISPATCH_INIT_CONSTRUCTOR, 1, | |
160 | [Define to tag libdispatch_init as a constructor])] | |
161 | ) | |
162 | ||
163 | # | |
164 | # On Mac OS X libdispatch can use the non-portable direct pthread TSD functions | |
165 | # | |
166 | AC_ARG_ENABLE([apple-tsd-optimizations], | |
167 | [AS_HELP_STRING([--enable-apple-tsd-optimizations], | |
168 | [Use non-portable pthread TSD optimizations for Mac OS X.])] | |
169 | ) | |
e85f4437 A |
170 | AS_IF([test "x$enable_apple_tsd_optimizations" = "xyes"], |
171 | [AC_DEFINE(USE_APPLE_TSD_OPTIMIZATIONS, 1, | |
172 | [Define to use non-portable pthread TSD optimizations for Mac OS X)])] | |
173 | ) | |
174 | ||
beb15981 A |
175 | # |
176 | # Enable building Swift overlay support into libdispatch | |
177 | # | |
178 | AC_ARG_WITH([swift-toolchain], | |
179 | [AS_HELP_STRING([--with-swift-toolchain], [Specify path to Swift toolchain])], | |
180 | [swift_toolchain_path=${withval} | |
181 | AC_DEFINE(HAVE_SWIFT, 1, [Define if building for Swift]) | |
182 | SWIFTC="$swift_toolchain_path/bin/swiftc" | |
183 | case $target_os in | |
6b746eb4 A |
184 | *android*) |
185 | os_string="android" | |
186 | ;; | |
beb15981 A |
187 | linux*) |
188 | os_string="linux" | |
fa22f35b A |
189 | case $target_cpu in |
190 | armv7l*) | |
191 | target_cpu="armv7" | |
192 | ;; | |
193 | *) | |
194 | esac | |
beb15981 A |
195 | ;; |
196 | *) | |
197 | os_string=$target_os | |
198 | ;; | |
199 | esac | |
200 | SWIFT_LIBDIR="$swift_toolchain_path/lib/swift/$os_string/$target_cpu" | |
201 | have_swift=true], | |
202 | [have_swift=false] | |
203 | ) | |
204 | AM_CONDITIONAL(HAVE_SWIFT, $have_swift) | |
205 | AC_SUBST([SWIFTC]) | |
6b746eb4 | 206 | AC_SUBST([SWIFTC_FLAGS]) |
beb15981 | 207 | AC_SUBST([SWIFT_LIBDIR]) |
6b746eb4 | 208 | AC_SUBST([OS_STRING], ["$os_string"]) |
beb15981 A |
209 | |
210 | # | |
211 | # Enable use of gold linker when building the Swift overlay | |
212 | # to avoid a symbol relocation issue. | |
213 | # Ultimately the request to use gold should be passed in as an arg | |
214 | # | |
215 | AC_CHECK_PROG(use_gold_linker, ld.gold, true, false) | |
216 | AM_CONDITIONAL(USE_GOLD_LINKER, $use_gold_linker) | |
217 | ||
6b746eb4 A |
218 | # |
219 | # Enable an extended test suite that includes | |
220 | # tests that are too unreliable to be enabled by | |
221 | # default in the Swift CI environment, but are still | |
222 | # useful for libdispatch developers to be able to run. | |
223 | # | |
224 | AC_ARG_ENABLE([extended-test-suite], | |
225 | [AS_HELP_STRING([--enable-extended-test-suite], | |
226 | [Include additional test cases that may fail intermittently])] | |
227 | ) | |
228 | AM_CONDITIONAL(EXTENDED_TEST_SUITE, test "x$enable_extended_test_suite" = "xyes") | |
229 | ||
beb15981 A |
230 | # |
231 | # Enable __thread based TSD on platforms where it is efficient | |
232 | # Allow override based on command line argument to configure | |
233 | # | |
234 | AC_ARG_ENABLE([thread-local-storage], | |
235 | [AS_HELP_STRING([--enable-thread-local-storage], | |
236 | [Enable usage of thread local storage via __thread])],, | |
237 | [case $target_os in | |
238 | linux*) | |
239 | enable_thread_local_storage=yes | |
240 | ;; | |
241 | *) | |
242 | enable_thread_local_storage=no | |
243 | esac] | |
244 | ) | |
245 | AS_IF([test "x$enable_thread_local_storage" = "xyes"], | |
246 | [AC_DEFINE(DISPATCH_USE_THREAD_LOCAL_STORAGE, 1, | |
247 | [Enable usage of thread local storage via __thread])] | |
248 | ) | |
249 | ||
e85f4437 | 250 | AC_USE_SYSTEM_EXTENSIONS |
beb15981 | 251 | AM_INIT_AUTOMAKE([foreign no-dependencies subdir-objects]) |
fe4ce08b A |
252 | LT_INIT([disable-static]) |
253 | ||
e85f4437 | 254 | AC_PROG_INSTALL |
e85f4437 | 255 | AC_PATH_PROGS(MIG, mig) |
beb15981 A |
256 | AC_PATH_PROG(DTRACE, dtrace) |
257 | AS_IF([test "x$DTRACE" != "x"], [use_dtrace=true],[ | |
258 | use_dtrace=false | |
259 | CPPFLAGS="$CPPFLAGS -DDISPATCH_USE_DTRACE=0" | |
260 | ]) | |
261 | AM_CONDITIONAL(USE_DTRACE, $use_dtrace) | |
e85f4437 A |
262 | AC_PATH_PROG(LEAKS, leaks) |
263 | AS_IF([test "x$LEAKS" != "x"], | |
beb15981 A |
264 | [AC_DEFINE(HAVE_LEAKS, 1, [Define if Apple leaks program is present]) |
265 | have_leaks=true], | |
266 | [have_leaks=false] | |
e85f4437 | 267 | ) |
beb15981 | 268 | AM_CONDITIONAL(HAVE_LEAKS, $have_leaks) |
e85f4437 | 269 | |
e85f4437 A |
270 | DISPATCH_C_ATOMIC_BUILTINS |
271 | ||
272 | case $dispatch_cv_atomic in | |
273 | yes) ;; | |
274 | -march*) MARCH_FLAGS="$dispatch_cv_atomic" | |
275 | AC_SUBST([MARCH_FLAGS]) ;; | |
276 | *) AC_MSG_ERROR([No gcc builtin atomic operations available]) ;; | |
277 | esac | |
278 | ||
279 | # | |
280 | # Find libraries we will need | |
281 | # | |
282 | AC_SEARCH_LIBS(clock_gettime, rt) | |
283 | AC_SEARCH_LIBS(pthread_create, pthread) | |
284 | ||
beb15981 A |
285 | AC_CHECK_FUNCS([strlcpy getprogname], [], |
286 | [PKG_CHECK_MODULES(BSD_OVERLAY, libbsd-overlay,[ | |
287 | AC_DEFINE(HAVE_STRLCPY, 1, []) | |
288 | AC_DEFINE(HAVE_GETPROGNAME, 1, []) | |
289 | ])], [#include <string.h>] | |
290 | ) | |
291 | ||
e85f4437 A |
292 | # |
293 | # Checks for header files. | |
294 | # | |
295 | AC_HEADER_STDC | |
beb15981 | 296 | AC_CHECK_HEADERS([TargetConditionals.h pthread_np.h malloc/malloc.h libkern/OSCrossEndian.h libkern/OSAtomic.h sys/guarded.h fcntl.h]) |
e85f4437 | 297 | |
beb15981 A |
298 | # hack for pthread/private headers |
299 | AS_IF([test -n "$apple_libpthread_source_path" -a -n "$apple_xnu_source_osfmk_path"], [ | |
e85f4437 A |
300 | saveCPPFLAGS="$CPPFLAGS" |
301 | CPPFLAGS="$CPPFLAGS -I." | |
beb15981 A |
302 | ln -fsh "$apple_libpthread_source_path"/private/tsd_private.h pthread_machdep.h |
303 | ln -fsh "$apple_libpthread_source_path"/private pthread | |
c093abd6 | 304 | ln -fsh "$apple_xnu_source_osfmk_path" System |
beb15981 | 305 | mkdir -p mach && ln -fsh "$apple_xnu_source_osfmk_path"/mach/coalition.h mach |
e85f4437 | 306 | ]) |
beb15981 A |
307 | AC_CHECK_HEADERS([pthread_machdep.h pthread/qos.h]) |
308 | ||
309 | # pthread_workqueues. | |
6b746eb4 A |
310 | # We can either use libdispatch's internal_workqueue or pthread_workqueue. |
311 | # If not specifically configured, default to internal_workqueues on | |
312 | # Linux and pthread_workqueue on all other platforms. | |
313 | # On any platform, if pthread_workqueue is not available, fall back | |
314 | # to using internal_workqueue. | |
315 | AC_ARG_ENABLE([internal-libpwq], | |
316 | [AS_HELP_STRING([--enable-internal-libpwq], | |
317 | [Use libdispatch's own implementation of pthread workqueues.])],, | |
318 | [case $target_os in | |
319 | linux*) | |
320 | enable_internal_libpwq=yes | |
321 | ;; | |
322 | *) | |
323 | enable_internal_libpwq=no | |
324 | esac] | |
325 | ) | |
326 | AS_IF([test "x$enable_internal_libpwq" = "xyes"], | |
327 | [AC_DEFINE(DISPATCH_USE_INTERNAL_WORKQUEUE, 1, [Use libdispatch's own implementation of pthread workqueues]) | |
328 | have_pthread_workqueues=false, | |
329 | dispatch_use_internal_workqueue=true], | |
330 | [AC_CHECK_HEADERS([pthread/workqueue_private.h pthread_workqueue.h], | |
beb15981 | 331 | [AC_DEFINE(HAVE_PTHREAD_WORKQUEUES, 1, [Define if pthread work queues are present]) |
6b746eb4 A |
332 | have_pthread_workqueues=true, |
333 | dispatch_use_internal_workqueue=false], | |
334 | [have_pthread_workqueues=false, | |
335 | dispatch_use_internal_workqueue=true] | |
336 | )] | |
beb15981 | 337 | ) |
6b746eb4 | 338 | AM_CONDITIONAL(DISPATCH_USE_INTERNAL_WORKQUEUE, $dispatch_use_internal_workqueue) |
beb15981 A |
339 | AM_CONDITIONAL(HAVE_PTHREAD_WORKQUEUES, $have_pthread_workqueues) |
340 | ||
341 | AC_CHECK_HEADERS([libproc_internal.h], [], [], [#include <mach/mach.h>]) | |
342 | AC_CHECK_FUNCS([pthread_workqueue_setdispatch_np _pthread_workqueue_init]) | |
343 | AS_IF([test -n "$apple_libpthread_source_path" -a -n "$apple_xnu_source_osfmk_path"], [ | |
344 | rm -f pthread_machdep.h pthread System mach/coalition.h | |
e85f4437 | 345 | CPPFLAGS="$saveCPPFLAGS" |
beb15981 A |
346 | AC_CONFIG_COMMANDS([src/pthread_machdep.h], |
347 | [ln -fsh "$apple_libpthread_source_path"/private/tsd_private.h src/pthread_machdep.h], | |
348 | [apple_libpthread_source_path="$apple_libpthread_source_path"]) | |
349 | AC_CONFIG_COMMANDS([src/pthread], | |
350 | [ln -fsh "$apple_libpthread_source_path"/private src/pthread], | |
351 | [apple_libpthread_source_path="$apple_libpthread_source_path"]) | |
c093abd6 A |
352 | AC_CONFIG_COMMANDS([src/System], |
353 | [ln -fsh "$apple_xnu_source_osfmk_path" src/System], | |
354 | [apple_xnu_source_osfmk_path="$apple_xnu_source_osfmk_path"]) | |
beb15981 A |
355 | AC_CONFIG_COMMANDS([src/mach/coalition.h], |
356 | [ln -fsh "$apple_xnu_source_osfmk_path"/mach/coalition.h src/mach], | |
357 | [apple_xnu_source_osfmk_path="$apple_xnu_source_osfmk_path"]) | |
e85f4437 | 358 | ]) |
fe4ce08b A |
359 | # hack for xnu/bsd/sys/event.h EVFILT_SOCK declaration |
360 | AS_IF([test -n "$apple_xnu_source_bsd_path"], [ | |
361 | CPPFLAGS="$CPPFLAGS -DPRIVATE=1" | |
362 | ]) | |
e85f4437 A |
363 | |
364 | # | |
fe4ce08b | 365 | # Check for CoreFoundation, Foundation and objc |
e85f4437 | 366 | # |
c093abd6 A |
367 | AC_CHECK_HEADER([CoreFoundation/CoreFoundation.h], |
368 | [have_corefoundation=true], [have_corefoundation=false] | |
e85f4437 | 369 | ) |
c093abd6 | 370 | AM_CONDITIONAL(HAVE_COREFOUNDATION, $have_corefoundation) |
fe4ce08b | 371 | |
c093abd6 | 372 | AC_LANG_PUSH([Objective C]) |
fe4ce08b A |
373 | AC_CHECK_HEADER([Foundation/Foundation.h], |
374 | [have_foundation=true], [have_foundation=false] | |
c093abd6 A |
375 | ) |
376 | AM_CONDITIONAL(HAVE_FOUNDATION, $have_foundation) | |
6b746eb4 | 377 | AC_CHECK_HEADER([objc/NSObject.h], [ |
517da941 | 378 | AC_DEFINE(HAVE_OBJC, 1, [Define if you have the Objective-C runtime]) |
6b746eb4 | 379 | have_objc=true], [have_objc=false] |
fe4ce08b | 380 | ) |
fe4ce08b | 381 | AM_CONDITIONAL(USE_OBJC, $have_objc) |
c093abd6 | 382 | AC_LANG_POP([Objective C]) |
e85f4437 A |
383 | |
384 | # | |
385 | # We use the availability of mach.h to decide whether to compile in all sorts | |
386 | # of Machisms, including using Mach ports as event sources, etc. | |
387 | # | |
388 | AC_CHECK_HEADER([mach/mach.h], [ | |
fe4ce08b A |
389 | AC_DEFINE(HAVE_MACH, 1, [Define if mach is present]) |
390 | AC_DEFINE(__DARWIN_NON_CANCELABLE, 1, [Define if using Darwin $NOCANCEL]) | |
391 | have_mach=true], [have_mach=false] | |
e85f4437 A |
392 | ) |
393 | AM_CONDITIONAL(USE_MIG, $have_mach) | |
beb15981 | 394 | AC_CHECK_FUNCS([mach_port_construct]) |
e85f4437 A |
395 | |
396 | # | |
397 | # Find functions and declarations we care about. | |
398 | # | |
6b746eb4 | 399 | AC_CHECK_DECLS([CLOCK_UPTIME, CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_UPTIME_FAST], [], [], |
e85f4437 | 400 | [[#include <time.h>]]) |
beb15981 | 401 | AC_CHECK_DECLS([NOTE_NONE, NOTE_REAP, NOTE_REVOKE, NOTE_SIGNAL, NOTE_LOWAT], [], [], |
e85f4437 A |
402 | [[#include <sys/event.h>]]) |
403 | AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]]) | |
404 | AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]]) | |
fa22f35b | 405 | AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK, VQ_QUOTA, VQ_NEARLOWDISK, VQ_DESIRED_DISK], [], [], [[#include <sys/mount.h>]]) |
e85f4437 | 406 | AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]]) |
6b746eb4 | 407 | AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time mach_approximate_time malloc_create_zone sysconf]) |
e85f4437 A |
408 | |
409 | AC_CHECK_DECLS([POSIX_SPAWN_START_SUSPENDED], | |
c093abd6 | 410 | [have_posix_spawn_start_suspended=true], [have_posix_spawn_start_suspended=false], |
e85f4437 A |
411 | [[#include <sys/spawn.h>]] |
412 | ) | |
413 | AM_CONDITIONAL(HAVE_POSIX_SPAWN_START_SUSPENDED, $have_posix_spawn_start_suspended) | |
414 | ||
415 | AC_CHECK_FUNC([sem_init], | |
c093abd6 | 416 | [have_sem_init=true], [have_sem_init=false] |
e85f4437 A |
417 | ) |
418 | ||
6b746eb4 A |
419 | AC_CHECK_HEADER([linux/futex.h], [ |
420 | AC_DEFINE(HAVE_FUTEX, 1, [Define if linux/futex.h is present]) | |
421 | have_futex=true], [have_futex=false] | |
422 | ) | |
423 | ||
e85f4437 A |
424 | # |
425 | # We support both Mach semaphores and POSIX semaphores; if the former are | |
426 | # available, prefer them. | |
427 | # | |
428 | AC_MSG_CHECKING([what semaphore type to use]); | |
429 | AS_IF([test "x$have_mach" = "xtrue"], | |
430 | [AC_DEFINE(USE_MACH_SEM, 1, [Define to use Mach semaphores]) | |
431 | AC_MSG_RESULT([Mach semaphores])], | |
432 | [test "x$have_sem_init" = "xtrue"], | |
433 | [AC_DEFINE(USE_POSIX_SEM, 1, [Define to use POSIX semaphores]) | |
434 | AC_MSG_RESULT([POSIX semaphores])], | |
435 | [AC_MSG_ERROR([no supported semaphore type])] | |
436 | ) | |
437 | ||
438 | AC_CHECK_HEADERS([sys/cdefs.h], [], [], | |
439 | [#ifdef HAVE_SYS_CDEFS_H | |
440 | #include <sys/cdefs.h> | |
441 | #endif]) | |
442 | ||
443 | DISPATCH_C_BLOCKS | |
444 | ||
445 | AC_CACHE_CHECK([for -fvisibility=hidden], [dispatch_cv_cc_visibility_hidden], [ | |
446 | saveCFLAGS="$CFLAGS" | |
447 | CFLAGS="$CFLAGS -fvisibility=hidden" | |
448 | AC_LINK_IFELSE([AC_LANG_PROGRAM([ | |
449 | extern __attribute__ ((visibility ("default"))) int foo; int foo;], [foo = 0;])], | |
450 | [dispatch_cv_cc_visibility_hidden="yes"], [dispatch_cv_cc_visibility_hidden="no"]) | |
451 | CFLAGS="$saveCFLAGS" | |
452 | ]) | |
453 | AS_IF([test "x$dispatch_cv_cc_visibility_hidden" != "xno"], [ | |
454 | VISIBILITY_FLAGS="-fvisibility=hidden" | |
455 | ]) | |
456 | AC_SUBST([VISIBILITY_FLAGS]) | |
457 | ||
458 | AC_CACHE_CHECK([for -momit-leaf-frame-pointer], [dispatch_cv_cc_omit_leaf_fp], [ | |
459 | saveCFLAGS="$CFLAGS" | |
460 | CFLAGS="$CFLAGS -momit-leaf-frame-pointer" | |
461 | AC_LINK_IFELSE([AC_LANG_PROGRAM([ | |
462 | extern int foo(void); int foo(void) {return 1;}], [foo();])], | |
463 | [dispatch_cv_cc_omit_leaf_fp="yes"], [dispatch_cv_cc_omit_leaf_fp="no"]) | |
464 | CFLAGS="$saveCFLAGS" | |
465 | ]) | |
466 | AS_IF([test "x$dispatch_cv_cc_omit_leaf_fp" != "xno"], [ | |
c093abd6 | 467 | OMIT_LEAF_FP_FLAGS="-momit-leaf-frame-pointer" |
e85f4437 A |
468 | ]) |
469 | AC_SUBST([OMIT_LEAF_FP_FLAGS]) | |
470 | ||
beb15981 A |
471 | AS_IF([test "x$have_mach" = "xtrue"], [ |
472 | AC_CACHE_CHECK([for darwin linker], [dispatch_cv_ld_darwin], [ | |
473 | saveLDFLAGS="$LDFLAGS" | |
474 | LDFLAGS="$LDFLAGS -dynamiclib -compatibility_version 1.2.3 -current_version 4.5.6 -dead_strip" | |
475 | AC_LINK_IFELSE([AC_LANG_PROGRAM([ | |
476 | extern int foo; int foo;], [foo = 0;])], | |
477 | [dispatch_cv_ld_darwin="yes"], [dispatch_cv_ld_darwin="no"]) | |
478 | LDFLAGS="$saveLDFLAGS" | |
479 | ]) | |
e85f4437 | 480 | ]) |
beb15981 | 481 | AM_CONDITIONAL(HAVE_DARWIN_LD, [test "x$dispatch_cv_ld_darwin" == "xyes"]) |
e85f4437 | 482 | |
fa22f35b A |
483 | # |
484 | # symlink platform-specific module.modulemap files | |
485 | # | |
486 | AS_CASE([$target_os], | |
487 | [darwin*], [ dispatch_module_map_os=darwin ], | |
488 | [ dispatch_module_map_os=generic ] | |
489 | ) | |
490 | AC_CONFIG_COMMANDS([modulemaps], [ | |
491 | ln -fs $dispatch_module_map_os/module.modulemap $ac_top_srcdir/dispatch/module.modulemap | |
492 | ln -fs $dispatch_module_map_os/module.modulemap $ac_top_srcdir/private/module.modulemap | |
493 | ], | |
494 | [dispatch_module_map_os="$dispatch_module_map_os"] | |
495 | ) | |
496 | ||
e85f4437 A |
497 | # |
498 | # Temporary: some versions of clang do not mark __builtin_trap() as | |
499 | # __attribute__((__noreturn__)). Detect and add if required. | |
500 | # | |
c093abd6 A |
501 | AC_COMPILE_IFELSE( |
502 | [AC_LANG_PROGRAM([void __attribute__((__noreturn__)) temp(void) { __builtin_trap(); }], [])], | |
503 | [AC_DEFINE(HAVE_NORETURN_BUILTIN_TRAP, 1, [Define if __builtin_trap marked noreturn])] | |
504 | ) | |
e85f4437 | 505 | |
6b746eb4 A |
506 | # |
507 | # Add option to avoid building tests | |
508 | # | |
509 | AC_ARG_ENABLE([build-tests], | |
510 | [AS_HELP_STRING([--disable-build-tests], [Disable tests compilation])]) | |
511 | AM_CONDITIONAL(BUILD_TESTS, [test "x$enable_build_tests" != "xno"]) | |
512 | ||
e85f4437 A |
513 | # |
514 | # Generate Makefiles. | |
515 | # | |
beb15981 A |
516 | AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile os/Makefile private/Makefile src/Makefile tests/Makefile]) |
517 | ||
518 | # | |
519 | # Generate testsuite links | |
520 | # | |
fa22f35b | 521 | AC_CONFIG_LINKS([tests/dispatch:$ac_top_srcdir/private tests/leaks-wrapper:tests/leaks-wrapper.sh]) |
beb15981 | 522 | |
e85f4437 | 523 | AC_OUTPUT |