2 # Contains macros to detect OS features.
6 # DRUNTIME_OS_THREAD_MODEL
7 # ------------------------
8 # Detect thread model and substitute DCFG_THREAD_MODEL
9 AC_DEFUN([DRUNTIME_OS_THREAD_MODEL],
11 AC_REQUIRE([AC_PROG_GDC])
12 AC_MSG_CHECKING([for thread model used by GDC])
13 d_thread_model=`$GDC -v 2>&1 | sed -n 's/^Thread model: //p'`
14 AC_MSG_RESULT([$d_thread_model])
16 # Map from thread model to thread interface.
17 DRUNTIME_CONFIGURE_THREADS([$d_thread_model])
21 # DRUNTIME_CONFIGURE_THREADS(thread_model)
22 # ----------------------------------------
23 # Map target os to D version identifier
24 AC_DEFUN([DRUNTIME_CONFIGURE_THREADS],
27 aix) DCFG_THREAD_MODEL="Posix" ;;
28 lynx) DCFG_THREAD_MODEL="Posix" ;;
29 posix) DCFG_THREAD_MODEL="Posix" ;;
30 single) DCFG_THREAD_MODEL="Single" ;;
31 win32) DCFG_THREAD_MODEL="Win32" ;;
32 # TODO: These targets need porting.
33 dce|mipssde|rtems|tpf|vxworks)
34 DCFG_THREAD_MODEL="Single" ;;
35 *) as_fn_error "Thread implementation '$1' not recognised" "$LINENO" 5 ;;
37 AC_SUBST(DCFG_THREAD_MODEL)
43 # Set the druntime_cv_target_os variable
44 AC_DEFUN([DRUNTIME_OS_DETECT],
46 AC_CACHE_CHECK([[for target OS]],
47 [[druntime_cv_target_os]],
48 [[druntime_cv_target_os=`echo $target_os | sed 's/^\([A-Za-z_]+\)/\1/'`]])
49 AS_IF([[test -z "$druntime_cv_target_os"]],
50 [AC_MSG_ERROR([[can't detect target OS]])],
57 # Add --enable-unix option or autodetects if system is unix
58 # and create the DRUNTIME_OS_UNIX conditional.
59 AC_DEFUN([DRUNTIME_OS_UNIX],
61 AC_REQUIRE([DRUNTIME_OS_DETECT])
63 AC_HELP_STRING([--enable-unix],
64 [enables Unix runtime (default: yes, for Unix targets)]),
67 case "$druntime_cv_target_os" in
68 aix*|*bsd*|cygwin*|darwin*|gnu*|linux*|skyos*|*solaris*|sysv*) d_have_unix=1 ;;
70 if test -n "$d_have_unix" && test "$enable_unix" = auto ; then
73 AM_CONDITIONAL([DRUNTIME_OS_UNIX], [test "$enable_unix" = "yes"])
79 # Detect target OS and add DRUNTIME_OS_AIX DRUNTIME_OS_DARWIN
80 # DRUNTIME_OS_FREEBSD DRUNTIME_OS_LINUX DRUNTIME_OS_MINGW
81 # DRUNTIME_OS_SOLARIS DRUNTIME_OS_OPENBSD conditionals.
82 AC_DEFUN([DRUNTIME_OS_SOURCES],
84 AC_REQUIRE([DRUNTIME_OS_DETECT])
86 druntime_target_os_parsed=""
87 case "$druntime_cv_target_os" in
88 aix*) druntime_target_os_parsed="aix"
91 druntime_target_os_parsed="android"
93 darwin*) druntime_target_os_parsed="darwin"
96 druntime_target_os_parsed="dragonflybsd"
99 druntime_target_os_parsed="freebsd"
102 druntime_target_os_parsed="openbsd"
105 druntime_target_os_parsed="netbsd"
107 linux*) druntime_target_os_parsed="linux"
109 mingw*) druntime_target_os_parsed="mingw"
111 *solaris*) druntime_target_os_parsed="solaris"
113 AM_CONDITIONAL([DRUNTIME_OS_AIX],
114 [test "$druntime_target_os_parsed" = "aix"])
115 AM_CONDITIONAL([DRUNTIME_OS_ANDROID],
116 [test "$druntime_target_os_parsed" = "android"])
117 AM_CONDITIONAL([DRUNTIME_OS_DARWIN],
118 [test "$druntime_target_os_parsed" = "darwin"])
119 AM_CONDITIONAL([DRUNTIME_OS_DRAGONFLYBSD],
120 [test "$druntime_target_os_parsed" = "dragonflybsd"])
121 AM_CONDITIONAL([DRUNTIME_OS_FREEBSD],
122 [test "$druntime_target_os_parsed" = "freebsd"])
123 AM_CONDITIONAL([DRUNTIME_OS_NETBSD],
124 [test "$druntime_target_os_parsed" = "netbsd"])
125 AM_CONDITIONAL([DRUNTIME_OS_OPENBSD],
126 [test "$druntime_target_os_parsed" = "openbsd"])
127 AM_CONDITIONAL([DRUNTIME_OS_LINUX],
128 [test "$druntime_target_os_parsed" = "linux"])
129 AM_CONDITIONAL([DRUNTIME_OS_MINGW],
130 [test "$druntime_target_os_parsed" = "mingw"])
131 AM_CONDITIONAL([DRUNTIME_OS_SOLARIS],
132 [test "$druntime_target_os_parsed" = "solaris"])
136 # DRUNTIME_OS_ARM_EABI_UNWINDER
137 # ------------------------
138 # Check if using ARM unwinder and substitute DCFG_ARM_EABI_UNWINDER
139 # and set DRUNTIME_OS_ARM_EABI_UNWINDER conditional.
140 AC_DEFUN([DRUNTIME_OS_ARM_EABI_UNWINDER],
143 AC_MSG_CHECKING([for ARM unwinder])
144 AC_TRY_COMPILE([#include <unwind.h>],[
145 #if __ARM_EABI_UNWINDER__
150 DCFG_ARM_EABI_UNWINDER=false],
151 [AC_MSG_RESULT([yes])
152 DCFG_ARM_EABI_UNWINDER=true])
153 AC_SUBST(DCFG_ARM_EABI_UNWINDER)
154 AM_CONDITIONAL([DRUNTIME_OS_ARM_EABI_UNWINDER], [test "$DCFG_ARM_EABI_UNWINDER" = "true"])
159 # DRUNTIME_OS_MINFO_BRACKETING
160 # ----------------------------
161 # Check if the linker provides __start_minfo and __stop_minfo symbols and
162 # substitute DCFG_MINFO_BRACKETING.
163 AC_DEFUN([DRUNTIME_OS_MINFO_BRACKETING],
166 AC_MSG_CHECKING([for minfo section bracketing])
167 AC_LINK_IFELSE([AC_LANG_SOURCE([
168 void* module_info_ptr __attribute__((section ("minfo")));
169 extern void* __start_minfo __attribute__((visibility ("hidden")));
170 extern void* __stop_minfo __attribute__((visibility ("hidden")));
174 // Never run, just to prevent compiler from optimizing access
175 return &__start_minfo == &__stop_minfo;
178 [AC_MSG_RESULT([yes])
179 DCFG_MINFO_BRACKETING=true],
181 DCFG_MINFO_BRACKETING=false])
182 AC_SUBST(DCFG_MINFO_BRACKETING)