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