Fix $(@RD) behaviour when TOP_BUILD_DIR is used

Hi again!

When using `TOP_BUILD_DIR` and specifying directory-specific configurations, these configurations aren't properly used. This is because the `$(@RD)` variable used doesn't properly convert build directories to real directories when `TOP_BUILD_DIR` is used.

Two helper functions are provided to convert between source and output directories, and a few variables are defined in terms of those helpers. A minimal test project is provided that doesn't work before this change.

Thanks,
Alex.