/[MITgcm]/MITgcm/tools/xmakedepend
ViewVC logotype

Annotation of /MITgcm/tools/xmakedepend

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Mon Feb 11 21:52:31 2002 UTC (22 years, 1 month ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint46n_post, checkpoint47e_post, checkpoint44e_post, checkpoint46l_post, checkpoint46g_pre, checkpoint47c_post, checkpoint50c_post, checkpoint46f_post, checkpoint48e_post, checkpoint50c_pre, checkpoint44f_post, checkpoint46b_post, checkpoint48i_post, checkpoint46l_pre, chkpt44d_post, checkpoint51, checkpoint50, checkpoint50d_post, checkpoint50b_pre, checkpoint44e_pre, checkpoint48b_post, checkpoint51d_post, checkpoint48c_pre, checkpoint47d_pre, checkpoint47a_post, checkpoint48d_pre, checkpoint47i_post, checkpoint47d_post, checkpoint46d_pre, checkpoint48d_post, checkpoint48f_post, checkpoint45d_post, checkpoint46j_pre, checkpoint44h_pre, checkpoint48h_post, checkpoint51b_pre, checkpoint46a_post, checkpoint47g_post, checkpoint46j_post, checkpoint46k_post, checkpoint48a_post, checkpoint45a_post, checkpoint50f_post, checkpoint50a_post, checkpoint50f_pre, checkpoint47j_post, branch-exfmods-tag, checkpoint44g_post, checkpoint46e_pre, checkpoint48c_post, checkpoint45b_post, checkpoint46b_pre, release1_final_v1, checkpoint51b_post, checkpoint51c_post, checkpoint46c_pre, checkpoint46, checkpoint47b_post, checkpoint46h_pre, checkpoint46m_post, checkpoint46a_pre, checkpoint50g_post, checkpoint45c_post, checkpoint44h_post, checkpoint46g_post, checkpoint50h_post, checkpoint50e_pre, checkpoint50i_post, checkpoint47f_post, checkpoint50e_post, checkpoint46i_post, checkpoint46c_post, checkpoint50d_pre, checkpoint46e_post, checkpoint51e_post, checkpoint47, checkpoint45, checkpoint48, checkpoint49, checkpoint46h_post, checkpoint51f_pre, checkpoint48g_post, checkpoint47h_post, checkpoint44f_pre, checkpoint46d_post, checkpoint50b_post, checkpoint51a_post
Branch point for: branch-exfmods-curt, release1_final, release1, ecco-branch
o added tools/xmakedepend to circumvene shortcoming of
  SUN's makedepend (size too small)
o in tools/genmake
  * invoking ../tools/xmakedepend instead of makedepend
  * changed compiler flags for case SunOS

1 heimbach 1.1 #!/usr/bin/sh
2     #
3     # $TOG: mdepend.cpp /main/13 1997/06/20 21:12:18 kaleb $
4     #
5     # Do the equivalent of the 'makedepend' program, but do it right.
6     #
7     # Usage:
8     #
9     # makedepend [cpp-flags] [-w width] [-s magic-string] [-f makefile]
10     # [-o object-suffix]
11     #
12     # Notes:
13     #
14     # The C compiler used can be overridden with the environment
15     # variable "CC".
16     #
17     # The "-v" switch of the "makedepend" program is not supported.
18     #
19     #
20     # This script should
21     # work on both USG and BSD systems. However, when System V.4 comes out,
22     # USG users will probably have to change "silent" to "-s" instead of
23     # "-" (at least, that is what the documentation implies).
24     #
25     # $XFree86: xc/config/util/mdepend.cpp,v 3.2 1997/06/29 07:54:20 dawes Exp $
26     #
27    
28     CC="cpp -traditional -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_GNU_SOURCE "
29    
30     silent='-'
31    
32     TMP=./mdep$$
33     CPPCMD=${TMP}a
34     DEPENDLINES=${TMP}b
35     TMPMAKEFILE=${TMP}c
36     MAGICLINE=${TMP}d
37     ARGS=${TMP}e
38    
39     trap "rm -f ${TMP}*; exit 1" 1 2 15
40     trap "rm -f ${TMP}*; exit 0" 1 2 13
41    
42     echo " \c" > $CPPCMD
43     if [ `wc -c < $CPPCMD` -eq 1 ]
44     then
45     c="\c"
46     n=
47     else
48     c=
49     n="-n"
50     fi
51    
52     echo $n "$c" >$ARGS
53    
54     files=
55     makefile=
56     magic_string='# DO NOT DELETE'
57     objsuffix='.o'
58     width=78
59     endmarker=""
60     verbose=n
61     append=n
62    
63     while [ $# != 0 ]
64     do
65     if [ "$endmarker"x != x ] && [ "$endmarker" = "$1" ]; then
66     endmarker=""
67     else
68     case "$1" in
69     -D*|-I*)
70     echo $n " '$1'$c" >> $ARGS
71     ;;
72    
73     -g|-O) # ignore so we can just pass $(CFLAGS) in
74     ;;
75    
76     *)
77     if [ "$endmarker"x = x ]; then
78     case "$1" in
79     -w)
80     width="$2"
81     shift
82     ;;
83     -s)
84     magic_string="$2"
85     shift
86     ;;
87     -f*)
88     if [ "$1" = "-f-" ]; then
89     makefile="-"
90     else
91     makefile="$2"
92     shift
93     fi
94     ;;
95     -o)
96     objsuffix="$2"
97     shift
98     ;;
99    
100     --*)
101     echo "$1" | sed 's/^\-\-//' >${TMP}end
102     endmarker="`cat ${TMP}end`"
103     rm -f ${TMP}end
104     if [ "$endmarker"x = x ]; then
105     endmarker="--"
106     fi
107     ;;
108     -v)
109     verbose="y"
110     ;;
111    
112     -a)
113     append="y"
114     ;;
115    
116     -cc)
117     CC="$2"
118     shift
119     ;;
120    
121     -*)
122     echo "Unknown option '$1' ignored" 1>&2
123     ;;
124     *)
125     files="$files $1"
126     ;;
127     esac
128     fi
129     ;;
130     esac
131     fi
132     shift
133     done
134     echo ' $*' >> $ARGS
135    
136     echo "#!/bin/sh" > $CPPCMD
137     echo "exec $CC `cat $ARGS`" >> $CPPCMD
138     chmod +x $CPPCMD
139     rm $ARGS
140    
141     case "$makefile" in
142     '')
143     if [ -r makefile ]
144     then
145     makefile=makefile
146     elif [ -r Makefile ]
147     then
148     makefile=Makefile
149     else
150     echo 'no makefile or Makefile found' 1>&2
151     exit 1
152     fi
153     ;;
154     -)
155     makefile=$TMPMAKEFILE
156     ;;
157     esac
158    
159     if [ "$verbose"x = "y"x ]; then
160     cat $CPPCMD
161     fi
162    
163     echo '' > $DEPENDLINES
164     for i in $files
165     do
166     $CPPCMD $i | sed -n "/^#/s;^;$i ;p"
167    
168     done | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g' -e 's|"||g' -e 's| \./| |' | awk '{
169     if ($1 != $4 && $2 != "#ident" && $2 != "#pragma")
170    
171    
172    
173     {
174     ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'"
175     print ofile, $4
176     }
177     }' | sort -u | awk '
178    
179    
180     {
181     newrec = rec " " $2
182     if ($1 != old1)
183     {
184     old1 = $1
185     if (rec != "")
186     print rec
187     rec = $1 ": " $2
188     }
189     else if (length (newrec) > '"$width"')
190     {
191     print rec
192     rec = $1 ": " $2
193     }
194     else
195     rec = newrec
196     }
197     END {
198    
199     if (rec != "")
200     print rec
201     }' | egrep -v '^[^:]*:[ ]*$' >> $DEPENDLINES
202    
203    
204     trap "" 1 2 13 15 # Now we are committed
205     case "$makefile" in
206     $TMPMAKEFILE)
207     ;;
208     *)
209     rm -f $makefile.bak
210     cp $makefile $makefile.bak
211     echo "Appending dependencies to $makefile"
212     ;;
213     esac
214    
215     #
216     # If not -a, append the magic string and a blank line so that
217     # /^$magic_string/+1,\$d can be used to delete everything from after
218     # the magic string to the end of the file. Then, append a blank
219     # line again and then the dependencies.
220     #
221     if [ "$append" = "n" ]
222     then
223     cat >> $makefile << END_OF_APPEND
224    
225     $magic_string
226    
227     END_OF_APPEND
228     ed $silent $makefile << END_OF_ED_SCRIPT
229     /^$magic_string/+1,\$d
230     w
231     q
232     END_OF_ED_SCRIPT
233     echo '' >>$makefile
234     fi
235    
236     cat $DEPENDLINES >>$makefile
237    
238     case "$makefile" in
239     $TMPMAKEFILE)
240     cat $TMPMAKEFILE
241     ;;
242    
243     esac
244    
245     rm -f ${TMP}*
246     exit 0

  ViewVC Help
Powered by ViewVC 1.1.22