Add -r (root_dir) option && only mkdir dir once

Allow the script to be run from the build directory (don't assume
it is in the root directory of the project).  Also, only try to
create the output directory once instead of for every request (it
wasn't broken, just smelled a bit).