Fix .d generation in Chrome OS.

Chrome OS toolchain generates "-:" instead of "-.o:" when reading the
source from stdin "-". This patch makes the code handle both cases and
fixes some missing quotes.

Bug: chromium:609385
Bug: 27954979
TEST=FEATURES=test emerge-link chromeos-minijail

Change-Id: I88b03d1c080308560f71b4d3f2e3b1522c8900e9
diff --git a/gen_constants.sh b/gen_constants.sh
index 2ec3971..0f330b9 100755
--- a/gen_constants.sh
+++ b/gen_constants.sh
@@ -35,10 +35,11 @@
 
 # Generate a dependency file which helps the build tool to see when it
 # should regenerate ${OUTFILE}.
-echo "${INCLUDES}" | ${CC} - -E -M -MF ${OUTFILE}.d.tmp
+echo "${INCLUDES}" | ${CC} - -E -M -MF "${OUTFILE}.d.tmp"
 # Correct the output filename.
-(echo "${OUTFILE}: \\" ; sed 's/^-\.o://' ${OUTFILE}.d.tmp) > ${OUTFILE}.d
-rm ${OUTFILE}.d.tmp
+(echo "${OUTFILE}: \\" ; sed -e 's/^-\.o://' -e 's/^-://' "${OUTFILE}.d.tmp") \
+  > "${OUTFILE}.d"
+rm "${OUTFILE}.d.tmp"
 
 # sed expression which extracts constants and converts them from:
 #   #define AT_FDWCD foo
diff --git a/gen_syscalls.sh b/gen_syscalls.sh
index 51b5838..f31031b 100755
--- a/gen_syscalls.sh
+++ b/gen_syscalls.sh
@@ -26,10 +26,11 @@
 
 # Generate a dependency file which helps the build tool to see when it
 # should regenerate ${OUTFILE}.
-echo '#include <asm/unistd.h>' | ${CC} - -E -M -MF ${OUTFILE}.d.tmp
+echo '#include <asm/unistd.h>' | ${CC} - -E -M -MF "${OUTFILE}.d.tmp"
 # Correct the output filename.
-(echo "${OUTFILE}: \\" ; sed 's/^-\.o://' ${OUTFILE}.d.tmp) > ${OUTFILE}.d
-rm ${OUTFILE}.d.tmp
+(echo "${OUTFILE}: \\" ; sed -e 's/^-\.o://' -e 's/^-://' "${OUTFILE}.d.tmp") \
+  > "${OUTFILE}.d"
+rm "${OUTFILE}.d.tmp"
 
 # sed expression which extracts system calls that are
 # defined via asm/unistd.h.  It converts them from: