Add support for Travis CI
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..2a931b6
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,23 @@
+language: c
+
+compiler:
+  - clang
+
+env:
+  - USE_CMAKE=1 DISABLE_TESTS=1
+  - USE_CMAKE=1 ENABLE_SANITIZERS="address,undefined" EXTRA_ARGS="-DPNG_HARDWARE_OPTIMIZATIONS=ON"
+  - USE_CMAKE=1 ENABLE_SANITIZERS="address,undefined" EXTRA_ARGS="-DPNG_HARDWARE_OPTIMIZATIONS=OFF"
+  - USE_CONFIGURE=1 DISABLE_TESTS=1
+  - USE_CONFIGURE=1 EXTRA_ARGS="--enable-hardware-optimizations"
+  - USE_CONFIGURE=1 EXTRA_ARGS="--disable-hardware-optimizations"
+  - USE_LEGACY_MAKEFILES=1 DISABLE_TESTS=1
+  - USE_LEGACY_MAKEFILES=1 ENABLE_SANITIZERS="address,undefined"
+
+os:
+  - linux
+  - osx
+
+script:
+  - bash ./scripts/travis.sh
+
+sudo: false
diff --git a/scripts/travis.sh b/scripts/travis.sh
new file mode 100755
index 0000000..7d59b24
--- /dev/null
+++ b/scripts/travis.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+set -e
+
+if [[ $ENABLE_SANITIZERS ]]; then
+    LOCAL_CMAKE_EXTRA_ARGS="-DCMAKE_C_FLAGS=-fsanitize=$ENABLE_SANITIZERS"
+    LOCAL_MAKE_EXTRA_ARGS="CFLAGS=-fsanitize=$ENABLE_SANITIZERS LDFLAGS=-fsanitize=$ENABLE_SANITIZERS"
+fi
+
+if [[ $USE_CMAKE ]]; then
+    echo "$0: using cmake + make:" $LOCAL_CMAKE_EXTRA_ARGS $EXTRA_ARGS
+    mkdir build-cmake
+    cd build-cmake
+    cmake $LOCAL_CMAKE_EXTRA_ARGS $EXTRA_ARGS ..
+    make
+    [[ $DISABLE_TESTS ]] || make test
+    make clean
+fi
+
+if [[ $USE_CONFIGURE ]]; then
+    mkdir build-configure
+    cd build-configure
+    echo "$0: using configure + make:" $LOCAL_MAKE_EXTRA_ARGS $EXTRA_ARGS
+    ../configure $LOCAL_MAKE_EXTRA_ARGS $EXTRA_ARGS
+    make
+    [[ $DISABLE_TESTS ]] || make test
+    make clean
+    make distclean
+fi
+
+if [[ $USE_LEGACY_MAKEFILES ]]; then
+    echo "$0: using scripts/makefile.$CC:" $LOCAL_MAKE_EXTRA_ARGS $EXTRA_ARGS
+    make -f scripts/makefile.$CC $LOCAL_MAKE_EXTRA_ARGS $EXTRA_ARGS
+    [[ $DISABLE_TESTS ]] || make -f scripts/makefile.$CC $LOCAL_MAKE_EXTRA_ARGS $EXTRA_ARGS test
+    make -f scripts/makefile.$CC $LOCAL_MAKE_EXTRA_ARGS $EXTRA_ARGS clean
+    # TODO: use scripts/makefile.std, etc.
+fi