xref: /netbsd-src/external/bsd/am-utils/dist/m4/macros/linux_headers.m4 (revision a53f50b9b44dc9467ccc9c464999b1d1c509cb0c)
1*a53f50b9Schristosdnl ######################################################################
2*a53f50b9Schristosdnl ensure that linux kernel headers match running kernel
3*a53f50b9SchristosAC_DEFUN([AMU_LINUX_HEADERS],
4*a53f50b9Schristos[
5*a53f50b9Schristos# test sanity of running kernel vs. kernel headers
6*a53f50b9Schristos  AC_MSG_CHECKING("host headers version")
7*a53f50b9Schristos  case ${host_os} in
8*a53f50b9Schristos    linux )
9*a53f50b9Schristos      host_header_version="bad"
10*a53f50b9Schristos      AMU_EXPAND_RUN_STRING(
11*a53f50b9Schristos[
12*a53f50b9Schristos#include <stdio.h>
13*a53f50b9Schristos#include <linux/version.h>
14*a53f50b9Schristos],
15*a53f50b9Schristos[
16*a53f50b9Schristosif (argc > 1)
17*a53f50b9Schristos#ifdef UTS_RELEASE
18*a53f50b9Schristos  printf("%s", UTS_RELEASE);
19*a53f50b9Schristos#else
20*a53f50b9Schristos# define AMU_MA(a) ((a) >> 16)
21*a53f50b9Schristos# define AMU_MI(a) (((a) & 0xffff) >> 8)
22*a53f50b9Schristos# define AMU_PL(a) ((a) & 0xff)
23*a53f50b9Schristos printf("%d.%d.%d", AMU_MA(LINUX_VERSION_CODE), AMU_MI(LINUX_VERSION_CODE), AMU_PL(LINUX_VERSION_CODE));
24*a53f50b9Schristos#endif
25*a53f50b9Schristos],
26*a53f50b9Schristos[ host_header_version=$value ],
27*a53f50b9Schristos[ echo
28*a53f50b9Schristos  AC_MSG_ERROR([cannot find UTS_RELEASE in <linux/version.h>.
29*a53f50b9Schristos  This Linux system may be misconfigured or unconfigured!])
30*a53f50b9Schristos])
31*a53f50b9Schristos	;;
32*a53f50b9Schristos	* ) host_header_version=$host_os_version ;;
33*a53f50b9Schristos  esac
34*a53f50b9Schristos  AC_DEFINE_UNQUOTED(HOST_HEADER_VERSION, "$host_header_version")
35*a53f50b9Schristos  AC_MSG_RESULT($host_header_version)
36*a53f50b9Schristos
37*a53f50b9Schristos  case ${host_os} in
38*a53f50b9Schristos    linux )
39*a53f50b9Schristos	if test "$host_os_version" != $host_header_version
40*a53f50b9Schristos	then
41*a53f50b9Schristos		AC_MSG_WARN([Linux kernel $host_os_version mismatch with $host_header_version headers!])
42*a53f50b9Schristos	fi
43*a53f50b9Schristos    ;;
44*a53f50b9Schristosesac
45*a53f50b9Schristosdnl cache these two for debugging purposes
46*a53f50b9Schristosac_cv_os_version=$host_os_version
47*a53f50b9Schristosac_cv_header_version=$host_header_version
48*a53f50b9Schristos])
49*a53f50b9Schristosdnl ======================================================================
50