Implement flexible target specification

See commit message.
Umm, I didn't find any todo's about Windows...