]> git.saurik.com Git - wxWidgets.git/blame - build/autoconf_prepend-include/autoconf/libs.m4
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / build / autoconf_prepend-include / autoconf / libs.m4
CommitLineData
194f742f
RD
1# This file is part of Autoconf. -*- Autoconf -*-
2# Checking for libraries.
3# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
580e09f7 4# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
194f742f
RD
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
580e09f7
DE
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19# 02110-1301, USA.
194f742f
RD
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.
69AC_DEFUN([AC_SEARCH_LIBS],
580e09f7
DE
70[AS_VAR_PUSHDEF([ac_Search], [ac_cv_search_$1])dnl
71AC_CACHE_CHECK([for library containing $1], [ac_Search],
194f742f 72[ac_func_search_save_LIBS=$LIBS
580e09f7
DE
73AC_LANG_CONFTEST([AC_LANG_CALL([], [$1])])
74for ac_lib in '' $2; do
75 if test -z "$ac_lib"; then
76 ac_res="none required"
77 else
78 ac_res=-l$ac_lib
194f742f 79 LIBS="-l$ac_lib $5 $ac_func_search_save_LIBS"
580e09f7
DE
80 fi
81 AC_LINK_IFELSE([], [AS_VAR_SET([ac_Search], [$ac_res])])
82 AS_VAR_SET_IF([ac_Search], [break])dnl
83done
84AS_VAR_SET_IF([ac_Search], , [AS_VAR_SET([ac_Search], [no])])dnl
85rm conftest.$ac_ext
194f742f 86LIBS=$ac_func_search_save_LIBS])
580e09f7
DE
87ac_res=AS_VAR_GET([ac_Search])
88AS_IF([test "$ac_res" != no],
89 [test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
194f742f
RD
90 $3],
91 [$4])dnl
580e09f7 92AS_VAR_POPDEF([ac_Search])dnl
194f742f
RD
93])
94
95
96
97# AC_CHECK_LIB(LIBRARY, FUNCTION,
98# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
99# [OTHER-LIBRARIES])
100# ------------------------------------------------------
101#
102# Use a cache variable name containing both the library and function name,
103# because the test really is for library $1 defining function $2, not
104# just for library $1. Separate tests with the same $1 and different $2s
105# may have different results.
106#
107# Note that using directly AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$2])
108# is asking for troubles, since AC_CHECK_LIB($lib, fun) would give
109# ac_cv_lib_$lib_fun, which is definitely not what was meant. Hence
110# the AS_LITERAL_IF indirection.
111#
112# FIXME: This macro is extremely suspicious. It DEFINEs unconditionally,
113# whatever the FUNCTION, in addition to not being a *S macro. Note
114# that the cache does depend upon the function we are looking for.
115#
116# It is on purpose we used `ac_check_lib_save_LIBS' and not just
117# `ac_save_LIBS': there are many macros which don't want to see `LIBS'
118# changed but still want to use AC_CHECK_LIB, so they save `LIBS'.
119# And ``ac_save_LIBS' is too tempting a name, so let's leave them some
120# freedom.
121AC_DEFUN([AC_CHECK_LIB],
122[m4_ifval([$3], , [AH_CHECK_LIB([$1])])dnl
123AS_LITERAL_IF([$1],
124 [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1_$2])],
125 [AS_VAR_PUSHDEF([ac_Lib], [ac_cv_lib_$1''_$2])])dnl
580e09f7 126AC_CACHE_CHECK([for $2 in -l$1], [ac_Lib],
194f742f
RD
127[ac_check_lib_save_LIBS=$LIBS
128LIBS="-l$1 $5 $LIBS"
129AC_LINK_IFELSE([AC_LANG_CALL([], [$2])],
580e09f7
DE
130 [AS_VAR_SET([ac_Lib], [yes])],
131 [AS_VAR_SET([ac_Lib], [no])])
194f742f 132LIBS=$ac_check_lib_save_LIBS])
580e09f7 133AS_IF([test AS_VAR_GET([ac_Lib]) = yes],
194f742f
RD
134 [m4_default([$3], [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_LIB$1))
135 LIBS="-l$1 $LIBS"
136])],
137 [$4])dnl
138AS_VAR_POPDEF([ac_Lib])dnl
139])# AC_CHECK_LIB
140
141
142# AH_CHECK_LIB(LIBNAME)
143# ---------------------
144m4_define([AH_CHECK_LIB],
580e09f7
DE
145[AH_TEMPLATE(AS_TR_CPP([HAVE_LIB$1]),
146 [Define to 1 if you have the `$1' library (-l$1).])])
194f742f
RD
147
148
149# AC_HAVE_LIBRARY(LIBRARY,
150# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
151# [OTHER-LIBRARIES])
152# ---------------------------------------------------------
153#
154# This macro is equivalent to calling `AC_CHECK_LIB' with a FUNCTION
155# argument of `main'. In addition, LIBRARY can be written as any of
156# `foo', `-lfoo', or `libfoo.a'. In all of those cases, the compiler
157# is passed `-lfoo'. However, LIBRARY cannot be a shell variable;
158# it must be a literal name.
159AU_DEFUN([AC_HAVE_LIBRARY],
160[m4_pushdef([AC_Lib_Name],
161 m4_bpatsubst(m4_bpatsubst([[$1]],
162 [lib\([^\.]*\)\.a], [\1]),
163 [-l], []))dnl
164AC_CHECK_LIB(AC_Lib_Name, main, [$2], [$3], [$4])dnl
165ac_cv_lib_[]AC_Lib_Name()=ac_cv_lib_[]AC_Lib_Name()_main
166m4_popdef([AC_Lib_Name])dnl
167])
168
169
170
171
172## --------------------------------- ##
173## 2. Tests for specific libraries. ##
174## --------------------------------- ##
175
176
177
178# --------------------- #
179# Checks for X window. #
180# --------------------- #
181
182
183# _AC_PATH_X_XMKMF
184# ----------------
185# Internal subroutine of _AC_PATH_X.
186# Set ac_x_includes and/or ac_x_libraries.
187m4_define([_AC_PATH_X_XMKMF],
580e09f7
DE
188[AC_ARG_VAR(XMKMF, [Path to xmkmf, Makefile generator for X Window System])dnl
189rm -f -r conftest.dir
194f742f
RD
190if mkdir conftest.dir; then
191 cd conftest.dir
194f742f 192 cat >Imakefile <<'_ACEOF'
580e09f7
DE
193incroot:
194 @echo incroot='${INCROOT}'
195usrlibdir:
196 @echo usrlibdir='${USRLIBDIR}'
197libdir:
198 @echo libdir='${LIBDIR}'
194f742f 199_ACEOF
580e09f7 200 if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then
194f742f 201 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
580e09f7
DE
202 for ac_var in incroot usrlibdir libdir; do
203 eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`"
204 done
194f742f
RD
205 # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR.
206 for ac_extension in a so sl; do
580e09f7
DE
207 if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" &&
208 test -f "$ac_im_libdir/libX11.$ac_extension"; then
194f742f
RD
209 ac_im_usrlibdir=$ac_im_libdir; break
210 fi
211 done
212 # Screen out bogus values from the imake configuration. They are
213 # bogus both because they are the default anyway, and because
214 # using them would break gcc on systems where it needs fixed includes.
215 case $ac_im_incroot in
580e09f7 216 /usr/include) ac_x_includes= ;;
194f742f
RD
217 *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;;
218 esac
219 case $ac_im_usrlibdir in
220 /usr/lib | /lib) ;;
221 *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;;
222 esac
223 fi
224 cd ..
580e09f7 225 rm -f -r conftest.dir
194f742f
RD
226fi
227])# _AC_PATH_X_XMKMF
228
229
230# _AC_PATH_X_DIRECT
231# -----------------
232# Internal subroutine of _AC_PATH_X.
233# Set ac_x_includes and/or ac_x_libraries.
234m4_define([_AC_PATH_X_DIRECT],
235[# Standard set of common directories for X headers.
236# Check X11 before X11Rn because it is often a symlink to the current release.
237ac_x_header_dirs='
238/usr/X11/include
239/usr/X11R6/include
240/usr/X11R5/include
241/usr/X11R4/include
242
243/usr/include/X11
244/usr/include/X11R6
245/usr/include/X11R5
246/usr/include/X11R4
247
248/usr/local/X11/include
249/usr/local/X11R6/include
250/usr/local/X11R5/include
251/usr/local/X11R4/include
252
253/usr/local/include/X11
254/usr/local/include/X11R6
255/usr/local/include/X11R5
256/usr/local/include/X11R4
257
258/usr/X386/include
259/usr/x386/include
260/usr/XFree86/include/X11
261
262/usr/include
263/usr/local/include
264/usr/unsupported/include
265/usr/athena/include
266/usr/local/x11r5/include
267/usr/lpp/Xamples/include
268
269/usr/openwin/include
270/usr/openwin/share/include'
271
272if test "$ac_x_includes" = no; then
580e09f7 273 # Guess where to find include files, by looking for Xlib.h.
194f742f 274 # First, try using that file with no special directory specified.
580e09f7 275 AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <X11/Xlib.h>])],
194f742f
RD
276[# We can compile using X headers with no special include directory.
277ac_x_includes=],
278[for ac_dir in $ac_x_header_dirs; do
580e09f7 279 if test -r "$ac_dir/X11/Xlib.h"; then
194f742f
RD
280 ac_x_includes=$ac_dir
281 break
282 fi
283done])
284fi # $ac_x_includes = no
285
286if test "$ac_x_libraries" = no; then
287 # Check for the libraries.
288 # See if we find them without any special options.
289 # Don't add to $LIBS permanently.
290 ac_save_LIBS=$LIBS
580e09f7
DE
291 LIBS="-lX11 $LIBS"
292 AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@include <X11/Xlib.h>],
293 [XrmInitialize ()])],
194f742f
RD
294 [LIBS=$ac_save_LIBS
295# We can link X programs with no special library path.
296ac_x_libraries=],
297 [LIBS=$ac_save_LIBS
298for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g`
299do
300 # Don't even attempt the hair of trying to link an X program!
301 for ac_extension in a so sl; do
580e09f7 302 if test -r "$ac_dir/libX11.$ac_extension"; then
194f742f
RD
303 ac_x_libraries=$ac_dir
304 break 2
305 fi
306 done
307done])
308fi # $ac_x_libraries = no
309])# _AC_PATH_X_DIRECT
310
311
312# _AC_PATH_X
313# ----------
314# Compute ac_cv_have_x.
315AC_DEFUN([_AC_PATH_X],
316[AC_CACHE_VAL(ac_cv_have_x,
317[# One or both of the vars are not set, and there is no cached value.
318ac_x_includes=no ac_x_libraries=no
319_AC_PATH_X_XMKMF
320_AC_PATH_X_DIRECT
580e09f7
DE
321case $ac_x_includes,$ac_x_libraries in #(
322 no,* | *,no | *\'*)
323 # Didn't find X, or a directory has "'" in its name.
324 ac_cv_have_x="have_x=no";; #(
325 *)
326 # Record where we found X for the cache.
327 ac_cv_have_x="have_x=yes\
328 ac_x_includes='$ac_x_includes'\
329 ac_x_libraries='$ac_x_libraries'"
330esac])dnl
194f742f
RD
331])
332
333
334# AC_PATH_X
335# ---------
336# If we find X, set shell vars x_includes and x_libraries to the
337# paths, otherwise set no_x=yes.
338# Uses ac_ vars as temps to allow command line to override cache and checks.
339# --without-x overrides everything else, but does not touch the cache.
340AN_HEADER([X11/Xlib.h], [AC_PATH_X])
341AC_DEFUN([AC_PATH_X],
342[dnl Document the X abnormal options inherited from history.
343m4_divert_once([HELP_BEGIN], [
344X features:
345 --x-includes=DIR X include files are in DIR
346 --x-libraries=DIR X library files are in DIR])dnl
580e09f7 347AC_MSG_CHECKING([for X])
194f742f 348
194f742f
RD
349AC_ARG_WITH(x, [ --with-x use the X Window System])
350# $have_x is `yes', `no', `disabled', or empty when we do not yet know.
351if test "x$with_x" = xno; then
352 # The user explicitly disabled X.
353 have_x=disabled
354else
580e09f7
DE
355 case $x_includes,$x_libraries in #(
356 *\'*) AC_MSG_ERROR([Cannot use X directory names containing ']);; #(
357 *,NONE | NONE,*) _AC_PATH_X;; #(
358 *) have_x=yes;;
359 esac
194f742f
RD
360 eval "$ac_cv_have_x"
361fi # $with_x != no
362
363if test "$have_x" != yes; then
364 AC_MSG_RESULT([$have_x])
365 no_x=yes
366else
367 # If each of the values was on the command line, it overrides each guess.
368 test "x$x_includes" = xNONE && x_includes=$ac_x_includes
369 test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries
370 # Update the cache value to reflect the command line values.
580e09f7
DE
371 ac_cv_have_x="have_x=yes\
372 ac_x_includes='$x_includes'\
373 ac_x_libraries='$x_libraries'"
374 AC_MSG_RESULT([libraries $x_libraries, headers $x_includes])
194f742f 375fi
580e09f7 376])# AC_PATH_X
194f742f
RD
377
378
379
380# AC_PATH_XTRA
381# ------------
382# Find additional X libraries, magic flags, etc.
383AC_DEFUN([AC_PATH_XTRA],
384[AC_REQUIRE([AC_PATH_X])dnl
385if test "$no_x" = yes; then
386 # Not all programs may use this symbol, but it does not hurt to define it.
387 AC_DEFINE([X_DISPLAY_MISSING], 1,
388 [Define to 1 if the X Window System is missing or not being used.])
389 X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS=
390else
391 if test -n "$x_includes"; then
392 X_CFLAGS="$X_CFLAGS -I$x_includes"
393 fi
394
395 # It would also be nice to do this for all -L options, not just this one.
396 if test -n "$x_libraries"; then
397 X_LIBS="$X_LIBS -L$x_libraries"
194f742f
RD
398 # For Solaris; some versions of Sun CC require a space after -R and
399 # others require no space. Words are not sufficient . . . .
580e09f7
DE
400 AC_MSG_CHECKING([whether -R must be followed by a space])
401 ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries"
402 ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag=$ac_[]_AC_LANG_ABBREV[]_werror_flag
403 ac_[]_AC_LANG_ABBREV[]_werror_flag=yes
404 AC_LINK_IFELSE([AC_LANG_PROGRAM()],
405 [AC_MSG_RESULT([no])
406 X_LIBS="$X_LIBS -R$x_libraries"],
407 [LIBS="$ac_xsave_LIBS -R $x_libraries"
408 AC_LINK_IFELSE([AC_LANG_PROGRAM()],
409 [AC_MSG_RESULT([yes])
410 X_LIBS="$X_LIBS -R $x_libraries"],
411 [AC_MSG_RESULT([neither works])])])
412 ac_[]_AC_LANG_ABBREV[]_werror_flag=$ac_xsave_[]_AC_LANG_ABBREV[]_werror_flag
413 LIBS=$ac_xsave_LIBS
194f742f
RD
414 fi
415
416 # Check for system-dependent libraries X programs must link with.
417 # Do this before checking for the system-independent R6 libraries
418 # (-lICE), since we may need -lsocket or whatever for X linking.
419
420 if test "$ISC" = yes; then
421 X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet"
422 else
423 # Martyn Johnson says this is needed for Ultrix, if the X
424 # libraries were built with DECnet support. And Karl Berry says
425 # the Alpha needs dnet_stub (dnet does not exist).
426 ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11"
427 AC_LINK_IFELSE([AC_LANG_CALL([], [XOpenDisplay])],
428 [],
429 [AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"])
430 if test $ac_cv_lib_dnet_dnet_ntoa = no; then
431 AC_CHECK_LIB(dnet_stub, dnet_ntoa,
432 [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"])
433 fi])
434 LIBS="$ac_xsave_LIBS"
435
436 # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT,
437 # to get the SysV transport functions.
438 # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4)
439 # needs -lnsl.
440 # The nsl library prevents programs from opening the X display
441 # on Irix 5.2, according to T.E. Dickey.
442 # The functions gethostbyname, getservbyname, and inet_addr are
443 # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking.
444 AC_CHECK_FUNC(gethostbyname)
445 if test $ac_cv_func_gethostbyname = no; then
446 AC_CHECK_LIB(nsl, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl")
447 if test $ac_cv_lib_nsl_gethostbyname = no; then
448 AC_CHECK_LIB(bsd, gethostbyname, X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd")
449 fi
450 fi
451
452 # lieder@skyler.mavd.honeywell.com says without -lsocket,
453 # socket/setsockopt and other routines are undefined under SCO ODT
454 # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary
455 # on later versions), says Simon Leinen: it contains gethostby*
456 # variants that don't use the name server (or something). -lsocket
457 # must be given before -lnsl if both are needed. We assume that
458 # if connect needs -lnsl, so does gethostbyname.
459 AC_CHECK_FUNC(connect)
460 if test $ac_cv_func_connect = no; then
461 AC_CHECK_LIB(socket, connect, X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS", ,
462 $X_EXTRA_LIBS)
463 fi
464
465 # Guillermo Gomez says -lposix is necessary on A/UX.
466 AC_CHECK_FUNC(remove)
467 if test $ac_cv_func_remove = no; then
468 AC_CHECK_LIB(posix, remove, X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix")
469 fi
470
471 # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay.
472 AC_CHECK_FUNC(shmat)
473 if test $ac_cv_func_shmat = no; then
474 AC_CHECK_LIB(ipc, shmat, X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc")
475 fi
476 fi
477
478 # Check for libraries that X11R6 Xt/Xaw programs need.
479 ac_save_LDFLAGS=$LDFLAGS
480 test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries"
481 # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to
482 # check for ICE first), but we must link in the order -lSM -lICE or
483 # we get undefined symbols. So assume we have SM if we have ICE.
484 # These have to be linked with before -lX11, unlike the other
485 # libraries we check for below, so use a different variable.
486 # John Interrante, Karl Berry
487 AC_CHECK_LIB(ICE, IceConnectionNumber,
488 [X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"], , $X_EXTRA_LIBS)
489 LDFLAGS=$ac_save_LDFLAGS
490
491fi
492AC_SUBST(X_CFLAGS)dnl
493AC_SUBST(X_PRE_LIBS)dnl
494AC_SUBST(X_LIBS)dnl
495AC_SUBST(X_EXTRA_LIBS)dnl
496])# AC_PATH_XTRA