From 629639ee601052907b2b67005fb1fda54314dd08 Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Wed, 4 Jul 2007 12:47:57 +0200
Subject: [PATCH] configure: Merge the libXrender existence check with the
 soname check.

---
 configure                  | 270 ++++++++++++++++++-------------------
 configure.ac               |  23 ++--
 dlls/winex11.drv/xrandr.c  |   3 -
 dlls/winex11.drv/xrender.c |   9 +-
 4 files changed, 150 insertions(+), 155 deletions(-)

diff --git a/configure b/configure
index dec471ead48..a1e264f5119 100755
--- a/configure
+++ b/configure
@@ -9324,32 +9324,45 @@ fi
 
         fi
 
-                if test "$ac_cv_header_X11_extensions_Xrandr_h" = "yes"
+                if test "$ac_cv_header_X11_extensions_Xrender_h" = "yes"
         then
-                cat >conftest.$ac_ext <<_ACEOF
+            { echo "$as_me:$LINENO: checking for -lXrender" >&5
+echo $ECHO_N "checking for -lXrender... $ECHO_C" >&6; }
+if test "${ac_cv_lib_soname_Xrender+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_soname_save_LIBS=$LIBS
+LIBS="-lXrender $X_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <X11/Xlib.h>
-#include <X11/extensions/Xrandr.h>
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char XRenderQueryExtension ();
 int
 main ()
 {
-static typeof(XRRSetScreenConfigAndRate) * func;
+return XRenderQueryExtension ();
   ;
   return 0;
 }
 _ACEOF
-rm -f conftest.$ac_objext
-if { (ac_try="$ac_compile"
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_compile") 2>conftest.er1
+  (eval "$ac_link") 2>conftest.er1
   ac_status=$?
   grep -v '^ *+' conftest.er1 >conftest.err
   rm -f conftest.er1
@@ -9358,15 +9371,44 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
   (exit $ac_status); } && {
 	 test -z "$ac_c_werror_flag" ||
 	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then
-  { echo "$as_me:$LINENO: checking for -lXrandr" >&5
-echo $ECHO_N "checking for -lXrandr... $ECHO_C" >&6; }
-if test "${ac_cv_lib_soname_Xrandr+set}" = set; then
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  case "$LIBEXT" in
+    dll) ;;
+    dylib) ac_cv_lib_soname_Xrender=`otool -L conftest$ac_exeext | grep "libXrender\\.[0-9A-Za-z.]*dylib" | sed -e "s/^.*\/\(libXrender\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;;
+    *) ac_cv_lib_soname_Xrender=`$ac_cv_path_LDD conftest$ac_exeext | grep "libXrender\\.$LIBEXT" | sed -e "s/^.*\(libXrender\.$LIBEXT[^	 ]*\).*$/\1/"';2,$d'` ;;
+  esac
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+  LIBS=$ac_check_soname_save_LIBS
+fi
+if test "x$ac_cv_lib_soname_Xrender" = "x"; then
+  { echo "$as_me:$LINENO: result: not found" >&5
+echo "${ECHO_T}not found" >&6; }
+
+else
+  { echo "$as_me:$LINENO: result: $ac_cv_lib_soname_Xrender" >&5
+echo "${ECHO_T}$ac_cv_lib_soname_Xrender" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define SONAME_LIBXRENDER "$ac_cv_lib_soname_Xrender"
+_ACEOF
+
+       { echo "$as_me:$LINENO: checking for XRenderSetPictureTransform in -lXrender" >&5
+echo $ECHO_N "checking for XRenderSetPictureTransform in -lXrender... $ECHO_C" >&6; }
+if test "${ac_cv_lib_Xrender_XRenderSetPictureTransform+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_soname_save_LIBS=$LIBS
-LIBS="-lXrandr $X_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
-  cat >conftest.$ac_ext <<_ACEOF
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lXrender $X_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -9379,11 +9421,11 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef __cplusplus
 extern "C"
 #endif
-char XRRQueryExtension ();
+char XRenderSetPictureTransform ();
 int
 main ()
 {
-return XRRQueryExtension ();
+return XRenderSetPictureTransform ();
   ;
   return 0;
 }
@@ -9406,57 +9448,76 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  case "$LIBEXT" in
-    dll) ;;
-    dylib) ac_cv_lib_soname_Xrandr=`otool -L conftest$ac_exeext | grep "libXrandr\\.[0-9A-Za-z.]*dylib" | sed -e "s/^.*\/\(libXrandr\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;;
-    *) ac_cv_lib_soname_Xrandr=`$ac_cv_path_LDD conftest$ac_exeext | grep "libXrandr\\.$LIBEXT" | sed -e "s/^.*\(libXrandr\.$LIBEXT[^	 ]*\).*$/\1/"';2,$d'` ;;
-  esac
+  ac_cv_lib_Xrender_XRenderSetPictureTransform=yes
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-
+	ac_cv_lib_Xrender_XRenderSetPictureTransform=no
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
-  LIBS=$ac_check_soname_save_LIBS
+LIBS=$ac_check_lib_save_LIBS
 fi
