check-kernel-headers.sh 623 B

123456789101112131415161718192021
  1. #!/bin/sh
  2. CC="${1}"
  3. # Make sure we have enough version components
  4. HDR_VER="${2}.0.0"
  5. HDR_M="${HDR_VER%%.*}"
  6. HDR_V="${HDR_VER#*.}"
  7. HDR_m="${HDR_V%%.*}"
  8. # We do not want to account for the patch-level, since headers are
  9. # not supposed to change for different patchlevels, so we mask it out.
  10. # This only applies to kernels >= 3.0, but those are the only one
  11. # we actually care about; we treat all 2.6.x kernels equally.
  12. exec ${CC} -E -x c -o - - >/dev/null 2>&1 <<_EOF_
  13. #include <linux/version.h>
  14. #if (LINUX_VERSION_CODE & ~0xFF) != KERNEL_VERSION(${HDR_M},${HDR_m},0)
  15. #error Incorrect kernel header version.
  16. #endif
  17. _EOF_