build: fix out of sourcedir build for check

Move the internal header to nodist (as we copy it around anyway).
Use builddir in pattern substitution for it.
Fixes #61483.
1 file changed