1## ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*- 2## Copyright (C) 1999-2000 Free Software Foundation, Inc. 3## 4## This file is free software; the Free Software Foundation gives 5## unlimited permission to copy and/or distribute it, with or without 6## modifications, as long as this notice is preserved. 7 8# serial 6 AC_LIB_LTDL 9 10# AC_WITH_LTDL 11# ------------ 12# Clients of libltdl can use this macro to allow the installer to 13# choose between a shipped copy of the ltdl sources or a preinstalled 14# version of the library. 15AC_DEFUN([AC_WITH_LTDL], 16[AC_REQUIRE([AC_LIB_LTDL]) 17AC_SUBST([LIBLTDL]) 18AC_SUBST([INCLTDL]) 19 20# Unless the user asks us to check, assume no installed ltdl exists. 21use_installed_libltdl=no 22 23AC_ARG_WITH([included_ltdl], 24 [ --with-included-ltdl use the GNU ltdl sources included here]) 25 26if test "x$with_included_ltdl" != xyes; then 27 # We are not being forced to use the included libltdl sources, so 28 # decide whether there is a useful installed version we can use. 29 AC_CHECK_HEADER([ltdl.h], 30 [AC_CHECK_LIB([ltdl], [lt_dlcaller_register], 31 [with_included_ltdl=no], 32 [with_included_ltdl=yes]) 33 ]) 34fi 35 36if test "x$enable_ltdl_install" != xyes; then 37 # If the user did not specify an installable libltdl, then default 38 # to a convenience lib. 39 AC_LIBLTDL_CONVENIENCE 40fi 41 42if test "x$with_included_ltdl" = xno; then 43 # If the included ltdl is not to be used. then Use the 44 # preinstalled libltdl we found. 45 AC_DEFINE([HAVE_LTDL], [1], 46 [Define this if a modern libltdl is already installed]) 47 LIBLTDL=-lltdl 48fi 49 50# Report our decision... 51AC_MSG_CHECKING([whether to use included libltdl]) 52AC_MSG_RESULT([$with_included_ltdl]) 53 54AC_CONFIG_SUBDIRS([libltdl]) 55])# AC_WITH_LTDL 56 57 58# AC_LIB_LTDL 59# ----------- 60# Perform all the checks necessary for compilation of the ltdl objects 61# -- including compiler checks and header checks. 62AC_DEFUN([AC_LIB_LTDL], 63[AC_PREREQ(2.50) 64AC_REQUIRE([AC_PROG_CC]) 65AC_REQUIRE([AC_C_CONST]) 66AC_REQUIRE([AC_HEADER_STDC]) 67AC_REQUIRE([AC_HEADER_DIRENT]) 68AC_REQUIRE([_LT_AC_CHECK_DLFCN]) 69AC_REQUIRE([AC_LTDL_ENABLE_INSTALL]) 70AC_REQUIRE([AC_LTDL_SHLIBEXT]) 71AC_REQUIRE([AC_LTDL_SHLIBPATH]) 72AC_REQUIRE([AC_LTDL_SYSSEARCHPATH]) 73AC_REQUIRE([AC_LTDL_OBJDIR]) 74AC_REQUIRE([AC_LTDL_DLPREOPEN]) 75AC_REQUIRE([AC_LTDL_DLLIB]) 76AC_REQUIRE([AC_LTDL_SYMBOL_USCORE]) 77AC_REQUIRE([AC_LTDL_DLSYM_USCORE]) 78AC_REQUIRE([AC_LTDL_SYS_DLOPEN_DEPLIBS]) 79AC_REQUIRE([AC_LTDL_FUNC_ARGZ]) 80 81AC_CHECK_HEADERS([assert.h ctype.h errno.h malloc.h memory.h stdlib.h \ 82 stdio.h unistd.h]) 83AC_CHECK_HEADERS([dl.h sys/dl.h dld.h mach-o/dyld.h]) 84AC_CHECK_HEADERS([string.h strings.h], [break]) 85 86AC_CHECK_FUNCS([strchr index], [break]) 87AC_CHECK_FUNCS([strrchr rindex], [break]) 88AC_CHECK_FUNCS([memcpy bcopy], [break]) 89AC_CHECK_FUNCS([memmove strcmp]) 90AC_CHECK_FUNCS([closedir opendir readdir]) 91])# AC_LIB_LTDL 92 93 94# AC_LTDL_ENABLE_INSTALL 95# ---------------------- 96AC_DEFUN([AC_LTDL_ENABLE_INSTALL], 97[AC_ARG_ENABLE([ltdl-install], 98 [AC_HELP_STRING([--enable-ltdl-install], [install libltdl])]) 99 100AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno) 101AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno) 102])])# AC_LTDL_ENABLE_INSTALL 103 104 105# AC_LTDL_SYS_DLOPEN_DEPLIBS 106# -------------------------- 107AC_DEFUN([AC_LTDL_SYS_DLOPEN_DEPLIBS], 108[AC_REQUIRE([AC_CANONICAL_HOST]) 109AC_CACHE_CHECK([whether deplibs are loaded by dlopen], 110 [libltdl_cv_sys_dlopen_deplibs], 111 [# PORTME does your system automatically load deplibs for dlopen? 112 # or its logical equivalent (e.g. shl_load for HP-UX < 11) 113 # For now, we just catch OSes we know something about -- in the 114 # future, we'll try test this programmatically. 115 libltdl_cv_sys_dlopen_deplibs=unknown 116 case "$host_os" in 117 aix3*|aix4.1.*|aix4.2.*) 118 # Unknown whether this is true for these versions of AIX, but 119 # we want this `case' here to explicitly catch those versions. 120 libltdl_cv_sys_dlopen_deplibs=unknown 121 ;; 122 aix[[45]]*) 123 libltdl_cv_sys_dlopen_deplibs=yes 124 ;; 125 darwin*) 126 # Assuming the user has installed a libdl from somewhere, this is true 127 # If you are looking for one http://www.opendarwin.org/projects/dlcompat 128 libltdl_cv_sys_dlopen_deplibs=yes 129 ;; 130 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) 131 # GNU and its variants, using gnu ld.so (Glibc) 132 libltdl_cv_sys_dlopen_deplibs=yes 133 ;; 134 hpux10*|hpux11*) 135 libltdl_cv_sys_dlopen_deplibs=yes 136 ;; 137 irix[[12345]]*|irix6.[[01]]*) 138 # Catch all versions of IRIX before 6.2, and indicate that we don't 139 # know how it worked for any of those versions. 140 libltdl_cv_sys_dlopen_deplibs=unknown 141 ;; 142 irix*) 143 # The case above catches anything before 6.2, and it's known that 144 # at 6.2 and later dlopen does load deplibs. 145 libltdl_cv_sys_dlopen_deplibs=yes 146 ;; 147 netbsd*) 148 libltdl_cv_sys_dlopen_deplibs=yes 149 ;; 150 openbsd*) 151 libltdl_cv_sys_dlopen_deplibs=yes 152 ;; 153 osf[[1234]]*) 154 # dlopen did load deplibs (at least at 4.x), but until the 5.x series, 155 # it did *not* use an RPATH in a shared library to find objects the 156 # library depends on, so we explictly say `no'. 157 libltdl_cv_sys_dlopen_deplibs=no 158 ;; 159 osf5.0|osf5.0a|osf5.1) 160 # dlopen *does* load deplibs and with the right loader patch applied 161 # it even uses RPATH in a shared library to search for shared objects 162 # that the library depends on, but there's no easy way to know if that 163 # patch is installed. Since this is the case, all we can really 164 # say is unknown -- it depends on the patch being installed. If 165 # it is, this changes to `yes'. Without it, it would be `no'. 166 libltdl_cv_sys_dlopen_deplibs=unknown 167 ;; 168 osf*) 169 # the two cases above should catch all versions of osf <= 5.1. Read 170 # the comments above for what we know about them. 171 # At > 5.1, deplibs are loaded *and* any RPATH in a shared library 172 # is used to find them so we can finally say `yes'. 173 libltdl_cv_sys_dlopen_deplibs=yes 174 ;; 175 solaris*) 176 libltdl_cv_sys_dlopen_deplibs=yes 177 ;; 178 esac 179 ]) 180if test "$libltdl_cv_sys_dlopen_deplibs" != yes; then 181 AC_DEFINE([LTDL_DLOPEN_DEPLIBS], [1], 182 [Define if the OS needs help to load dependent libraries for dlopen().]) 183fi 184])# AC_LTDL_SYS_DLOPEN_DEPLIBS 185 186 187# AC_LTDL_SHLIBEXT 188# ---------------- 189AC_DEFUN([AC_LTDL_SHLIBEXT], 190[AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER]) 191AC_CACHE_CHECK([which extension is used for loadable modules], 192 [libltdl_cv_shlibext], 193[ 194module=yes 195eval libltdl_cv_shlibext=$shrext_cmds 196 ]) 197if test -n "$libltdl_cv_shlibext"; then 198 AC_DEFINE_UNQUOTED([LTDL_SHLIB_EXT], ["$libltdl_cv_shlibext"], 199 [Define to the extension used for shared libraries, say, ".so".]) 200fi 201])# AC_LTDL_SHLIBEXT 202 203 204# AC_LTDL_SHLIBPATH 205# ----------------- 206AC_DEFUN([AC_LTDL_SHLIBPATH], 207[AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER]) 208AC_CACHE_CHECK([which variable specifies run-time library path], 209 [libltdl_cv_shlibpath_var], [libltdl_cv_shlibpath_var="$shlibpath_var"]) 210if test -n "$libltdl_cv_shlibpath_var"; then 211 AC_DEFINE_UNQUOTED([LTDL_SHLIBPATH_VAR], ["$libltdl_cv_shlibpath_var"], 212 [Define to the name of the environment variable that determines the dynamic library search path.]) 213fi 214])# AC_LTDL_SHLIBPATH 215 216 217# AC_LTDL_SYSSEARCHPATH 218# --------------------- 219AC_DEFUN([AC_LTDL_SYSSEARCHPATH], 220[AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER]) 221AC_CACHE_CHECK([for the default library search path], 222 [libltdl_cv_sys_search_path], 223 [libltdl_cv_sys_search_path="$sys_lib_dlsearch_path_spec"]) 224if test -n "$libltdl_cv_sys_search_path"; then 225 sys_search_path= 226 for dir in $libltdl_cv_sys_search_path; do 227 if test -z "$sys_search_path"; then 228 sys_search_path="$dir" 229 else 230 sys_search_path="$sys_search_path$PATH_SEPARATOR$dir" 231 fi 232 done 233 AC_DEFINE_UNQUOTED([LTDL_SYSSEARCHPATH], ["$sys_search_path"], 234 [Define to the system default library search path.]) 235fi 236])# AC_LTDL_SYSSEARCHPATH 237 238 239# AC_LTDL_OBJDIR 240# -------------- 241AC_DEFUN([AC_LTDL_OBJDIR], 242[AC_CACHE_CHECK([for objdir], 243 [libltdl_cv_objdir], 244 [libltdl_cv_objdir="$objdir" 245 if test -n "$objdir"; then 246 : 247 else 248 rm -f .libs 2>/dev/null 249 mkdir .libs 2>/dev/null 250 if test -d .libs; then 251 libltdl_cv_objdir=.libs 252 else 253 # MS-DOS does not allow filenames that begin with a dot. 254 libltdl_cv_objdir=_libs 255 fi 256 rmdir .libs 2>/dev/null 257 fi 258 ]) 259AC_DEFINE_UNQUOTED([LTDL_OBJDIR], ["$libltdl_cv_objdir/"], 260 [Define to the sub-directory in which libtool stores uninstalled libraries.]) 261])# AC_LTDL_OBJDIR 262 263 264# AC_LTDL_DLPREOPEN 265# ----------------- 266AC_DEFUN([AC_LTDL_DLPREOPEN], 267[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE]) 268AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen], 269 [libltdl_cv_preloaded_symbols], 270 [if test -n "$lt_cv_sys_global_symbol_pipe"; then 271 libltdl_cv_preloaded_symbols=yes 272 else 273 libltdl_cv_preloaded_symbols=no 274 fi 275 ]) 276if test x"$libltdl_cv_preloaded_symbols" = xyes; then 277 AC_DEFINE([HAVE_PRELOADED_SYMBOLS], [1], 278 [Define if libtool can extract symbol lists from object files.]) 279fi 280])# AC_LTDL_DLPREOPEN 281 282 283# AC_LTDL_DLLIB 284# ------------- 285AC_DEFUN([AC_LTDL_DLLIB], 286[LIBADD_DL= 287AC_SUBST(LIBADD_DL) 288AC_LANG_PUSH([C]) 289 290AC_CHECK_FUNC([shl_load], 291 [AC_DEFINE([HAVE_SHL_LOAD], [1], 292 [Define if you have the shl_load function.])], 293 [AC_CHECK_LIB([dld], [shl_load], 294 [AC_DEFINE([HAVE_SHL_LOAD], [1], 295 [Define if you have the shl_load function.]) 296 LIBADD_DL="$LIBADD_DL -ldld"], 297 [AC_CHECK_LIB([dl], [dlopen], 298 [AC_DEFINE([HAVE_LIBDL], [1], 299 [Define if you have the libdl library or equivalent.]) 300 LIBADD_DL="-ldl" libltdl_cv_lib_dl_dlopen="yes"], 301 [AC_TRY_LINK([#if HAVE_DLFCN_H 302# include <dlfcn.h> 303#endif 304 ], 305 [dlopen(0, 0);], 306 [AC_DEFINE([HAVE_LIBDL], [1], 307 [Define if you have the libdl library or equivalent.]) libltdl_cv_func_dlopen="yes"], 308 [AC_CHECK_LIB([svld], [dlopen], 309 [AC_DEFINE([HAVE_LIBDL], [1], 310 [Define if you have the libdl library or equivalent.]) 311 LIBADD_DL="-lsvld" libltdl_cv_func_dlopen="yes"], 312 [AC_CHECK_LIB([dld], [dld_link], 313 [AC_DEFINE([HAVE_DLD], [1], 314 [Define if you have the GNU dld library.]) 315 LIBADD_DL="$LIBADD_DL -ldld"], 316 [AC_CHECK_FUNC([_dyld_func_lookup], 317 [AC_DEFINE([HAVE_DYLD], [1], 318 [Define if you have the _dyld_func_lookup function.])]) 319 ]) 320 ]) 321 ]) 322 ]) 323 ]) 324]) 325 326if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes 327then 328 lt_save_LIBS="$LIBS" 329 LIBS="$LIBS $LIBADD_DL" 330 AC_CHECK_FUNCS([dlerror]) 331 LIBS="$lt_save_LIBS" 332fi 333AC_LANG_POP 334])# AC_LTDL_DLLIB 335 336 337# AC_LTDL_SYMBOL_USCORE 338# --------------------- 339# does the compiler prefix global symbols with an underscore? 340AC_DEFUN([AC_LTDL_SYMBOL_USCORE], 341[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE]) 342AC_CACHE_CHECK([for _ prefix in compiled symbols], 343 [ac_cv_sys_symbol_underscore], 344 [ac_cv_sys_symbol_underscore=no 345 cat > conftest.$ac_ext <<EOF 346void nm_test_func(){} 347int main(){nm_test_func;return 0;} 348EOF 349 if AC_TRY_EVAL(ac_compile); then 350 # Now try to grab the symbols. 351 ac_nlist=conftest.nm 352 if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then 353 # See whether the symbols have a leading underscore. 354 if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then 355 ac_cv_sys_symbol_underscore=yes 356 else 357 if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then 358 : 359 else 360 echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC 361 fi 362 fi 363 else 364 echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC 365 fi 366 else 367 echo "configure: failed program was:" >&AC_FD_CC 368 cat conftest.c >&AC_FD_CC 369 fi 370 rm -rf conftest* 371 ]) 372])# AC_LTDL_SYMBOL_USCORE 373 374 375# AC_LTDL_DLSYM_USCORE 376# -------------------- 377AC_DEFUN([AC_LTDL_DLSYM_USCORE], 378[AC_REQUIRE([AC_LTDL_SYMBOL_USCORE]) 379if test x"$ac_cv_sys_symbol_underscore" = xyes; then 380 if test x"$libltdl_cv_func_dlopen" = xyes || 381 test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then 382 AC_CACHE_CHECK([whether we have to add an underscore for dlsym], 383 [libltdl_cv_need_uscore], 384 [libltdl_cv_need_uscore=unknown 385 save_LIBS="$LIBS" 386 LIBS="$LIBS $LIBADD_DL" 387 _LT_AC_TRY_DLOPEN_SELF( 388 [libltdl_cv_need_uscore=no], [libltdl_cv_need_uscore=yes], 389 [], [libltdl_cv_need_uscore=cross]) 390 LIBS="$save_LIBS" 391 ]) 392 fi 393fi 394 395if test x"$libltdl_cv_need_uscore" = xyes; then 396 AC_DEFINE([NEED_USCORE], [1], 397 [Define if dlsym() requires a leading underscore in symbol names.]) 398fi 399])# AC_LTDL_DLSYM_USCORE 400 401# AC_LTDL_FUNC_ARGZ 402# ----------------- 403AC_DEFUN([AC_LTDL_FUNC_ARGZ], 404[AC_CHECK_HEADERS([argz.h]) 405 406AC_CHECK_TYPES([error_t], 407 [], 408 [AC_DEFINE([error_t], [int], 409 [Define to a type to use for `error_t' if it is not otherwise available.])], 410 [#if HAVE_ARGZ_H 411# include <argz.h> 412#endif]) 413 414AC_CHECK_FUNCS([argz_append argz_create_sep argz_insert argz_next argz_stringify]) 415])# AC_LTDL_FUNC_ARGZ 416