1 dnl Process this file with autoconf to create configure.
5 if test -z "$enable_ltdl_install$enable_ltdl_convenience"; then
6 if test -f ${srcdir}/ltconfig && test -f ${srcdir}/ltmain.sh; then
7 # if libltdl is libtoolized, it is assumed to be stand-alone and
8 # installed unless the command line overrides it (tested above)
9 enable_ltdl_install=yes
11 AC_MSG_WARN([*** The top-level configure must select either])
12 AC_MSG_WARN([*** [A""C_LIBLTDL_INSTALLABLE] or [A""C_LIBLTDL_CONVENIENCE].])
13 AC_MSG_ERROR([*** Maybe you want to --enable-ltdl-install?])
17 AM_INIT_AUTOMAKE(libltdl,1.0,-)
18 AM_CONFIG_HEADER(config.h)
25 AC_SUBST(LIBTOOL_DEPS)
27 AC_ARG_ENABLE(ltdl-install,
28 [ --enable-ltdl-install install libltdl])
30 AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno)
31 AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno)
33 dnl Read the libtool configuration
35 ./libtool --config > conftest
39 AC_CACHE_CHECK([which extension is used for shared libraries],
40 libltdl_cv_shlibext, [dnl
43 for spec in $library_names_spec; do
47 echo "$last" | sed 's/\[.*\]//;s/^[^.]*//;s/\$.*$//;s/\.$//' > conftest
50 libltdl_cv_shlibext=`cat conftest`
53 if test -n "$libltdl_cv_shlibext"; then
54 AC_DEFINE_UNQUOTED(LTDL_SHLIB_EXT, "$libltdl_cv_shlibext",
55 [Define to the extension used for shared libraries, say, ".so". ])
58 AC_CACHE_CHECK([which variable specifies run-time library path],
59 libltdl_cv_shlibpath_var, [libltdl_cv_shlibpath_var="$shlibpath_var"])
60 if test -n "$libltdl_cv_shlibpath_var"; then
61 AC_DEFINE_UNQUOTED(LTDL_SHLIBPATH_VAR, "$libltdl_cv_shlibpath_var",
62 [Define to the name of the environment variable that determines the dynamic library search path. ])
65 AC_CACHE_CHECK([for objdir],
66 libltdl_cv_objdir, [libltdl_cv_objdir="$objdir"])
67 test -z "$libltdl_cv_objdir" && libltdl_cv_objdir=".libs"
68 AC_DEFINE_UNQUOTED(LTDL_OBJDIR, "$libltdl_cv_objdir/",
69 [Define to the sub-directory in which libtool stores uninstalled libraries. ])
72 AC_CHECK_HEADERS(malloc.h memory.h stdlib.h stdio.h ctype.h dlfcn.h dl.h dld.h)
73 AC_CHECK_HEADERS(string.h strings.h, break)
74 AC_CHECK_FUNCS(strchr index, break)
75 AC_CHECK_FUNCS(strrchr rindex, break)
77 AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen],
78 libltdl_cv_preloaded_symbols, [dnl
79 if test -n "$global_symbol_pipe"; then
80 libltdl_cv_preloaded_symbols=yes
82 libltdl_cv_preloaded_symbols=no
85 if test x"$libltdl_cv_preloaded_symbols" = x"yes"; then
86 AC_DEFINE(HAVE_PRELOADED_SYMBOLS, 1,
87 [Define if libtool can extract symbol lists from object files. ])
91 AC_CHECK_LIB(dl, dlopen, [AC_DEFINE(HAVE_LIBDL, 1) LIBADD_DL="-ldl"],
92 [AC_CHECK_FUNC(dlopen, [AC_DEFINE(HAVE_LIBDL, 1)])])
93 AC_CHECK_FUNC(shl_load, [AC_DEFINE(HAVE_SHL_LOAD, 1)],
94 [AC_CHECK_LIB(dld, shl_load, [AC_DEFINE(HAVE_SHL_LOAD, 1) LIBADD_DL="$LIBADD_DL -ldld"])])
95 AC_CHECK_LIB(dld, dld_link, [AC_DEFINE(HAVE_DLD, 1)dnl
96 test "x$ac_cv_lib_dld_shl_load" = yes || LIBADD_DL="$LIBADD_DL -ldld"])
99 if test "x$ac_cv_func_dlopen" = xyes || test "x$ac_cv_lib_dl_dlopen" = xyes; then
101 LIBS="$LIBS $LIBADD_DL"
102 AC_CHECK_FUNCS(dlerror)
106 dnl Check for command to grab the raw symbol name followed
107 dnl by C symbol name from nm.
108 AC_REQUIRE([AC_CANONICAL_HOST])dnl
109 AC_REQUIRE([AC_PROG_NM])dnl
110 # Check for command to grab the raw symbol name followed by C symbol from nm.
111 AC_MSG_CHECKING([command to parse $NM output])
112 AC_CACHE_VAL(ac_cv_sys_global_symbol_pipe,
113 [# These are sane defaults that work on at least a few old systems.
114 # {They come from Ultrix. What could be older than Ultrix?!! ;)}
117 # Character class describing NM global symbol codes.
118 ac_symcode='[BCDEGRST]'
120 # Regexp to match symbols that can be accessed directly from C.
121 ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
123 # Transform the above into a raw symbol and a C symbol.
124 ac_symxfrm='\1 \2\3 \3'
126 # Transform an extracted symbol line into a proper C declaration
127 ac_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
129 # Define system-specific variables.
135 ac_symcode='[ABCDGISTW]'
138 ac_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'"
141 ac_symcode='[BCDEGRST]'
148 # If we're using GNU nm, then use its standard symbol codes.
149 if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
150 ac_symcode='[ABCDGISTW]'
154 # Try without a prefix undercore, then with it.
155 for ac_symprfx in "" "_"; do
157 ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($ac_symcode\)[ ][ ]*\($ac_symprfx\)$ac_sympat$/$ac_symxfrm/p'"
159 # Check to see that the pipe works correctly.
161 rm -f conftest.$ac_ext
162 cat > conftest.$ac_ext <<EOF
167 void nm_test_func(){}
171 int main(){nm_test_var='a';nm_test_func;return 0;}
174 if AC_TRY_EVAL(ac_compile); then
175 # Now try to grab the symbols.
178 if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
180 # Try sorting and uniquifying the output.
181 if sort "$ac_nlist" | uniq > "$ac_nlist"T; then
182 mv -f "$ac_nlist"T "$ac_nlist"
187 # Make sure that we snagged all the symbols we need.
188 if egrep ' nm_test_var$' "$ac_nlist" >/dev/null; then
189 if egrep ' nm_test_func$' "$ac_nlist" >/dev/null; then
190 cat <<EOF > conftest.c
196 # Now generate the symbol file.
197 eval "$ac_global_symbol_to_cdecl"' < "$ac_nlist" >> conftest.c'
199 cat <<EOF >> conftest.c
200 #if defined (__STDC__) && __STDC__
201 # define lt_ptr_t void *
203 # define lt_ptr_t char *
207 /* The mapping between symbol names and symbols. */
213 lt_preloaded_symbols[] =
217 sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
218 cat <<\EOF >> conftest.c
226 # Now try linking the two files.
227 mv conftest.$ac_objext conftstm.$ac_objext
229 ac_save_CFLAGS="$CFLAGS"
230 LIBS="conftstm.$ac_objext"
231 CFLAGS="$CFLAGS$no_builtin_flag"
232 if AC_TRY_EVAL(ac_link) && test -s conftest; then
235 echo "configure: failed program was:" >&AC_FD_CC
236 cat conftest.c >&AC_FD_CC
239 CFLAGS="$ac_save_CFLAGS"
241 echo "cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
244 echo "cannot find nm_test_var in $ac_nlist" >&AC_FD_CC
247 echo "cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
250 echo "$progname: failed program was:" >&AC_FD_CC
251 cat conftest.c >&AC_FD_CC
253 rm -rf conftest* conftst*
255 # Do not use the global_symbol_pipe unless it works.
256 if test "$ac_pipe_works" = yes; then
257 if test x"$ac_symprfx" = x"_"; then
258 ac_cv_sys_symbol_underscore=yes
260 ac_cv_sys_symbol_underscore=no
264 ac_cv_sys_global_symbol_pipe=
270 if test -z "$ac_cv_sys_global_symbol_pipe"; then
273 AC_MSG_RESULT($ac_result)
275 dnl does the compiler prefix global symbols with an underscore?
276 AC_MSG_CHECKING([for _ prefix in compiled symbols])
277 AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
278 [ac_cv_sys_symbol_underscore=no
279 cat > conftest.$ac_ext <<EOF
280 void nm_test_func(){}
281 int main(){nm_test_func;return 0;}
283 if AC_TRY_EVAL(ac_compile); then
284 # Now try to grab the symbols.
286 if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
287 # See whether the symbols have a leading underscore.
288 if egrep '^. _nm_test_func' "$ac_nlist" >/dev/null; then
289 ac_cv_sys_symbol_underscore=yes
291 if egrep '^. nm_test_func ' "$ac_nlist" >/dev/null; then
294 echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
298 echo "configure: cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
301 echo "configure: failed program was:" >&AC_FD_CC
302 cat conftest.c >&AC_FD_CC
306 AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
308 if test x"$ac_cv_sys_symbol_underscore" = xyes; then
309 if test x"$ac_cv_func_dlopen" = xyes ||
310 test x"$ac_cv_lib_dl_dlopen" = xyes ; then
311 AC_CACHE_CHECK([whether we have to add an underscore for dlsym],
312 libltdl_cv_need_uscore, [dnl
321 # define LTDL_GLOBAL RTLD_GLOBAL
324 # define LTDL_GLOBAL DL_GLOBAL
326 # define LTDL_GLOBAL 0
330 /* We may have to define LTDL_LAZY_OR_NOW in the command line if we
331 find out it does not work in some platform. */
332 #ifndef LTDL_LAZY_OR_NOW
334 # define LTDL_LAZY_OR_NOW RTLD_LAZY
337 # define LTDL_LAZY_OR_NOW DL_LAZY
340 # define LTDL_LAZY_OR_NOW RTLD_NOW
343 # define LTDL_LAZY_OR_NOW DL_NOW
345 # define LTDL_LAZY_OR_NOW 0
353 main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW);
354 if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
355 if(ptr1 && !ptr2) { dlclose(self); exit(0); } } exit(1); }
356 ], libltdl_cv_need_uscore=no, libltdl_cv_need_uscore=yes,
357 libltdl_cv_need_uscore=cross
362 if test x"$libltdl_cv_need_uscore" = xyes; then
363 AC_DEFINE(NEED_USCORE, 1,
364 [Define if dlsym() requires a leading underscode in symbol names. ])
367 dnl Output the makefile