]> git.proxmox.com Git - mirror_zfs.git/blob - configure.ac
- Properly fix the debug support for all the ASSERT's, VERIFIES, etc can be
[mirror_zfs.git] / configure.ac
1 AC_INIT
2
3 AC_CANONICAL_SYSTEM
4 AM_INIT_AUTOMAKE(spl, 0.2.2)
5 AC_CONFIG_HEADERS([config.h])
6
7 AC_PROG_INSTALL
8 AC_PROG_CC
9 AC_PROG_LIBTOOL
10
11 kernelsrc=
12 kernelbuild=
13
14 AC_DEFUN([SPL_AC_KERNEL], [
15 ver=`uname -r`
16
17 AC_ARG_WITH([linux],
18 AS_HELP_STRING([--with-linux=PATH],
19 [Path to kernel source]),
20 [kernelsrc="$withval"; kernelbuild="$withval"])
21
22 AC_ARG_WITH([linux-build],
23 AS_HELP_STRING([--with-linux-obj=PATH],
24 [Path to kernel build objects]),
25 [kernelbuild="$withval"])
26
27 AC_MSG_CHECKING([kernel source directory])
28 if test -z "$kernelsrc"; then
29 kernelbuild=
30 sourcelink=/lib/modules/${ver}/source
31 buildlink=/lib/modules/${ver}/build
32
33 if test -e $sourcelink; then
34 kernelsrc=`(cd $sourcelink; /bin/pwd)`
35 fi
36 if test -e $buildlink; then
37 kernelbuild=`(cd $buildlink; /bin/pwd)`
38 fi
39 if test -z "$kernelsrc"; then
40 kernelsrc=$kernelbuild
41 fi
42 if test -z "$kernelsrc" -o -z "$kernelbuild"; then
43 AC_MSG_RESULT([Not found])
44 AC_MSG_ERROR([
45 *** Please specify the location of the kernel source
46 *** with the '--with-kernel=PATH' option])
47 fi
48 fi
49
50 AC_MSG_RESULT([$kernelsrc])
51 AC_MSG_CHECKING([kernel build directory])
52 AC_MSG_RESULT([$kernelbuild])
53
54 AC_MSG_CHECKING([kernel source version])
55 if test -r $kernelbuild/include/linux/version.h &&
56 fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then
57
58 kernsrcver=`(echo "#include <linux/version.h>";
59 echo "kernsrcver=UTS_RELEASE") |
60 cpp -I $kernelbuild/include |
61 grep "^kernsrcver=" | cut -d \" -f 2`
62
63 elif test -r $kernelbuild/include/linux/utsrelease.h &&
64 fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then
65
66 kernsrcver=`(echo "#include <linux/utsrelease.h>";
67 echo "kernsrcver=UTS_RELEASE") |
68 cpp -I $kernelbuild/include |
69 grep "^kernsrcver=" | cut -d \" -f 2`
70 fi
71
72 if test -z "$kernsrcver"; then
73 AC_MSG_RESULT([Not found])
74 AC_MSG_ERROR([
75 *** Cannot determine the version of the linux kernel source.
76 *** Please prepare the kernel before running this script])
77 fi
78
79 AC_MSG_RESULT([$kernsrcver])
80 kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver
81 AC_SUBST(kernelsrc)
82 AC_SUBST(kmoduledir)
83 ])
84
85 AC_DEFUN([SPL_AC_DEBUG], [
86 AC_MSG_CHECKING([whether debugging is enabled])
87 AC_ARG_ENABLE( [debug],
88 AS_HELP_STRING([--enable-debug],
89 [Enable generic debug support (default off)]),
90 [ case "$enableval" in
91 yes) spl_ac_debug=yes ;;
92 no) spl_ac_debug=no ;;
93 *) AC_MSG_RESULT([Error!])
94 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;;
95 esac ]
96 )
97 if test "$spl_ac_debug" = yes; then
98 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG"
99 else
100 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG"
101 AC_DEFINE([NDEBUG], [1],
102 [Define to 1 to disable debug tracing])
103 fi
104 AC_MSG_RESULT([${spl_ac_debug=no}])
105 ])
106
107 AC_DEFUN([SPL_AC_DEBUG_KMEM], [
108 AC_MSG_CHECKING([whether kmem debugging is enabled])
109 AC_ARG_ENABLE( [debug-kmem],
110 AS_HELP_STRING([--enable-debug-kmem],
111 [Enable kmem debug support (default off)]),
112 [ case "$enableval" in
113 yes) spl_ac_debug=yes ;;
114 no) spl_ac_debug=no ;;
115 *) AC_MSG_RESULT([Error!])
116 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;;
117 esac ]
118 )
119 if test "$spl_ac_debug" = yes; then
120 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM"
121 AC_DEFINE([DEBUG_KMEM], [1],
122 [Define to 1 to enable kmem debugging])
123 fi
124 AC_MSG_RESULT([${spl_ac_debug=no}])
125 ])
126
127 AC_DEFUN([SPL_AC_DEBUG_MUTEX], [
128 AC_MSG_CHECKING([whether mutex debugging is enabled])
129 AC_ARG_ENABLE( [debug-mutex],
130 AS_HELP_STRING([--enable-debug-mutex],
131 [Enable mutex debug support (default off)]),
132 [ case "$enableval" in
133 yes) spl_ac_debug=yes ;;
134 no) spl_ac_debug=no ;;
135 *) AC_MSG_RESULT([Error!])
136 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;;
137 esac ]
138 )
139 if test "$spl_ac_debug" = yes; then
140 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX"
141 AC_DEFINE([DEBUG_MUTEX], [1],
142 [Define to 1 to enable mutex debugging])
143 fi
144 AC_MSG_RESULT([${spl_ac_debug=no}])
145 ])
146
147 AC_DEFUN([SPL_AC_DEBUG_KSTAT], [
148 AC_MSG_CHECKING([whether kstat debugging is enabled])
149 AC_ARG_ENABLE( [debug-kstat],
150 AS_HELP_STRING([--enable-debug-kstat],
151 [Enable kstat debug support (default off)]),
152 [ case "$enableval" in
153 yes) spl_ac_debug=yes ;;
154 no) spl_ac_debug=no ;;
155 *) AC_MSG_RESULT([Error!])
156 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;;
157 esac ]
158 )
159 if test "$spl_ac_debug" = yes; then
160 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT"
161 AC_DEFINE([DEBUG_KSTAT], [1],
162 [Define to 1 to enable kstat debugging])
163 fi
164 AC_MSG_RESULT([${spl_ac_debug=no}])
165 ])
166
167 AC_DEFUN([SPL_AC_DEBUG_CALLB], [
168 AC_MSG_CHECKING([whether callb debugging is enabled])
169 AC_ARG_ENABLE( [debug-callb],
170 AS_HELP_STRING([--enable-debug-callb],
171 [Enable callb debug support (default off)]),
172 [ case "$enableval" in
173 yes) spl_ac_debug=yes ;;
174 no) spl_ac_debug=no ;;
175 *) AC_MSG_RESULT([Error!])
176 AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;;
177 esac ]
178 )
179 if test "$spl_ac_debug" = yes; then
180 KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB"
181 AC_DEFINE([DEBUG_CALLB], [1],
182 [Define to 1 to enable callb debugging])
183 fi
184 AC_MSG_RESULT([${spl_ac_debug=no}])
185 ])
186
187 SPL_AC_KERNEL
188 SPL_AC_DEBUG
189 SPL_AC_DEBUG_KMEM
190 SPL_AC_DEBUG_MUTEX
191 SPL_AC_DEBUG_KSTAT
192 SPL_AC_DEBUG_CALLB
193
194 TOPDIR=`/bin/pwd`
195
196 # Add "V=1" to KERNELMAKE_PARAMS to enable verbose module build
197 KERNELMAKE_PARAMS=
198 KERNELCPPFLAGS="${KERNELCPPFLAGS} -I$TOPDIR -I$TOPDIR/include"
199
200 if test "$kernelbuild" != "$kernelsrc"; then
201 KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$kernelbuild"
202 fi
203
204 AC_SUBST(KERNELMAKE_PARAMS)
205 AC_SUBST(KERNELCPPFLAGS)
206 AC_SUBST(KERNELCFLAGS)
207
208 AC_CONFIG_FILES([ Makefile
209 lib/Makefile
210 cmd/Makefile
211 modules/Makefile
212 modules/spl/Makefile
213 modules/splat/Makefile
214 include/Makefile
215 include/sys/Makefile
216 scripts/Makefile
217 scripts/spl.spec
218 ])
219
220 AC_OUTPUT