Avoid including non-portable header sys/poll.h.
[profile/ivi/pulseaudio.git] / ltdl.m4
1 ## ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*-
2 ## Copyright (C) 1999-2000 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 # Debian $Rev: 214 $
25
26 # AC_WITH_LTDL
27 # ------------
28 # Clients of libltdl can use this macro to allow the installer to
29 # choose between a shipped copy of the ltdl sources or a preinstalled
30 # version of the library.
31 AC_DEFUN([AC_WITH_LTDL],
32 [AC_REQUIRE([AC_LIB_LTDL])
33 AC_SUBST([LIBLTDL])
34 AC_SUBST([INCLTDL])
35
36 # Unless the user asks us to check, assume no installed ltdl exists.
37 use_installed_libltdl=no
38
39 AC_ARG_WITH([included_ltdl],
40     [  --with-included-ltdl    use the GNU ltdl sources included here])
41
42 if test "x$with_included_ltdl" != xyes; then
43   # We are not being forced to use the included libltdl sources, so
44   # decide whether there is a useful installed version we can use.
45   AC_CHECK_HEADER([ltdl.h],
46       [AC_CHECK_LIB([ltdl], [lt_dlcaller_register],
47           [with_included_ltdl=no],
48           [with_included_ltdl=yes])
49   ])
50 fi
51
52 if test "x$enable_ltdl_install" != xyes; then
53   # If the user did not specify an installable libltdl, then default
54   # to a convenience lib.
55   AC_LIBLTDL_CONVENIENCE
56 fi
57
58 if test "x$with_included_ltdl" = xno; then
59   # If the included ltdl is not to be used. then Use the
60   # preinstalled libltdl we found.
61   AC_DEFINE([HAVE_LTDL], 1,
62     [Define this if a modern libltdl is already installed])
63   LIBLTDL=-lltdl
64 fi
65
66 # Report our decision...
67 AC_MSG_CHECKING([whether to use included libltdl])
68 AC_MSG_RESULT([$with_included_ltdl])
69
70 AC_CONFIG_SUBDIRS([libltdl])
71 ])# AC_WITH_LTDL
72
73
74 # AC_LIB_LTDL
75 # -----------
76 # Perform all the checks necessary for compilation of the ltdl objects
77 #  -- including compiler checks and header checks.
78 AC_DEFUN([AC_LIB_LTDL],
79 [AC_PREREQ(2.50)
80 AC_REQUIRE([AC_PROG_CC])
81 AC_REQUIRE([AC_C_CONST])
82 AC_REQUIRE([AC_HEADER_STDC])
83 AC_REQUIRE([AC_HEADER_DIRENT])
84 AC_REQUIRE([_LT_AC_CHECK_DLFCN])
85 AC_REQUIRE([AC_LTDL_ENABLE_INSTALL])
86 AC_REQUIRE([AC_LTDL_SHLIBEXT])
87 AC_REQUIRE([AC_LTDL_SHLIBPATH])
88 AC_REQUIRE([AC_LTDL_SYSSEARCHPATH])
89 AC_REQUIRE([AC_LTDL_OBJDIR])
90 AC_REQUIRE([AC_LTDL_DLPREOPEN])
91 AC_REQUIRE([AC_LTDL_DLLIB])
92 AC_REQUIRE([AC_LTDL_SYMBOL_USCORE])
93 AC_REQUIRE([AC_LTDL_DLSYM_USCORE])
94 AC_REQUIRE([AC_LTDL_SYS_DLOPEN_DEPLIBS])
95 AC_REQUIRE([AC_LTDL_FUNC_ARGZ])
96
97 AC_CHECK_HEADERS([assert.h ctype.h errno.h malloc.h memory.h stdlib.h \
98                   stdio.h unistd.h])
99 AC_CHECK_HEADERS([dl.h sys/dl.h dld.h mach-o/dyld.h])
100 AC_CHECK_HEADERS([string.h strings.h], [break])
101
102 AC_CHECK_FUNCS([strchr index], [break])
103 AC_CHECK_FUNCS([strrchr rindex], [break])
104 AC_CHECK_FUNCS([memcpy bcopy], [break])
105 AC_CHECK_FUNCS([memmove strcmp])
106 AC_CHECK_FUNCS([closedir opendir readdir])
107 ])# AC_LIB_LTDL
108
109
110 # AC_LTDL_ENABLE_INSTALL
111 # ----------------------
112 AC_DEFUN([AC_LTDL_ENABLE_INSTALL],
113 [AC_ARG_ENABLE([ltdl-install],
114     [AC_HELP_STRING([--enable-ltdl-install], [install libltdl])])
115
116 AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno)
117 AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno)
118 ])])# AC_LTDL_ENABLE_INSTALL
119
120
121 # AC_LTDL_SYS_DLOPEN_DEPLIBS
122 # --------------------------
123 AC_DEFUN([AC_LTDL_SYS_DLOPEN_DEPLIBS],
124 [AC_REQUIRE([AC_CANONICAL_HOST])
125 AC_CACHE_CHECK([whether deplibs are loaded by dlopen],
126   [libltdl_cv_sys_dlopen_deplibs],
127   [# PORTME does your system automatically load deplibs for dlopen?
128   # or its logical equivalent (e.g. shl_load for HP-UX < 11)
129   # For now, we just catch OSes we know something about -- in the
130   # future, we'll try test this programmatically.
131   libltdl_cv_sys_dlopen_deplibs=unknown
132   case "$host_os" in
133   aix3*|aix4.1.*|aix4.2.*)
134     # Unknown whether this is true for these versions of AIX, but
135     # we want this `case' here to explicitly catch those versions.
136     libltdl_cv_sys_dlopen_deplibs=unknown
137     ;;
138   aix[[45]]*)
139     libltdl_cv_sys_dlopen_deplibs=yes
140     ;;
141   darwin*)
142     # Assuming the user has installed a libdl from somewhere, this is true
143     # If you are looking for one http://www.opendarwin.org/projects/dlcompat
144     libltdl_cv_sys_dlopen_deplibs=yes
145     ;;   
146   gnu* | linux* | kfreebsd*-gnu | knetbsd*-gnu)
147     # GNU and its variants, using gnu ld.so (Glibc)
148     libltdl_cv_sys_dlopen_deplibs=yes
149     ;;
150   hpux10*|hpux11*)
151     libltdl_cv_sys_dlopen_deplibs=yes
152     ;;
153   irix[[12345]]*|irix6.[[01]]*)
154     # Catch all versions of IRIX before 6.2, and indicate that we don't
155     # know how it worked for any of those versions.
156     libltdl_cv_sys_dlopen_deplibs=unknown
157     ;;
158   irix*)
159     # The case above catches anything before 6.2, and it's known that
160     # at 6.2 and later dlopen does load deplibs.
161     libltdl_cv_sys_dlopen_deplibs=yes
162     ;;
163   netbsd* | netbsdelf*-gnu)
164     libltdl_cv_sys_dlopen_deplibs=yes
165     ;;
166   openbsd*)
167     libltdl_cv_sys_dlopen_deplibs=yes
168     ;;
169   osf[[1234]]*)
170     # dlopen did load deplibs (at least at 4.x), but until the 5.x series,
171     # it did *not* use an RPATH in a shared library to find objects the
172     # library depends on, so we explictly say `no'.
173     libltdl_cv_sys_dlopen_deplibs=no
174     ;;
175   osf5.0|osf5.0a|osf5.1)
176     # dlopen *does* load deplibs and with the right loader patch applied
177     # it even uses RPATH in a shared library to search for shared objects
178     # that the library depends on, but there's no easy way to know if that
179     # patch is installed.  Since this is the case, all we can really
180     # say is unknown -- it depends on the patch being installed.  If
181     # it is, this changes to `yes'.  Without it, it would be `no'.
182     libltdl_cv_sys_dlopen_deplibs=unknown
183     ;;
184   osf*)
185     # the two cases above should catch all versions of osf <= 5.1.  Read
186     # the comments above for what we know about them.
187     # At > 5.1, deplibs are loaded *and* any RPATH in a shared library
188     # is used to find them so we can finally say `yes'.
189     libltdl_cv_sys_dlopen_deplibs=yes
190     ;;
191   solaris*)
192     libltdl_cv_sys_dlopen_deplibs=yes
193     ;;
194   esac
195   ])
196 if test "$libltdl_cv_sys_dlopen_deplibs" != yes; then
197  AC_DEFINE([LTDL_DLOPEN_DEPLIBS], [1],
198     [Define if the OS needs help to load dependent libraries for dlopen().])
199 fi
200 ])# AC_LTDL_SYS_DLOPEN_DEPLIBS
201
202
203 # AC_LTDL_SHLIBEXT
204 # ----------------
205 AC_DEFUN([AC_LTDL_SHLIBEXT],
206 [AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER])
207 AC_CACHE_CHECK([which extension is used for loadable modules],
208   [libltdl_cv_shlibext],
209 [
210 module=yes
211 eval libltdl_cv_shlibext=$shrext_cmds
212   ])
213 if test -n "$libltdl_cv_shlibext"; then
214   AC_DEFINE_UNQUOTED(LTDL_SHLIB_EXT, "$libltdl_cv_shlibext",
215     [Define to the extension used for shared libraries, say, ".so".])
216 fi
217 ])# AC_LTDL_SHLIBEXT
218
219
220 # AC_LTDL_SHLIBPATH
221 # -----------------
222 AC_DEFUN([AC_LTDL_SHLIBPATH],
223 [AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER])
224 AC_CACHE_CHECK([which variable specifies run-time library path],
225   [libltdl_cv_shlibpath_var], [libltdl_cv_shlibpath_var="$shlibpath_var"])
226 if test -n "$libltdl_cv_shlibpath_var"; then
227   AC_DEFINE_UNQUOTED(LTDL_SHLIBPATH_VAR, "$libltdl_cv_shlibpath_var",
228     [Define to the name of the environment variable that determines the dynamic library search path.])
229 fi
230 ])# AC_LTDL_SHLIBPATH
231
232
233 # AC_LTDL_SYSSEARCHPATH
234 # ---------------------
235 AC_DEFUN([AC_LTDL_SYSSEARCHPATH],
236 [AC_REQUIRE([AC_LIBTOOL_SYS_DYNAMIC_LINKER])
237 AC_CACHE_CHECK([for the default library search path],
238   [libltdl_cv_sys_search_path],
239   [libltdl_cv_sys_search_path="$sys_lib_dlsearch_path_spec"])
240 if test -n "$libltdl_cv_sys_search_path"; then
241   sys_search_path=
242   for dir in $libltdl_cv_sys_search_path; do
243     if test -z "$sys_search_path"; then
244       sys_search_path="$dir"
245     else
246       sys_search_path="$sys_search_path$PATH_SEPARATOR$dir"
247     fi
248   done
249   AC_DEFINE_UNQUOTED(LTDL_SYSSEARCHPATH, "$sys_search_path",
250     [Define to the system default library search path.])
251 fi
252 ])# AC_LTDL_SYSSEARCHPATH
253
254
255 # AC_LTDL_OBJDIR
256 # --------------
257 AC_DEFUN([AC_LTDL_OBJDIR],
258 [AC_CACHE_CHECK([for objdir],
259   [libltdl_cv_objdir],
260   [libltdl_cv_objdir="$objdir"
261   if test -n "$objdir"; then
262     :
263   else
264     rm -f .libs 2>/dev/null
265     mkdir .libs 2>/dev/null
266     if test -d .libs; then
267       libltdl_cv_objdir=.libs
268     else
269       # MS-DOS does not allow filenames that begin with a dot.
270       libltdl_cv_objdir=_libs
271     fi
272   rmdir .libs 2>/dev/null
273   fi
274   ])
275 AC_DEFINE_UNQUOTED(LTDL_OBJDIR, "$libltdl_cv_objdir/",
276   [Define to the sub-directory in which libtool stores uninstalled libraries.])
277 ])# AC_LTDL_OBJDIR
278
279
280 # AC_LTDL_DLPREOPEN
281 # -----------------
282 AC_DEFUN([AC_LTDL_DLPREOPEN],
283 [AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
284 AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen],
285   [libltdl_cv_preloaded_symbols],
286   [if test -n "$lt_cv_sys_global_symbol_pipe"; then
287     libltdl_cv_preloaded_symbols=yes
288   else
289     libltdl_cv_preloaded_symbols=no
290   fi
291   ])
292 if test x"$libltdl_cv_preloaded_symbols" = xyes; then
293   AC_DEFINE(HAVE_PRELOADED_SYMBOLS, 1,
294     [Define if libtool can extract symbol lists from object files.])
295 fi
296 ])# AC_LTDL_DLPREOPEN
297
298
299 # AC_LTDL_DLLIB
300 # -------------
301 AC_DEFUN([AC_LTDL_DLLIB],
302 [LIBADD_DL=
303 AC_SUBST(LIBADD_DL)
304 AC_LANG_PUSH([C])
305
306 AC_CHECK_FUNC([shl_load],
307       [AC_DEFINE([HAVE_SHL_LOAD], [1],
308                  [Define if you have the shl_load function.])],
309   [AC_CHECK_LIB([dld], [shl_load],
310         [AC_DEFINE([HAVE_SHL_LOAD], [1],
311                    [Define if you have the shl_load function.])
312         LIBADD_DL="$LIBADD_DL -ldld"],
313     [AC_CHECK_LIB([dl], [dlopen],
314           [AC_DEFINE([HAVE_LIBDL], [1],
315                      [Define if you have the libdl library or equivalent.])
316                 LIBADD_DL="-ldl" libltdl_cv_lib_dl_dlopen="yes"],
317       [AC_TRY_LINK([#if HAVE_DLFCN_H
318 #  include <dlfcn.h>
319 #endif
320       ],
321         [dlopen(0, 0);],
322             [AC_DEFINE([HAVE_LIBDL], [1],
323                              [Define if you have the libdl library or equivalent.]) libltdl_cv_func_dlopen="yes"],
324         [AC_CHECK_LIB([svld], [dlopen],
325               [AC_DEFINE([HAVE_LIBDL], [1],
326                          [Define if you have the libdl library or equivalent.])
327                     LIBADD_DL="-lsvld" libltdl_cv_func_dlopen="yes"],
328           [AC_CHECK_LIB([dld], [dld_link],
329                 [AC_DEFINE([HAVE_DLD], [1],
330                            [Define if you have the GNU dld library.])
331                 LIBADD_DL="$LIBADD_DL -ldld"],
332                 [AC_CHECK_FUNC([_dyld_func_lookup],
333                        [AC_DEFINE([HAVE_DYLD], [1],
334                           [Define if you have the _dyld_func_lookup function.])])
335           ])
336         ])
337       ])
338     ])
339   ])
340 ])
341
342 if test x"$libltdl_cv_func_dlopen" = xyes || test x"$libltdl_cv_lib_dl_dlopen" = xyes
343 then
344   lt_save_LIBS="$LIBS"
345   LIBS="$LIBS $LIBADD_DL"
346   AC_CHECK_FUNCS([dlerror])
347   LIBS="$lt_save_LIBS"
348 fi
349 AC_LANG_POP
350 ])# AC_LTDL_DLLIB
351
352
353 # AC_LTDL_SYMBOL_USCORE
354 # ---------------------
355 # does the compiler prefix global symbols with an underscore?
356 AC_DEFUN([AC_LTDL_SYMBOL_USCORE],
357 [AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])
358 AC_CACHE_CHECK([for _ prefix in compiled symbols],
359   [ac_cv_sys_symbol_underscore],
360   [ac_cv_sys_symbol_underscore=no
361   cat > conftest.$ac_ext <<EOF
362 void nm_test_func(){}
363 int main(){nm_test_func;return 0;}
364 EOF
365   if AC_TRY_EVAL(ac_compile); then
366     # Now try to grab the symbols.
367     ac_nlist=conftest.nm
368     if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
369       # See whether the symbols have a leading underscore.
370       if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then
371         ac_cv_sys_symbol_underscore=yes
372       else
373         if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then
374           :
375         else
376           echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
377         fi
378       fi
379     else
380       echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC
381     fi
382   else
383     echo "configure: failed program was:" >&AC_FD_CC
384     cat conftest.c >&AC_FD_CC
385   fi
386   rm -rf conftest*
387   ])
388 ])# AC_LTDL_SYMBOL_USCORE
389
390
391 # AC_LTDL_DLSYM_USCORE
392 # --------------------
393 AC_DEFUN([AC_LTDL_DLSYM_USCORE],
394 [AC_REQUIRE([AC_LTDL_SYMBOL_USCORE])
395 if test x"$ac_cv_sys_symbol_underscore" = xyes; then
396   if test x"$libltdl_cv_func_dlopen" = xyes ||
397      test x"$libltdl_cv_lib_dl_dlopen" = xyes ; then
398         AC_CACHE_CHECK([whether we have to add an underscore for dlsym],
399           [libltdl_cv_need_uscore],
400           [libltdl_cv_need_uscore=unknown
401           save_LIBS="$LIBS"
402           LIBS="$LIBS $LIBADD_DL"
403           _LT_AC_TRY_DLOPEN_SELF(
404             [libltdl_cv_need_uscore=no], [libltdl_cv_need_uscore=yes],
405             [],                          [libltdl_cv_need_uscore=cross])
406           LIBS="$save_LIBS"
407         ])
408   fi
409 fi
410
411 if test x"$libltdl_cv_need_uscore" = xyes; then
412   AC_DEFINE(NEED_USCORE, 1,
413     [Define if dlsym() requires a leading underscore in symbol names.])
414 fi
415 ])# AC_LTDL_DLSYM_USCORE
416
417 # AC_LTDL_FUNC_ARGZ
418 # -----------------
419 AC_DEFUN([AC_LTDL_FUNC_ARGZ],
420 [AC_CHECK_HEADERS([argz.h])
421
422 AC_CHECK_TYPES([error_t],
423   [],
424   [AC_DEFINE([error_t], [int],
425     [Define to a type to use for `error_t' if it is not otherwise available.])],
426   [#if HAVE_ARGZ_H
427 #  include <argz.h>
428 #endif])
429
430 AC_CHECK_FUNCS([argz_append argz_create_sep argz_insert argz_next argz_stringify])
431 ])# AC_LTDL_FUNC_ARGZ