- Rewrite logic to guess TARGET_ARCH/TARGET to be more readable,   but without changes in behavior.
- Rewrite logic to guess TARGET_ARCH/TARGET to be more readable,
  but without changes in behavior.

- Add sanity checking for TARGET_ARCH/TARGET.

jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase