Autotools pull in standard build system
The main M4 file


  Should I pull the setup script into this macros or leave it separate?


I think it's good you separated.
For the same reason that it's good to decompose a large function doing many things to smaller functions.

If it doesn't make sense to ever run the setup script independently,
then an alternative is to put it in a function,
if that's possible in M4.

This may be a matter of taste,
I avoid pushd and popd in shell scripts for fear that I might forget to do popd, or that later I delete one of them by mistake.
An alternative is a (...) subshell, for example:

    (
        cd build/third
        ./setup "$CXX" || AC_MSG_ERROR([Failed to set up the test utilities], [1])
    )


The subshell has its own environment, its own $PWD,
so directory changes will not affect the encapsulating shell process.
Forgetting one of the parens in (...) is impossible as that would be a blatant syntax error.

The setup script

It would be better to give the setup script a .sh extension to indicate it's a shell script.



Some variables containing filenames are not carefully quoted, for example:


THORSANVIL_ROOT=$(dirname ${ROOT})



This will break down if the path contains spaces.

Maybe on your computer you have the good sense to avoid spaces in paths of your dev stuff,
but others cloning your project might not,
and annoy you with dumb questions when something doesn't work.
It's better to quote such variables.
Paste your script on shellcheck.net and review all similar cases.




if [[ -e ${THORSANVIL_ROOT}/lib/libgtest.a ]]; then
    exit 0
fi



Instead of -e, which gives true for directories too,
I'd use -f that more explicitly requires regular files.
(It will match symlinks pointing to regular files too.)
Sure, it's unlikely that a .a file would be a directory,
but if that ever happens, it will really suck.




GTEST_ARCHIEVE=`ls gtest-*.zip 2&gt;/dev/null | tail -n 1`
if [[ ${GTEST_ARCHIEVE} == "" ]]; then
    echo "Retrieving: gtest-1.7.0"
    wget http://googletest.googlecode.com/files/gtest-1.7.0.zip
    GTEST_ARCHIEVE=`ls gtest-*.zip 2&gt;/dev/null | tail -n 1`
fi



Always prefer the modern $(...) subshells instead of the old and troublesome ``...`` style.

Also, since you're duplicating that ls ... command,
it would be better to put that in a helper function.
Even though it's just one line,
it's not exactly trivial, 
and copy-pasted code very often comes back to haunt you.

Btw I guess you meant to name that variable GTEST_ARCHIVE instead of GTEST_ARCHIEVE.

As in the other script, I would wrap the pushd/popd in (...) instead.