]>
Commit | Line | Data |
---|---|---|
b4c522fa IB |
1 | # |
2 | # Contains macros to detect OS features. | |
3 | # | |
4 | ||
5 | ||
6 | # DRUNTIME_OS_THREAD_MODEL | |
7 | # ------------------------ | |
8 | # Detect thread model and substitute DCFG_THREAD_MODEL | |
9 | AC_DEFUN([DRUNTIME_OS_THREAD_MODEL], | |
10 | [ | |
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]) | |
15 | ||
16 | # Map from thread model to thread interface. | |
17 | DRUNTIME_CONFIGURE_THREADS([$d_thread_model]) | |
18 | ]) | |
19 | ||
20 | ||
21 | # DRUNTIME_CONFIGURE_THREADS(thread_model) | |
22 | # ---------------------------------------- | |
23 | # Map target os to D version identifier | |
24 | AC_DEFUN([DRUNTIME_CONFIGURE_THREADS], | |
25 | [ | |
26 | case $1 in | |
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 ;; | |
36 | esac | |
37 | AC_SUBST(DCFG_THREAD_MODEL) | |
38 | ]) | |
39 | ||
40 | ||
41 | # DRUNTIME_OS_DETECT | |
42 | # ------------------ | |
43 | # Set the druntime_cv_target_os variable | |
44 | AC_DEFUN([DRUNTIME_OS_DETECT], | |
45 | [ | |
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]])], | |
51 | []) | |
52 | ]) | |
53 | ||
54 | ||
55 | # DRUNTIME_OS_UNIX | |
56 | # ---------------- | |
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], | |
60 | [ | |
61 | AC_REQUIRE([DRUNTIME_OS_DETECT]) | |
62 | AC_ARG_ENABLE(unix, | |
63 | AC_HELP_STRING([--enable-unix], | |
64 | [enables Unix runtime (default: yes, for Unix targets)]), | |
65 | :,[enable_unix=auto]) | |
66 | ||
67 | case "$druntime_cv_target_os" in | |
68 | aix*|*bsd*|cygwin*|darwin*|gnu*|linux*|skyos*|*solaris*|sysv*) d_have_unix=1 ;; | |
69 | esac | |
70 | if test -n "$d_have_unix" && test "$enable_unix" = auto ; then | |
71 | enable_unix=yes | |
72 | fi | |
73 | AM_CONDITIONAL([DRUNTIME_OS_UNIX], [test "$enable_unix" = "yes"]) | |
74 | ]) | |
75 | ||
76 | ||
77 | # DRUNTIME_OS_SOURCES | |
78 | # ------------------- | |
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], | |
83 | [ | |
84 | AC_REQUIRE([DRUNTIME_OS_DETECT]) | |
85 | ||
86 | druntime_target_os_parsed="" | |
87 | case "$druntime_cv_target_os" in | |
88 | aix*) druntime_target_os_parsed="aix" | |
89 | ;; | |
90 | *android*) | |
91 | druntime_target_os_parsed="android" | |
92 | ;; | |
93 | darwin*) druntime_target_os_parsed="darwin" | |
94 | ;; | |
95 | dragonfly*) | |
96 | druntime_target_os_parsed="dragonflybsd" | |
97 | ;; | |
98 | freebsd*|k*bsd*-gnu) | |
99 | druntime_target_os_parsed="freebsd" | |
100 | ;; | |
101 | openbsd*) | |
102 | druntime_target_os_parsed="openbsd" | |
103 | ;; | |
104 | netbsd*) | |
105 | druntime_target_os_parsed="netbsd" | |
106 | ;; | |
107 | linux*) druntime_target_os_parsed="linux" | |
108 | ;; | |
109 | mingw*) druntime_target_os_parsed="mingw" | |
110 | ;; | |
111 | *solaris*) druntime_target_os_parsed="solaris" | |
112 | esac | |
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"]) | |
133 | ]) | |
134 | ||
135 | ||
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], | |
141 | [ | |
142 | AC_LANG_PUSH([C]) | |
143 | AC_MSG_CHECKING([for ARM unwinder]) | |
144 | AC_TRY_COMPILE([#include <unwind.h>],[ | |
145 | #if __ARM_EABI_UNWINDER__ | |
146 | #error Yes, it is. | |
147 | #endif | |
148 | ], | |
149 | [AC_MSG_RESULT([no]) | |
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"]) | |
155 | AC_LANG_POP([C]) | |
156 | ]) | |
157 | ||
158 | ||
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], | |
164 | [ | |
165 | AC_LANG_PUSH([C]) | |
166 | AC_MSG_CHECKING([for minfo section bracketing]) | |
22e05272 | 167 | AC_LINK_IFELSE([AC_LANG_SOURCE([ |
b4c522fa IB |
168 | void* module_info_ptr __attribute__((section ("minfo"))); |
169 | extern void* __start_minfo __attribute__((visibility ("hidden"))); | |
170 | extern void* __stop_minfo __attribute__((visibility ("hidden"))); | |
171 | ||
172 | int main() | |
173 | { | |
174 | // Never run, just to prevent compiler from optimizing access | |
175 | return &__start_minfo == &__stop_minfo; | |
176 | } | |
22e05272 | 177 | ])], |
b4c522fa IB |
178 | [AC_MSG_RESULT([yes]) |
179 | DCFG_MINFO_BRACKETING=true], | |
180 | [AC_MSG_RESULT([no]) | |
181 | DCFG_MINFO_BRACKETING=false]) | |
182 | AC_SUBST(DCFG_MINFO_BRACKETING) | |
183 | AC_LANG_POP([C]) | |
184 | ]) |