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