[gnome-color-manager] Add gcm-compat.h to deal with unreleases versions of libusb



commit a4dbe5e6ddf6e96f59826537dbbcc542e7fd5fa1
Author: Richard Hughes <richard hughsie com>
Date:   Wed Jul 28 11:00:22 2010 +0200

    Add gcm-compat.h to deal with unreleases versions of libusb

 configure.ac                    |    8 +++++++-
 libcolor-glib/Makefile.am       |    1 +
 libcolor-glib/gcm-compat.h      |   37 +++++++++++++++++++++++++++++++++++++
 libcolor-glib/gcm-sensor-huey.c |    1 +
 libcolor-glib/gcm-usb.c         |    1 +
 libcolor-glib/libcolor-glib.h   |    1 +
 6 files changed, 48 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 584ca05..de5cc4b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -141,7 +141,12 @@ PKG_CHECK_MODULES(GUDEV, gudev-1.0)
 PKG_CHECK_MODULES(LCMS, lcms2)
 PKG_CHECK_MODULES(X11, x11)
 PKG_CHECK_MODULES(SETTINGS_DAEMON, gnome-settings-daemon)
-PKG_CHECK_MODULES(USB, [libusb-1.0 >= 1.0.0])
+PKG_CHECK_MODULES(USB, libusb-1.0 >= 1.0.8, has_new_libusb=yes, has_new_libusb=no)
+if test x$has_new_libusb = xyes; then
+	AC_DEFINE(HAVE_NEW_USB,1,[Got new libusb])
+else
+	PKG_CHECK_MODULES(USB, libusb-1.0 >= 1.0.0)
+fi
 
 dnl Required for the properties window
 PKG_CHECK_MODULES(CONTROL_CENTER, [
@@ -340,6 +345,7 @@ echo "
         SANE support:              ${enable_sane}
         RAW support:               ${enable_exiv}
         VTE support:               ${has_vte}
+        New LIBUSB:                ${has_new_libusb}
         building unit tests:       ${enable_tests}
 "
 
diff --git a/libcolor-glib/Makefile.am b/libcolor-glib/Makefile.am
index 71b8c89..4c6c70d 100644
--- a/libcolor-glib/Makefile.am
+++ b/libcolor-glib/Makefile.am
@@ -33,6 +33,7 @@ libcolor_glib_includedir = $(includedir)/libcolor-glib
 libcolor_glib_include_HEADERS =					\
 	libcolor-glib.h						\
 	gcm-common.h						\
+	gcm-compat.h						\
 	gcm-color.h						\
 	gcm-ddc-client.h					\
 	gcm-ddc-device.h					\
diff --git a/libcolor-glib/gcm-compat.h b/libcolor-glib/gcm-compat.h
new file mode 100644
index 0000000..3e30993
--- /dev/null
+++ b/libcolor-glib/gcm-compat.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#if !defined (__LIBCOLOR_GLIB_H_INSIDE__) && !defined (LIBCOLOR_GLIB_COMPILATION)
+#error "Only <libcolor-glib.h> can be included directly."
+#endif
+
+#ifndef __GCM_COMPAT_H__
+#define __GCM_COMPAT_H__
+
+#include "config.h"
+
+/* only libusb 1.0.8 has libusb_strerror */
+#ifndef HAVE_NEW_USB
+#define	libusb_strerror(f1)				"unknown"
+#endif
+
+#endif /* __GCM_COMPAT_H__ */
+
diff --git a/libcolor-glib/gcm-sensor-huey.c b/libcolor-glib/gcm-sensor-huey.c
index c54a0cc..a5991dc 100644
--- a/libcolor-glib/gcm-sensor-huey.c
+++ b/libcolor-glib/gcm-sensor-huey.c
@@ -36,6 +36,7 @@
 #include "gcm-buffer.h"
 #include "gcm-usb.h"
 #include "gcm-common.h"
+#include "gcm-compat.h"
 #include "gcm-sensor-huey.h"
 
 static void     gcm_sensor_huey_finalize	(GObject     *object);
diff --git a/libcolor-glib/gcm-usb.c b/libcolor-glib/gcm-usb.c
index b5a628f..043f832 100644
--- a/libcolor-glib/gcm-usb.c
+++ b/libcolor-glib/gcm-usb.c
@@ -33,6 +33,7 @@
 #include <libusb-1.0/libusb.h>
 
 #include "gcm-usb.h"
+#include "gcm-compat.h"
 
 #include "egg-debug.h"
 
diff --git a/libcolor-glib/libcolor-glib.h b/libcolor-glib/libcolor-glib.h
index 39ab6b2..a96b102 100644
--- a/libcolor-glib/libcolor-glib.h
+++ b/libcolor-glib/libcolor-glib.h
@@ -30,6 +30,7 @@
 
 #include <gcm-buffer.h>
 #include <gcm-common.h>
+#include <gcm-compat.h>
 #include <gcm-color.h>
 #include <gcm-ddc-common.h>
 #include <gcm-ddc-device.h>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]