gphoto2.ds: Check for libgphoto2 and libgphoto2_port independently.

Francois Gouget fgouget at free.fr
Sun May 5 18:05:33 CDT 2013


We may have one and not the other. Also the gphoto2-config may not return the information needed for gphoto2_port.
---

Note that initially configure.ac was gathering the outputs of both 
gphoto2-config and gphoto2-port-config. But since f54b8581 we're getting 
either the output of gphoto2-config or that of gphoto2-port-config. That 
does not make sense:
 * Either we assume that gphoto2-config provides information about both 
   libraries, like it does on Linux (Debian Testing at least), and 
   then there's no point ever calling gphoto2-port-config.
 * Or we assume that they return different information and then one is 
   not a substitute for the other.

My Solaris 10u5 and 10u9 VMs show that the latter is (or at least 
was) true, and conceptually it certainly makes sense. So I opted to 
handle them separately.

My understanding is that we only need libgphoto2_port to autodetect the 
cameras, so that's what the Wine notice says. This also reinforces my 
belief that it makes sense to separate the libgphoto2 and 
libgphoto2_port checks.

 configure                      |   85 +++++++++++++++++++++++++++++++++++++++-
 configure.ac                   |   16 ++++++--
 dlls/gphoto2.ds/Makefile.in    |    4 +-
 dlls/gphoto2.ds/gphoto2_main.c |   10 ++---
 include/config.h.in            |    5 ++-
 5 files changed, 107 insertions(+), 13 deletions(-)

diff --git a/configure b/configure
index 90109d1..c2f434a 100755
--- a/configure
+++ b/configure
@@ -654,6 +654,8 @@ FREETYPE_LIBS
 FREETYPE_CFLAGS
 LCMSLIBS
 RESOLVLIBS
+GPHOTO2_PORT_LIBS
+GPHOTO2_PORT_CFLAGS
 GPHOTO2_LIBS
 GPHOTO2_CFLAGS
 SANE_LIBS
@@ -874,6 +876,8 @@ SANE_CFLAGS
 SANE_LIBS
 GPHOTO2_CFLAGS
 GPHOTO2_LIBS
+GPHOTO2_PORT_CFLAGS
+GPHOTO2_PORT_LIBS
 FREETYPE_CFLAGS
 FREETYPE_LIBS
 GSTREAMER_CFLAGS
@@ -1582,6 +1586,10 @@ Some influential environment variables:
               C compiler flags for libgphoto2, overriding pkg-config
   GPHOTO2_LIBS
               Linker flags for libgphoto2, overriding pkg-config
+  GPHOTO2_PORT_CFLAGS
+              C compiler flags for libgphoto2_port, overriding pkg-config
+  GPHOTO2_PORT_LIBS
+              Linker flags for libgphoto2_port, overriding pkg-config
   FREETYPE_CFLAGS
               C compiler flags for freetype2, overriding pkg-config
   FREETYPE_LIBS
@@ -10653,14 +10661,14 @@ then
 elif test -n "$PKG_CONFIG"; then :
   GPHOTO2_CFLAGS=`$PKG_CONFIG --cflags libgphoto2 2>/dev/null`
 fi
-GPHOTO2_CFLAGS=${GPHOTO2_CFLAGS:-`(gphoto2-config --cflags || gphoto2-port-config --cflags) 2>/dev/null`}
+GPHOTO2_CFLAGS=${GPHOTO2_CFLAGS:-`gphoto2-config --cflags 2>/dev/null`}
 CPPFLAGS="$CPPFLAGS $GPHOTO2_CFLAGS"
 if test -n "$GPHOTO2_LIBS"; then :
 
 elif test -n "$PKG_CONFIG"; then :
   GPHOTO2_LIBS=`$PKG_CONFIG --libs libgphoto2 2>/dev/null`
 fi
-GPHOTO2_LIBS=${GPHOTO2_LIBS:-`(gphoto2-config --libs || gphoto2-port-config --libs) 2>/dev/null`}
+GPHOTO2_LIBS=${GPHOTO2_LIBS:-`gphoto2-config --libs 2>/dev/null`}
 GPHOTO2_LIBS=${GPHOTO2_LIBS:-"-lgphoto2"}
     ac_fn_c_check_header_mongrel "$LINENO" "gphoto2-camera.h" "ac_cv_header_gphoto2_camera_h" "$ac_includes_default"
 if test "x$ac_cv_header_gphoto2_camera_h" = xyes; then :
@@ -10713,6 +10721,71 @@ else
 fi
 
 
