diff --git a/configure.ac b/configure.ac
index 9f785dd..ca9a4e9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -102,6 +102,29 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Package name for gettex
 
 AM_GLIB_GNU_GETTEXT
 
+# GObject Introspection
+have_introspection=false
+PKG_CHECK_MODULES(INTROSPECTION, gobject-introspection-1.0 >= 0.6.4, have_introspection=true, have_introspection=false)
+AM_CONDITIONAL(HAVE_INTROSPECTION, $have_introspection)
+
+G_IR_SCANNER=
+G_IR_COMPILER=
+G_IR_GENERATE=
+GIRDIR=
+TYPELIBDIR=
+if $have_introspection; then
+   G_IR_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+   G_IR_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+   G_IR_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+   GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+   TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+fi
+AC_SUBST(G_IR_SCANNER)
+AC_SUBST(G_IR_COMPILER)
+AC_SUBST(G_IR_GENERATE)
+AC_SUBST(GIRDIR)
+AC_SUBST(TYPELIBDIR)
+
 # test-widget uses this to find lang files and gtksourcebuffer.c 	 
 ABS_TOP_SRCDIR=`cd $srcdir && pwd` 	 
 AC_SUBST(ABS_TOP_SRCDIR)
diff --git a/gtksourceview/Makefile.am b/gtksourceview/Makefile.am
index 20d5f8c..1ada68b 100644
--- a/gtksourceview/Makefile.am
+++ b/gtksourceview/Makefile.am
@@ -146,6 +146,37 @@ stamp-gtksourceview-typebuiltins.h: Makefile.am $(libgtksourceview_headers)
 	&& (cmp -s xgen-gth gtksourceview-typebuiltins.h || cp xgen-gth gtksourceview-typebuiltins.h) \
 	&& rm -f xgen-gth && echo stamp > $(@F)
 
+BUILT_GIRSOURCES = GtkSource-2.0.gir
+
+GtkSource-2.0.gir: $(libgtksourceview_headers)
+GtkSource-2.0.gir: $(NOINST_H_FILES)
+GtkSource-2.0.gir: $(libgtksourceview_2_0_la_SOURCES)
+GtkSource-2.0.gir: libgtksourceview-2.0.la
+GtkSource-2.0.gir: $(G_IR_SCANNER) Makefile
+	$(AM_V_GEN) $(G_IR_SCANNER) -v --namespace GtkSource --nsversion=2.0 \
+	    --add-include-path=$(srcdir) --add-include-path=. \
+	    --include=GObject-2.0 \
+	    --include=Gtk-2.0 \
+	    --library=libgtksourceview-2.0.la \
+	    --libtool="$(LIBTOOL)" \
+	    --output $@ \
+	    --pkg gtksourceview-2.0 \
+	    -I$(top_srcdir) \
+	    $(libgtksourceview_headers)
+
+if HAVE_INTROSPECTION
+
+girdir = $(GIRDIR)
+gir_DATA = $(BUILT_GIRSOURCES)
+
+typelibsdir = $(TYPELIBDIR)
+typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
+
+%.typelib: %.gir $(G_IR_COMPILER)
+	$(AM_V_GEN) LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}. $(G_IR_COMPILER) --includedir=$(srcdir) --includedir=. $(G_IR_COMPILER_OPTS) $< -o $(builddir)/$(@F)
+
+endif # HAVE_INTROSPECTION
+
 EXTRA_DIST = \
 	gtksourceview-marshal.list \
 	$(ui_DATA)
