Cross compilation support (#709)

* build: add cross-compilation support to make

Set CROSS_COMPILE when running make to use the selected cross
compilation toolchain, such as arm-linux-gnueabihf, or
aarch64-linux-gnu.

Testing requires the presence of qemu - 'qemu-$(ARCH)' will be executed,
where ARCH is the first part of the toolchain triplet.

* build: add cross-compilation support to cmake

If C_COMPILER/CXX_COMPILER/CC/CXX are found to have cross-compilation
triplets in front of the compiler, then qemu will be used to execute the
tests.

* CI: add arm-linux-gnueabihf-gcc builder to Travis

The version of qemu available in Ubuntu trusty (as provided by Travis)
appears to have a bug in qemu-aarch64, which leads to the compatibility
tests failing on some inputs, erroneously rejecting the input as
corrupt.

Once Travis supports xenial, we could add an aarch64-gnu-linux-gcc
builder as well.

* CI: propagate cmake errors out of .travis.sh

Seems like even if cmake fails, the error isn't picked up by Travis.
diff --git a/Makefile b/Makefile
index c48d798..58e563a 100644
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,18 @@
   CPPFLAGS += -DOS_MACOSX
 endif
 
+ifneq ($(strip $(CROSS_COMPILE)), )
+	CC=$(CROSS_COMPILE)-gcc
+	ARCH=$(firstword $(subst -, ,$(CROSS_COMPILE)))
+	BROTLI_WRAPPER="qemu-$(ARCH) -L /usr/$(CROSS_COMPILE)"
+endif
+
+# The arm-linux-gnueabi compiler defaults to Armv5. Since we only support Armv7
+# and beyond, we need to select Armv7 explicitly with march.
+ifeq ($(ARCH), arm)
+	CFLAGS += -march=armv7-a
+endif
+
 all: test
 	@:
 
@@ -31,8 +43,8 @@
 	ar -crs $(LIB_A) $(LIBOBJECTS)
 
 test: $(EXECUTABLE)
-	tests/compatibility_test.sh
-	tests/roundtrip_test.sh
+	tests/compatibility_test.sh $(BROTLI_WRAPPER)
+	tests/roundtrip_test.sh $(BROTLI_WRAPPER)
 
 clean:
 	rm -rf $(BINDIR) $(LIB_A)