+    if test -n "$GPHOTO2_PORT_CFLAGS"; then :
+
+elif test -n "$PKG_CONFIG"; then :
+  GPHOTO2_PORT_CFLAGS=`$PKG_CONFIG --cflags libgphoto2_port 2>/dev/null`
+fi
+GPHOTO2_PORT_CFLAGS=${GPHOTO2_PORT_CFLAGS:-`gphoto2-port-config --cflags 2>/dev/null`}
+CPPFLAGS="$CPPFLAGS $GPHOTO2_PORT_CFLAGS"
+if test -n "$GPHOTO2_PORT_LIBS"; then :
+
+elif test -n "$PKG_CONFIG"; then :
+  GPHOTO2_PORT_LIBS=`$PKG_CONFIG --libs libgphoto2_port 2>/dev/null`
+fi
+GPHOTO2_PORT_LIBS=${GPHOTO2_PORT_LIBS:-`gphoto2-port-config --libs 2>/dev/null`}
+GPHOTO2_PORT_LIBS=${GPHOTO2_PORT_LIBS:-"-lgphoto2_port"}
+    ac_fn_c_check_header_mongrel "$LINENO" "gphoto2-port.h" "ac_cv_header_gphoto2_port_h" "$ac_includes_default"
+if test "x$ac_cv_header_gphoto2_port_h" = xyes; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gp_port_info_list_new in -lgphoto2_port" >&5
+$as_echo_n "checking for gp_port_info_list_new in -lgphoto2_port... " >&6; }
+if ${ac_cv_lib_gphoto2_port_gp_port_info_list_new+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgphoto2_port $GPHOTO2_PORT_LIBS $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* 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 gp_port_info_list_new ();
+int
+main ()
+{
+return gp_port_info_list_new ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_gphoto2_port_gp_port_info_list_new=yes
+else
+  ac_cv_lib_gphoto2_port_gp_port_info_list_new=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gphoto2_port_gp_port_info_list_new" >&5
+$as_echo "$ac_cv_lib_gphoto2_port_gp_port_info_list_new" >&6; }
+if test "x$ac_cv_lib_gphoto2_port_gp_port_info_list_new" = xyes; then :
+
+$as_echo "#define HAVE_GPHOTO2_PORT 1" >>confdefs.h
+
+else
+  GPHOTO2_PORT_LIBS=""; GPHOTO2_PORT_CFLAGS=""
+fi
+
+else
+  GPHOTO2_PORT_LIBS=""; GPHOTO2_PORT_CFLAGS=""
+fi
+
+
     CPPFLAGS="$ac_save_CPPFLAGS"
 fi
 if test "$ac_cv_lib_gphoto2_gp_camera_new" != "yes"; then :
@@ -10723,6 +10796,14 @@ if test "$ac_cv_lib_gphoto2_gp_camera_new" != "yes"; then :
 This is an error since --with-gphoto was requested." "$LINENO" 5 ;;
 esac
 fi
+if test "$ac_cv_lib_gphoto2_port_gp_port_info_list_new" != "yes"; then :
+  case "x$with_gphoto" in
+  x)   as_fn_append wine_notices "|libgphoto2_port ${notice_platform}development files not found, digital cameras won't be auto-detected." ;;
+  xno) ;;
+  *)   as_fn_error $? "libgphoto2_port ${notice_platform}development files not found, digital cameras won't be auto-detected.
+This is an error since --with-gphoto was requested." "$LINENO" 5 ;;
+esac
+fi
 
 
 if test "$ac_cv_header_resolv_h" = "yes"
diff --git a/configure.ac b/configure.ac
index 97da660..aa8cc8f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1400,18 +1400,28 @@ if test "x$with_gphoto" != "xno"
 then
     ac_save_CPPFLAGS="$CPPFLAGS"
     WINE_PACKAGE_FLAGS(GPHOTO2,[libgphoto2],[-lgphoto2],
-                       [(gphoto2-config --cflags || gphoto2-port-config --cflags)],
-                       [(gphoto2-config --libs || gphoto2-port-config --libs)])
+                       [gphoto2-config --cflags], [gphoto2-config --libs])
     AC_CHECK_HEADER(gphoto2-camera.h,
                     [AC_CHECK_LIB(gphoto2,gp_camera_new,
-                                  [AC_DEFINE(HAVE_GPHOTO2, 1, [Define if we have libgphoto2 development environment])],
+                                  [AC_DEFINE(HAVE_GPHOTO2, 1, [Define if we have the libgphoto2 development environment])],
                                   [GPHOTO2_LIBS=""; GPHOTO2_CFLAGS=""],
                                   [$GPHOTO2_LIBS])],
                     [GPHOTO2_LIBS=""; GPHOTO2_CFLAGS=""])
