Protect against empty $CXX
Define variable closer to its use
Remove unnecessary declarations
Simpler test
Don't test for presence of standard C++ header files