check-local-headers.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. # Copyright (C) 2005-2019 Free Software Foundation, Inc.
  3. # This file is part of the GNU C Library.
  4. # The GNU C Library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Lesser General Public
  6. # License as published by the Free Software Foundation; either
  7. # version 2.1 of the License, or (at your option) any later version.
  8. # The GNU C Library is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. # Lesser General Public License for more details.
  12. # You should have received a copy of the GNU Lesser General Public
  13. # License along with the GNU C Library; if not, see
  14. # <http://www.gnu.org/licenses/>.
  15. #
  16. includedir="$1"
  17. objpfx="$2"
  18. # To avoid long paths.
  19. cd "$objpfx"
  20. # OK if *.os is missing.
  21. shopt -s nullglob
  22. # Search all dependency files for file names in the include directory.
  23. # There are a few system headers we are known to use.
  24. # These include Linux kernel headers (asm*, arch, and linux),
  25. # and Mach kernel headers (mach).
  26. exec ${AWK} -v includedir="$includedir" '
  27. BEGIN {
  28. status = 0
  29. exclude = "^" includedir \
  30. "/(.*-.*-.*/|.*-.*/|)(asm[-/]|arch|linux/|selinux/|mach/|mach_debug/|device/|hurd/(((hurd|ioctl)_types|paths)\\.h|ioctls\\.defs|ihash\\.h)|cthreads\\.h|gd|nss3/|nspr4?/|c\\+\\+/|sys/(capability|sdt(|-config))\\.h|libaudit\\.h)"
  31. }
  32. /^[^ ]/ && $1 ~ /.*:/ { obj = $1 }
  33. {
  34. for (i = 1; i <= NF; ++i) {
  35. if ($i ~ ("^" includedir) && $i !~ exclude) {
  36. print "***", obj, "uses", $i
  37. status = 1
  38. }
  39. }
  40. }
  41. END { exit status }' */*.{o,os,oS}.d