Fix HAVE_PEDANTIC_ALLOWING_TRAILING_COMMAS test

-Werror is necessary to make
check_c_source_compiles_with_flags fail for annoying
compilers.
Kill dead code
Write thread mutex abstraction

Mutex and associated functions provide never-failing
lock/unlock operations and the lack of a static initializer
(a la PTHREAD_MUTEX_INITIALIZER, known to cause bugs in some
cases).
Test with GCC 4.9 on Linux
Inline valgrind=true for Travis CI

It's kind of pointless to support branching when the branch
is always taken...
Replace $cc, $cxx with $CC, $CXX

cc and cxx were pretty redundant when they're just
re-exported as uppercase.