]> git.saurik.com Git - apple/libdispatch.git/blame - configure.ac
libdispatch-913.20.5.tar.gz
[apple/libdispatch.git] / configure.ac
CommitLineData
e85f4437
A
1#
2# When this file changes, rerun autogen.sh.
3#
4
beb15981 5AC_PREREQ(2.69)
fa22f35b 6AC_INIT([libdispatch], [1.3], [https://bugs.swift.org], [libdispatch], [https://github.com/apple/swift-corelibs-libdispatch])
e85f4437
A
7AC_REVISION([$$])
8AC_CONFIG_AUX_DIR(config)
beb15981 9AC_CONFIG_HEADER([config/config_ac.h])
e85f4437 10AC_CONFIG_MACRO_DIR([m4])
c093abd6 11ac_clean_files=a.out.dSYM
e85f4437
A
12AM_MAINTAINER_MODE
13
6b746eb4
A
14AC_CANONICAL_BUILD
15AC_CANONICAL_HOST
16AC_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#
22AC_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)
27AS_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)
50AM_CONDITIONAL(DISPATCH_ENABLE_ASSERTS, $dispatch_enable_asserts)
51AM_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
58AC_PROG_CC([clang gcc cc])
59AC_PROG_CXX([clang++ g++ c++])
60AC_PROG_OBJC([clang gcc cc])
beb15981 61AC_PROG_OBJCXX([clang++ g++ c++])
c093abd6 62
6b746eb4
A
63#
64# Android cross-compilation support
65#
66AC_ARG_WITH([android-ndk],
67 [AS_HELP_STRING([--with-android-ndk],
68 [Android NDK location])], [
69 android_ndk=${withval}
70])
71AC_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])
75AC_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])
80AC_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])
108AM_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
114AC_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
121AC_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
128AC_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
139AC_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)
143AS_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#
152AC_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
158AS_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#
166AC_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
170AS_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#
178AC_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)
204AM_CONDITIONAL(HAVE_SWIFT, $have_swift)
205AC_SUBST([SWIFTC])
6b746eb4 206AC_SUBST([SWIFTC_FLAGS])
beb15981 207AC_SUBST([SWIFT_LIBDIR])
6b746eb4 208AC_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#
215AC_CHECK_PROG(use_gold_linker, ld.gold, true, false)
216AM_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#
224AC_ARG_ENABLE([extended-test-suite],
225 [AS_HELP_STRING([--enable-extended-test-suite],
226 [Include additional test cases that may fail intermittently])]
227)
228AM_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#
234AC_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)
245AS_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 250AC_USE_SYSTEM_EXTENSIONS
beb15981 251AM_INIT_AUTOMAKE([foreign no-dependencies subdir-objects])
fe4ce08b
A
252LT_INIT([disable-static])
253
e85f4437 254AC_PROG_INSTALL
e85f4437 255AC_PATH_PROGS(MIG, mig)
beb15981
A
256AC_PATH_PROG(DTRACE, dtrace)
257AS_IF([test "x$DTRACE" != "x"], [use_dtrace=true],[
258 use_dtrace=false
259 CPPFLAGS="$CPPFLAGS -DDISPATCH_USE_DTRACE=0"
260])
261AM_CONDITIONAL(USE_DTRACE, $use_dtrace)
e85f4437
A
262AC_PATH_PROG(LEAKS, leaks)
263AS_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 268AM_CONDITIONAL(HAVE_LEAKS, $have_leaks)
e85f4437 269
e85f4437
A
270DISPATCH_C_ATOMIC_BUILTINS
271
272case $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]) ;;
277esac
278
279#
280# Find libraries we will need
281#
282AC_SEARCH_LIBS(clock_gettime, rt)
283AC_SEARCH_LIBS(pthread_create, pthread)
284
beb15981
A
285AC_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#
295AC_HEADER_STDC
beb15981 296AC_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
299AS_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
307AC_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.
315AC_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)
326AS_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 338AM_CONDITIONAL(DISPATCH_USE_INTERNAL_WORKQUEUE, $dispatch_use_internal_workqueue)
beb15981
A
339AM_CONDITIONAL(HAVE_PTHREAD_WORKQUEUES, $have_pthread_workqueues)
340
341AC_CHECK_HEADERS([libproc_internal.h], [], [], [#include <mach/mach.h>])
342AC_CHECK_FUNCS([pthread_workqueue_setdispatch_np _pthread_workqueue_init])
343AS_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
360AS_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
367AC_CHECK_HEADER([CoreFoundation/CoreFoundation.h],
368 [have_corefoundation=true], [have_corefoundation=false]
e85f4437 369)
c093abd6 370AM_CONDITIONAL(HAVE_COREFOUNDATION, $have_corefoundation)
fe4ce08b 371
c093abd6 372AC_LANG_PUSH([Objective C])
fe4ce08b
A
373AC_CHECK_HEADER([Foundation/Foundation.h],
374 [have_foundation=true], [have_foundation=false]
c093abd6
A
375)
376AM_CONDITIONAL(HAVE_FOUNDATION, $have_foundation)
6b746eb4 377AC_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 381AM_CONDITIONAL(USE_OBJC, $have_objc)
c093abd6 382AC_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#
388AC_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)
393AM_CONDITIONAL(USE_MIG, $have_mach)
beb15981 394AC_CHECK_FUNCS([mach_port_construct])
e85f4437
A
395
396#
397# Find functions and declarations we care about.
398#
6b746eb4 399AC_CHECK_DECLS([CLOCK_UPTIME, CLOCK_MONOTONIC, CLOCK_REALTIME, CLOCK_UPTIME_FAST], [], [],
e85f4437 400 [[#include <time.h>]])
beb15981 401AC_CHECK_DECLS([NOTE_NONE, NOTE_REAP, NOTE_REVOKE, NOTE_SIGNAL, NOTE_LOWAT], [], [],
e85f4437
A
402 [[#include <sys/event.h>]])
403AC_CHECK_DECLS([FD_COPY], [], [], [[#include <sys/select.h>]])
404AC_CHECK_DECLS([SIGEMT], [], [], [[#include <signal.h>]])
fa22f35b 405AC_CHECK_DECLS([VQ_UPDATE, VQ_VERYLOWDISK, VQ_QUOTA, VQ_NEARLOWDISK, VQ_DESIRED_DISK], [], [], [[#include <sys/mount.h>]])
e85f4437 406AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
6b746eb4 407AC_CHECK_FUNCS([pthread_key_init_np pthread_main_np mach_absolute_time mach_approximate_time malloc_create_zone sysconf])
e85f4437
A
408
409AC_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)
413AM_CONDITIONAL(HAVE_POSIX_SPAWN_START_SUSPENDED, $have_posix_spawn_start_suspended)
414
415AC_CHECK_FUNC([sem_init],
c093abd6 416 [have_sem_init=true], [have_sem_init=false]
e85f4437
A
417)
418
6b746eb4
A
419AC_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#
428AC_MSG_CHECKING([what semaphore type to use]);
429AS_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
438AC_CHECK_HEADERS([sys/cdefs.h], [], [],
439 [#ifdef HAVE_SYS_CDEFS_H
440 #include <sys/cdefs.h>
441 #endif])
442
443DISPATCH_C_BLOCKS
444
445AC_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])
453AS_IF([test "x$dispatch_cv_cc_visibility_hidden" != "xno"], [
454 VISIBILITY_FLAGS="-fvisibility=hidden"
455])
456AC_SUBST([VISIBILITY_FLAGS])
457
458AC_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])
466AS_IF([test "x$dispatch_cv_cc_omit_leaf_fp" != "xno"], [
c093abd6 467 OMIT_LEAF_FP_FLAGS="-momit-leaf-frame-pointer"
e85f4437
A
468])
469AC_SUBST([OMIT_LEAF_FP_FLAGS])
470
beb15981
A
471AS_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 481AM_CONDITIONAL(HAVE_DARWIN_LD, [test "x$dispatch_cv_ld_darwin" == "xyes"])
e85f4437 482
fa22f35b
A
483#
484# symlink platform-specific module.modulemap files
485#
486AS_CASE([$target_os],
487 [darwin*], [ dispatch_module_map_os=darwin ],
488 [ dispatch_module_map_os=generic ]
489)
490AC_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
501AC_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#
509AC_ARG_ENABLE([build-tests],
510 [AS_HELP_STRING([--disable-build-tests], [Disable tests compilation])])
511AM_CONDITIONAL(BUILD_TESTS, [test "x$enable_build_tests" != "xno"])
512
e85f4437
A
513#
514# Generate Makefiles.
515#
beb15981
A
516AC_CONFIG_FILES([Makefile dispatch/Makefile man/Makefile os/Makefile private/Makefile src/Makefile tests/Makefile])
517
518#
519# Generate testsuite links
520#
fa22f35b 521AC_CONFIG_LINKS([tests/dispatch:$ac_top_srcdir/private tests/leaks-wrapper:tests/leaks-wrapper.sh])
beb15981 522
e85f4437 523AC_OUTPUT