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 7 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.60) 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_SYSSEARCHPATH]) 72AC_REQUIRE([AC_LTDL_OBJDIR]) 73AC_REQUIRE([AC_LTDL_DLPREOPEN]) 74AC_REQUIRE([AC_LTDL_DLLIB]) 75AC_REQUIRE([AC_LTDL_SYMBOL_USCORE]) 76AC_REQUIRE([AC_LTDL_DLSYM_USCORE]) 77AC_REQUIRE([AC_LTDL_SYS_DLOPEN_DEPLIBS]) 78AC_REQUIRE([AC_LTDL_FUNC_ARGZ]) 79 80AC_CHECK_HEADERS([errno.h malloc.h memory.h unistd.h]) 81AC_CHECK_HEADERS([mach-o/dyld.h]) 82 83AC_CHECK_FUNCS([closedir opendir readdir]) 84])# AC_LIB_LTDL 85 86 87# AC_LTDL_ENABLE_INSTALL 88# ---------------------- 89AC_DEFUN([AC_LTDL_ENABLE_INSTALL], 90[AC_ARG_ENABLE([ltdl-install], 91 [AS_HELP_STRING([--enable-ltdl-install],[install libltdl])]) 92 93AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno) 94AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno) 95])# AC_LTDL_ENABLE_INSTALL 96 97 98# AC_LTDL_SYS_DLOPEN_DEPLIBS 99# -------------------------- 100AC_DEFUN([AC_LTDL_SYS_DLOPEN_DEPLIBS], 101[AC_REQUIRE([AC_CANONICAL_HOST]) 102AC_CACHE_CHECK([whether deplibs are loaded by dlopen], 103 [libltdl_cv_sys_dlopen_deplibs], 104 [# PORTME does your system automatically load deplibs for dlopen? 105 # or its logical equivalent (e.g. shl_load for HP-UX < 11) 106 # For now, we just catch OSes we know something about -- in the 107 # future, we'll try test this programmatically. 108 libltdl_cv_sys_dlopen_deplibs=unknown 109 case "$host_os" in 110 aix3*|aix4.1.*|aix4.2.*) 111 # Unknown whether this is true for these versions of AIX, but 112 # we want this `case' here to explicitly catch those versions. 113 libltdl_cv_sys_dlopen_deplibs=unknown 114 ;; 115 aix[[45]]*) 116 libltdl_cv_sys_dlopen_deplibs=yes 117 ;; 118 darwin*) 119 # Assuming the user has installed a libdl from somewhere, this is true 120 # If you are looking for one http://www.opendarwin.org/projects/dlcompat 121 libltdl_cv_sys_dlopen_deplibs=yes 122 ;; 123 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu) 124 # GNU and its variants, using gnu ld.so (Glibc) 125 libltdl_cv_sys_dlopen_deplibs=yes 126 ;; 127 hpux10*|hpux11*) 128 libltdl_cv_sys_dlopen_deplibs=yes 129 ;; 130 interix*) 131 libltdl_cv_sys_dlopen_deplibs=yes 132 ;; 133 irix[[12345]]*|irix6.[[01]]*) 134 # Catch all versions of IRIX before 6.2, and indicate that we don't 135 # know how it worked for any of those versions. 136 libltdl_cv_sys_dlopen_deplibs=unknown 137 ;; 138 irix*) 139 # The case above catches anything before 6.2, and it's known that 140 # at 6.2 and later dlopen does load deplibs. 141 libltdl_cv_sys_dlopen_deplibs=yes 142 ;; 143 netbsd*) 144 libltdl_cv_sys_dlopen_deplibs=yes 145 ;; 146 openbsd*) 147 libltdl_cv_sys_dlopen_deplibs=yes 148 ;; 149 osf[[1234]]*) 150 # dlopen did load deplibs (at least at 4.x), but until the 5.x series, 151 # it did *not* use an RPATH in a shared library to find objects the 152 # library depends on, so we explicitly say `no'. 153 libltdl_cv_sys_dlopen_deplibs=no 154 ;; 155 osf5.0|osf5.0a|osf5.1) 156 # dlopen *does* load deplibs and with the right loader patch applied 157 # it even uses RPATH in a shared library to search for shared objects 158 # that the library depends on, but there's no easy way to know if that 159 # patch is installed. Since this is the case, all we can really 160 # say is unknown -- it depends on the patch being installed. If 161 # it is, this changes to `yes'. Without it, it would be `no'. 162 libltdl_cv_sys_dlopen_deplibs=unknown 163 ;; 164 osf*) 165 # the two cases above should catch all versions of osf <= 5.1. Read 166 # the comments above for what we know about them. 167 # At > 5.1, deplibs are loaded *and* any RPATH in a shared library 168 # is used to find them so we can finally say `yes'. 169 libltdl_cv_sys_dlopen_deplibs=yes 170 ;; 171 solaris*) 172 libltdl_cv_sys_dlopen_deplibs=yes 173 ;; 174 sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) 175 libltdl_cv_sys_dlopen_deplibs=yes 176 ;; 177 esac 178 ]) 179if test "$libltdl_cv_sys_dlopen_deplibs" != yes; then 180 AC_DEFINE([LTDL_DLOPEN_DEPLIBS], [1], 181 [Define if the OS needs help to load dependent libraries for dlopen().]) 182fi 183])# AC_LTDL_SYS_DLOPEN_DEPLIBS 184 185 186# AC_LTDL_SHLIBEXT 187# ---------------- 188AC_DEFUN([AC_LTDL_SHLIBEXT], 189[AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER]) 190AC_CACHE_CHECK([which extension is used for loadable modules], 191 [libltdl_cv_shlibext], 192[ 193module=yes 194eval libltdl_cv_shlibext=$shrext_cmds 195 ]) 196if test -n "$libltdl_cv_shlibext"; then 197 AC_DEFINE_UNQUOTED([LTDL_SHLIB_EXT], ["$libltdl_cv_shlibext"], 198 [Define to the extension used for shared libraries, say, ".so".]) 199fi 200])# AC_LTDL_SHLIBEXT 201 202# AC_LTDL_SYSSEARCHPATH 203# --------------------- 204AC_DEFUN([AC_LTDL_SYSSEARCHPATH], 205[AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER]) 206AC_CACHE_CHECK([for the default library search path], 207 [libltdl_cv_sys_search_path], 208 [libltdl_cv_sys_search_path="$sys_lib_dlsearch_path_spec"]) 209if test -n "$libltdl_cv_sys_search_path"; then 210 sys_search_path= 211 for dir in $libltdl_cv_sys_search_path; do 212 if test -z "$sys_search_path"; then 213 sys_search_path="$dir" 214 else 215 sys_search_path="$sys_search_path$PATH_SEPARATOR$dir" 216 fi 217 done 218 AC_DEFINE_UNQUOTED([LTDL_SYSSEARCHPATH], ["$sys_search_path"], 219 [Define to the system default library search path.]) 220fi 221])# AC_LTDL_SYSSEARCHPATH 222 223 224# AC_LTDL_OBJDIR 225# -------------- 226AC_DEFUN([AC_LTDL_OBJDIR], 227[AC_CACHE_CHECK([for objdir], 228 [libltdl_cv_objdir], 229 [libltdl_cv_objdir="$objdir" 230 if test -n "$objdir"; then 231 : 232 else 233 rm -f .libs 2>/dev/null 234 mkdir .libs 2>/dev/null 235 if test -d .libs; then 236 libltdl_cv_objdir=.libs 237 else 238 # MS-DOS does not allow filenames that begin with a dot. 239 libltdl_cv_objdir=_libs 240 fi 241 rmdir .libs 2>/dev/null 242 fi 243 ]) 244AC_DEFINE_UNQUOTED([LTDL_OBJDIR], ["$libltdl_cv_objdir/"], 245 [Define to the sub-directory in which libtool stores uninstalled libraries.]) 246])# AC_LTDL_OBJDIR 247 248 249# AC_LTDL_DLPREOPEN 250# ----------------- 251AC_DEFUN([AC_LTDL_DLPREOPEN], 252[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE]) 253AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen], 254 [libltdl_cv_preloaded_symbols], 255 [if test -n "$lt_cv_sys_global_symbol_pipe"; then 256 libltdl_cv_preloaded_symbols=yes 257 else 258 libltdl_cv_preloaded_symbols=no 259 fi 260 ]) 261if test x"$libltdl_cv_preloaded_symbols" = xyes; then 262 AC_DEFINE([HAVE_PRELOADED_SYMBOLS], [1], 263 [Define if libtool can extract symbol lists from object files.]) 264fi 265])# AC_LTDL_DLPREOPEN 266 267 268# AC_LTDL_DLLIB 269# ------------- 270AC_DEFUN([AC_LTDL_DLLIB], 271[LIBADD_DL= 272AC_SUBST(LIBADD_DL) 273AC_LANG_PUSH([C]) 274 275AC_CHECK_FUNC([shl_load], 276 [AC_DEFINE([HAVE_SHL_LOAD], [1], 277 [Define if you have the shl_load function.])], 278 [AC_CHECK_LIB([dld], [shl_load], 279 [AC_DEFINE([HAVE_SHL_LOAD], [1], 280 [Define if you have the shl_load function.]) 281 LIBADD_DL="$LIBADD_DL -ldld"], 282 [AC_CHECK_LIB([dl], [dlopen], 283 [AC_DEFINE([HAVE_LIBDL], [1], 284 [Define if you have the libdl library or equivalent.]) 285 LIBADD_DL="-ldl" libltdl_cv_lib_dl_dlopen="yes"], 286 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_DLFCN_H 287# include <dlfcn.h> 288#endif 289 ]], [[dlopen(0, 0);]])],[AC_DEFINE([HAVE_LIBDL], [1], 290 [Define if you have the libdl library or equivalent.]) libltdl_cv_func_dlopen="yes"],[AC_CHECK_LIB([svld], [dlopen], 291 [AC_DEFINE([HAVE_LIBDL], [1], 292 [Define if you have the libdl library or equivalent.]) 293 LIBADD_DL="-lsvld" libltdl_cv_func_dlopen="yes"], 294 [AC_CHECK_LIB([dld], [dld_link], 295 [AC_DEFINE([HAVE_DLD], [1], 296 [Define if you have the GNU dld library.]) 297 LIBADD_DL="$LIBADD_DL -ldld"], 298 [AC_CHECK_FUNC([_dyld_func_lookup], 299 [AC_DEFINE([HAVE_DYLD], [1], 300 [Define if you have the _dyld_func_lookup function.])]) 301 ]) 302 ]) 303 ]) 304 ]) 305 ]) 306]) 307 308if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes 309then 310 lt_save_LIBS="$LIBS" 311 LIBS="$LIBS $LIBADD_DL" 312 AC_CHECK_FUNCS([dlerror]) 313 LIBS="$lt_save_LIBS" 314fi 315AC_LANG_POP 316])# AC_LTDL_DLLIB 317 318 319# AC_LTDL_SYMBOL_USCORE 320# --------------------- 321# does the compiler prefix global symbols with an underscore? 322AC_DEFUN([AC_LTDL_SYMBOL_USCORE], 323[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE]) 324AC_CACHE_CHECK([for _ prefix in compiled symbols], 325 [ac_cv_sys_symbol_underscore], 326 [ac_cv_sys_symbol_underscore=no 327 cat > conftest.$ac_ext <<EOF 328void nm_test_func(){} 329int main(){nm_test_func;return 0;} 330EOF 331 if AC_TRY_EVAL(ac_compile); then 332 # Now try to grab the symbols. 333 ac_nlist=conftest.nm 334 if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then 335 # See whether the symbols have a leading underscore. 336 if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then 337 ac_cv_sys_symbol_underscore=yes 338 else 339 if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then 340 : 341 else 342 echo "configure: cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD 343 fi 344 fi 345 else 346 echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD 347 fi 348 else 349 echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD 350 cat conftest.c >&AS_MESSAGE_LOG_FD 351 fi 352 rm -rf conftest* 353 ]) 354])# AC_LTDL_SYMBOL_USCORE 355 356 357# AC_LTDL_DLSYM_USCORE 358# -------------------- 359AC_DEFUN([AC_LTDL_DLSYM_USCORE], 360[AC_REQUIRE([AC_LTDL_SYMBOL_USCORE]) 361if test x"$ac_cv_sys_symbol_underscore" = xyes; then 362 if test x"$libltdl_cv_func_dlopen" = xyes || 363 test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then 364 AC_CACHE_CHECK([whether we have to add an underscore for dlsym], 365 [libltdl_cv_need_uscore], 366 [libltdl_cv_need_uscore=unknown 367 save_LIBS="$LIBS" 368 LIBS="$LIBS $LIBADD_DL" 369 _LT_AC_TRY_DLOPEN_SELF( 370 [libltdl_cv_need_uscore=no], [libltdl_cv_need_uscore=yes], 371 [], [libltdl_cv_need_uscore=cross]) 372 LIBS="$save_LIBS" 373 ]) 374 fi 375fi 376 377if test x"$libltdl_cv_need_uscore" = xyes; then 378 AC_DEFINE([NEED_USCORE], [1], 379 [Define if dlsym() requires a leading underscore in symbol names.]) 380fi 381])# AC_LTDL_DLSYM_USCORE 382