diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-07-16 09:38:02 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-07-16 09:38:02 +0000 |
commit | 06a5c27beffb6c2f1171a8b5095305e342355d16 (patch) | |
tree | 61798f42e64b4f9ae03443f7ea94a149759e729c /usr.bin/mkdep/mkdep.gcc.sh | |
parent | 442edfa0552daaa288bcabf95facfd73b77c22d8 (diff) |
Produce correct output if the options include "-o". Remove umask
juggling that is no longer needed.
ok millert@ henning@
Diffstat (limited to 'usr.bin/mkdep/mkdep.gcc.sh')
-rw-r--r-- | usr.bin/mkdep/mkdep.gcc.sh | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/usr.bin/mkdep/mkdep.gcc.sh b/usr.bin/mkdep/mkdep.gcc.sh index aa3355dede5..dcbdbd56520 100644 --- a/usr.bin/mkdep/mkdep.gcc.sh +++ b/usr.bin/mkdep/mkdep.gcc.sh @@ -1,6 +1,6 @@ #!/bin/sh - # -# $OpenBSD: mkdep.gcc.sh,v 1.12 2003/06/03 02:56:13 millert Exp $ +# $OpenBSD: mkdep.gcc.sh,v 1.13 2003/07/16 09:38:01 otto Exp $ # $NetBSD: mkdep.gcc.sh,v 1.9 1994/12/23 07:34:59 jtc Exp $ # # Copyright (c) 1991, 1993 @@ -33,6 +33,24 @@ # @(#)mkdep.gcc.sh 8.1 (Berkeley) 6/6/93 # +# +# Scan for a -o option in the arguments are record the filename given. +# This is needed, since "cc -M -o out" writes to the file "out", not to +# stdout. +# +scanfordasho() { + while [ $# != 0 ] + do case "$1" in + -o) + file="$2"; shift; shift ;; + -o*) + file="${1#-o}"; shift ;; + *) + shift ;; + esac + done +} + D=.depend # default dependency file is .depend append=0 pflag= @@ -64,18 +82,21 @@ if [ $# = 0 ] ; then exit 1 fi -um=`umask` -umask 022 +scanfordasho "$@" TMP=`mktemp /tmp/mkdep.XXXXXXXXXX` || exit 1 -umask $um trap 'rm -f $TMP ; trap 2 ; kill -2 $$' 1 2 3 13 15 +if [ "x$file" = x ]; then + ${CC:-cc} -M "$@" +else + ${CC:-cc} -M "$@" && cat "$file" +fi | if [ x$pflag = x ]; then - ${CC:-cc} -M "$@" | sed -e 's; \./; ;g' > $TMP + sed -e 's; \./; ;g' > $TMP else - ${CC:-cc} -M "$@" | sed -e 's;\.o[ ]*:; :;' -e 's; \./; ;g' > $TMP + sed -e 's;\.o[ ]*:; :;' -e 's; \./; ;g' > $TMP fi if [ $? != 0 ]; then |