bootstrap: Add a 'dev' mode

Enables sanitizers and stricter CFLAGS useful for development.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I1db80b5a83c2e155e1007923546b36176481b78a
diff --git a/bootstrap.sh b/bootstrap.sh
index c508090..ac02a30 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -1,2 +1,28 @@
 #!/bin/sh
-exec autoreconf -f -i
+
+set -eu
+
+autoreconf -f -i
+
+
+BOOTSTRAP_MODE=""
+
+if [ $# -gt 0 ];
+then
+    BOOTSTRAP_MODE="${1}"
+    shift 1
+fi
+
+case "${BOOTSTRAP_MODE}" in
+    dev)
+        FLAGS="-fsanitize=address,leak,undefined -Wformat -Werror=format-security -Werror=array-bounds -ggdb"
+        ./configure \
+            CFLAGS="${FLAGS}" \
+            CXXFLAGS="${FLAGS}" \
+            --enable-code-coverage \
+            "$@"
+        ;;
+    *)
+        echo 'Run "./configure ${CONFIGURE_FLAGS} && make"'
+        ;;
+esac