blob: e2d277fffd1851a9b4d18845a00c34e1a0458ff0 [file] [log] [blame]
paule0a29622004-08-19 04:34:29 +00001## ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*-
2## Copyright (C) 1999-2004 Free Software Foundation, Inc.
3##
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful, but
10## WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12## General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17##
18## As a special exception to the GNU General Public License, if you
19## distribute this file as part of a program that contains a
20## configuration script generated by Autoconf, you may include it under
21## the same distribution terms that you use for the rest of that program.
22
23# serial 6 AC_LIB_LTDL
24
25# AC_WITH_LTDL([DIRECTORY])
26# -------------------------
27# Clients of libltdl can use this macro to allow the installer to
28# choose between a shipped copy of the ltdl sources or a preinstalled
29# version of the library.
30AC_DEFUN([AC_WITH_LTDL],
31[AC_ARG_WITH([included_ltdl],
32 [AC_HELP_STRING([--with-included-ltdl],
33 [use the GNU ltdl sources included here])])
34
35if test "x$with_included_ltdl" != xyes; then
36 # We are not being forced to use the included libltdl sources, so
37 # decide whether there is a useful installed version we can use.
38 AC_CHECK_HEADER([ltdl.h],
39 [AC_CHECK_LIB([ltdl], [lt_dlcaller_register],
40 [with_included_ltdl=no],
41 [with_included_ltdl=yes])],
42
43 [],
44 [AC_INCLUDES_DEFAULT]
45 )
46fi
47
48if test "x$enable_ltdl_install" != xyes; then
49 # If the user did not specify an installable libltdl, then default
50 # to a convenience lib.
51 AC_LIBLTDL_CONVENIENCE
52fi
53
54if test "x$with_included_ltdl" = xno; then
55 # If the included ltdl is not to be used. then Use the
56 # preinstalled libltdl we found.
57 AC_DEFINE([HAVE_LTDL], 1,
58 [Define this if a modern libltdl is already installed])
59 LIBLTDL=-lltdl
60fi
61
62# Report our decision...
63AC_MSG_CHECKING([whether to use included libltdl])
64AC_MSG_RESULT([$with_included_ltdl])
65
66AC_CONFIG_SUBDIRS(m4_if($#, 1, [$1], [libltdl]))
67])# AC_WITH_LTDL
68
69
70# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
71# -----------------------------------
72# sets LIBLTDL to the link flags for the libltdl convenience library and
73# LTDLINCL to the include flags for the libltdl header and adds
74# --enable-ltdl-convenience to the configure arguments. Note that LIBLTDL
75# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If
76# DIRECTORY is not provided, it is assumed to be `libltdl'. LIBLTDL will
77# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed with
78# '${top_srcdir}/' (note the single quotes!). If your package is not
79# flat and you're not using automake, define top_builddir and
80# top_srcdir appropriately in the Makefiles.
81AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
82[case $enable_ltdl_convenience in
83 no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
84 "") enable_ltdl_convenience=yes
85 ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
86 esac
87LIBLTDL='${top_builddir}/'m4_if($#, 1, [$1], ['libltdl'])/libltdlc.la
88LTDLINCL='-I${top_srcdir}/'m4_if($#, 1, [$1], ['libltdl'])
89
90AC_SUBST([LIBLTDL])
91AC_SUBST([LTDLINCL])
92
93# For backwards non-gettext consistent compatibility...
94INCLTDL="$LTDLINCL"
95AC_SUBST([INCLTDL])
96])# AC_LIBLTDL_CONVENIENCE
97
98
99# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
100# -----------------------------------
101# sets LIBLTDL to the link flags for the libltdl installable library and
102# LTDLINCL to the include flags for the libltdl header and adds
103# --enable-ltdl-install to the configure arguments. Note that LIBLTDL
104# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If
105# DIRECTORY is not provided and an installed libltdl is not found, it is
106# assumed to be `libltdl'. LIBLTDL will be prefixed with '${top_builddir}/'
107# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single
108# quotes!). If your package is not flat and you're not using automake,
109# define top_builddir and top_srcdir appropriately in the Makefiles.
110# In the future, this macro may have to be called after LT_INIT.
111AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
112[AC_CHECK_LIB(ltdl, lt_dlinit,
113 [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
114 [if test x"$enable_ltdl_install" = xno; then
115 AC_MSG_WARN([libltdl not installed, but installation disabled])
116 else
117 enable_ltdl_install=yes
118 fi
119 ])
120if test x"$enable_ltdl_install" = x"yes"; then
121 ac_configure_args="$ac_configure_args --enable-ltdl-install"
122 LIBLTDL='${top_builddir}/'m4_if($#, 1, [$1], ['libltdl'])/libltdl.la
123 LTDLINCL='-I${top_srcdir}/'m4_if($#, 1, [$1], ['libltdl'])
124else
125 ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
126 LIBLTDL="-lltdl"
127 LTDLINCL=
128fi
129
130AC_SUBST([LIBLTDL])
131AC_SUBST([LTDLINCL])
132
133# For backwards non-gettext consistent compatibility...
134INCLTDL="$LTDLINCL"
135AC_SUBST([INCLTDL])
136])# AC_LIBLTDL_INSTALLABLE
137
138
139# AC_LIB_LTDL
140# -----------
141# Perform all the checks necessary for compilation of the ltdl objects
142# -- including compiler checks and header checks.
143AC_DEFUN([AC_LIB_LTDL],
144[AC_REQUIRE([AC_PROG_CC])
145AC_REQUIRE([AC_C_CONST])
146AC_REQUIRE([AC_HEADER_STDC])
147AC_REQUIRE([AC_HEADER_DIRENT])
148AC_REQUIRE([_LT_AC_CHECK_DLFCN])
149AC_REQUIRE([AC_LTDL_ENABLE_INSTALL])
150AC_REQUIRE([AC_LTDL_SHLIBEXT])
151AC_REQUIRE([AC_LTDL_SHLIBPATH])
152AC_REQUIRE([AC_LTDL_SYSSEARCHPATH])
153AC_REQUIRE([AC_LTDL_OBJDIR])
154AC_REQUIRE([AC_LTDL_DLPREOPEN])
155AC_REQUIRE([AC_LTDL_DLLIB])
156AC_REQUIRE([AC_LTDL_SYMBOL_USCORE])
157AC_REQUIRE([AC_LTDL_DLSYM_USCORE])
158AC_REQUIRE([AC_LTDL_SYS_DLOPEN_DEPLIBS])
159AC_REQUIRE([gl_FUNC_ARGZ])
160
161# In order that ltdl.c can compile, run AC_CONFIG_HEADERS for the user
162# if they did not call it themself. This is so that ltdl.h can pick up
163# the parent projects config.h file, The first file in AC_CONFIG_HEADERS
164# must contain the definitions required by ltdl.c.
165m4_ifset([AC_LIST_HEADERS],
166 [CONFIG_H=`echo "AC_LIST_HEADERS" | $SED 's,^[[ ]]*,,;s,[[ :]].*$,,'`],
167 [CONFIG_H=config.h;AC_CONFIG_HEADERS([config.h])])
168AC_SUBST([CONFIG_H])
169
170AC_CHECK_HEADERS([memory.h unistd.h dl.h sys/dl.h dld.h mach-o/dyld.h],
171 [], [], [AC_INCLUDES_DEFAULT])
172AC_CHECK_HEADERS([string.h strings.h], [break], [], [AC_INCLUDES_DEFAULT])
173
174AC_CHECK_FUNCS([closedir opendir readdir], [], [AC_LIBOBJ([lt__dirent])])
175])# AC_LIB_LTDL
176
177
178# AC_LTDL_ENABLE_INSTALL
179# ----------------------
180AC_DEFUN([AC_LTDL_ENABLE_INSTALL],
181[AC_ARG_ENABLE([ltdl-install],
182 [AC_HELP_STRING([--enable-ltdl-install], [install libltdl])])
183
184AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno)
185AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno)
186])])# AC_LTDL_ENABLE_INSTALL
187
188
189# AC_LTDL_SYS_DLOPEN_DEPLIBS
190# --------------------------
191AC_DEFUN([AC_LTDL_SYS_DLOPEN_DEPLIBS],
192[AC_REQUIRE([AC_CANONICAL_HOST])
193AC_CACHE_CHECK([whether deplibs are loaded by dlopen],
194 [libltdl_cv_sys_dlopen_deplibs],
195 [# PORTME does your system automatically load deplibs for dlopen?
196 # or its logical equivalent (e.g. shl_load for HP-UX < 11)
197 # For now, we just catch OSes we know something about -- in the
198 # future, we'll try test this programmatically.
199 libltdl_cv_sys_dlopen_deplibs=unknown
200 case "$host_os" in
201 aix3*|aix4.1.*|aix4.2.*)
202 # Unknown whether this is true for these versions of AIX, but
203 # we want this `case' here to explicitly catch those versions.
204 libltdl_cv_sys_dlopen_deplibs=unknown
205 ;;
206 aix[[45]]*)
207 libltdl_cv_sys_dlopen_deplibs=yes
208 ;;
209 darwin*)
210 # Assuming the user has installed a libdl from somewhere, this is true
211 # If you are looking for one http://www.opendarwin.org/projects/dlcompat
212 libltdl_cv_sys_dlopen_deplibs=yes
213 ;;
214 gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
215 # GNU and its variants, using gnu ld.so (Glibc)
216 libltdl_cv_sys_dlopen_deplibs=yes
217 ;;
218 hpux10*|hpux11*)
219 libltdl_cv_sys_dlopen_deplibs=yes
220 ;;
221 irix[[12345]]*|irix6.[[01]]*)
222 # Catch all versions of IRIX before 6.2, and indicate that we don't
223 # know how it worked for any of those versions.
224 libltdl_cv_sys_dlopen_deplibs=unknown
225 ;;
226 irix*)
227 # The case above catches anything before 6.2, and it's known that
228 # at 6.2 and later dlopen does load deplibs.
229 libltdl_cv_sys_dlopen_deplibs=yes
230 ;;
231 netbsd*)
232 libltdl_cv_sys_dlopen_deplibs=yes
233 ;;
234 openbsd*)
235 libltdl_cv_sys_dlopen_deplibs=yes
236 ;;
237 osf[[1234]]*)
238 # dlopen did load deplibs (at least at 4.x), but until the 5.x series,
239 # it did *not* use an RPATH in a shared library to find objects the
240 # library depends on, so we explictly say `no'.
241 libltdl_cv_sys_dlopen_deplibs=no
242 ;;
243 osf5.0|osf5.0a|osf5.1)
244 # dlopen *does* load deplibs and with the right loader patch applied
245 # it even uses RPATH in a shared library to search for shared objects
246 # that the library depends on, but there's no easy way to know if that
247 # patch is installed. Since this is the case, all we can really
248 # say is unknown -- it depends on the patch being installed. If
249 # it is, this changes to `yes'. Without it, it would be `no'.
250 libltdl_cv_sys_dlopen_deplibs=unknown
251 ;;
252 osf*)
253 # the two cases above should catch all versions of osf <= 5.1. Read
254 # the comments above for what we know about them.
255 # At > 5.1, deplibs are loaded *and* any RPATH in a shared library
256 # is used to find them so we can finally say `yes'.
257 libltdl_cv_sys_dlopen_deplibs=yes
258 ;;
259 qnx*)
260 libltdl_cv_sys_dlopen_deplibs=yes
261 ;;
262 solaris*)
263 libltdl_cv_sys_dlopen_deplibs=yes
264 ;;
265 esac
266 ])
267if test "$libltdl_cv_sys_dlopen_deplibs" != yes; then
268 AC_DEFINE([LTDL_DLOPEN_DEPLIBS], [1],
269 [Define if the OS needs help to load dependent libraries for dlopen().])
270fi
271])# AC_LTDL_SYS_DLOPEN_DEPLIBS
272
273
274# AC_LTDL_SHLIBEXT
275# ----------------
276AC_DEFUN([AC_LTDL_SHLIBEXT],
277[AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER])
278AC_CACHE_CHECK([which extension is used for loadable modules],
279 [libltdl_cv_shlibext],
280[
281module=yes
282eval libltdl_cv_shlibext=$shrext_cmds
283 ])
284if test -n "$libltdl_cv_shlibext"; then
285 AC_DEFINE_UNQUOTED(LTDL_SHLIB_EXT, "$libltdl_cv_shlibext",
286 [Define to the extension used for shared libraries, say, ".so".])
287fi
288])# AC_LTDL_SHLIBEXT
289
290
291# AC_LTDL_SHLIBPATH
292# -----------------
293AC_DEFUN([AC_LTDL_SHLIBPATH],
294[AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER])
295AC_CACHE_CHECK([which variable specifies run-time library path],
296 [libltdl_cv_shlibpath_var], [libltdl_cv_shlibpath_var="$shlibpath_var"])
297if test -n "$libltdl_cv_shlibpath_var"; then
298 AC_DEFINE_UNQUOTED(LTDL_SHLIBPATH_VAR, "$libltdl_cv_shlibpath_var",
299 [Define to the name of the environment variable that determines the dynamic library search path.])
300fi
301])# AC_LTDL_SHLIBPATH
302
303
304# AC_LTDL_SYSSEARCHPATH
305# ---------------------
306AC_DEFUN([AC_LTDL_SYSSEARCHPATH],
307[AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER])
308AC_CACHE_CHECK([for the default library search path],
309 [libltdl_cv_sys_search_path],
310 [libltdl_cv_sys_search_path="$sys_lib_dlsearch_path_spec"])
311if test -n "$libltdl_cv_sys_search_path"; then
312 sys_search_path=
313 for dir in $libltdl_cv_sys_search_path; do
314 if test -z "$sys_search_path"; then
315 sys_search_path="$dir"
316 else
317 sys_search_path="$sys_search_path$PATH_SEPARATOR$dir"
318 fi
319 done
320 AC_DEFINE_UNQUOTED(LTDL_SYSSEARCHPATH, "$sys_search_path",
321 [Define to the system default library search path.])
322fi
323])# AC_LTDL_SYSSEARCHPATH
324
325
326# AC_LTDL_OBJDIR
327# --------------
328AC_DEFUN([AC_LTDL_OBJDIR],
329[AC_CACHE_CHECK([for objdir],
330 [libltdl_cv_objdir],
331 [libltdl_cv_objdir="$objdir"
332 if test -n "$objdir"; then
333 :
334 else
335 rm -f .libs 2>/dev/null
336 mkdir .libs 2>/dev/null
337 if test -d .libs; then
338 libltdl_cv_objdir=.libs
339 else
340 # MS-DOS does not allow filenames that begin with a dot.
341 libltdl_cv_objdir=_libs
342 fi
343 rmdir .libs 2>/dev/null
344 fi
345 ])
346AC_DEFINE_UNQUOTED(LTDL_OBJDIR, "$libltdl_cv_objdir/",
347 [Define to the sub-directory in which libtool stores uninstalled libraries.])
348])# AC_LTDL_OBJDIR
349
350
351# AC_LTDL_DLPREOPEN
352# -----------------
353AC_DEFUN([AC_LTDL_DLPREOPEN],
354[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
355AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen],
356 [libltdl_cv_preloaded_symbols],
357 [if test -n "$lt_cv_sys_global_symbol_pipe"; then
358 libltdl_cv_preloaded_symbols=yes
359 else
360 libltdl_cv_preloaded_symbols=no
361 fi
362 ])
363if test x"$libltdl_cv_preloaded_symbols" = xyes; then
364 AC_DEFINE(HAVE_PRELOADED_SYMBOLS, 1,
365 [Define if libtool can extract symbol lists from object files.])
366fi
367])# AC_LTDL_DLPREOPEN
368
369
370# AC_LTDL_DLLIB
371# -------------
372AC_DEFUN([AC_LTDL_DLLIB],
373[m4_pattern_allow([^LT_DLLOADERS$])
374LT_DLLOADERS=
375AC_SUBST([LT_DLLOADERS])
376
377AC_LANG_PUSH([C])
378
379LIBADD_DLOPEN=
380AC_CHECK_LIB([dl], [dlopen],
381 [AC_DEFINE([HAVE_LIBDL], [1],
382 [Define if you have the libdl library or equivalent.])
383 LIBADD_DLOPEN="-ldl" libltdl_cv_lib_dl_dlopen="yes"
384 LT_DLLOADERS="$LT_DLLOADERS dlopen.la"],
385 [AC_TRY_LINK([#if HAVE_DLFCN_H
386# include <dlfcn.h>
387#endif
388 ], [dlopen(0, 0);],
389 [AC_DEFINE([HAVE_LIBDL], [1],
390 [Define if you have the libdl library or equivalent.])
391 libltdl_cv_func_dlopen="yes"
392 LT_DLLOADERS="$LT_DLLOADERS dlopen.la"],
393 [AC_CHECK_LIB([svld], [dlopen],
394 [AC_DEFINE([HAVE_LIBDL], [1],
395 [Define if you have the libdl library or equivalent.])
396 LIBADD_DLOPEN="-lsvld" libltdl_cv_func_dlopen="yes"
397 LT_DLLOADERS="$LT_DLLOADERS dlopen.la"])])])
398if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes
399then
400 lt_save_LIBS="$LIBS"
401 LIBS="$LIBS $LIBADD_DLOPEN"
402 AC_CHECK_FUNCS([dlerror])
403 LIBS="$lt_save_LIBS"
404fi
405AC_SUBST([LIBADD_DLOPEN])
406
407LIBADD_SHL_LOAD=
408AC_CHECK_FUNC([shl_load],
409 [AC_DEFINE([HAVE_SHL_LOAD], [1],
410 [Define if you have the shl_load function.])
411 LT_DLLOADERS="$LT_DLLOADERS shl_load.la"],
412 [AC_CHECK_LIB([dld], [shl_load],
413 [AC_DEFINE([HAVE_SHL_LOAD], [1],
414 [Define if you have the shl_load function.])
415 LT_DLLOADERS="$LT_DLLOADERS shl_load.la"
416 LIBADD_SHL_LOAD="-ldld"])])
417AC_SUBST([LIBADD_SHL_LOAD])
418
419AC_CHECK_FUNC([_dyld_func_lookup],
420 [AC_DEFINE([HAVE_DYLD], [1],
421 [Define if you have the _dyld_func_lookup function.])
422 LT_DLLOADERS="$LT_DLLOADERS dyld.la"])
423
424case $host_os in
425beos*)
426 LT_DLLOADERS="$LT_DLLOADERS load_add_on.la"
427 ;;
428cygwin* | mingw* | os2* | pw32*)
429 LT_DLLOADERS="$LT_DLLOADERS loadlibrary.la"
430 ;;
431esac
432
433AC_CHECK_LIB([dld], [dld_link],
434 [AC_DEFINE([HAVE_DLD], [1],
435 [Define if you have the GNU dld library.])
436 LT_DLLOADERS="$LT_DLLOADERS dld_link.la"])
437AC_SUBST([LIBADD_DLD_LINK])
438
439m4_pattern_allow([^LT_DLPREOPEN$])
440LT_DLPREOPEN=
441for lt_loader in $LT_DLLOADERS; do
442 LT_DLPREOPEN="$LT_DLPREOPEN-dlpreopen loaders/$lt_loader "
443done
444AC_SUBST([LT_DLPREOPEN])
445
446dnl This isn't used anymore, but set it for backwards compatibility
447LIBADD_DL="$LIBADD_DLOPEN $LIBADD_SHL_LOAD"
448AC_SUBST([LIBADD_DL])
449
450AC_LANG_POP
451])# AC_LTDL_DLLIB
452
453
454# AC_LTDL_SYMBOL_USCORE
455# ---------------------
456# does the compiler prefix global symbols with an underscore?
457AC_DEFUN([AC_LTDL_SYMBOL_USCORE],
458[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
459AC_CACHE_CHECK([for _ prefix in compiled symbols],
460 [ac_cv_sys_symbol_underscore],
461 [ac_cv_sys_symbol_underscore=no
462 cat > conftest.$ac_ext <<EOF
463void nm_test_func(){}
464int main(){nm_test_func;return 0;}
465EOF
466 if AC_TRY_EVAL(ac_compile); then
467 # Now try to grab the symbols.
468 ac_nlist=conftest.nm
469 if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
470 # See whether the symbols have a leading underscore.
471 if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then
472 ac_cv_sys_symbol_underscore=yes
473 else
474 if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then
475 :
476 else
477 echo "configure: cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD
478 fi
479 fi
480 else
481 echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
482 fi
483 else
484 echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
485 cat conftest.c >&AS_MESSAGE_LOG_FD
486 fi
487 rm -rf conftest*
488 ])
489])# AC_LTDL_SYMBOL_USCORE
490
491
492# AC_LTDL_DLSYM_USCORE
493# --------------------
494AC_DEFUN([AC_LTDL_DLSYM_USCORE],
495[AC_REQUIRE([AC_LTDL_SYMBOL_USCORE])
496if test x"$ac_cv_sys_symbol_underscore" = xyes; then
497 if test x"$libltdl_cv_func_dlopen" = xyes ||
498 test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then
499 AC_CACHE_CHECK([whether we have to add an underscore for dlsym],
500 [libltdl_cv_need_uscore],
501 [libltdl_cv_need_uscore=unknown
502 save_LIBS="$LIBS"
503 LIBS="$LIBS $LIBADD_DLOPEN"
504 _LT_AC_TRY_DLOPEN_SELF(
505 [libltdl_cv_need_uscore=no], [libltdl_cv_need_uscore=yes],
506 [], [libltdl_cv_need_uscore=cross])
507 LIBS="$save_LIBS"
508 ])
509 fi
510fi
511
512if test x"$libltdl_cv_need_uscore" = xyes; then
513 AC_DEFINE(NEED_USCORE, 1,
514 [Define if dlsym() requires a leading underscore in symbol names.])
515fi
516])# AC_LTDL_DLSYM_USCORE