fix build on ubuntu 12.04: add pthread for gtest and move AC_CONFIG_AUX_DIR to top for its usage inside ACX_PTHREAD