check_makefile_deps.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #! /bin/sh
  2. #
  3. # Check for accurate dependencies in gcc/Makefile.in.
  4. #
  5. # Copyright (C) 2008, 2012 Free Software Foundation, Inc.
  6. # Written by Ralf Wildenhues <Ralf.Wildenhues@gmx.de>.
  7. #
  8. # This script is Free Software, and it can be copied, distributed and
  9. # modified as defined in the GNU General Public License. A copy of
  10. # its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
  11. #
  12. # Start this script in an up to date build-tree/gcc directory.
  13. # Using it in stage1 only works if the host compiler is GCC.
  14. # To continue an interrupted check, make sure there are no *.o.backup
  15. # files lying around (i.e., move them back to their original name),
  16. # and set $start_after to the name of the last object that should be skipped.
  17. start_after=
  18. # Skip some objects unconditionally; make sure each name in this list is
  19. # surrounded by spaces.
  20. skip=" crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o crtfastmath.o crtprec64.o crtprec80.o crtprec32.o ecrti.o ecrtn.o ncrti.o ncrtn.o "
  21. # Files which show up as dependencies other than through unconditional #include.
  22. # This is an egrep pattern.
  23. hidden_dep_files='(BASE-VER|DATESTAMP|DEV-PHASE|Makefile|xcoffout\.h|basic-block\.h|bconfig\.h)$'
  24. : ${MAKE=make}
  25. : ${EGREP="grep -E"}
  26. # -------------------------------------------------------------------------
  27. # There should be no need for changes beyond this point.
  28. set -e
  29. st=0
  30. if test -f c-family/c-common.o; then :; else
  31. echo "$0: rerun in an up to date build-tree/gcc directory" >&2
  32. exit 1
  33. fi
  34. for obj in *.o
  35. do
  36. if test -n "$start_after"; then
  37. if test $obj = $start_after; then
  38. start_after=
  39. fi
  40. continue
  41. fi
  42. case $skip in *\ $obj\ *) continue ;; esac
  43. mv -f $obj $obj.backup
  44. ${MAKE} $obj CFLAGS='-MM -MF depfile'
  45. mv -f $obj.backup $obj
  46. ${MAKE} -t
  47. LC_ALL=C ${MAKE} -d $obj >make-d-log
  48. hdrs=`cat depfile`
  49. for hdr in $hdrs; do
  50. case $hdr in
  51. *: | *.o | \\ | /* ) ;;
  52. *)
  53. echo $hdr ;;
  54. esac
  55. done < depfile |
  56. LC_ALL=C sort -u > hdrs
  57. sed -n '/.*Prerequisite..\([^ ]*\). is newer than target .'"$obj"'.*/s//\1/p' \
  58. < make-d-log |
  59. LC_ALL=C sort -u > not-up-to-date
  60. if test -s not-up-to-date; then
  61. st=1
  62. echo "$0: error: prerequisites for $obj are not up to date:" >&2
  63. cat not-up-to-date >&2
  64. fi
  65. sed -n '/.*Prerequisite..\([^ ]*\). is older than target .'"$obj"'.*/s//\1/p' \
  66. < make-d-log |
  67. LC_ALL=C sort -u > deps
  68. missing_deps=`LC_ALL=C join -v 1 hdrs deps`
  69. unneeded_deps=`LC_ALL=C join -v 2 hdrs deps | $EGREP -v "$hidden_dep_files" || :`
  70. if test -n "$missing_deps"; then
  71. st=1
  72. echo "missing deps for $obj:"
  73. echo "$missing_deps" | sed 's/^/ /'
  74. fi
  75. if test -n "$unneeded_deps"; then
  76. # unneeded dependencies are not a big problem, so they cause no failure.
  77. echo "unneeded deps for $obj:"
  78. echo "$unneeded_deps" | sed 's/^/ /'
  79. fi
  80. done
  81. exit $st
  82. # vi:sw=2: