--- /dev/null
+#!/bin/bash
+#
+# Build a sanitized version with clang.
+# Author: Emil Mikulic <emikulic@gmail.com>
+#
+BOLD=$(tput bold)
+NORMAL=$(tput sgr0)
+RED=$(tput setf 9)
+GRAY=$(tput setf 8)
+RULER=${GRAY}$(for i in $(seq $(tput cols)); do echo -n -; done)${NORMAL}
+notice() { echo "${BOLD}==> $*${NORMAL}"; }
+fatal() { echo "${RED}==> FATAL: $*${NORMAL}" >&2; exit 1; }
+report() {
+ local RET=$?
+ echo -n "${BOLD}==> $*: "
+ if [[ $RET = 0 ]]; then
+ echo success${NORMAL}
+ else
+ echo ${RED}FAILURE${NORMAL}
+ fi
+}
+
+RUNDIR=$PWD
+notice "[$0] run from [$RUNDIR]"
+cd $RUNDIR || exit 1
+SRCDIR=$(cd $(dirname $0)/..; pwd)
+notice "src dir is [$SRCDIR]"
+cd $SRCDIR || exit 1
+
+# Local hacks.
+MY_CLANG=$HOME/llvm/install/bin/clang
+if [[ -z $CLANG ]]; then
+ # No CLANG env var set, try to guess.
+ if [[ -e $MY_CLANG ]]; then
+ CLANG=$MY_CLANG
+ else
+ CLANG=clang
+ fi
+fi
+if ! which $CLANG >/dev/null; then
+ fatal "can't find clang as [$CLANG]"
+fi
+notice "clang is [$CLANG]"
+
+rm -f buftee
+echo ${RULER}
+notice build: clang with sanitizer
+CFLAGS="-g -O0 -fno-omit-frame-pointer \
+ -fsanitize=address-full \
+ -fsanitize=integer \
+ -fsanitize=undefined \
+ -fsanitize=unsigned-integer-overflow \
+ -Weverything \
+ -Wno-c++98-compat \
+ -Wno-padded \
+ -fshow-diagnostics"
+env "CC=$CLANG" "CFLAGS=$CFLAGS" make
+report build
+
+# vim:set ts=2 sw=2 et tw=80: