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

Diff of /MITgcm/tools/xmakedepend

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

revision 1.1.2.1 by heimbach, Mon Feb 11 23:15:24 2002 UTC revision 1.13 by jmc, Fri Dec 30 23:56:52 2016 UTC
# Line 1  Line 1 
1  #!/usr/bin/sh  #! /usr/bin/env sh
2    #
3    # $Header$
4    # $Name$
5  #  #
6  # $TOG: mdepend.cpp /main/13 1997/06/20 21:12:18 kaleb $  # $TOG: mdepend.cpp /main/13 1997/06/20 21:12:18 kaleb $
7  #  #
# Line 23  Line 26 
26  #       "-" (at least, that is what the documentation implies).  #       "-" (at least, that is what the documentation implies).
27  #  #
28  # $XFree86: xc/config/util/mdepend.cpp,v 3.2 1997/06/29 07:54:20 dawes Exp $  # $XFree86: xc/config/util/mdepend.cpp,v 3.2 1997/06/29 07:54:20 dawes Exp $
 #  
29    
30  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  "  CPPARGS="-Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE  -D_GNU_SOURCE  "
31    CPPARGS="-traditional $CPPARGS"
32    
33    CC="cpp $CPPARGS"
34    if test -x /lib/cpp ; then
35        CC="/lib/cpp $CPPARGS"
36    fi
37    
38  silent='-'  silent='-'
39    
40  TMP=./mdep$$  #TMP=./mdep$$
41    #- try to put temporary files in system-local /tmp dir
42    TMP=/tmp/mdep$$
43    touch $TMP ; retVal=$?
44    if [ $retVal -eq 0 ] ; then
45      if test ! -r $TMP ; then TMP=./mdep$$ ; fi
46    else
47      TMP=./mdep$$
48    fi
49    rm -f $TMP
50    #echo "temp files: $TMP"
51    
52  CPPCMD=${TMP}a  CPPCMD=${TMP}a
53  DEPENDLINES=${TMP}b  DEPENDLINES=${TMP}b
54  TMPMAKEFILE=${TMP}c  TMPMAKEFILE=${TMP}c
55  MAGICLINE=${TMP}d  HEAD_MKFILE=${TMP}d
56  ARGS=${TMP}e  ARGS=${TMP}e
57    
58  trap "rm -f ${TMP}*; exit 1" 1 2 15  trap "rm -f ${TMP}*; exit 1" 1 2 15
# Line 118  do Line 137  do
137                              shift                              shift
138                              ;;                              ;;
139    
140                            -cpp)
141                                CC="$2 $CPPARGS"
142                                shift
143                                ;;
144    
145                          -*)                          -*)
146                              echo "Unknown option '$1' ignored" 1>&2                              echo "Unknown option '$1' ignored" 1>&2
147                              ;;                              ;;
# Line 156  case "$makefile" in Line 180  case "$makefile" in
180          ;;          ;;
181  esac  esac
182    
183  if [ "$verbose"x = "y"x ]; then  if [ "$verbose"x = "y"x ]; then
184      cat $CPPCMD      cat $CPPCMD
185  fi  fi
186    
# Line 165  for i in $files Line 189  for i in $files
189  do  do
190      $CPPCMD $i       | sed -n "/^#/s;^;$i ;p"      $CPPCMD $i       | sed -n "/^#/s;^;$i ;p"
191    
192  done   | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g'     -e 's|"||g' -e 's| \./| |'   | awk '{  done   | sed -e 's|/[^/.][^/]*/\.\.||g' -e 's|/\.[^.][^/]*/\.\.||g'     -e 's|"||g' -e 's| \./| |'   | awk '!/<.*>/{
193          if ($1 != $4  &&  $2 != "#ident" && $2 != "#pragma")          if ($1 != $4  &&  $2 != "#ident" && $2 != "#pragma")
194    
   
   
195              {              {
196              ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'"              ofile = substr ($1, 1, length ($1) - 2) "'"$objsuffix"'"
197              print ofile, $4              print ofile, $4
198              }              }
199          }'   | sort -u   | awk '          }'   | sort -u   | awk '
200    
   
201              {              {
202              newrec = rec " " $2              newrec = rec " " $2
203              if ($1 != old1)              if ($1 != old1)
# Line 200  done   | sed -e 's|/[^/.][^/]*/\.\.||g' Line 221  done   | sed -e 's|/[^/.][^/]*/\.\.||g'
221                  print rec                  print rec
222              }'   | egrep -v '^[^:]*:[   ]*$' >> $DEPENDLINES              }'   | egrep -v '^[^:]*:[   ]*$' >> $DEPENDLINES
223    
   
224  trap "" 1 2 13 15       # Now we are committed  trap "" 1 2 13 15       # Now we are committed
225  case "$makefile" in  case "$makefile" in
226      $TMPMAKEFILE)      $TMPMAKEFILE)
# Line 212  case "$makefile" in Line 232  case "$makefile" in
232          ;;          ;;
233  esac  esac
234    
 #  
235  # If not -a, append the magic string and a blank line so that  # If not -a, append the magic string and a blank line so that
236  # /^$magic_string/+1,\$d can be used to delete everything from after  # /^$magic_string/+1,\$d can be used to delete everything from after
237  # the magic string to the end of the file.  Then, append a blank  # the magic string to the end of the file.  Then, append a blank
238  # line again and then the dependencies.  # line again and then the dependencies.
 #  
239  if [ "$append" = "n" ]  if [ "$append" = "n" ]
240  then  then
241      cat >> $makefile << END_OF_APPEND      cat >> $makefile << END_OF_APPEND
# Line 225  then Line 243  then
243  $magic_string  $magic_string
244    
245  END_OF_APPEND  END_OF_APPEND
246    # ed -h > /dev/null 2>&1
247      which ed > /dev/null 2>&1
248      RETVAL=$?
249      if test x"$RETVAL" = x0 ; then
250        if [ $verbose = y ]; then echo ' using line editor "ed"' ; fi
251      ed $silent $makefile << END_OF_ED_SCRIPT      ed $silent $makefile << END_OF_ED_SCRIPT
252  /^$magic_string/+1,\$d  /^$magic_string/+1,\$d
253  w  w
254  q  q
255  END_OF_ED_SCRIPT  END_OF_ED_SCRIPT
256      else
257        if [ $verbose = y ]; then echo ' using sed command' ; fi
258        sed -n "1,/^$magic_string/p" $makefile > $HEAD_MKFILE
259        mv $HEAD_MKFILE $makefile
260      fi
261      echo '' >>$makefile      echo '' >>$makefile
262  fi  fi
263    
# Line 239  case "$makefile" in Line 267  case "$makefile" in
267      $TMPMAKEFILE)      $TMPMAKEFILE)
268          cat $TMPMAKEFILE          cat $TMPMAKEFILE
269          ;;          ;;
   
270  esac  esac
271    
272  rm -f ${TMP}*  rm -f ${TMP}*

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.22