Implement flexible target specification

See commit message.
No, I accidentally changed "ios" to "darwin" with a bad sed I think.