Account for changes in boost dependencies

Recent versions of boost require -lboost_system before -lboost_thread
will work, resulting in a failure of this test if not accounted for.

Make it try without -lboost_system first, but try again with it added to
$LIBS if that fails.