]>
Commit | Line | Data |
---|---|---|
f1ca4da6 | 1 | AC_INIT |
2 | ||
3 | AC_CANONICAL_SYSTEM | |
4 | AM_INIT_AUTOMAKE(spl, 0.0.1) | |
5 | AC_CONFIG_HEADERS([config.h]) | |
6 | ||
7 | AC_PROG_INSTALL | |
8 | AC_PROG_CC | |
9 | ||
10 | ver=`uname -r` | |
11 | KERNELCFLAGS= | |
12 | ||
13 | kernelsrc= | |
14 | kernelbuild= | |
15 | AC_ARG_WITH(kernel, | |
16 | [ --with-linux=PATH Path to kernel source ], | |
17 | [kernelsrc="$withval"; kernelbuild="$withval"]) | |
18 | AC_ARG_WITH(kernel-build, | |
19 | [ --with-linux-obj=PATH Path to kernel build objects ], | |
20 | [kernelbuild="$withval"]) | |
21 | ||
22 | AC_MSG_CHECKING([kernel source directory]) | |
23 | if test -z "$kernelsrc"; then | |
24 | kernelbuild= | |
25 | sourcelink=/lib/modules/${ver}/source | |
26 | buildlink=/lib/modules/${ver}/build | |
27 | ||
28 | if test -e $sourcelink; then | |
29 | kernelsrc=`(cd $sourcelink; /bin/pwd)` | |
30 | fi | |
31 | if test -e $buildlink; then | |
32 | kernelbuild=`(cd $buildlink; /bin/pwd)` | |
33 | fi | |
34 | if test -z "$kernelsrc"; then | |
35 | kernelsrc=$kernelbuild | |
36 | fi | |
37 | if test -z "$kernelsrc" -o -z "$kernelbuild"; then | |
38 | AC_MSG_RESULT([Not found]) | |
39 | AC_MSG_ERROR([ | |
40 | *** Please specify the location of the kernel source | |
41 | *** with the '--with-kernel=PATH' option]) | |
42 | fi | |
43 | fi | |
44 | ||
45 | AC_MSG_RESULT([$kernelsrc]) | |
46 | AC_MSG_CHECKING([kernel build directory]) | |
47 | AC_MSG_RESULT([$kernelbuild]) | |
48 | ||
49 | AC_MSG_CHECKING([kernel source version]) | |
50 | if test -r $kernelbuild/include/linux/version.h && | |
51 | fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then | |
52 | ||
53 | kernsrcver=`(echo "#include <linux/version.h>"; | |
54 | echo "kernsrcver=UTS_RELEASE") | | |
55 | cpp -I $kernelbuild/include | | |
56 | grep "^kernsrcver=" | cut -d \" -f 2` | |
57 | ||
58 | elif test -r $kernelbuild/include/linux/utsrelease.h && | |
59 | fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then | |
60 | ||
61 | kernsrcver=`(echo "#include <linux/utsrelease.h>"; | |
62 | echo "kernsrcver=UTS_RELEASE") | | |
63 | cpp -I $kernelbuild/include | | |
64 | grep "^kernsrcver=" | cut -d \" -f 2` | |
65 | fi | |
66 | ||
67 | if test -z "$kernsrcver"; then | |
68 | AC_MSG_RESULT([Not found]) | |
69 | AC_MSG_ERROR([ | |
70 | *** Cannot determine the version of the linux kernel source. | |
71 | *** Please prepare the kernel before running this script]) | |
72 | fi | |
73 | ||
74 | AC_MSG_RESULT([$kernsrcver]) | |
75 | kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver | |
76 | AC_SUBST(kernelsrc) | |
77 | AC_SUBST(kmoduledir) | |
78 | ||
79 | # | |
80 | # Each version of the kernel provides a slightly different | |
81 | # ABI, so figure out what we have to work with and adapt. | |
82 | # | |
83 | AC_MSG_CHECKING([if kernel defines kzalloc function]) | |
84 | if egrep -qw "kzalloc" $kernelsrc/include/linux/slab.h; then | |
85 | AC_DEFINE(HAVE_KZALLOC, 1, [kzalloc() is defined]) | |
86 | AC_MSG_RESULT([yes]) | |
87 | else | |
88 | AC_MSG_RESULT([no]) | |
89 | fi | |
90 | ||
91 | AC_MSG_CHECKING([if inode has i_private field]) | |
92 | if egrep -qw "i_private" $kernelsrc/include/linux/fs.h; then | |
93 | AC_DEFINE(HAVE_I_PRIVATE, 1, [inode has i_private field]) | |
94 | AC_MSG_RESULT([yes]) | |
95 | else | |
96 | AC_MSG_RESULT([no]) | |
97 | fi | |
98 | ||
99 | AC_MSG_CHECKING([if inode has i_mutex field ]) | |
100 | if egrep -qw "i_mutex" $kernelsrc/include/linux/fs.h; then | |
101 | AC_DEFINE(HAVE_I_MUTEX, 1, [inode has i_mutex field]) | |
102 | AC_MSG_RESULT([yes]) | |
103 | else | |
104 | AC_MSG_RESULT([no]) | |
105 | fi | |
106 | ||
107 | AC_MSG_CHECKING([if kernel has mutex.h ]) | |
108 | if test -f $kernelsrc/include/linux/mutex.h; then | |
109 | AC_DEFINE(HAVE_MUTEX_H, 1, [kernel has mutex.h]) | |
110 | AC_MSG_RESULT([yes]) | |
111 | else | |
112 | AC_MSG_RESULT([no]) | |
113 | fi | |
114 | ||
115 | if test "$kernelbuild" != "$kernelsrc"; then | |
116 | KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$kernelbuild" | |
117 | fi | |
118 | ||
119 | AC_SUBST(KERNELMAKE_PARAMS) | |
120 | AC_SUBST(KERNELCPPFLAGS) | |
121 | AC_SUBST(KERNELCFLAGS) | |
122 | ||
123 | AC_CONFIG_FILES([ Makefile | |
124 | src/Makefile | |
125 | src/cmd/Makefile | |
126 | src/spl/Makefile | |
127 | src/splat/Makefile | |
128 | include/Makefile | |
129 | scripts/Makefile | |
130 | scripts/spl.spec | |
131 | ]) | |
132 | ||
133 | AC_OUTPUT |