-if test "x$ac_cv_lib_soname_Xrandr" = "x"; then
-  { echo "$as_me:$LINENO: result: not found" >&5
-echo "${ECHO_T}not found" >&6; }
-
-else
-  { echo "$as_me:$LINENO: result: $ac_cv_lib_soname_Xrandr" >&5
-echo "${ECHO_T}$ac_cv_lib_soname_Xrandr" >&6; }
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xrender_XRenderSetPictureTransform" >&5
+echo "${ECHO_T}$ac_cv_lib_Xrender_XRenderSetPictureTransform" >&6; }
+if test $ac_cv_lib_Xrender_XRenderSetPictureTransform = yes; then
 
-cat >>confdefs.h <<_ACEOF
-#define SONAME_LIBXRANDR "$ac_cv_lib_soname_Xrandr"
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_XRENDERSETPICTURETRANSFORM 1
 _ACEOF
 
-
 fi
 
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
 fi
 
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
         fi
 
-                if test "$ac_cv_header_X11_extensions_Xrender_h" = "yes"
+                if test "$ac_cv_header_X11_extensions_Xrandr_h" = "yes" -a "x$ac_cv_lib_soname_Xrender" != "x"
         then
-              { echo "$as_me:$LINENO: checking for XRenderSetPictureTransform in -lXrender" >&5
-echo $ECHO_N "checking for XRenderSetPictureTransform in -lXrender... $ECHO_C" >&6; }
-if test "${ac_cv_lib_Xrender_XRenderSetPictureTransform+set}" = set; then
+                cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <X11/Xlib.h>
+#include <X11/extensions/Xrandr.h>
+int
+main ()
+{
+static typeof(XRRSetScreenConfigAndRate) * func;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  { echo "$as_me:$LINENO: checking for -lXrandr" >&5
+echo $ECHO_N "checking for -lXrandr... $ECHO_C" >&6; }
+if test "${ac_cv_lib_soname_Xrandr+set}" = set; then
   echo $ECHO_N "(cached) $ECHO_C" >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lXrender $X_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
-cat >conftest.$ac_ext <<_ACEOF
+  ac_check_soname_save_LIBS=$LIBS
+LIBS="-lXrandr $X_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
+  cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
@@ -9469,11 +9530,11 @@ cat >>conftest.$ac_ext <<_ACEOF
 #ifdef __cplusplus
 extern "C"
 #endif
-char XRenderSetPictureTransform ();
+char XRRQueryExtension ();
 int
 main ()
 {
-return XRenderSetPictureTransform ();
+return XRRQueryExtension ();
   ;
   return 0;
 }
@@ -9496,28 +9557,45 @@ eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext &&
        $as_test_x conftest$ac_exeext; then
-  ac_cv_lib_Xrender_XRenderSetPictureTransform=yes
+  case "$LIBEXT" in
+    dll) ;;
+    dylib) ac_cv_lib_soname_Xrandr=`otool -L conftest$ac_exeext | grep "libXrandr\\.[0-9A-Za-z.]*dylib" | sed -e "s/^.*\/\(libXrandr\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;;
+    *) ac_cv_lib_soname_Xrandr=`$ac_cv_path_LDD conftest$ac_exeext | grep "libXrandr\\.$LIBEXT" | sed -e "s/^.*\(libXrandr\.$LIBEXT[^	 ]*\).*$/\1/"';2,$d'` ;;
+  esac
 else
   echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_cv_lib_Xrender_XRenderSetPictureTransform=no
+
 fi
 
 rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
       conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+  LIBS=$ac_check_soname_save_LIBS
 fi
-{ echo "$as_me:$LINENO: result: $ac_cv_lib_Xrender_XRenderSetPictureTransform" >&5
-echo "${ECHO_T}$ac_cv_lib_Xrender_XRenderSetPictureTransform" >&6; }
-if test $ac_cv_lib_Xrender_XRenderSetPictureTransform = yes; then
+if test "x$ac_cv_lib_soname_Xrandr" = "x"; then
+  { echo "$as_me:$LINENO: result: not found" >&5
+echo "${ECHO_T}not found" >&6; }
 
-cat >>confdefs.h <<\_ACEOF
-#define HAVE_XRENDERSETPICTURETRANSFORM 1
+else
+  { echo "$as_me:$LINENO: result: $ac_cv_lib_soname_Xrandr" >&5
+echo "${ECHO_T}$ac_cv_lib_soname_Xrandr" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define SONAME_LIBXRANDR "$ac_cv_lib_soname_Xrandr"
 _ACEOF
 
+
 fi
 
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
         fi
 
                 if test "$ac_cv_header_X11_extensions_Xinerama_h" = "yes"
@@ -15260,84 +15338,6 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-fi
-
-{ echo "$as_me:$LINENO: checking for -lXrender" >&5
-echo $ECHO_N "checking for -lXrender... $ECHO_C" >&6; }
-if test "${ac_cv_lib_soname_Xrender+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  ac_check_soname_save_LIBS=$LIBS
-LIBS="-lXrender $X_LIBS -lXext -lX11 $X_EXTRA_LIBS $LIBS"
-  cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h.  */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char XRenderQueryExtension ();
-int
-main ()
-{
-return XRenderQueryExtension ();
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext conftest$ac_exeext
-if { (ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
-  (eval "$ac_link") 2>conftest.er1
-  ac_status=$?
-  grep -v '^ *+' conftest.er1 >conftest.err
-  rm -f conftest.er1
-  cat conftest.err >&5
-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
-  (exit $ac_status); } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext &&
-       $as_test_x conftest$ac_exeext; then
-  case "$LIBEXT" in
-    dll) ;;
-    dylib) ac_cv_lib_soname_Xrender=`otool -L conftest$ac_exeext | grep "libXrender\\.[0-9A-Za-z.]*dylib" | sed -e "s/^.*\/\(libXrender\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;;
-    *) ac_cv_lib_soname_Xrender=`$ac_cv_path_LDD conftest$ac_exeext | grep "libXrender\\.$LIBEXT" | sed -e "s/^.*\(libXrender\.$LIBEXT[^	 ]*\).*$/\1/"';2,$d'` ;;
-  esac
-else
-  echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-
-rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
-      conftest$ac_exeext conftest.$ac_ext
-  LIBS=$ac_check_soname_save_LIBS
-fi
-if test "x$ac_cv_lib_soname_Xrender" = "x"; then
-  { echo "$as_me:$LINENO: result: not found" >&5
-echo "${ECHO_T}not found" >&6; }
-
-else
-  { echo "$as_me:$LINENO: result: $ac_cv_lib_soname_Xrender" >&5
-echo "${ECHO_T}$ac_cv_lib_soname_Xrender" >&6; }
-
-cat >>confdefs.h <<_ACEOF
-#define SONAME_LIBXRENDER "$ac_cv_lib_soname_Xrender"
-_ACEOF
-
-
 fi
 
 { echo "$as_me:$LINENO: checking for -lXcursor" >&5
diff --git a/configure.ac b/configure.ac
index b271ffc40b5..3e7c97b7c05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -534,21 +534,23 @@ then
                   $X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
         fi
 
-        dnl *** Check for X RandR extension
-        if test "$ac_cv_header_X11_extensions_Xrandr_h" = "yes"
-        then
-                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>
-#include <X11/extensions/Xrandr.h>]], [[static typeof(XRRSetScreenConfigAndRate) * func;]])],
-                  [WINE_CHECK_SONAME(Xrandr,XRRQueryExtension,,,[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])])
-        fi
-
         dnl *** Check for Transform functions in Xrender
         if test "$ac_cv_header_X11_extensions_Xrender_h" = "yes"
         then
