-PKG_CHECK_MODULES(LIBGSSDP, gssdp-1.0 >= $GSSDP_REQUIRED)
-PKG_CHECK_MODULES(LIBGUPNP, gupnp-1.0 >= $GUPNP_REQUIRED)
-PKG_CHECK_MODULES(LIBGUPNP_AV, gupnp-av-1.0 >= $GUPNP_AV_REQUIRED)
-PKG_CHECK_MODULES(LIBGUPNP_DLNA, gupnp-dlna-1.0 >= $GUPNP_DLNA_REQUIRED)
-PKG_CHECK_MODULES(LIBGSTREAMER, gstreamer-0.10 >= $GSTREAMER_REQUIRED)
-PKG_CHECK_MODULES(GSTREAMER_BASE, gstreamer-base-0.10 >= $GSTREAMER_REQUIRED)
-PKG_CHECK_MODULES(GST_PBU, gstreamer-pbutils-0.10 >= $GSTPBU_REQUIRED)
-PKG_CHECK_MODULES(LIBGIO, gio-2.0 >= $GIO_REQUIRED)
-PKG_CHECK_MODULES(GEE, gee-1.0 >= $GEE_REQUIRED)
-PKG_CHECK_MODULES(UUID, uuid >= $UUID_REQUIRED)
-PKG_CHECK_MODULES(LIBSOUP, libsoup-2.4 >= $LIBSOUP_REQUIRED)
-
-dnl glib-genmarshal
-GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0`
-AC_SUBST(GLIB_GENMARSHAL)
+RYGEL_BASE_MODULES="gupnp-1.0 >= $GUPNP_REQUIRED gee-0.8 >= $GEE_REQUIRED"
+PKG_CHECK_MODULES([LIBRYGEL_CORE_DEPS], [$RYGEL_BASE_MODULES uuid >= $UUID_REQUIRED gssdp-1.0 >= $GSSDP_REQUIRED gio-2.0 >= $GIO_REQUIRED gmodule-2.0 libxml-2.0 >= $LIBXML_REQUIRED])
+RYGEL_BASE_MODULES_VALAFLAGS='--pkg gupnp-1.0 --pkg gee-0.8'
+LIBRYGEL_CORE_DEPS_VALAFLAGS="$RYGEL_BASE_MODULES_VALAFLAGS --pkg gssdp-1.0 --pkg gio-2.0 --pkg gmodule-2.0 --pkg posix"
+AC_SUBST([LIBRYGEL_CORE_DEPS_VALAFLAGS])
+
+RYGEL_COMMON_MODULES="$RYGEL_BASE_MODULES gupnp-av-1.0 >= $GUPNP_AV_REQUIRED"
+PKG_CHECK_MODULES([LIBRYGEL_SERVER_DEPS], [$RYGEL_COMMON_MODULES uuid >= $UUID_REQUIRED gssdp-1.0 >= $GSSDP_REQUIRED gio-2.0 >= $GIO_REQUIRED gmodule-2.0 libxml-2.0 >= $LIBXML_REQUIRED libsoup-2.4 >= $LIBSOUP_REQUIRED])
+RYGEL_COMMON_MODULES_VALAFLAGS="$RYGEL_BASE_MODULES_VALAFLAGS --pkg gupnp-av-1.0"
+LIBRYGEL_SERVER_DEPS_VALAFLAGS="$RYGEL_COMMON_MODULES_VALAFLAGS --pkg gssdp-1.0 --pkg gio-2.0 --pkg libsoup-2.4 --pkg gmodule-2.0"
+AC_SUBST([LIBRYGEL_SERVER_DEPS_VALAFLAGS])
+
+PKG_CHECK_MODULES([LIBRYGEL_RENDERER_DEPS], [$RYGEL_COMMON_MODULES gio-2.0 >= $GIO_REQUIRED libsoup-2.4 >= $LIBSOUP_REQUIRED])
+LIBRYGEL_RENDERER_DEPS_VALAFLAGS="$RYGEL_COMMON_MODULES_VALAFLAGS --pkg gio-2.0 --pkg libsoup-2.4"
+AC_SUBST([LIBRYGEL_RENDERER_DEPS_VALAFLAGS])
+
+PKG_CHECK_MODULES([RYGEL_DEPS], [$RYGEL_COMMON_MODULES gio-2.0 >= $GIO_REQUIRED gssdp-1.0 >= $GSSDP_REQUIRED])
+
+# Not all tests use all of these dependencies,
+# but having one set of dependencies keeps things simple.
+PKG_CHECK_MODULES([TEST_DEPS], [$RYGEL_COMMON_MODULES uuid >= $UUID_REQUIRED gio-2.0 >= $GIO_REQUIRED gssdp-1.0 >= $GSSDP_REQUIRED libsoup-2.4 >= $LIBSOUP_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED])
+TEST_DEPS_VALAFLAGS="$RYGEL_COMMON_MODULES_VALAFLAGS --pkg gio-2.0 --pkg gssdp-1.0 --pkg libsoup-2.4 --pkg libxml-2.0 --pkg gmodule-2.0"
+AC_SUBST([TEST_DEPS_VALAFLAGS])
+
+PKG_CHECK_MODULES([EXAMPLE_DEPS], [$RYGEL_COMMON_MODULES gio-2.0 >= $GIO_REQUIRED gssdp-1.0 >= $GSSDP_REQUIRED])
+
+
+
+dnl Media engine to use
+BUILT_ENGINES="librygel-media-engine-simple"
+
+dnl Disabling the gstreamer media_engine also disables
+dnl anything else that uses gstreamer.
+AC_ARG_WITH([media_engine],
+ AS_HELP_STRING(
+ [--with-media-engine=@<:@gstreamer|simple@:>@],
+ [Media Engine to use]),
+ [with_media_engine="$withval"],
+ [with_media_engine="gstreamer"])
+
+AS_IF([test "x$with_media_engine" = "xgstreamer"],
+ [
+ enable_gstreamer="yes"
+ BUILT_ENGINES="$BUILT_ENGINES;librygel-media-engine-gst"
+
+ PKG_CHECK_MODULES([RYGEL_MEDIA_ENGINE_GSTREAMER_DEPS],
+ [$RYGEL_COMMON_MODULES
+ gstreamer-pbutils-1.0 >= $GSTPBU_REQUIRED
+ gstreamer-app-1.0 >= $GSTREAMER_APP_REQUIRED
+ gupnp-dlna-2.0 >= $GUPNP_DLNA_REQUIRED
+ gio-2.0 >= $GIO_REQUIRED])
+ RYGEL_MEDIA_ENGINE_GSTREAMER_DEPS_VALAFLAGS="$RYGEL_COMMON_MODULES_VALAFLAGS --pkg gstreamer-base-1.0 --pkg gstreamer-pbutils-1.0 --pkg gupnp-dlna-2.0"
+ AC_SUBST([RYGEL_MEDIA_ENGINE_GSTREAMER_DEPS_VALAFLAGS])
+
+ PKG_CHECK_MODULES([LIBRYGEL_RENDERER_GST_DEPS], [$RYGEL_COMMON_MODULES gstreamer-1.0 >= $GSTREAMER_REQUIRED gio-2.0 >= $GIO_REQUIRED])
+ LIBRYGEL_RENDERER_GST_DEPS_VALAFLAGS="$RYGEL_COMMON_MODULES_VALAFLAGS --pkg gstreamer-1.0"
+ AC_SUBST([LIBRYGEL_RENDERER_GST_DEPS_VALAFLAGS])
+ ],
+ [enable_gstreamer="no"])
+AM_CONDITIONAL([HAVE_GSTREAMER],[test "x$enable_gstreamer" = "xyes"])
+AC_SUBST([BUILT_ENGINES])