Add WX_FIND_LIB() function to simplify testing for libraries in configure.

No real changes in behaviour but the new WX_FIND_LIB() function can now be
used to test for any library.

Closes #13375.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69556 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2011-10-26 23:20:19 +00:00
parent 218116bd0a
commit d0260bd894
3 changed files with 2507 additions and 137 deletions

View File

@@ -115,6 +115,71 @@ AC_DEFUN([WX_LINK_PATH_EXIST],
fi
])
dnl ---------------------------------------------------------------------------
dnl Usage: WX_FIND_LIB(search-path, lib-name, [lib-function to test])
dnl
dnl Tests in a variety of ways for the presence of lib-name
dnl
dnl On success, returns any novel path found in ac_find_libraries; else "std"
dnl and any cflags in ac_find_cflags
dnl On failure, ac_find_libraries will be empty
dnl ---------------------------------------------------------------------------
AC_DEFUN([WX_FIND_LIB],
[
ac_find_libraries=
dnl Try with pkg-config first. It requires its lib-name parameter lowercase
fl_pkgname=`echo "$2" | tr [[:upper:]] [[:lower:]]`
dnl suppress PKG_PROG_PKG_CONFIG output; we don't want to keep seeing it
PKG_PROG_PKG_CONFIG() AS_MESSAGE_FD> /dev/null
PKG_CHECK_MODULES([$2], [$fl_pkgname],
[
dnl Start by assuming there are no novel lib paths
ac_find_libraries="std"
dnl A simple copy of the internal vars $2_CFLAGS $2_LIBS doesn't work
dnl inside the macro
dnl
dnl TODO: When we stop being autoconf 2.61 compatible, the next 2 lines
dnl should become:
dnl AS_VAR_COPY([ac_find_cflags], [$2_CFLAGS])
dnl AS_VAR_COPY([fl_libs], [$2_LIBS])
eval ac_find_cflags=\$$2_CFLAGS
eval fl_libs=\$$2_LIBS
dnl fl_libs may now contain -Lfoopath -lfoo (only non-standard paths are
dnl added) We only want the path bit, not the lib names
for fl_path in $fl_libs
do
if test `echo "$fl_path" | cut -c 1-2` = "-L"; then
dnl there shouldn't be >1 novel path
dnl return it without the -L, ready for WX_LINK_PATH_EXIST
ac_find_libraries=`echo "$fl_path" | cut -c 3-`
fi
done
],
[
if test "x$ac_find_libraries" = "x"; then
dnl Next with AC_CHECK_LIB, if a test function was provided
if test "x$3" != "x"; then
AC_CHECK_LIB([$2], [$3], [ac_find_libraries="std"])
fi
fi
if test "x$ac_find_libraries" = "x"; then
dnl Finally try the search path
dnl Output a message again, as AC_CHECK_LIB will just have said "no"
AC_MSG_CHECKING([elsewhere])
WX_PATH_FIND_LIBRARIES([$1],[$2])
if test "x$ac_find_libraries" != "x"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
fi
])
])
dnl ===========================================================================
dnl C++ features test
dnl ===========================================================================

