| 1 |
# |
| 2 |
# Contains macros to handle library dependencies. |
| 3 |
# |
| 4 |
|
| 5 |
|
| 6 |
# DRUNTIME_LIBRARIES_DLOPEN |
| 7 |
# ----------------------- |
| 8 |
# Autodetect and add dl library to LIBS if necessary. |
| 9 |
AC_DEFUN([DRUNTIME_LIBRARIES_DLOPEN], |
| 10 |
[ |
| 11 |
# Libtool has already checked this, so re-use the inferred dlopen lib. |
| 12 |
AS_IF([test "x$enable_dlopen" = "xyes" && test -n "$lt_cv_dlopen_libs"], [ |
| 13 |
LIBS="$LIBS $lt_cv_dlopen_libs" |
| 14 |
], [ |
| 15 |
]) |
| 16 |
]) |
| 17 |
|
| 18 |
|
| 19 |
# DRUNTIME_LIBRARIES_NET |
| 20 |
# ----------------------- |
| 21 |
# Autodetect and add networking library to LIBS if necessary. |
| 22 |
AC_DEFUN([DRUNTIME_LIBRARIES_NET], |
| 23 |
[ |
| 24 |
dnl Check for the existence of the -lsocket and -lnsl libraries. |
| 25 |
dnl The order here is important, so that they end up in the right |
| 26 |
dnl order in the command line generated by make. Here are some |
| 27 |
dnl special considerations: |
| 28 |
dnl 1. Use "connect" and "accept" to check for -lsocket, and |
| 29 |
dnl "gethostbyname" to check for -lnsl. |
| 30 |
dnl 2. Use each function name only once: can't redo a check because |
| 31 |
dnl autoconf caches the results of the last check and won't redo it. |
| 32 |
dnl 3. Use -lnsl and -lsocket only if they supply procedures that |
| 33 |
dnl aren't already present in the normal libraries. |
| 34 |
dnl 4. On some systems, can't use -lsocket without -lnsl too. |
| 35 |
dnl To get around this problem, check for both libraries together |
| 36 |
dnl if -lsocket doesn't work by itself. |
| 37 |
druntime_check_both=no |
| 38 |
AC_CHECK_FUNC(connect, , |
| 39 |
[AC_CHECK_LIB(socket, connect, |
| 40 |
LIBS="$LIBS -lsocket", druntime_check_both=yes)]) |
| 41 |
if test "$druntime_check_both" = "yes"; then |
| 42 |
druntime_old_libs=$LIBS |
| 43 |
LIBS="$LIBS -lsocket -lnsl" |
| 44 |
AC_CHECK_FUNC(accept, , LIBS=$druntime_old_libs) |
| 45 |
fi |
| 46 |
AC_CHECK_FUNC(gethostbyname, , |
| 47 |
[AC_CHECK_LIB(nsl, gethostbyname, LIBS="$LIBS -lnsl")]) |
| 48 |
]) |
| 49 |
|
| 50 |
# DRUNTIME_LIBRARIES_ZLIB |
| 51 |
# ----------------------- |
| 52 |
# Allow specifying whether to use the system zlib or |
| 53 |
# compiling the zlib included in GCC. Adds substitute |
| 54 |
# for LIBZ or adds zlib to LIBS if necessary. |
| 55 |
AC_DEFUN([DRUNTIME_LIBRARIES_ZLIB], |
| 56 |
[ |
| 57 |
AC_LANG_PUSH([C]) |
| 58 |
LIBZ="" |
| 59 |
|
| 60 |
AC_ARG_WITH(target-system-zlib, |
| 61 |
AS_HELP_STRING([--with-target-system-zlib={yes,no,auto}], |
| 62 |
[use installed libz (default: no)]),, |
| 63 |
[with_target_system_zlib=no]) |
| 64 |
|
| 65 |
case "$with_target_system_zlib" in |
| 66 |
yes|no|auto) ;; |
| 67 |
*) AC_MSG_ERROR([Invalid argument for --with-target-system-zlib]) ;; |
| 68 |
esac |
| 69 |
|
| 70 |
AC_MSG_CHECKING([for system zlib]) |
| 71 |
save_LIBS=$LIBS |
| 72 |
LIBS="$LIBS -lz" |
| 73 |
dnl the link test is not good enough for ARM32 multilib detection, |
| 74 |
dnl first check to link, then to run |
| 75 |
AC_LINK_IFELSE( |
| 76 |
[AC_LANG_PROGRAM([#include <zlib.h>],[gzopen("none", "rb")])], |
| 77 |
[ |
| 78 |
AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
| 79 |
#include <zlib.h> |
| 80 |
int main() { |
| 81 |
gzFile file = gzopen("none", "rb"); |
| 82 |
return 0; |
| 83 |
} |
| 84 |
]])], |
| 85 |
[system_zlib_found=yes], |
| 86 |
[system_zlib_found=no], |
| 87 |
dnl no system zlib for cross builds ... |
| 88 |
[system_zlib_found=no] |
| 89 |
) |
| 90 |
], |
| 91 |
[system_zlib_found=no]) |
| 92 |
LIBS=$save_LIBS |
| 93 |
|
| 94 |
if test x$system_zlib_found = xyes && test x$with_target_system_zlib != xno; then |
| 95 |
AC_MSG_RESULT([found]) |
| 96 |
LIBS="$LIBS -lz" |
| 97 |
elif test x$system_zlib_found = xno && test x$with_target_system_zlib = xyes; then |
| 98 |
AC_MSG_ERROR([system zlib required but not found]) |
| 99 |
else |
| 100 |
AC_MSG_RESULT([just compiled]) |
| 101 |
LIBZ=../../zlib/libz_convenience.la |
| 102 |
fi |
| 103 |
|
| 104 |
AC_SUBST(LIBZ) |
| 105 |
AC_LANG_POP([C]) |
| 106 |
]) |
| 107 |
|
| 108 |
# DRUNTIME_LIBRARIES_ATOMIC |
| 109 |
# ------------------------- |
| 110 |
# Allow specifying whether to use libatomic for atomic support. |
| 111 |
AC_DEFUN([DRUNTIME_LIBRARIES_ATOMIC], |
| 112 |
[ |
| 113 |
AC_ARG_WITH(libatomic, |
| 114 |
AS_HELP_STRING([--without-libatomic], |
| 115 |
[Do not use libatomic in core.atomic (default: auto)])) |
| 116 |
|
| 117 |
DCFG_HAVE_LIBATOMIC=false |
| 118 |
LIBATOMIC= |
| 119 |
AS_IF([test "x$enable_libatomic" != "xno" && test "x$with_libatomic" != "xno"], [ |
| 120 |
DCFG_HAVE_LIBATOMIC=true |
| 121 |
LIBATOMIC=../../libatomic/libatomic_convenience.la |
| 122 |
], [ |
| 123 |
AC_MSG_CHECKING([for libatomic]) |
| 124 |
AC_MSG_RESULT([disabled]) |
| 125 |
]) |
| 126 |
|
| 127 |
AC_SUBST(DCFG_HAVE_LIBATOMIC) |
| 128 |
AC_SUBST(LIBATOMIC) |
| 129 |
]) |
| 130 |
|
| 131 |
# DRUNTIME_LIBRARIES_BACKTRACE |
| 132 |
# --------------------------- |
| 133 |
# Allow specifying whether to use libbacktrace for backtrace support. |
| 134 |
# Adds subsitute for BACKTRACE_SUPPORTED, BACKTRACE_USES_MALLOC, |
| 135 |
# and BACKTRACE_SUPPORTS_THREADS. |
| 136 |
AC_DEFUN([DRUNTIME_LIBRARIES_BACKTRACE], |
| 137 |
[ |
| 138 |
AC_LANG_PUSH([C]) |
| 139 |
BACKTRACE_SUPPORTED=false |
| 140 |
BACKTRACE_USES_MALLOC=false |
| 141 |
BACKTRACE_SUPPORTS_THREADS=false |
| 142 |
LIBBACKTRACE="" |
| 143 |
|
| 144 |
AC_ARG_WITH(libbacktrace, |
| 145 |
AS_HELP_STRING([--without-libbacktrace], |
| 146 |
[Do not use libbacktrace in core.runtime (default: auto)])) |
| 147 |
|
| 148 |
AS_IF([test "x$enable_libbacktrace" != "xno" && test "x$with_libbacktrace" != "xno"], [ |
| 149 |
LIBBACKTRACE=../../libbacktrace/libbacktrace.la |
| 150 |
|
| 151 |
gdc_save_CPPFLAGS=$CPPFLAGS |
| 152 |
CPPFLAGS="$CPPFLAGS -I../libbacktrace " |
| 153 |
|
| 154 |
AC_CHECK_HEADER(backtrace-supported.h, have_libbacktrace_h=true, |
| 155 |
have_libbacktrace_h=false) |
| 156 |
|
| 157 |
if $have_libbacktrace_h; then |
| 158 |
AC_MSG_CHECKING([libbacktrace: BACKTRACE_SUPPORTED]) |
| 159 |
AC_EGREP_CPP(FOUND_LIBBACKTRACE_RESULT_GDC, |
| 160 |
[ |
| 161 |
#include <backtrace-supported.h> |
| 162 |
#if BACKTRACE_SUPPORTED |
| 163 |
FOUND_LIBBACKTRACE_RESULT_GDC |
| 164 |
#endif |
| 165 |
], BACKTRACE_SUPPORTED=true, BACKTRACE_SUPPORTED=false) |
| 166 |
AC_MSG_RESULT($BACKTRACE_SUPPORTED) |
| 167 |
|
| 168 |
AC_MSG_CHECKING([libbacktrace: BACKTRACE_USES_MALLOC]) |
| 169 |
AC_EGREP_CPP(FOUND_LIBBACKTRACE_RESULT_GDC, |
| 170 |
[ |
| 171 |
#include <backtrace-supported.h> |
| 172 |
#if BACKTRACE_USES_MALLOC |
| 173 |
FOUND_LIBBACKTRACE_RESULT_GDC |
| 174 |
#endif |
| 175 |
], BACKTRACE_USES_MALLOC=true, BACKTRACE_USES_MALLOC=false) |
| 176 |
AC_MSG_RESULT($BACKTRACE_USES_MALLOC) |
| 177 |
|
| 178 |
AC_MSG_CHECKING([libbacktrace: BACKTRACE_SUPPORTS_THREADS]) |
| 179 |
AC_EGREP_CPP(FOUND_LIBBACKTRACE_RESULT_GDC, |
| 180 |
[ |
| 181 |
#include <backtrace-supported.h> |
| 182 |
#if BACKTRACE_SUPPORTS_THREADS |
| 183 |
FOUND_LIBBACKTRACE_RESULT_GDC |
| 184 |
#endif |
| 185 |
], BACKTRACE_SUPPORTS_THREADS=true, BACKTRACE_SUPPORTS_THREADS=false) |
| 186 |
AC_MSG_RESULT($BACKTRACE_SUPPORTS_THREADS) |
| 187 |
fi |
| 188 |
CPPFLAGS=$gdc_save_CPPFLAGS |
| 189 |
], [ |
| 190 |
AC_MSG_CHECKING([for libbacktrace]) |
| 191 |
AC_MSG_RESULT([disabled]) |
| 192 |
]) |
| 193 |
|
| 194 |
AC_SUBST(LIBBACKTRACE) |
| 195 |
AC_SUBST(BACKTRACE_SUPPORTED) |
| 196 |
AC_SUBST(BACKTRACE_USES_MALLOC) |
| 197 |
AC_SUBST(BACKTRACE_SUPPORTS_THREADS) |
| 198 |
AC_LANG_POP([C]) |
| 199 |
]) |
| 200 |
|
| 201 |
# DRUNTIME_LIBRARIES_CLIB |
| 202 |
# ----------------------- |
| 203 |
# Perform various feature checks on the C library. |
| 204 |
AC_DEFUN([DRUNTIME_LIBRARIES_CLIB], |
| 205 |
[ |
| 206 |
AC_LANG_PUSH([C]) |
| 207 |
DCFG_HAVE_QSORT_R=false |
| 208 |
AC_CHECK_FUNC(qsort_r, [DCFG_HAVE_QSORT_R=true]) |
| 209 |
AC_SUBST(DCFG_HAVE_QSORT_R) |
| 210 |
AC_LANG_POP([C]) |
| 211 |
]) |
| 212 |
|
| 213 |
# DRUNTIME_LIBRARIES_UCONTEXT |
| 214 |
# ------------------------------ |
| 215 |
# Autodetect and add ucontext library to LIBS if necessary. |
| 216 |
# This is only required if fiber_switchContext does not have |
| 217 |
# its own internal asm implementation. |
| 218 |
AC_DEFUN([DRUNTIME_LIBRARIES_UCONTEXT], |
| 219 |
[ |
| 220 |
# Keep this in sync with core/thread.d, set druntime_fiber_asm_external to |
| 221 |
# "yes" for targets that have 'version = AsmExternal'. |
| 222 |
druntime_fiber_asm_external=no |
| 223 |
case "$target_cpu" in |
| 224 |
aarch64* | \ |
| 225 |
arm* | \ |
| 226 |
i[[34567]]86|x86_64 | \ |
| 227 |
powerpc) |
| 228 |
druntime_fiber_asm_external=yes |
| 229 |
;; |
| 230 |
esac |
| 231 |
if test "$druntime_fiber_asm_external" = no; then |
| 232 |
AC_SEARCH_LIBS([swapcontext], [c ucontext], [], |
| 233 |
AC_MSG_ERROR([swapcontext required but not found])) |
| 234 |
fi |
| 235 |
]) |
| 236 |
|
| 237 |
# DRUNTIME_LIBRARIES_VALGRIND |
| 238 |
# ------------------------------ |
| 239 |
# Allow specifying whether to use valgrind integration in the GC, which enables |
| 240 |
# the D run-time to communicate which memory access operations are valid. |
| 241 |
# This is only required if `--enable-libphobos-checking=valgrind' was seen. |
| 242 |
AC_DEFUN([DRUNTIME_LIBRARIES_VALGRIND], |
| 243 |
[ |
| 244 |
AC_CHECK_HEADERS(stddef.h stdlib.h) |
| 245 |
|
| 246 |
AC_CHECK_HEADER(valgrind.h, have_valgrind_h=yes, have_valgrind_h=no) |
| 247 |
|
| 248 |
AC_MSG_CHECKING(for VALGRIND_DISCARD in <valgrind/memcheck.h>) |
| 249 |
AC_PREPROC_IFELSE([AC_LANG_SOURCE( |
| 250 |
[[#include <valgrind/memcheck.h> |
| 251 |
#ifndef VALGRIND_DISCARD |
| 252 |
#error VALGRIND_DISCARD not defined |
| 253 |
#endif]])], |
| 254 |
[have_valgrind_memcheck_h=yes], |
| 255 |
[have_valgrind_memcheck_h=no]) |
| 256 |
AC_MSG_RESULT($have_valgrind_memcheck_h) |
| 257 |
AC_MSG_CHECKING(for VALGRIND_DISCARD in <memcheck.h>) |
| 258 |
AC_PREPROC_IFELSE([AC_LANG_SOURCE( |
| 259 |
[[#include <memcheck.h> |
| 260 |
#ifndef VALGRIND_DISCARD |
| 261 |
#error VALGRIND_DISCARD not defined |
| 262 |
#endif]])], |
| 263 |
[have_memcheck_h=yes], |
| 264 |
[have_memcheck_h=no]) |
| 265 |
AC_MSG_RESULT($have_memcheck_h) |
| 266 |
|
| 267 |
if test x$VALGRIND_FLAG != x ; then |
| 268 |
AC_DEFINE(ENABLE_VALGRIND_CHECKING, 1, |
| 269 |
[Define to enable to integrate valgrind (a memory checker) in the GC.]) |
| 270 |
fi |
| 271 |
if test $have_valgrind_memcheck_h = yes; then |
| 272 |
AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1, |
| 273 |
[Define if valgrind's valgrind/memcheck.h header is installed.]) |
| 274 |
fi |
| 275 |
if test $have_memcheck_h = yes; then |
| 276 |
AC_DEFINE(HAVE_MEMCHECK_H, 1, |
| 277 |
[Define if valgrind's memcheck.h header is installed.]) |
| 278 |
fi |
| 279 |
|
| 280 |
if test x$VALGRIND_FLAG != x; then |
| 281 |
if (test $have_valgrind_h = no \ |
| 282 |
&& test $have_memcheck_h = no \ |
| 283 |
&& test $have_valgrind_memcheck_h = no); then |
| 284 |
AC_MSG_ERROR([*** valgrind checking requested, but |
| 285 |
*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h]) |
| 286 |
fi |
| 287 |
fi |
| 288 |
]) |