Commit | Line | Data |
---|---|---|
2a4665f5 KB |
1 | #!/bin/sh - |
2 | # | |
0293662b | 3 | # Copyright (c) 1991 The Regents of the University of California. |
2a4665f5 KB |
4 | # All rights reserved. |
5 | # | |
0293662b | 6 | # %sccs.include.redist.sh% |
2a4665f5 | 7 | # |
99de9ff2 | 8 | # @(#)mkdep.gcc.sh 5.3 (Berkeley) %G% |
2a4665f5 | 9 | # |
0293662b | 10 | |
2a4665f5 KB |
11 | PATH=/bin:/usr/bin:/usr/ucb |
12 | export PATH | |
13 | ||
14 | D=.depend # default dependency file is .depend | |
15 | append=0 | |
16 | ||
17 | while : | |
18 | do case "$1" in | |
19 | # -a appends to the depend file | |
20 | -a) | |
21 | append=1 | |
22 | shift ;; | |
23 | ||
24 | # -f allows you to select a makefile name | |
25 | -f) | |
26 | D=$2 | |
27 | shift; shift ;; | |
28 | ||
29 | # the -p flag produces "program: program.c" style dependencies | |
30 | # so .o's don't get produced | |
31 | -p) | |
32 | SED='s;\.o;;' | |
33 | shift ;; | |
2a4665f5 KB |
34 | *) |
35 | break ;; | |
36 | esac | |
37 | done | |
38 | ||
39 | if [ $# = 0 ] ; then | |
40 | echo 'usage: mkdep [-p] [-f depend_file] [cc_flags] file ...' | |
41 | exit 1 | |
42 | fi | |
43 | ||
44 | TMP=/tmp/mkdep$$ | |
45 | ||
46 | trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 | |
47 | ||
48 | cpp -M $* > $TMP | |
49 | ||
50 | if [ $? != 0 ]; then | |
51 | echo 'mkdep: compile failed.' | |
52 | rm -f $TMP | |
53 | exit 1 | |
54 | fi | |
55 | ||
56 | if [ $append = 1 ]; then | |
57 | cat $TMP >> $D | |
58 | rm -f $TMP | |
59 | else | |
60 | mv $TMP $D | |
61 | fi | |
62 | exit 0 |