acinclude.m4 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. ##
  2. ## additional m4 macros
  3. ##
  4. ## (C) 1999 Christoph Bartelmus (lirc@bartelmus.de)
  5. ##
  6. dnl check for kernel source
  7. AC_DEFUN([AC_PATH_KERNEL_SOURCE_SEARCH],
  8. [
  9. kerneldir=missing
  10. kernelext=ko
  11. no_kernel=yes
  12. if test `uname` != "Linux"; then
  13. kerneldir="not running Linux"
  14. else
  15. shortvers="$( uname -r | sed -r 's/(@<:@2-9@:>@\.@<:@0-9@:>@+).*/\1/' )"
  16. if test x${ac_kerneldir} != x; then
  17. if test -d ${ac_kerneldir}; then
  18. kerneldir=`dirname ${ac_kerneldir}/Makefile`/
  19. no_kernel=no
  20. fi
  21. else
  22. for dir in /lib/modules/`uname -r`/build \
  23. /lib/modules/`uname -r`/source \
  24. /usr/src/kernel-source-`uname -r` \
  25. /usr/src/linux-source-`uname -r` \
  26. /usr/src/kernel-source-$shortvers \
  27. /usr/src/linux-source-$shortvers \
  28. /usr/src/linux
  29. do
  30. if test -d $dir; then
  31. kerneldir=`dirname $dir/Makefile`/
  32. no_kernel=no
  33. break
  34. fi
  35. done
  36. fi
  37. fi
  38. if test x${no_kernel} != xyes; then
  39. if test -f ${kerneldir}/Makefile -a -f ${kerneldir}/.config; then
  40. version=$( sed -n '/^VERSION/s/.*=\ *//p' ${kerneldir}/Makefile )
  41. patchlevel=$( sed -n -e '/^PATCHLEVEL/s/.*=\ *//p' ${kerneldir}/Makefile )
  42. kerneluname=$( sed -n '/Linux kernel version/s/.*:\ *//p' ${kerneldir}/.config )
  43. if test "${version}" -eq 2; then
  44. if test "${patchlevel}" -lt 5; then
  45. kernelext=o
  46. fi
  47. fi
  48. else
  49. kerneldir="not found"
  50. no_kernel=yes
  51. fi
  52. fi
  53. ac_cv_have_kernel="no_kernel=${no_kernel} \
  54. kerneldir=\"${kerneldir}\" \
  55. kernelext=\"${kernelext}\""
  56. ]
  57. )
  58. AC_DEFUN([AC_PATH_KERNEL_SOURCE],
  59. [
  60. AC_CHECK_PROG(ac_pkss_mktemp,mktemp,yes,no)
  61. AC_PROVIDE([AC_PATH_KERNEL_SOURCE])
  62. AC_MSG_CHECKING(for Linux kernel sources)
  63. AC_ARG_WITH(kernel,
  64. [ --with-kernel=DIR Use Linux kernel sources in DIR],
  65. ac_kerneldir=${withval}
  66. AC_PATH_KERNEL_SOURCE_SEARCH,
  67. ac_kerneldir=""
  68. AC_CACHE_VAL(ac_cv_have_kernel,AC_PATH_KERNEL_SOURCE_SEARCH)
  69. )
  70. eval "$ac_cv_have_kernel"
  71. AC_SUBST(kerneldir)
  72. AC_SUBST(kernelext)
  73. AC_MSG_RESULT(${kerneldir})
  74. ]
  75. )