Fix a ton of comment typos found by codespell. Patch by
[oota-llvm.git] / autoconf / m4 / ltdl.m4
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.
15 AC_DEFUN([AC_WITH_LTDL],
16 [AC_REQUIRE([AC_LIB_LTDL])
17 AC_SUBST([LIBLTDL])
18 AC_SUBST([INCLTDL])
19
20 # Unless the user asks us to check, assume no installed ltdl exists.
21 use_installed_libltdl=no
22
23 AC_ARG_WITH([included_ltdl],
24     [  --with-included-ltdl    use the GNU ltdl sources included here])
25
26 if 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   ])
34 fi
35
36 if 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
40 fi
41
42 if 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
48 fi
49
50 # Report our decision...
51 AC_MSG_CHECKING([whether to use included libltdl])
52 AC_MSG_RESULT([$with_included_ltdl])
53
54 AC_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.
62 AC_DEFUN([AC_LIB_LTDL],
63 [AC_PREREQ(2.60)
64 AC_REQUIRE([AC_PROG_CC])
65 AC_REQUIRE([AC_C_CONST])
66 AC_REQUIRE([AC_HEADER_STDC])
67 AC_REQUIRE([AC_HEADER_DIRENT])
68 AC_REQUIRE([_LT_AC_CHECK_DLFCN])
69 AC_REQUIRE([AC_LTDL_ENABLE_INSTALL])
70 AC_REQUIRE([AC_LTDL_SHLIBEXT])
71 AC_REQUIRE([AC_LTDL_SHLIBPATH])
72 AC_REQUIRE([AC_LTDL_SYSSEARCHPATH])
73 AC_REQUIRE([AC_LTDL_OBJDIR])
74 AC_REQUIRE([AC_LTDL_DLPREOPEN])
75 AC_REQUIRE([AC_LTDL_DLLIB])
76 AC_REQUIRE([AC_LTDL_SYMBOL_USCORE])
77 AC_REQUIRE([AC_LTDL_DLSYM_USCORE])
78 AC_REQUIRE([AC_LTDL_SYS_DLOPEN_DEPLIBS])
79 AC_REQUIRE([AC_LTDL_FUNC_ARGZ])
80
81 AC_CHECK_HEADERS([assert.h ctype.h errno.h malloc.h memory.h stdlib.h \
82                   stdio.h unistd.h])
83 AC_CHECK_HEADERS([dl.h sys/dl.h dld.h mach-o/dyld.h])
84 AC_CHECK_HEADERS([string.h strings.h], [break])
85
86 AC_CHECK_FUNCS([strchr index], [break])
87 AC_CHECK_FUNCS([strrchr rindex], [break])
88 AC_CHECK_FUNCS([memcpy bcopy], [break])
89 AC_CHECK_FUNCS([memmove strcmp])
90 AC_CHECK_FUNCS([closedir opendir readdir])
91 ])# AC_LIB_LTDL
92
93
94 # AC_LTDL_ENABLE_INSTALL
95 # ----------------------
96 AC_DEFUN([AC_LTDL_ENABLE_INSTALL],
97 [AC_ARG_ENABLE([ltdl-install],
98     [AS_HELP_STRING([--enable-ltdl-install],[install libltdl])])
99
100 AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno)
101 AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno)
102 ])# AC_LTDL_ENABLE_INSTALL
103
104
105 # AC_LTDL_SYS_DLOPEN_DEPLIBS
106 # --------------------------
107 AC_DEFUN([AC_LTDL_SYS_DLOPEN_DEPLIBS],
108 [AC_REQUIRE([AC_CANONICAL_HOST])
109 AC_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   interix*)
138     libltdl_cv_sys_dlopen_deplibs=yes
139     ;;
140   irix[[12345]]*|irix6.[[01]]*)
141     # Catch all versions of IRIX before 6.2, and indicate that we don't
142     # know how it worked for any of those versions.
143     libltdl_cv_sys_dlopen_deplibs=unknown
144     ;;
145   irix*)
146     # The case above catches anything before 6.2, and it's known that
147     # at 6.2 and later dlopen does load deplibs.
148     libltdl_cv_sys_dlopen_deplibs=yes
149     ;;
150   netbsd*)
151     libltdl_cv_sys_dlopen_deplibs=yes
152     ;;
153   openbsd*)
154     libltdl_cv_sys_dlopen_deplibs=yes
155     ;;
156   osf[[1234]]*)
157     # dlopen did load deplibs (at least at 4.x), but until the 5.x series,
158     # it did *not* use an RPATH in a shared library to find objects the
159     # library depends on, so we explicitly say `no'.
160     libltdl_cv_sys_dlopen_deplibs=no
161     ;;
162   osf5.0|osf5.0a|osf5.1)
163     # dlopen *does* load deplibs and with the right loader patch applied
164     # it even uses RPATH in a shared library to search for shared objects
165     # that the library depends on, but there's no easy way to know if that
166     # patch is installed.  Since this is the case, all we can really
167     # say is unknown -- it depends on the patch being installed.  If
168     # it is, this changes to `yes'.  Without it, it would be `no'.
169     libltdl_cv_sys_dlopen_deplibs=unknown
170     ;;
171   osf*)
172     # the two cases above should catch all versions of osf <= 5.1.  Read
173     # the comments above for what we know about them.
174     # At > 5.1, deplibs are loaded *and* any RPATH in a shared library
175     # is used to find them so we can finally say `yes'.
176     libltdl_cv_sys_dlopen_deplibs=yes
177     ;;
178   solaris*)
179     libltdl_cv_sys_dlopen_deplibs=yes
180     ;;
181   sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
182     libltdl_cv_sys_dlopen_deplibs=yes
183     ;;
184   esac
185   ])
186 if test "$libltdl_cv_sys_dlopen_deplibs" != yes; then
187  AC_DEFINE([LTDL_DLOPEN_DEPLIBS], [1],
188     [Define if the OS needs help to load dependent libraries for dlopen().])
189 fi
190 ])# AC_LTDL_SYS_DLOPEN_DEPLIBS
191
192
193 # AC_LTDL_SHLIBEXT
194 # ----------------
195 AC_DEFUN([AC_LTDL_SHLIBEXT],
196 [AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER])
197 AC_CACHE_CHECK([which extension is used for loadable modules],
198   [libltdl_cv_shlibext],
199 [
200 module=yes
201 eval libltdl_cv_shlibext=$shrext_cmds
202   ])
203 if test -n "$libltdl_cv_shlibext"; then
204   AC_DEFINE_UNQUOTED([LTDL_SHLIB_EXT], ["$libltdl_cv_shlibext"],
205     [Define to the extension used for shared libraries, say, ".so".])
206 fi
207 ])# AC_LTDL_SHLIBEXT
208
209
210 # AC_LTDL_SHLIBPATH
211 # -----------------
212 AC_DEFUN([AC_LTDL_SHLIBPATH],
213 [AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER])
214 AC_CACHE_CHECK([which variable specifies run-time library path],
215   [libltdl_cv_shlibpath_var], [libltdl_cv_shlibpath_var="$shlibpath_var"])
216 if test -n "$libltdl_cv_shlibpath_var"; then
217   AC_DEFINE_UNQUOTED([LTDL_SHLIBPATH_VAR], ["$libltdl_cv_shlibpath_var"],
218     [Define to the name of the environment variable that determines the dynamic library search path.])
219 fi
220 ])# AC_LTDL_SHLIBPATH
221
222
223 # AC_LTDL_SYSSEARCHPATH
224 # ---------------------
225 AC_DEFUN([AC_LTDL_SYSSEARCHPATH],
226 [AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER])
227 AC_CACHE_CHECK([for the default library search path],
228   [libltdl_cv_sys_search_path],
229   [libltdl_cv_sys_search_path="$sys_lib_dlsearch_path_spec"])
230 if test -n "$libltdl_cv_sys_search_path"; then
231   sys_search_path=
232   for dir in $libltdl_cv_sys_search_path; do
233     if test -z "$sys_search_path"; then
234       sys_search_path="$dir"
235     else
236       sys_search_path="$sys_search_path$PATH_SEPARATOR$dir"
237     fi
238   done
239   AC_DEFINE_UNQUOTED([LTDL_SYSSEARCHPATH], ["$sys_search_path"],
240     [Define to the system default library search path.])
241 fi
242 ])# AC_LTDL_SYSSEARCHPATH
243
244
245 # AC_LTDL_OBJDIR
246 # --------------
247 AC_DEFUN([AC_LTDL_OBJDIR],
248 [AC_CACHE_CHECK([for objdir],
249   [libltdl_cv_objdir],
250   [libltdl_cv_objdir="$objdir"
251   if test -n "$objdir"; then
252     :
253   else
254     rm -f .libs 2>/dev/null
255     mkdir .libs 2>/dev/null
256     if test -d .libs; then
257       libltdl_cv_objdir=.libs
258     else
259       # MS-DOS does not allow filenames that begin with a dot.
260       libltdl_cv_objdir=_libs
261     fi
262   rmdir .libs 2>/dev/null
263   fi
264   ])
265 AC_DEFINE_UNQUOTED([LTDL_OBJDIR], ["$libltdl_cv_objdir/"],
266   [Define to the sub-directory in which libtool stores uninstalled libraries.])
267 ])# AC_LTDL_OBJDIR
268
269
270 # AC_LTDL_DLPREOPEN
271 # -----------------
272 AC_DEFUN([AC_LTDL_DLPREOPEN],
273 [AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
274 AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen],
275   [libltdl_cv_preloaded_symbols],
276   [if test -n "$lt_cv_sys_global_symbol_pipe"; then
277     libltdl_cv_preloaded_symbols=yes
278   else
279     libltdl_cv_preloaded_symbols=no
280   fi
281   ])
282 if test x"$libltdl_cv_preloaded_symbols" = xyes; then
283   AC_DEFINE([HAVE_PRELOADED_SYMBOLS], [1],
284     [Define if libtool can extract symbol lists from object files.])
285 fi
286 ])# AC_LTDL_DLPREOPEN
287
288
289 # AC_LTDL_DLLIB
290 # -------------
291 AC_DEFUN([AC_LTDL_DLLIB],
292 [LIBADD_DL=
293 AC_SUBST(LIBADD_DL)
294 AC_LANG_PUSH([C])
295
296 AC_CHECK_FUNC([shl_load],
297       [AC_DEFINE([HAVE_SHL_LOAD], [1],
298                  [Define if you have the shl_load function.])],
299   [AC_CHECK_LIB([dld], [shl_load],
300         [AC_DEFINE([HAVE_SHL_LOAD], [1],
301                    [Define if you have the shl_load function.])
302         LIBADD_DL="$LIBADD_DL -ldld"],
303     [AC_CHECK_LIB([dl], [dlopen],
304           [AC_DEFINE([HAVE_LIBDL], [1],
305                      [Define if you have the libdl library or equivalent.])
306                 LIBADD_DL="-ldl" libltdl_cv_lib_dl_dlopen="yes"],
307       [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_DLFCN_H
308 #  include <dlfcn.h>
309 #endif
310       ]], [[dlopen(0, 0);]])],[AC_DEFINE([HAVE_LIBDL], [1],
311                              [Define if you have the libdl library or equivalent.]) libltdl_cv_func_dlopen="yes"],[AC_CHECK_LIB([svld], [dlopen],
312               [AC_DEFINE([HAVE_LIBDL], [1],
313                          [Define if you have the libdl library or equivalent.])
314                     LIBADD_DL="-lsvld" libltdl_cv_func_dlopen="yes"],
315           [AC_CHECK_LIB([dld], [dld_link],
316                 [AC_DEFINE([HAVE_DLD], [1],
317                            [Define if you have the GNU dld library.])
318                 LIBADD_DL="$LIBADD_DL -ldld"],
319                 [AC_CHECK_FUNC([_dyld_func_lookup],
320                        [AC_DEFINE([HAVE_DYLD], [1],
321                           [Define if you have the _dyld_func_lookup function.])])
322           ])
323         ])
324       ])
325     ])
326   ])
327 ])
328
329 if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes
330 then
331   lt_save_LIBS="$LIBS"
332   LIBS="$LIBS $LIBADD_DL"
333   AC_CHECK_FUNCS([dlerror])
334   LIBS="$lt_save_LIBS"
335 fi
336 AC_LANG_POP
337 ])# AC_LTDL_DLLIB
338
339
340 # AC_LTDL_SYMBOL_USCORE
341 # ---------------------
342 # does the compiler prefix global symbols with an underscore?
343 AC_DEFUN([AC_LTDL_SYMBOL_USCORE],
344 [AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
345 AC_CACHE_CHECK([for _ prefix in compiled symbols],
346   [ac_cv_sys_symbol_underscore],
347   [ac_cv_sys_symbol_underscore=no
348   cat > conftest.$ac_ext <<EOF
349 void nm_test_func(){}
350 int main(){nm_test_func;return 0;}
351 EOF
352   if AC_TRY_EVAL(ac_compile); then
353     # Now try to grab the symbols.
354     ac_nlist=conftest.nm
355     if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
356       # See whether the symbols have a leading underscore.
357       if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then
358         ac_cv_sys_symbol_underscore=yes
359       else
360         if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then
361           :
362         else
363           echo "configure: cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD
364         fi
365       fi
366     else
367       echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
368     fi
369   else
370     echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD
371     cat conftest.c >&AS_MESSAGE_LOG_FD
372   fi
373   rm -rf conftest*
374   ])
375 ])# AC_LTDL_SYMBOL_USCORE
376
377
378 # AC_LTDL_DLSYM_USCORE
379 # --------------------
380 AC_DEFUN([AC_LTDL_DLSYM_USCORE],
381 [AC_REQUIRE([AC_LTDL_SYMBOL_USCORE])
382 if test x"$ac_cv_sys_symbol_underscore" = xyes; then
383   if test x"$libltdl_cv_func_dlopen" = xyes ||
384      test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then
385         AC_CACHE_CHECK([whether we have to add an underscore for dlsym],
386           [libltdl_cv_need_uscore],
387           [libltdl_cv_need_uscore=unknown
388           save_LIBS="$LIBS"
389           LIBS="$LIBS $LIBADD_DL"
390           _LT_AC_TRY_DLOPEN_SELF(
391             [libltdl_cv_need_uscore=no], [libltdl_cv_need_uscore=yes],
392             [],                          [libltdl_cv_need_uscore=cross])
393           LIBS="$save_LIBS"
394         ])
395   fi
396 fi
397
398 if test x"$libltdl_cv_need_uscore" = xyes; then
399   AC_DEFINE([NEED_USCORE], [1],
400     [Define if dlsym() requires a leading underscore in symbol names.])
401 fi
402 ])# AC_LTDL_DLSYM_USCORE
403
404 # AC_LTDL_FUNC_ARGZ
405 # -----------------
406 AC_DEFUN([AC_LTDL_FUNC_ARGZ],
407 [AC_CHECK_HEADERS([argz.h])
408
409 AC_CHECK_TYPES([error_t],
410   [],
411   [AC_DEFINE([error_t], [int],
412     [Define to a type to use for `error_t' if it is not otherwise available.])],
413   [#if HAVE_ARGZ_H
414 #  include <argz.h>
415 #endif])
416
417 AC_CHECK_FUNCS([argz_append argz_create_sep argz_insert argz_next argz_stringify])
418 ])# AC_LTDL_FUNC_ARGZ