diff --git a/Makefile.am b/Makefile.am
index 0c2f78c..7782354 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,11 +19,12 @@ AM_CPPFLAGS = \
 	-I${top_srcdir}/src
 
 AM_CFLAGS = ${warn_CFLAGS} \
+	${asan_CFLAGS} \
 	${my_CFLAGS} \
 	-ffunction-sections \
 	-fdata-sections
 
-AM_LDFLAGS =
+AM_LDFLAGS = ${asan_LDFLAGS}
 
 # leaving a space here to work around automake's conditionals
  ifeq ($(OS),Darwin)
diff --git a/configure.ac b/configure.ac
index dd1ca64..6a4ee0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,6 +104,32 @@ AS_IF([test "x$more_warnings" = "xyes"],[
 
 AC_SUBST([warn_CFLAGS])
 
+# - asan -----------------------------------------------------------------------
+
+asan_CFLAGS=""
+asan_LDFLAGS=""
+
+AC_ARG_ENABLE([asan],
+        AS_HELP_STRING([--enable-asan], [enable the address sanitizer @<:@default=disabled@:>@]),
+        [asan=yes], [asan=no])
+AS_IF([test "x$asan" = "xyes"],[
+	asan_CFLAGS+="\
+	-g \
+	-fsanitize=address \
+	-fno-omit-frame-pointer \
+	-fsanitize-recover=address \
+	"
+
+	asan_LDFLAGS+="\
+	-fsanitize=address \
+	"
+])
+
+AC_SUBST([asan_CFLAGS])
+AC_SUBST([asan_LDFLAGS])
+
+# ------------------------------------------------------------------------------
+
 my_CFLAGS="\
 -Wall \
 -Wchar-subscripts \
