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