added lines to make directories before redirect files

Build failed when sed trying to redirect output to non-existent directories. Create those directories before sed needs them.