python-pathvalidate: bump version to 0.14.1
[buildroot-gz.git] / support / scripts / check-kernel-headers.sh
bloba8cca78b275de310bd75a28509fcd4929cdd8075
1 #!/bin/sh
3 SYSROOT="${1}"
4 # Make sure we have enough version components
5 HDR_VER="${2}.0.0"
7 HDR_M="${HDR_VER%%.*}"
8 HDR_V="${HDR_VER#*.}"
9 HDR_m="${HDR_V%%.*}"
11 EXEC="$(mktemp -t check-headers.XXXXXX)"
13 # We do not want to account for the patch-level, since headers are
14 # not supposed to change for different patchlevels, so we mask it out.
15 # This only applies to kernels >= 3.0, but those are the only one
16 # we actually care about; we treat all 2.6.x kernels equally.
17 ${HOSTCC} -imacros "${SYSROOT}/usr/include/linux/version.h" \
18 -x c -o "${EXEC}" - <<_EOF_
19 #include <stdio.h>
20 #include <stdlib.h>
22 int main(int argc __attribute__((unused)),
23 char** argv __attribute__((unused)))
25 if((LINUX_VERSION_CODE & ~0xFF)
26 != KERNEL_VERSION(${HDR_M},${HDR_m},0))
28 printf("Incorrect selection of kernel headers: ");
29 printf("expected %d.%d.x, got %d.%d.x\n", ${HDR_M}, ${HDR_m},
30 ((LINUX_VERSION_CODE>>16) & 0xFF),
31 ((LINUX_VERSION_CODE>>8) & 0xFF));
32 return 1;
34 return 0;
36 _EOF_
38 "${EXEC}"
39 ret=${?}
40 rm -f "${EXEC}"
41 exit ${ret}