configure: Make examples optional
diff --git a/configure.ac b/configure.ac
index 0d1f16d..f0e2e86 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,6 +54,11 @@
 ])
 AX_RESTORE_FLAGS_WITH_PREFIX(OLD, [LDFLAGS])
 
+# Make it possible for users to choose to disable examples
+AC_ARG_ENABLE([examples], AC_HELP_STRING([--disable-examples],
+                                         [Build example programs]))
+AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$enable_examples" != "xno"])
+
 # Make it possible for users to choose if they want test support
 # explicitly or not at all
 AC_ARG_ENABLE([tests], AC_HELP_STRING([--disable-tests],
diff --git a/example/Makefile.am b/example/Makefile.am
index 3d8e3cf..fa40acb 100644
--- a/example/Makefile.am
+++ b/example/Makefile.am
@@ -1,5 +1,9 @@
 noinst_PROGRAMS =
 
+if BUILD_EXAMPLES
+
 noinst_PROGRAMS += follow
 follow_SOURCES = follow.cpp
 follow_LDADD = $(SDEVENTPLUS_LIBS)
+
+endif