configure --enable-gst to turn on gst plugin build

 default: configure would disable gstreamer plugin build

Signed-off-by: Wind Yuan <feng.yuan@intel.com>
diff --git a/configure.ac b/configure.ac
index 103c022..c1285a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,11 @@
                    [enable Aiq 3A algorithm build, @<:@default=no@:>@]),
     [], [enable_aiq="no"])
 
+AC_ARG_ENABLE([gst],
+    AS_HELP_STRING([--enable-gst],
+                   [enable gstreamer plugin build, @<:@default=no@:>@]),
+    [], [enable_gst="no"])
+
 AC_ARG_ENABLE(libcl,
     AS_HELP_STRING([--enable-libcl],
                    [enable libcl image processor, @<:@default=yes@:>@]),
@@ -113,6 +118,18 @@
 ])
 
 
+# build gstreamer plugin
+GST_API_VERSION=1.0
+GST_VERSION_REQUIRED=1.2.3
+ENABLE_GST=0
+if test "$enable_gst" = "yes"; then
+    ENABLE_GST=1
+    PKG_CHECK_MODULES([GST], [gstreamer-$GST_API_VERSION >= $GST_VERSION_REQUIRED])
+    PKG_CHECK_MODULES([GST_ALLOCATOR], [gstreamer-allocators-$GST_API_VERSION >= $GST_VERSION_REQUIRED])
+    PKG_CHECK_MODULES([GST_VIDEO], [gstreamer-video-$GST_API_VERSION >= $GST_VERSION_REQUIRED])
+fi
+AM_CONDITIONAL([ENABLE_GST], [test "$ENABLE_GST" -eq 1])
+
 dnl set XCAM_CFLAGS and XCAM_CXXFLAGS
 XCAM_CFLAGS=" -fPIC -DSTDC99 -W -Wall -D_REENTRANT"
 if test "$enable_debug" = "yes"; then
@@ -160,6 +177,7 @@
      version                    : $XCAM_VERSION
      enable debug               : $enable_debug
      build aiq analyzer         : $enable_aiq
+     build GStreamer plugin     : $enable_gst
      use local aiq              : $use_local_aiq
      use local atomisp          : $use_local_atomisp
      have opencl lib            : $have_libcl
diff --git a/wrapper/Makefile.am b/wrapper/Makefile.am
index 875ebce..63dbffd 100644
--- a/wrapper/Makefile.am
+++ b/wrapper/Makefile.am
@@ -1 +1,8 @@
-SUBDIRS = gstreamer
+
+if ENABLE_GST
+GST_DIR = gstreamer
+else
+GST_DIR =
+endif
+
+SUBDIRS = $(GST_DIR)
diff --git a/wrapper/gstreamer/Makefile.am b/wrapper/gstreamer/Makefile.am
index a98eb77..eb48f0d 100644
--- a/wrapper/gstreamer/Makefile.am
+++ b/wrapper/gstreamer/Makefile.am
@@ -1,7 +1,5 @@
 lib_LTLIBRARIES = libstub.la
 
-GST_CFLAGS = -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/lib/glib-2.0/include
-
 PTHREAD_LDFLAGS = -pthread
 
 STUB_CXXFLAGS = -fPIC -std=c++11
@@ -34,19 +32,8 @@
 # Note: plugindir is set in configure
 plugindir="\$(libdir)/gstreamer-1.0"
 
-##############################################################################
-# TODO: change libgstxcamsrc.la to something else, e.g. libmysomething.la     #
-##############################################################################
 plugin_LTLIBRARIES = libgstxcamsrc.la
 
-##############################################################################
-# TODO: for the next set of variables, name the prefix if you named the .la, #
-#  e.g. libmysomething.la => libmysomething_la_SOURCES                       #
-#                            libmysomething_la_CFLAGS                        #
-#                            libmysomething_la_LIBADD                        #
-#                            libmysomething_la_LDFLAGS                       #
-##############################################################################
-
 # sources used to compile this plug-in
 libgstxcamsrc_la_SOURCES = gstxcambufferpool.c	\
 			   gstxcamsrc.c
@@ -56,14 +43,15 @@
 			  -I$(top_builddir)/xcore -I$(top_builddir)/xcore/base   \
 			  -I$(top_builddir)/wrapper/gstreamer
 
-libgstxcamsrc_la_LIBADD = $(GST_LIBS)	\
+libgstxcamsrc_la_LIBADD = \
 			  $(top_builddir)/wrapper/gstreamer/libstub.la	\
-			  -lgstvideo-1.0    \
-			  -lgstallocators-1.0
+			  $(GST_ALLOCATOR_LIBS)    \
+			  $(GST_VIDEO_LIBS)        \
+			  $(GST_LIBS)
 
 libgstxcamsrc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
 libgstxcamsrc_la_LIBTOOLFLAGS = --tag=disable-static
 
 # headers we need but don't want installed
-noinst_HEADERS = gstxcambufferpool.h	\
+noinst_HEADERS += gstxcambufferpool.h	\
 		 gstxcamsrc.h