]> git.saurik.com Git - wxWidgets.git/blob - build/autoconf_prepend-include/autoconf/libs.m4
copy wxAutohacks into main tree
[wxWidgets.git] / build / autoconf_prepend-include / autoconf / libs.m4
1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for libraries.
3 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
4 # 2002 Free Software Foundation, Inc.
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 # 02111-1307, USA.
20
21 # As a special exception, the Free Software Foundation gives unlimited
22 # permission to copy, distribute and modify the configure scripts that
23 # are the output of Autoconf. You need not follow the terms of the GNU
24 # General Public License when using or distributing such scripts, even
25 # though portions of the text of Autoconf appear in them. The GNU
26 # General Public License (GPL) does govern all other use of the material
27 # that constitutes the Autoconf program.
28 #
29 # Certain portions of the Autoconf source text are designed to be copied
30 # (in certain cases, depending on the input) into the output of
31 # Autoconf. We call these the "data" portions. The rest of the Autoconf
32 # source text consists of comments plus executable code that decides which
33 # of the data portions to output in any given case. We call these
34 # comments and executable code the "non-data" portions. Autoconf never
35 # copies any of the non-data portions into its output.
36 #
37 # This special exception to the GPL applies to versions of Autoconf
38 # released by the Free Software Foundation. When you make and
39 # distribute a modified version of Autoconf, you may extend this special
40 # exception to the GPL to apply to your modified version as well, *unless*
41 # your modified version has the potential to copy into its output some
42 # of the text that was the non-data portion of the version that you started
43 # with. (In other words, unless your change moves or copies text from
44 # the non-data portions to the data portions.) If your modification has
45 # such potential, you must delete any notice of this special exception
46 # to the GPL from your modified version.
47 #
48 # Written by David MacKenzie, with help from
49 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
50 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
51
52 # Table of contents
53 #
54 # 1. Generic tests for libraries
55 # 2. Tests for specific libraries
56
57
58 ## --------------------------------- ##
59 ## 1. Generic tests for libraries.## ##
60 ## --------------------------------- ##
61
62
63
64 # AC_SEARCH_LIBS(FUNCTION, SEARCH-LIBS,
65 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
66 # [OTHER-LIBRARIES])
67 # --------------------------------------------------------
68 # Search for a library defining FUNC, if it's not already available.
69 AC_DEFUN([AC_SEARCH_LIBS],
70 [AC_CACHE_CHECK([for library containing $1], [ac_cv_search_$1],
71 [ac_func_search_save_LIBS=$LIBS
72 ac_cv_search_$1=no
73 AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
74 [ac_cv_search_$1="none required"])
75 if test "$ac_cv_search_$1" = no; then
76 for ac_lib in $2; do
77 LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
78 AC_LINK_IFELSE([AC_LANG_CALL([], [$1])],
79 [ac_cv_search_$1="-l$ac_lib"
80 break])
81 done
82 fi
83 LIBS=$ac_func_search_save_LIBS])
84 AS_IF([test "$ac_cv_search_$1" != no],
85 [test "$ac_cv_search_$1" = "none required" || LIBS="$ac_cv_search_$1 $LIBS"
86 $3],
87 [$4])dnl
88 ])
89
90
91
92 # AC_CHECK_LIB(LIBRARY, FUNCTION,
93 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
94 # [OTHER-LIBRARIES])
95 # ------------------------------------------------------
96 #
97 # Use a cache variable name containing both the library and function name,
98 # because the test really is for library $1 defining function $2, not
99 # just for library $1. Separate tests with the same $1 and different $2s
100 # may have different results.
101 #
102 # Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$2])
103 # is asking for troubles, since AC_CHECK_LIB($lib, fun) would give
104 # ac_cv_lib_$lib_fun, which is definitely not what was meant. Hence
105 # the AS_LITERAL_IF indirection.
106 #
107 # FIXME: This macro is extremely suspicious. It DEFINEs unconditionally,
108 # whatever the FUNCTION, in addition to not being a *S macro. Note
109 # that the cache does depend upon the function we are looking for.
110 #
111 # It is on purpose we used `ac_check_lib_save_LIBS' and not just
112 # `ac_save_LIBS': there are many macros which don't want to see `LIBS'
113 # changed but still want to use AC_CHECK_LIB, so they save `LIBS'.
114 # And ``ac_save_LIBS' is too tempting a name, so let's leave them some
115 # freedom.
116 AC_DEFUN([AC_CHECK_LIB],
117 [m4_ifval([$3], , [AH_CHECK_LIB([$1])])dnl
118 AS_LITERAL_IF([$1],
119 [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$2])],
120 [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1''_$2])])dnl
121 AC_CACHE_CHECK([for $2 in -l$1], ac_Lib,
122 [ac_check_lib_save_LIBS=$LIBS
123 LIBS="-l$1 $5 $LIBS"
124 AC_LINK_IFELSE([AC_LANG_CALL([], [$2])],
125 [AS_VAR_SET(ac_Lib, yes)],
126 [AS_VAR_SET(ac_Lib, no)])
127 LIBS=$ac_check_lib_save_LIBS])
128 AS_IF([test AS_VAR_GET(ac_Lib) = yes],
129 [m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
130 LIBS="-l$1 $LIBS"
131 ])],
132 [$4])dnl
133 AS_VAR_POPDEF([ac_Lib])dnl
134 ])# AC_CHECK_LIB
135
136
137 # AH_CHECK_LIB(LIBNAME)
138 # ---------------------
139 m4_define([AH_CHECK_LIB],
140 [AH_TEMPLATE(AS_TR_CPP(HAVE_LIB$1),
141 [Define to 1 if you have the `]$1[' library (-l]$1[).])])
142
143
144 # AC_HAVE_LIBRARY(LIBRARY,
145 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
146 # [OTHER-LIBRARIES])
147 # ---------------------------------------------------------
148 #
149 # This macro is equivalent to calling `AC_CHECK_LIB' with a FUNCTION
150 # argument of `main'. In addition, LIBRARY can be written as any of
151 # `foo', `-lfoo', or `libfoo.a'. In all of those cases, the compiler
152 # is passed `-lfoo'. However, LIBRARY cannot be a shell variable;
153 # it must be a literal name.
154 AU_DEFUN([AC_HAVE_LIBRARY],
155 [m4_pushdef([AC_Lib_Name],
156 m4_bpatsubst(m4_bpatsubst([[$1]],
157 [lib\([^\.]*\)\.a], [\1]),
158 [-l], []))dnl
159 AC_CHECK_LIB(AC_Lib_Name, main, [$2], [$3], [$4])dnl
160 ac_cv_lib_[]AC_Lib_Name()=ac_cv_lib_[]AC_Lib_Name()_main
161 m4_popdef([AC_Lib_Name])dnl
162 ])
163
164
165
166
167 ## --------------------------------- ##
168 ## 2. Tests for specific libraries. ##
169 ## --------------------------------- ##
170
171
172
173 # --------------------- #
174 # Checks for X window. #
175 # --------------------- #
176
177
178 # _AC_PATH_X_XMKMF
179 # ----------------
180 # Internal subroutine of _AC_PATH_X.
181 # Set ac_x_includes and/or ac_x_libraries.
182 m4_define([_AC_PATH_X_XMKMF],
183 [rm -fr conftest.dir
184 if mkdir conftest.dir; then
185 cd conftest.dir
186 # Make sure to not put "make" in the Imakefile rules, since we grep it out.
187 cat >Imakefile <<'_ACEOF'
188 acfindx:
189 @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"'
190 _ACEOF
191 if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then
192 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
193 eval `${MAKE-make} acfindx 2>/dev/null | grep -v make`
194 # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
195 for ac_extension in a so sl; do
196 if test ! -f $ac_im_usrlibdir/libX11.$ac_extension &&
197 test -f $ac_im_libdir/libX11.$ac_extension; then
198 ac_im_usrlibdir=$ac_im_libdir; break
199 fi
200 done
201 # Screen out bogus values from the imake configuration. They are
202 # bogus both because they are the default anyway, and because
203 # using them would break gcc on systems where it needs fixed includes.
204 case $ac_im_incroot in
205 /usr/include) ;;
206 *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
207 esac
208 case $ac_im_usrlibdir in
209 /usr/lib | /lib) ;;
210 *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
211 esac
212 fi
213 cd ..
214 rm -fr conftest.dir
215 fi
216 ])# _AC_PATH_X_XMKMF
217
218
219 # _AC_PATH_X_DIRECT
220 # -----------------
221 # Internal subroutine of _AC_PATH_X.
222 # Set ac_x_includes and/or ac_x_libraries.
223 m4_define([_AC_PATH_X_DIRECT],
224 [# Standard set of common directories for X headers.
225 # Check X11 before X11Rn because it is often a symlink to the current release.
226 ac_x_header_dirs='
227 /usr/X11/include
228 /usr/X11R6/include
229 /usr/X11R5/include
230 /usr/X11R4/include
231
232 /usr/include/X11
233 /usr/include/X11R6
234 /usr/include/X11R5
235 /usr/include/X11R4
236
237 /usr/local/X11/include
238 /usr/local/X11R6/include
239 /usr/local/X11R5/include
240 /usr/local/X11R4/include
241
242 /usr/local/include/X11
243 /usr/local/include/X11R6
244 /usr/local/include/X11R5
245 /usr/local/include/X11R4
246
247 /usr/X386/include
248 /usr/x386/include
249 /usr/XFree86/include/X11
250
251 /usr/include
252 /usr/local/include
253 /usr/unsupported/include
254 /usr/athena/include
255 /usr/local/x11r5/include
256 /usr/lpp/Xamples/include
257
258 /usr/openwin/include
259 /usr/openwin/share/include'
260
261 if test "$ac_x_includes" = no; then
262 # Guess where to find include files, by looking for a specified header file.
263 # First, try using that file with no special directory specified.
264 AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <X11/Intrinsic.h>])],
265 [# We can compile using X headers with no special include directory.
266 ac_x_includes=],
267 [for ac_dir in $ac_x_header_dirs; do
268 if test -r "$ac_dir/X11/Intrinsic.h"; then
269 ac_x_includes=$ac_dir
270 break
271 fi
272 done])
273 fi # $ac_x_includes = no
274
275 if test "$ac_x_libraries" = no; then
276 # Check for the libraries.
277 # See if we find them without any special options.
278 # Don't add to $LIBS permanently.
279 ac_save_LIBS=$LIBS
280 LIBS="-lXt $LIBS"
281 AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <X11/Intrinsic.h>],
282 [XtMalloc (0)])],
283 [LIBS=$ac_save_LIBS
284 # We can link X programs with no special library path.
285 ac_x_libraries=],
286 [LIBS=$ac_save_LIBS
287 for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
288 do
289 # Don't even attempt the hair of trying to link an X program!
290 for ac_extension in a so sl; do
291 if test -r $ac_dir/libXt.$ac_extension; then
292 ac_x_libraries=$ac_dir
293 break 2
294 fi
295 done
296 done])
297 fi # $ac_x_libraries = no
298 ])# _AC_PATH_X_DIRECT
299
300
301 # _AC_PATH_X
302 # ----------
303 # Compute ac_cv_have_x.
304 AC_DEFUN([_AC_PATH_X],
305 [AC_CACHE_VAL(ac_cv_have_x,
306 [# One or both of the vars are not set, and there is no cached value.
307 ac_x_includes=no ac_x_libraries=no
308 _AC_PATH_X_XMKMF
309 _AC_PATH_X_DIRECT
310 if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then
311 # Didn't find X anywhere. Cache the known absence of X.
312 ac_cv_have_x="have_x=no"
313 else
314 # Record where we found X for the cache.
315 ac_cv_have_x="have_x=yes \
316 ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries"
317 fi])dnl
318 ])
319
320
321 # AC_PATH_X
322 # ---------
323 # If we find X, set shell vars x_includes and x_libraries to the
324 # paths, otherwise set no_x=yes.
325 # Uses ac_ vars as temps to allow command line to override cache and checks.
326 # --without-x overrides everything else, but does not touch the cache.
327 AN_HEADER([X11/Xlib.h], [AC_PATH_X])
328 AC_DEFUN([AC_PATH_X],
329 [dnl Document the X abnormal options inherited from history.
330 m4_divert_once([HELP_BEGIN], [
331 X features:
332 --x-includes=DIR X include files are in DIR
333 --x-libraries=DIR X library files are in DIR])dnl
334
335 if test "x$ac_path_x_has_been_run" != xyes; then
336 AC_MSG_CHECKING([for X])
337
338 ac_path_x_has_been_run=yes
339 AC_ARG_WITH(x, [ --with-x use the X Window System])
340 # $have_x is `yes', `no', `disabled', or empty when we do not yet know.
341 if test "x$with_x" = xno; then
342 # The user explicitly disabled X.
343 have_x=disabled
344 else
345 if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then
346 # Both variables are already set.
347 have_x=yes
348 else
349 _AC_PATH_X
350 fi
351 eval "$ac_cv_have_x"
352 fi # $with_x != no
353
354 if test "$have_x" != yes; then
355 AC_MSG_RESULT([$have_x])
356 no_x=yes
357 else
358 # If each of the values was on the command line, it overrides each guess.
359 test "x$x_includes" = xNONE && x_includes=$ac_x_includes
360 test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
361 # Update the cache value to reflect the command line values.
362 ac_cv_have_x="have_x=yes \
363 ac_x_includes=$x_includes ac_x_libraries=$x_libraries"
364 # It might be that x_includes is empty (headers are found in the
365 # standard search path. Then output the corresponding message
366 ac_out_x_includes=$x_includes
367 test "x$x_includes" = x && ac_out_x_includes="in standard search path"
368 AC_MSG_RESULT([libraries $x_libraries, headers $ac_out_x_includes])
369 fi
370
371 fi])# AC_PATH_X
372
373
374
375 # AC_PATH_XTRA
376 # ------------
377 # Find additional X libraries, magic flags, etc.
378 AC_DEFUN([AC_PATH_XTRA],
379 [AC_REQUIRE([AC_PATH_X])dnl
380 if test "$no_x" = yes; then
381 # Not all programs may use this symbol, but it does not hurt to define it.
382 AC_DEFINE([X_DISPLAY_MISSING], 1,
383 [Define to 1 if the X Window System is missing or not being used.])
384 X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
385 else
386 if test -n "$x_includes"; then
387 X_CFLAGS="$X_CFLAGS -I$x_includes"
388 fi
389
390 # It would also be nice to do this for all -L options, not just this one.
391 if test -n "$x_libraries"; then
392 X_LIBS="$X_LIBS -L$x_libraries"
393 dnl FIXME: banish uname from this macro!
394 # For Solaris; some versions of Sun CC require a space after -R and
395 # others require no space. Words are not sufficient . . . .
396 case `(uname -sr) 2>/dev/null` in
397 "SunOS 5"*)
398 AC_MSG_CHECKING([whether -R must be followed by a space])
399 ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
400 AC_LINK_IFELSE([AC_LANG_PROGRAM()], ac_R_nospace=yes, ac_R_nospace=no)
401 if test $ac_R_nospace = yes; then
402 AC_MSG_RESULT([no])
403 X_LIBS="$X_LIBS -R$x_libraries"
404 else
405 LIBS="$ac_xsave_LIBS -R $x_libraries"
406 AC_LINK_IFELSE([AC_LANG_PROGRAM()], ac_R_space=yes, ac_R_space=no)
407 if test $ac_R_space = yes; then
408 AC_MSG_RESULT([yes])
409 X_LIBS="$X_LIBS -R $x_libraries"
410 else
411 AC_MSG_RESULT([neither works])
412 fi
413 fi
414 LIBS=$ac_xsave_LIBS
415 esac
416 fi
417
418 # Check for system-dependent libraries X programs must link with.
419 # Do this before checking for the system-independent R6 libraries
420 # (-lICE), since we may need -lsocket or whatever for X linking.
421
422 if test "$ISC" = yes; then
423 X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
424 else
425 # Martyn Johnson says this is needed for Ultrix, if the X
426 # libraries were built with DECnet support. And Karl Berry says
427 # the Alpha needs dnet_stub (dnet does not exist).
428 ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
429 AC_LINK_IFELSE([AC_LANG_CALL([], [XOpenDisplay])],
430 [],
431 [AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
432 if test $ac_cv_lib_dnet_dnet_ntoa = no; then
433 AC_CHECK_LIB(dnet_stub, dnet_ntoa,
434 [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
435 fi])
436 LIBS="$ac_xsave_LIBS"
437
438 # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
439 # to get the SysV transport functions.
440 # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
441 # needs -lnsl.
442 # The nsl library prevents programs from opening the X display
443 # on Irix 5.2, according to T.E. Dickey.
444 # The functions gethostbyname, getservbyname, and inet_addr are
445 # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
446 AC_CHECK_FUNC(gethostbyname)
447 if test $ac_cv_func_gethostbyname = no; then
448 AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
449 if test $ac_cv_lib_nsl_gethostbyname = no; then
450 AC_CHECK_LIB(bsd, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd")
451 fi
452 fi
453
454 # lieder@skyler.mavd.honeywell.com says without -lsocket,
455 # socket/setsockopt and other routines are undefined under SCO ODT
456 # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary
457 # on later versions), says Simon Leinen: it contains gethostby*
458 # variants that don't use the name server (or something). -lsocket
459 # must be given before -lnsl if both are needed. We assume that
460 # if connect needs -lnsl, so does gethostbyname.
461 AC_CHECK_FUNC(connect)
462 if test $ac_cv_func_connect = no; then
463 AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
464 $X_EXTRA_LIBS)
465 fi
466
467 # Guillermo Gomez says -lposix is necessary on A/UX.
468 AC_CHECK_FUNC(remove)
469 if test $ac_cv_func_remove = no; then
470 AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
471 fi
472
473 # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
474 AC_CHECK_FUNC(shmat)
475 if test $ac_cv_func_shmat = no; then
476 AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc")
477 fi
478 fi
479
480 # Check for libraries that X11R6 Xt/Xaw programs need.
481 ac_save_LDFLAGS=$LDFLAGS
482 test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
483 # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
484 # check for ICE first), but we must link in the order -lSM -lICE or
485 # we get undefined symbols. So assume we have SM if we have ICE.
486 # These have to be linked with before -lX11, unlike the other
487 # libraries we check for below, so use a different variable.
488 # John Interrante, Karl Berry
489 AC_CHECK_LIB(ICE, IceConnectionNumber,
490 [X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"], , $X_EXTRA_LIBS)
491 LDFLAGS=$ac_save_LDFLAGS
492
493 fi
494 AC_SUBST(X_CFLAGS)dnl
495 AC_SUBST(X_PRE_LIBS)dnl
496 AC_SUBST(X_LIBS)dnl
497 AC_SUBST(X_EXTRA_LIBS)dnl
498 ])# AC_PATH_XTRA