factor out flag parsing from enormous NinjaMain()
simplify some ifdefs