qcap: Fix compilation on systems that have v4l1 but not VIDIOCMCAPTURE & co.

Francois Gouget fgouget at free.fr
Tue Mar 5 16:11:38 CST 2013


---

In particular this fixes compilation on FreeBSD 8.1.

 configure           |   74 +++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac        |   18 +++++++++++++
 dlls/qcap/v4l.c     |    4 +--
 include/config.h.in |    3 +++
 4 files changed, 97 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 17cc687..1372a13 100755
--- a/configure
+++ b/configure
@@ -1956,6 +1956,52 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_header_compile
 
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
+
 # ac_fn_c_check_func LINENO FUNC VAR
 # ----------------------------------
 # Tests whether FUNC exists, setting the cache variable VAR accordingly
@@ -6273,6 +6319,34 @@ fi
 done
 
 
+ac_fn_c_check_decl "$LINENO" "VIDIOCMCAPTURE" "ac_cv_have_decl_VIDIOCMCAPTURE" "#ifdef HAVE_SYS_TIME_H
+ #include <sys/time.h>
+ #endif
+ #include <sys/types.h>
+ #ifdef HAVE_ASM_TYPES_H
+ #include <asm/types.h>
+ #endif
+ #ifdef HAVE_LINUX_VIDEODEV_H
+ #include <linux/videodev.h>
+ #endif
+ #ifdef HAVE_LINUX_VIDEODEV2_H
+ #include <linux/videodev2.h>
+ #endif
+ #ifdef HAVE_LIBV4L1_H
+ #include <libv4l1.h>
+ #endif
+"
+if test "x$ac_cv_have_decl_VIDIOCMCAPTURE" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_VIDIOCMCAPTURE $ac_have_decl
+_ACEOF
+
+
 for ac_header in linux/capi.h
 do :
   ac_fn_c_check_header_compile "$LINENO" "linux/capi.h" "ac_cv_header_linux_capi_h" "#define __user
diff --git a/configure.ac b/configure.ac
index 836c4e7..f5415d0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -676,6 +676,24 @@ AC_CHECK_HEADERS([linux/videodev.h linux/videodev2.h libv4l1.h],,,
 #include <asm/types.h>
 #endif])
 
+AC_CHECK_DECLS([VIDIOCMCAPTURE],,,
+[#ifdef HAVE_SYS_TIME_H
+ #include <sys/time.h>
+ #endif
+ #include <sys/types.h>
+ #ifdef HAVE_ASM_TYPES_H
+ #include <asm/types.h>
+ #endif
+ #ifdef HAVE_LINUX_VIDEODEV_H
+ #include <linux/videodev.h>
+ #endif
+ #ifdef HAVE_LINUX_VIDEODEV2_H
+ #include <linux/videodev2.h>
+ #endif
+ #ifdef HAVE_LIBV4L1_H
+ #include <libv4l1.h>
+ #endif])
+
 dnl Check for broken kernel header that doesn't define __user
 AC_CHECK_HEADERS([linux/capi.h],,,[#define __user])
 
diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c
index 41cc752..ec7d815 100644
--- a/dlls/qcap/v4l.c
+++ b/dlls/qcap/v4l.c
@@ -71,7 +71,7 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(qcap_v4l);
 
-#if defined(HAVE_LINUX_VIDEODEV_H) || defined(HAVE_LIBV4L1_H)
+#if defined(SONAME_LIBV4L1) && HAVE_DECL_VIDIOCMCAPTURE
 
 static typeof(open) *video_open = open;
 static typeof(close) *video_close = close;
@@ -973,4 +973,4 @@ HRESULT qcap_driver_stop(Capture *capBox, FILTER_STATE *state)
     FAIL_WITH_ERR;
 }
 
-#endif /* HAVE_LINUX_VIDEODEV_H || HAVE_LINUX_LIBV4L1_H */
+#endif /* defined(SONAME_LIBV4L1) && HAVE_DECL_VIDIOCMCAPTURE */
diff --git a/include/config.h.in b/include/config.h.in
index 1a5652c..97a0c61 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -1097,6 +1097,9 @@
 /* Define to 1 if you have the <valgrind/valgrind.h> header file. */
 #undef HAVE_VALGRIND_VALGRIND_H
 
+/* Define to 1 if VIDIOCMCAPTURE is defined. */
+#undef HAVE_DECL_VIDIOCMCAPTURE
+
 /* Define to 1 if you have the `vsnprintf' function. */
 #undef HAVE_VSNPRINTF
 
-- 
1.7.10.4



More information about the wine-patches mailing list