/[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.7 by jahn, Mon Mar 15 22:06:20 2010 UTC revision 1.12 by jmc, Thu Aug 22 20:49:59 2013 UTC
# Line 1  Line 1 
1  #! /usr/bin/env 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  #  #
8  #       Do the equivalent of the 'makedepend' program, but do it right.  #       Do the equivalent of the 'makedepend' program, but do it right.
# 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  CPPARGS="-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"  CC="cpp $CPPARGS"
34  if test -x /lib/cpp ; then  if test -x /lib/cpp ; then
# Line 34  fi Line 37  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
# Line 166  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    
 cat $CPPCMD  
   
   
187  echo '' > $DEPENDLINES  echo '' > $DEPENDLINES
188  for i in $files  for i in $files
189  do  do
# Line 181  do Line 192  do
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 213  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 225  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 252  case "$makefile" in Line 257  case "$makefile" in
257      $TMPMAKEFILE)      $TMPMAKEFILE)
258          cat $TMPMAKEFILE          cat $TMPMAKEFILE
259          ;;          ;;
   
260  esac  esac
261    
262  rm -f ${TMP}*  rm -f ${TMP}*

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.12

  ViewVC Help
Powered by ViewVC 1.1.22