34 [ |
34 [ |
35 version=[`uname -r`] |
35 version=[`uname -r`] |
36 modulesdir=/lib/modules/${version} |
36 modulesdir=/lib/modules/${version} |
37 if test \! -d ${modulesdir} || test \! -d ${modulesdir}/build; then |
37 if test \! -d ${modulesdir} || test \! -d ${modulesdir}/build; then |
38 echo |
38 echo |
39 AC_MSG_ERROR([Invalid modules directory ${modulesdir}]) |
39 AC_MSG_ERROR([Failed to find Linux sources. Use --with-linux-dir!]) |
40 fi |
40 fi |
41 sourcedir=`cd ${modulesdir}/build && pwd -P` |
41 sourcedir=`cd ${modulesdir}/build && pwd -P` |
42 ] |
42 ] |
43 ) |
43 ) |
44 |
44 |
45 AC_MSG_CHECKING([for Linux kernel sources]) |
45 AC_MSG_CHECKING([for Linux kernel sources]) |
46 |
46 |
47 if test \! -r ${sourcedir}/.config; then |
47 if test \! -r ${sourcedir}/.config; then |
48 echo |
48 echo |
49 AC_MSG_ERROR([No configured Linux kernel sources in $sourcedir]) |
49 AC_MSG_ERROR([No configured Linux kernel sources in $sourcedir]) |
50 fi |
50 fi |
51 |
51 |
|
52 # Try to get kernel release string |
|
53 if test -r ${sourcedir}/.kernelrelease; then |
|
54 kernelrelease=`cat $sourcedir/.kernelrelease` |
|
55 elif test -r ${sourcedir}/include/linux/version.h; then |
|
56 hdr=$sourcedir/include/linux/version.h |
|
57 kernelrelease=`grep UTS_RELEASE $hdr | cut -d " " -f 3- | tr -d \"` |
|
58 fi |
|
59 |
|
60 if test -z "$kernelrelease"; then |
|
61 echo |
|
62 AC_MSG_ERROR([Failed to extract Linux kernel version!]) |
|
63 fi |
|
64 |
|
65 # Extract three numbers from kernel release string |
|
66 linuxversion=`echo $kernelrelease | grep -oE [[0-9]]+\.[[0-9]]+\.[[0-9]]+` |
|
67 |
52 AC_SUBST(LINUX_SOURCE_DIR,[$sourcedir]) |
68 AC_SUBST(LINUX_SOURCE_DIR,[$sourcedir]) |
53 AC_MSG_RESULT($LINUX_SOURCE_DIR) |
69 AC_SUBST(LINUX_KERNEL_RELEASE,[$kernelrelease]) |
|
70 AC_SUBST(LINUX_KERNEL_VERSION,[$linuxversion]) |
|
71 AC_SUBST(LINUX_MOD_PATH,[/lib/modules/$kernelrelease/ethercat]) |
|
72 AC_MSG_RESULT([$LINUX_SOURCE_DIR (Kernel $LINUX_KERNEL_RELEASE)]) |
54 |
73 |
55 #------------------------------------------------------------------------------ |
74 #------------------------------------------------------------------------------ |
56 # Debug interface |
75 # Debug interface |
57 #------------------------------------------------------------------------------ |
76 #------------------------------------------------------------------------------ |
58 |
77 |