Implement flexible target specification

See commit message.
Multiple boolean flags is normally an area of danger, this function may want to move into the compiler and take a `&Target` as an argument.