1
2# AC_LTDL_DLLIB
3# -------------
4AC_DEFUN([AC_LTDL_DLLIB],
5[LIBADD_DL=
6AC_SUBST(LIBADD_DL)
7
8AC_CHECK_FUNC([shl_load],
9      [AC_DEFINE([HAVE_SHL_LOAD], [1],
10		 [Define if you have the shl_load function.])],
11  [AC_CHECK_LIB([dld], [shl_load],
12	[AC_DEFINE([HAVE_SHL_LOAD], [1],
13		   [Define if you have the shl_load function.])
14	LIBADD_DL="$LIBADD_DL -ldld"],
15    [AC_CHECK_LIB([dl], [dlopen],
16	  [AC_DEFINE([HAVE_LIBDL], [1],
17		     [Define if you have the libdl library or equivalent.])
18	  LIBADD_DL="-ldl"],
19      [AC_TRY_LINK([#if HAVE_DLFCN_H
20#  include <dlfcn.h>
21#endif
22      ],
23	[dlopen(0, 0);],
24	    [AC_DEFINE([HAVE_LIBDL], [1],
25		       [Define if you have the libdl library or equivalent.])],
26	[AC_CHECK_LIB([svld], [dlopen],
27	      [AC_DEFINE([HAVE_LIBDL], [1],
28			 [Define if you have the libdl library or equivalent.])
29	      LIBADD_DL="-lsvld"],
30	  [AC_CHECK_LIB([dld], [dld_link],
31	        [AC_DEFINE([HAVE_DLD], [1],
32			   [Define if you have the GNU dld library.])
33	 	LIBADD_DL="$LIBADD_DL -ldld"
34          ])
35        ])
36      ])
37    ])
38  ])
39])
40
41if test "x$ac_cv_func_dlopen" = xyes || test "x$ac_cv_lib_dl_dlopen" = xyes; then
42 LIBS_SAVE="$LIBS"
43 LIBS="$LIBS $LIBADD_DL"
44 AC_CHECK_FUNCS(dlerror)
45 LIBS="$LIBS_SAVE"
46fi
47])# AC_LTDL_DLLIB
48