+    WINE_PACKAGE_FLAGS(GPHOTO2_PORT,[libgphoto2_port],[-lgphoto2_port],
+                       [gphoto2-port-config --cflags],
+                       [gphoto2-port-config --libs])
+    AC_CHECK_HEADER(gphoto2-port.h,
+                    [AC_CHECK_LIB(gphoto2_port,gp_port_info_list_new,
+                                  [AC_DEFINE(HAVE_GPHOTO2_PORT, 1, [Define if we have the libgphoto2_port development environment])],
+                                  [GPHOTO2_PORT_LIBS=""; GPHOTO2_PORT_CFLAGS=""],
+                                  [$GPHOTO2_PORT_LIBS])],
+                    [GPHOTO2_PORT_LIBS=""; GPHOTO2_PORT_CFLAGS=""])
     CPPFLAGS="$ac_save_CPPFLAGS"
 fi
 WINE_NOTICE_WITH(gphoto,[test "$ac_cv_lib_gphoto2_gp_camera_new" != "yes"],
                  [libgphoto2 ${notice_platform}development files not found, digital cameras won't be supported.])
+WINE_NOTICE_WITH(gphoto,[test "$ac_cv_lib_gphoto2_port_gp_port_info_list_new" != "yes"],
+                 [libgphoto2_port ${notice_platform}development files not found, digital cameras won't be auto-detected.])
 
 
 dnl **** Check for resolver library ***
diff --git a/dlls/gphoto2.ds/Makefile.in b/dlls/gphoto2.ds/Makefile.in
index e77de86..1e716fc 100644
--- a/dlls/gphoto2.ds/Makefile.in
+++ b/dlls/gphoto2.ds/Makefile.in
@@ -1,7 +1,7 @@
 MODULE    = gphoto2.ds
 IMPORTS   = comctl32 user32 gdi32 advapi32
-EXTRALIBS = @GPHOTO2_LIBS@
-EXTRAINCL = @GPHOTO2_CFLAGS@
+EXTRALIBS = @GPHOTO2_LIBS@ @GPHOTO2_PORT_LIBS@
+EXTRAINCL = @GPHOTO2_CFLAGS@ @GPHOTO2_PORT_CFLAGS@
 
 C_SRCS = \
 	capability.c \
diff --git a/dlls/gphoto2.ds/gphoto2_main.c b/dlls/gphoto2.ds/gphoto2_main.c
index 005fece..bb8104e 100644
--- a/dlls/gphoto2.ds/gphoto2_main.c
+++ b/dlls/gphoto2.ds/gphoto2_main.c
@@ -578,7 +578,7 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
     return TRUE;
 }
 
-#ifdef HAVE_GPHOTO2
+#if defined(HAVE_GPHOTO2) && defined(HAVE_GPHOTO2_PORT)
 static TW_UINT16 GPHOTO2_GetIdentity( pTW_IDENTITY, pTW_IDENTITY);
 static TW_UINT16 GPHOTO2_OpenDS( pTW_IDENTITY, pTW_IDENTITY);
 #endif
@@ -597,7 +597,7 @@ static TW_UINT16 GPHOTO2_SourceControlHandler (
 	    switch (MSG)
 	    {
 		case MSG_CLOSEDS:
-#ifdef HAVE_GPHOTO2
+#if defined(HAVE_GPHOTO2) && defined(HAVE_GPHOTO2_PORT)
 		     if (activeDS.camera) {
 			gp_camera_free (activeDS.camera);
 			activeDS.camera = NULL;
@@ -605,14 +605,14 @@ static TW_UINT16 GPHOTO2_SourceControlHandler (
 #endif
 		     break;
 		case MSG_GET:
-#ifdef HAVE_GPHOTO2
+#if defined(HAVE_GPHOTO2) && defined(HAVE_GPHOTO2_PORT)
 		     twRC = GPHOTO2_GetIdentity(pOrigin,(pTW_IDENTITY)pData);
 #else
 		     twRC = TWRC_FAILURE;
 #endif
 		     break;
 		case MSG_OPENDS:
-#ifdef HAVE_GPHOTO2
+#if defined(HAVE_GPHOTO2) && defined(HAVE_GPHOTO2_PORT)
 		     twRC = GPHOTO2_OpenDS(pOrigin,(pTW_IDENTITY)pData);
 #else
 		     twRC = TWRC_FAILURE;
@@ -1024,7 +1024,7 @@ DS_Entry ( pTW_IDENTITY pOrigin,
     return twRC;
 }
 
-#ifdef HAVE_GPHOTO2
+#if defined(HAVE_GPHOTO2) && defined(HAVE_GPHOTO2_PORT)
 static GPPortInfoList *port_list;
 static int curcamera;
 static CameraList *detected_cameras;
diff --git a/include/config.h.in b/include/config.h.in
index 0a1d78a..91bfdcb 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -236,9 +236,12 @@
 /* Define to 1 if you have the `getuid' function. */
 #undef HAVE_GETUID
 
-/* Define if we have libgphoto2 development environment */
+/* Define if we have the libgphoto2 development environment */
 #undef HAVE_GPHOTO2
 
+/* Define if we have the libgphoto2_port development environment */
+#undef HAVE_GPHOTO2_PORT
+
 /* Define to 1 if you have the <grp.h> header file. */
 #undef HAVE_GRP_H
 
-- 
1.7.10.4



More information about the wine-patches mailing list