[the-board] [build] Make Cheese-based features optional



commit 9ca9854e015b40bca00c546d77f69886600e0414
Author: Lucas Rocha <lucasr gnome org>
Date:   Tue Apr 12 22:27:42 2011 +0100

    [build] Make Cheese-based features optional
    
    We'll have to disable Cheese-based features on distros not shipping
    GNOME 3 yet (i.e. Ubuntu Natty).

 configure.ac               |   27 ++++++++++++++++++++++++---
 src/Makefile-tb.am         |   23 ++++++++++++++++++++---
 src/Makefile.am            |    3 ++-
 src/js/ui/things/photo.js  |   18 ++++++++++++------
 src/js/util/features.js.in |    1 +
 5 files changed, 59 insertions(+), 13 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9a4767b..9dac7f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -70,8 +70,7 @@ PKG_CHECK_MODULES(THE_BOARD,
                   mx-1.0 >= $MX_MIN_VERSION
                   gtk+-3.0 >= $GTK_MIN_VERSION
                   clutter-gtk-1.0 >= $CLUTTER_GTK_MIN_VERSION
-                  clutter-gst-1.0 >= $CLUTTER_GST_MIN_VERSION
-                  cheese >= $CHEESE_MIN_VERSION)
+                  clutter-gst-1.0 >= $CLUTTER_GST_MIN_VERSION)
 
 PKG_CHECK_MODULES(TB,
                   glib-2.0 >= $GLIB_MIN_VERSION
@@ -79,9 +78,30 @@ PKG_CHECK_MODULES(TB,
                   clutter-1.0 >= $CLUTTER_MIN_VERSION
                   mx-1.0 >= $MX_MIN_VERSION
                   gtk+-3.0 >= $GTK_MIN_VERSION
-                  cheese >= $CHEESE_MIN_VERSION
                   gstreamer-0.10)
 
+AC_ARG_WITH([cheese],
+             AC_HELP_STRING([--without-cheese],[disable cheese support]),,
+             [with_cheese=yes])
+
+HAVE_CHEESE=0
+
+if test x$with_cheese = xyes ; then
+   PKG_CHECK_MODULES([CHEESE],
+                     [cheese >= $CHEESE_MIN_VERSION],
+                     [HAVE_CHEESE=1],[HAVE_CHEESE=0])
+fi
+
+AC_SUBST(HAVE_CHEESE)
+
+if test x$HAVE_CHEESE = x1 ; then
+    HAVE_CHEESE_RESULT="yes"
+else
+    HAVE_CHEESE_RESULT="no"
+fi
+
+AM_CONDITIONAL(HAVE_CHEESE, [test "$HAVE_CHEESE" = 1])
+
 AC_ARG_WITH([libnotify],
              AC_HELP_STRING([--without-libnotify],[disable libnotify support]),,
              [with_libnotify=yes])
@@ -177,6 +197,7 @@ echo "
         prefix:    ${prefix}
         compiler:  ${CC}
 
+        cheese:    $HAVE_CHEESE_RESULT
         nautilus:  $HAVE_NAUTILUS_RESULT
         libnotify: $HAVE_LIBNOTIFY_RESULT
         libsoup:   $HAVE_LIBSOUP_RESULT
diff --git a/src/Makefile-tb.am b/src/Makefile-tb.am
index 1ef4e37..64db86e 100644
--- a/src/Makefile-tb.am
+++ b/src/Makefile-tb.am
@@ -6,6 +6,10 @@ tb_cflags = \
     -DG_DISABLE_DEPRECATED \
     $(TB_CFLAGS)
 
+if HAVE_CHEESE
+tb_cflags += $(CHEESE_CFLAGS)
+endif
+
 if HAVE_LIBSOUP
 tb_cflags += $(LIBSOUP_CFLAGS)
 endif
@@ -20,7 +24,6 @@ THE_BOARD_STAMP_FILES = stamp-tb-marshal.h stamp-tb-enum-types.h
 
 tb_source_h = \
     tb/tb-box.h \
-    tb/tb-cheese-util.h \
     tb/tb-gio-util.h \
     tb/tb-gdk-util.h \
     tb/tb-gobject-util.h \
@@ -28,13 +31,16 @@ tb_source_h = \
     tb/tb-sound-player.h \
     tb/tb-sound-recorder.h
 
+if HAVE_CHEESE
+tb_source_h += tb/tb-cheese-util.h
+endif
+
 if HAVE_LIBSOUP
 tb_source_h += tb/tb-soup-util.h
 endif
 
 tb_source_c = \
     tb/tb-box.c \
-    tb/tb-cheese-util.c \
     tb/tb-gio-util.c \
     tb/tb-gdk-util.c \
     tb/tb-gobject-util.c \
@@ -42,6 +48,10 @@ tb_source_c = \
     tb/tb-sound-player.c \
     tb/tb-sound-recorder.c
 
+if HAVE_CHEESE
+tb_source_c += tb/tb-cheese-util.c
+endif
+
 if HAVE_LIBSOUP
 tb_source_c += tb/tb-soup-util.c
 endif
@@ -71,6 +81,10 @@ lib_LTLIBRARIES += libthe-board-1.0.la
 libthe_board_1_0_la_LIBADD = \
 	$(TB_LIBS)
 
+if HAVE_CHEESE
+libthe_board_1_0_la_LIBADD += $(CHEESE_LIBS)
+endif
+
 if HAVE_LIBSOUP
 libthe_board_1_0_la_LIBADD += $(LIBSOUP_LIBS)
 endif
@@ -97,12 +111,15 @@ TheBoard_1_0_gir_LIBS = libthe-board-1.0.la
 TheBoard_1_0_gir_CFLAGS = $(AM_CPPFLAGS) $(tb_cflags)
 TheBoard_1_0_gir_SCANNERFLAGS = --warn-all --symbol-prefix=tb --identifier-prefix=Tb
 TheBoard_1_0_gir_INCLUDES = \
-    Cheese-3.0 \
     Clutter-1.0 \
     GdkPixbuf-2.0 \
     Gtk-3.0 \
     Mx-1.0
 
+if HAVE_CHEESE
+TheBoard_1_0_gir_INCLUDES += Cheese-3.0
+endif
+
 if HAVE_LIBSOUP
 TheBoard_1_0_gir_INCLUDES += Soup-2.4
 endif
diff --git a/src/Makefile.am b/src/Makefile.am
index 22d9411..287ae41 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,7 +40,8 @@ do_subst = sed -e 's|@abs_top_srcdir[ ]|$(abs_top_srcdir)|g' \
 	       -e 's|@pkglibdir[ ]|$(pkglibdir)|g' \
 	       -e 's|@pkgdatadir[ ]|$(pkgdatadir)|g' \
 	       -e 's|@have_libnotify[ ]|$(HAVE_LIBNOTIFY)|g' \
-	       -e 's|@have_libsoup[ ]|$(HAVE_LIBSOUP)|g'
+	       -e 's|@have_libsoup[ ]|$(HAVE_LIBSOUP)|g' \
+	       -e 's|@have_cheese[ ]|$(HAVE_CHEESE)|g'
 
 # gobject-introspection rules
 include $(INTROSPECTION_MAKEFILE)
diff --git a/src/js/ui/things/photo.js b/src/js/ui/things/photo.js
index edfe071..367e6d1 100644
--- a/src/js/ui/things/photo.js
+++ b/src/js/ui/things/photo.js
@@ -5,8 +5,15 @@ const Mainloop = imports.mainloop;
 const Signals = imports.signals;
 const Tweener = imports.tweener.tweener;
 
+// util imports
+const Features = imports.util.features;
+const Path = imports.util.path;
+
+if (Features.HAVE_CHEESE) {
+    const Cheese = imports.gi.Cheese;
+}
+
 // gi imports
-const Cheese = imports.gi.Cheese;
 const Clutter = imports.gi.Clutter;
 const GLib = imports.gi.GLib;
 const Gst = imports.gi.Gst;
@@ -20,9 +27,6 @@ const Thing = imports.ui.thing;
 const ToolBox = imports.ui.toolBox;
 const Toolbar = imports.ui.toolbar;
 
-// util imports
-const Path = imports.util.path;
-
 const NAME = Gettext.gettext("Photo");
 const STYLE = Path.THINGS_DATA_DIR + "photo/style.css";
 
@@ -711,8 +715,10 @@ function createToolbar(args) {
     toolBox.addButton({ label: Gettext.gettext("File"),
                         actionName: "chooseFile" });
 
-    toolBox.addButton({ label: Gettext.gettext("Webcam"),
-                        actionName: "takePhoto" });
+    if (Features.HAVE_CHEESE) {
+        toolBox.addButton({ label: Gettext.gettext("Webcam"),
+                            actionName: "takePhoto" });
+    }
 
     toolbar.addToolBox(toolBox);
 
diff --git a/src/js/util/features.js.in b/src/js/util/features.js.in
index 5362929..a856de7 100644
--- a/src/js/util/features.js.in
+++ b/src/js/util/features.js.in
@@ -1,2 +1,3 @@
 let HAVE_LIBNOTIFY = @have_libnotify@; 
 let HAVE_LIBSOUP = @have_libsoup@;
+let HAVE_CHEESE = @have_cheese@;



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