Target auto-detection (and config file override ability)

See commit log for details.