-              AC_CHECK_LIB(Xrender, XRenderSetPictureTransform,
+            WINE_CHECK_SONAME(Xrender,XRenderQueryExtension,
+              [AC_CHECK_LIB(Xrender,XRenderSetPictureTransform,
                 [AC_DEFINE(HAVE_XRENDERSETPICTURETRANSFORM, 1,
                  [Define if Xrender has the XRenderSetPictureTransform function])],,
-                $X_LIBS -lXext -lX11 $X_EXTRA_LIBS)
+                [$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])],,[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])
+
+        fi
+
+        dnl *** Check for X RandR extension
+        if test "$ac_cv_header_X11_extensions_Xrandr_h" = "yes" -a "x$ac_cv_lib_soname_Xrender" != "x"
+        then
+                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>
+#include <X11/extensions/Xrandr.h>]], [[static typeof(XRRSetScreenConfigAndRate) * func;]])],
+                  [WINE_CHECK_SONAME(Xrandr,XRRQueryExtension,,,[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])])
         fi
 
         dnl *** Check for Xinerama extension
@@ -1147,7 +1149,6 @@ WINE_CHECK_SONAME(X11,XCreateWindow,,,[$X_LIBS $X_EXTRA_LIBS])
 WINE_CHECK_SONAME(Xext,XextCreateExtension,,,[$X_LIBS -lX11 $X_EXTRA_LIBS])
 WINE_CHECK_SONAME(Xi,XOpenDevice,,,[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])
 WINE_CHECK_SONAME(Xinerama,XineramaQueryScreens,,,[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])
-WINE_CHECK_SONAME(Xrender,XRenderQueryExtension,,,[$X_LIBS -lXext -lX11 $X_EXTRA_LIBS])
 WINE_CHECK_SONAME(Xcursor,XcursorImageLoadCursor,,,[$X_LIBS -lX11 $X_EXTRA_LIBS])
 WINE_CHECK_SONAME(freetype,FT_Init_FreeType,,,[$X_LIBS])
 WINE_CHECK_SONAME(txc_dxtn,fetch_2d_texel_rgba_dxt1)
diff --git a/dlls/winex11.drv/xrandr.c b/dlls/winex11.drv/xrandr.c
index 07775d8c35f..67aa14e935e 100644
--- a/dlls/winex11.drv/xrandr.c
+++ b/dlls/winex11.drv/xrandr.c
@@ -49,9 +49,6 @@ static void *xrandr_handle;
 #ifndef SONAME_LIBXEXT
 #define SONAME_LIBXEXT "libXext" SONAME_EXT
 #endif
-#ifndef SONAME_LIBXRENDER
-#define SONAME_LIBXRENDER "libXrender" SONAME_EXT
-#endif
 
 #define MAKE_FUNCPTR(f) static typeof(f) * p##f;
 MAKE_FUNCPTR(XRRConfigCurrentConfiguration)
diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index 846e352925c..77ba9e59e01 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -41,7 +41,7 @@ int using_client_side_fonts = FALSE;
 
 WINE_DEFAULT_DEBUG_CHANNEL(xrender);
 
-#ifdef HAVE_X11_EXTENSIONS_XRENDER_H
+#ifdef SONAME_LIBXRENDER
 
 #include <X11/Xlib.h>
 #include <X11/extensions/Xrender.h>
@@ -103,9 +103,6 @@ static int antialias = 1;
 #ifndef SONAME_LIBXEXT
 #define SONAME_LIBXEXT "libXext" SONAME_EXT
 #endif
-#ifndef SONAME_LIBXRENDER
-#define SONAME_LIBXRENDER "libXrender" SONAME_EXT
-#endif
 
 static void *xrender_handle;
 
@@ -1678,7 +1675,7 @@ BOOL X11DRV_AlphaBlend(X11DRV_PDEVICE *devDst, INT xDst, INT yDst, INT widthDst,
     return TRUE;
 }
 
-#else /* HAVE_X11_EXTENSIONS_XRENDER_H */
+#else /* SONAME_LIBXRENDER */
 
 void X11DRV_XRender_Init(void)
 {
@@ -1727,4 +1724,4 @@ BOOL X11DRV_AlphaBlend(X11DRV_PDEVICE *devDst, INT xDst, INT yDst, INT widthDst,
   return FALSE;
 }
 
-#endif /* HAVE_X11_EXTENSIONS_XRENDER_H */
+#endif /* SONAME_LIBXRENDER */
-- 
GitLab