improve target-needs-ref error reporting

Signed-off-by: Jan Dvořák <mordae@anilinux.org>