home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume27 / mthreads / part01 / makedepend.SH < prev    next >
Encoding:
Text File  |  1993-11-20  |  2.4 KB  |  70 lines

  1. case $CONFIG in
  2.     '') . ./config.sh ;;
  3. esac
  4. echo "Extracting makedepend (with variable substitutions)"
  5. $spitshell >makedepend <<!GROK!THIS!
  6. $startsh
  7. # $Id: makedepend.SH,v 3.0 1991/09/09 20:23:31 davison Trn $
  8. # This software is Copyright 1991 by Stan Barber. 
  9. #
  10. # Permission is hereby granted to copy, reproduce, redistribute or otherwise
  11. # use this software as long as: there is no monetary profit gained
  12. # specifically from the use or reproduction of this software, it is not
  13. # sold, rented, traded or otherwise marketed, and this copyright notice is
  14. # included prominently in any copy made. 
  15. #
  16. # The author make no claims as to the fitness or correctness of this software
  17. # for any use whatsoever, and it is provided as is. Any use of this software
  18. # is at the user's own risk. 
  19. export PATH || (echo "OOPS, this isn't sh.  Desperation time.  I will feed myself to sh."; sh \$0; kill \$\$)
  20.  
  21. $cat /dev/null >.deptmp
  22. $echo "(Note: this is going to take a while.)"
  23. for file in *.[cy]; do
  24.     case "\$file" in
  25.     *.c) filebase=\`basename \$file .c\`;;
  26.     *.y) filebase=\`basename \$file .y\`;;
  27.     esac
  28.     $echo "Finding dependencies for \$filebase.o."
  29.     $sed -n <\$file \\
  30.     -e "/^\${filebase}_init(/q" \\
  31.     -e '/^#/{' \\
  32.     -e 's|/\*.*$||' \\
  33.     -e 's/\\\\[     ]*$//' \\
  34.     -e p \\
  35.     -e '}' | $cppstdin -I/usr/local/include | $sed \\
  36.     -e '/^# *line/s/line//' \
  37.     -e '/^# *[0-9]/!d' \\
  38.     -e 's/^.*"\(.*\)".*\$/'\$filebase'.o: \1/' \\
  39.     -e 's|: \./|: |' \\
  40.     -e 's/: .*\.c/: '\$file'/' | \\
  41.     $uniq | $sort | $uniq >> .deptmp
  42. done
  43.  
  44. for file in *.SH; do
  45.     $echo \`basename \$file .SH\`: \$file config.sh \; /bin/sh \$file >> .deptmp
  46. done
  47.  
  48. $sed <Makefile >Makefile.new -e '1,/^# AUTOMATICALLY/!d'
  49.  
  50. if $test -s .deptmp; then
  51.     echo "Updating Makefile..."
  52.     $sed -e 's/\\\$/\$\$/g' .deptmp | $egrep -v $usrinc >dependencies
  53. else
  54.     $echo "You don't seem to have a proper C preprocessor.  Using grep instead."
  55.     $egrep '^#include ' *.[cyh] ?.[cyh] >.deptmp
  56.     echo "Updating Makefile..."
  57.     <.deptmp $sed -n 's|c:#include "\(.*\)".*\$\$|o: \1|p' > dependencies
  58.     <.deptmp $sed -n 's|y:#include "\(.*\)".*\$\$|o: \1|p' >> dependencies
  59.     <.deptmp $sed -n 's|h:#include "\(.*\)".*\$\$|h: \1|p' >> dependencies
  60. fi
  61. $echo "# WARNING: Put nothing here or make depend will gobble it up!" >> dependencies
  62. $mv Makefile Makefile.old
  63. $mv Makefile.new Makefile
  64. $cat dependencies >>Makefile
  65. rm .deptmp
  66. !GROK!THIS!
  67. $eunicefix makedepend
  68. chmod 755 makedepend
  69.