optimize mkdir calls

The vast majority of mkdir calls are not necessary as the dir in question
already exists.  Hoist the stat() call into the makefile level to avoid
the fork+exec most of the time.  In the rare case (the dir doesn't exist),
there's no real additional overhead.

We can also delete the main mkdir in the main wrapping target as we call
mkdir in global scope already:
	# Make OUT now so we can use realpath.
	$(shell mkdir -p "$(OUT)")

BUG=None
TEST=`./run_tests.sh` works
TEST=building mtpd in/out of tree with updated common.mk works

Change-Id: I26e9aa027d4f9e4c36a953f2002560f3ebc59f2a
Reviewed-on: https://gerrit.chromium.org/gerrit/31160
Reviewed-by: Will Drewry <[email protected]>
Reviewed-by: Elly Jones <[email protected]>
Commit-Ready: Mike Frysinger <[email protected]>
Tested-by: Mike Frysinger <[email protected]>
1 file changed
tree: 492917d5e905a113b52cf9f122fd7555fb3392bc
  1. example/
  2. common.mk
  3. LICENSE
  4. OWNERS
  5. README