2510
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -3772,18 +3772,17 @@ USE_XINERAMA=0
if test "$wxUSE_DISPLAY" = "yes"; then
dnl Xinerama is used for wxGTK1/wxX11/wxMotif only
if test "$wxUSE_MOTIF" = 1 -o "$wxUSE_X11" = 1 -o "$wxUSE_GTK1" = 1; then
AC_MSG_CHECKING([for Xinerama])
WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],Xinerama)
WX_FIND_LIB([$SEARCH_LIB], Xinerama, XineramaQueryScreens)
if test "$ac_find_libraries" != "" ; then
WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
if test "$ac_path_to_link" != " -L/usr/lib" ; then
LDFLAGS="$LDFLAGS $ac_path_to_link"
if test "$ac_find_libraries" != "std" ; then
WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
if test "$ac_path_to_link" != " -L/usr/lib" ; then
LDFLAGS="$LDFLAGS $ac_path_to_link"
fi
fi
USE_XINERAMA=1
GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXinerama"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_WARN([Xinerama not found; disabling wxDisplay])
wxUSE_DISPLAY="no"
fi
@@ -3796,10 +3795,8 @@ fi
if test "$wxUSE_DISPLAY" = "yes"; then
dnl wxGTK2 needs Xxf86vm as well as Xinerama-using ports from above
if test "$USE_XINERAMA" = 1 -o "$wxUSE_GTK" = 1; then
AC_MSG_CHECKING([for Xxf86vm extension])
WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],Xxf86vm)
WX_FIND_LIB([$SEARCH_LIB], Xxf86vm, XF86VidModeQueryExtension)
if test "$ac_find_libraries" != "" ; then
AC_MSG_RESULT([yes])
AC_CHECK_HEADERS([X11/extensions/xf86vmode.h],
[
GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lXxf86vm"
@@ -3810,8 +3807,6 @@ if test "$wxUSE_DISPLAY" = "yes"; then
#include <X11/Xlib.h>
#endif
])
else
AC_MSG_RESULT([no])
fi
fi
fi
@@ -3821,17 +3816,16 @@ dnl X11 session management
dnl ---------------------------------------------------------------------------
if test "$wxUSE_DETECT_SM" = "yes"; then
if test "$wxUSE_UNIX" = "yes" -a "$wxUSE_MAC" != 1 -a "$wxUSE_OLD_COCOA" != 1; then
AC_MSG_CHECKING([for -lSM - X11 session management])
WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],SM)
WX_FIND_LIB([$SEARCH_LIB], SM, SmcOpenConnection)
if test "$ac_find_libraries" != "" ; then
WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
if test "$ac_path_to_link" != " -L/usr/lib" ; then
if test "$ac_find_libraries" != "std" ; then
WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
if test "$ac_path_to_link" != " -L/usr/lib" ; then
LDFLAGS="$LDFLAGS $ac_path_to_link"
fi
fi
GUI_TK_LIBRARY="$GUI_TK_LIBRARY -lSM"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_WARN([libSM not found; disabling session management detection])
wxUSE_DETECT_SM="no"
fi
@@ -3872,48 +3866,43 @@ if test "$wxUSE_OPENGL" = "yes" -o "$wxUSE_OPENGL" = "auto"; then
AC_CHECK_HEADER(GL/glu.h, [
found_gl=0
AC_MSG_CHECKING([for -lGL])
WX_PATH_FIND_LIBRARIES([$SEARCH_LIB /opt/graphics/OpenGL/lib],GL)
WX_FIND_LIB([$SEARCH_LIB /opt/graphics/OpenGL/lib], GL, glBegin)
if test "$ac_find_libraries" != "" ; then
AC_MSG_RESULT([found in $ac_find_libraries])
WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
if test "$ac_path_to_link" != " -L/usr/lib" ; then
if test "$ac_find_libraries" != "std" ; then
WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
if test "$ac_path_to_link" != " -L/usr/lib" ; then
LDFLAGS_GL="$ac_path_to_link"
fi
fi
dnl don't suppose that libGL and libGLU are always in the
dnl same directory -- this is not true for some common
dnl distributions
AC_MSG_CHECKING([for -lGLU])
WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],GLU)
WX_FIND_LIB([$SEARCH_LIB], GLU, gluBeginCurve)
if test "$ac_find_libraries" != "" ; then
if test "$ac_find_libraries" != "std" ; then
WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
if test "$ac_path_to_link" != " -L/usr/lib" -a \
"$ac_path_to_link" != "$LDFLAGS_GL"; then
LDFLAGS_GL="$LDFLAGS_GL$ac_path_to_link"
"$ac_path_to_link" != "$LDFLAGS_GL" ; then
LDFLAGS_GL="$LDFLAGS_GL$ac_path_to_link"
fi
fi
found_gl=1
OPENGL_LIBS="-lGL -lGLU"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
else
AC_MSG_RESULT([no])
fi
if test "$found_gl" != 1; then
AC_MSG_CHECKING([for -lMesaGL])
WX_PATH_FIND_LIBRARIES([$SEARCH_LIB],MesaGL)
WX_FIND_LIB([$SEARCH_LIB], MesaGL, glEnable)
if test "$ac_find_libraries" != "" ; then
if test "$ac_find_libraries" != "std" ; then
WX_LINK_PATH_EXIST([$ac_find_libraries],[$LDFLAGS])
LDFLAGS_GL="$LDFLAGS$ac_path_to_link"
OPENGL_LIBS="-lMesaGL -lMesaGLU"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
if test "$ac_path_to_link" != " -L/usr/lib" ; then
LDFLAGS_GL="$LDFLAGS_GL$ac_path_to_link"
fi
fi
OPENGL_LIBS="-lMesaGL -lMesaGLU"
fi
fi
],, [ ])