home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 7 / FreshFishVol7.bin / bbs / gnu / libg++-2.6-fsf.lha / libg++-2.6 / libg++ / utils / gendepend < prev    next >
Text File  |  1992-06-17  |  2KB  |  58 lines

  1. #!/bin/sh
  2.  
  3. # to use this script, cd to the utils source directory and sh
  4. # gendepend.
  5.  
  6. gdep=`pwd`/g++dep.sh
  7.  
  8. cd ..
  9. popdir=`pwd`
  10.  
  11. gxx_include=${popdir}/g\+\+-include
  12. io_dir=${popdir}/iostream
  13. src_dir=${popdir}/src
  14. gxx_flags="-I. -I${gxx_include} -I${io_dir}"
  15.  
  16.  
  17. for i in `find . -name depend -print` ; do
  18.     down=`dirname $i`
  19.     up=`echo $down | sed -e "s:/[-a-zA-Z0-9]*:/..:g" -e "s:^\./::"`
  20.  
  21.     cd ${popdir}/${down}
  22.  
  23.     echo "" > depend.tmp
  24.     ${gdep} -f depend.tmp ${gxx_flags} *.[cC]*
  25. # --- Generate depend rules ---
  26.  
  27. # The sed script below attempts to make the depend output portable by
  28. # making the output use the same macros used elsewhere in the Makefile:
  29. # - It replaces double // by a single /.
  30. # - It replaces include files that match part of the GXX_INCLUDE_DIRS
  31. #   by names defined in terms of the macros used to define GXX_INCLUDE_DIRS.
  32. #   However, files in g++-include are ignored.
  33. # - It removes any absolute include file names that remain.
  34. # - then remove lines, which contain only `\'
  35. #
  36.  
  37. #      -e 's|$(srcdir)|$$(srcdir)|g'
  38. #      -e 's|: *\$$(srcdir)/\(.*\.[cC]*\)|: \1|'
  39.  
  40.     sed < depend.tmp \
  41.       -e 's|//|/|g' \
  42.       -e "s|${io_dir}|\$(srcdir)/${up}/\$(IO_DIR)|g" \
  43.       -e "s| ${gxx_include}/[^ ]*[.]h||g" \
  44.       -e "s|${src_dir}|\$(srcdir)/${up}/src_dir|g" \
  45.       -e 's| /[^ ]*[.]h||g' \
  46.       -e '/^[     ]*\\$/d' -e 's/^[     ]*$//' \
  47.     | awk 'BEGIN   { prev = "" } \
  48.           /^( )*$/ { if (prev ~ /\\$/) \
  49.              { prev = substr(prev,1,length(prev)-1); next } \
  50.                } \
  51.                        { print prev; prev = $0 } \
  52.            END { if (prev !~ /^( )*$/) print prev }' \
  53.     > depend
  54.     rm -f depend.tmp
  55. done
  56.  
  57. exit 0
  58.