diff --git a/build-plugin.mak b/build-plugin.mak
new file mode 100644
index 0000000..c2fbd2a
--- /dev/null
+++ b/build-plugin.mak
@@ -0,0 +1,10 @@
+# generate plugin
+$(srcdir)/build-plugin.mak: $(top_srcdir)/common/build-plugin.mak $(top_srcdir)/common/build-plugin.mak.templ $(srcdir)/plugin_name
+	@test -f "$(srcdir)/plugin_name" || exit 1; \
+	plugin_name=`cat $(srcdir)/plugin_name | $(SED) 's/[[:space:]]//g' | tr -d "\r\n"`; \
+	test "x$${plugin_name}" = "x" && { echo "error: $(srcdir)/plugin_name does not contain anything"; exit 1; }; \
+	rm -f "$(abs_srcdir)/build-plugin.mak"; \
+	$(SED) -e "s|%GST_PLUGIN_NAME%|$${plugin_name}|g" < "$(top_srcdir)/common/build-plugin.mak.templ" > "$(srcdir)/build-plugin.mak"
+
+$(srcdir)/plugin_name:
+	test -f "$(srcdir)/plugin_name" || echo "`basename $(abs_srcdir)`" > $(srcdir)/plugin_name;
diff --git a/build-plugin.mak.templ b/build-plugin.mak.templ
new file mode 100644
index 0000000..4f87f61
--- /dev/null
+++ b/build-plugin.mak.templ
@@ -0,0 +1,34 @@
+
+staticplugin_LTLIBRARIES = static/lib%GST_PLUGIN_NAME%.la
+static_lib%GST_PLUGIN_NAME%_la_CPPFLAGS = -DGST_PLUGIN_BUILD_STATIC $(lib%GST_PLUGIN_NAME%_la_CPPFLAGS)
+static_lib%GST_PLUGIN_NAME%_la_CFLAGS = $(lib%GST_PLUGIN_NAME%_la_CFLAGS)
+static_lib%GST_PLUGIN_NAME%_la_CXXFLAGS = $(lib%GST_PLUGIN_NAME%_la_CXXFLAGS)
+static_lib%GST_PLUGIN_NAME%_la_OBJCFLAGS = $(lib%GST_PLUGIN_NAME%_la_OBJCFLAGS)
+static_lib%GST_PLUGIN_NAME%_la_SOURCES = %GST_PLUGIN_NAME%.c
+static_lib%GST_PLUGIN_NAME%_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+static_lib%GST_PLUGIN_NAME%_la_LIBADD = lib%GST_PLUGIN_NAME%.la
+static_lib%GST_PLUGIN_NAME%_la_LIBTOOLFLAGS = --tag=disable-shared
+
+sharedplugin_LTLIBRARIES = shared/lib%GST_PLUGIN_NAME%.la
+shared_lib%GST_PLUGIN_NAME%_la_CPPFLAGS = $(lib%GST_PLUGIN_NAME%_la_CPPFLAGS)
+shared_lib%GST_PLUGIN_NAME%_la_CFLAGS = $(lib%GST_PLUGIN_NAME%_la_CFLAGS)
+shared_lib%GST_PLUGIN_NAME%_la_CXXFLAGS = $(lib%GST_PLUGIN_NAME%_la_CXXFLAGS)
+shared_lib%GST_PLUGIN_NAME%_la_OBJCFLAGS = $(lib%GST_PLUGIN_NAME%_la_OBJCFLAGS)
+shared_lib%GST_PLUGIN_NAME%_la_SOURCES = %GST_PLUGIN_NAME%.c
+shared_lib%GST_PLUGIN_NAME%_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+shared_lib%GST_PLUGIN_NAME%_la_LIBADD = lib%GST_PLUGIN_NAME%.la
+shared_lib%GST_PLUGIN_NAME%_la_LIBTOOLFLAGS = --tag=disable-static
+
+$(sharedplugin_LTLIBRARIES): $(top_srcdir)/common/build-plugin.mak $(srcdir)/build-plugin.mak
+$(staticplugin_LTLIBRARIES): $(top_srcdir)/common/build-plugin.mak $(srcdir)/build-plugin.mak
+
+#distclean-local: distclean-plugin
+#distclean-plugin:
+#	rm -f build-plugin.mak
+clean-plugin-dirs:
+	rm -rf shared static
+clean-local: clean-plugin-dirs
+
+.PHONY: clean-plugin-dirs
+
+include $(top_srcdir)/common/build-plugin.mak
diff --git a/gst-autogen.sh b/gst-autogen.sh
index 71049e6..2c12091 100644
--- a/gst-autogen.sh
+++ b/gst-autogen.sh
@@ -133,3 +133,24 @@ install_git_hooks ()
     done
   fi
 }
+
+# this is needed to generate the correct static and shared libraries
+install_plugin_makefiles ()
+{
+  # arguments passed are the top level directories (ext, sys, gst, etc)
+  # to generate the plugin makefiles for.  We need to generate them for each
+  # plugin folder in each directory
+  while test "x$1" != "x"; do
+    if test -d "$1"; then
+      top_srcdir="../.."
+      srcdir="."
+      for plugin in `find "$1" -maxdepth 1 -mindepth 1 -type d`; do
+        echo "copying into $plugin"
+        abs_srcdir="`pwd`/$plugin"
+        rm -f "${abs_srcdir}/build-plugin.mak"
+        make -f "../../common/build-plugin.mak" -C "./$plugin" srcdir="$srcdir" top_srcdir="$top_srcdir" abs_srcdir="$abs_srcdir" SED=sed ./build-plugin.mak
+      done
+    fi
+    shift
+  done
+}
diff --git a/m4/gst-plugindir.m4 b/m4/gst-plugindir.m4
index c9e1301..02d9331 100644
--- a/m4/gst-plugindir.m4
+++ b/m4/gst-plugindir.m4
@@ -12,6 +12,10 @@ AC_DEFUN([AG_GST_SET_PLUGINDIR],
   AC_MSG_NOTICE([Using $PLUGINDIR as the plugin install location])
 
   dnl plugin directory configure-time variable for use in Makefile.am
-  plugindir="\$(libdir)/gstreamer-$GST_API_VERSION"
+  plugindir="\$(libdir)/gstreamer-$GST_API_VERSION/static"
+  staticplugindir="\$(libdir)/gstreamer-$GST_API_VERSION/static"
+  sharedplugindir="\$(libdir)/gstreamer-$GST_API_VERSION"
   AC_SUBST(plugindir)
+  AC_SUBST(sharedplugindir)
+  AC_SUBST(staticplugindir)
 ])
