build: Fix non-POSIX commands realpath and mktemp

realpath is not POSIX and not available on all systems.
POSIX mktemp requires a mandatory template argument.