]>
Commit | Line | Data |
---|---|---|
715f6251 | 1 | /* |
2 | * This file is part of the SPL: Solaris Porting Layer. | |
3 | * | |
4 | * Copyright (c) 2008 Lawrence Livermore National Security, LLC. | |
5 | * Produced at Lawrence Livermore National Laboratory | |
6 | * Written by: | |
7 | * Brian Behlendorf <behlendorf1@llnl.gov>, | |
8 | * Herb Wartens <wartens2@llnl.gov>, | |
9 | * Jim Garlick <garlick@llnl.gov> | |
10 | * UCRL-CODE-235197 | |
11 | * | |
12 | * This is free software; you can redistribute it and/or modify it | |
13 | * under the terms of the GNU General Public License as published by | |
14 | * the Free Software Foundation; either version 2 of the License, or | |
15 | * (at your option) any later version. | |
16 | * | |
17 | * This is distributed in the hope that it will be useful, but WITHOUT | |
18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
19 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
20 | * for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU General Public License along | |
23 | * with this program; if not, write to the Free Software Foundation, Inc., | |
24 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
25 | */ | |
26 | ||
f1ca4da6 | 27 | AC_INIT |
28 | ||
29 | AC_CANONICAL_SYSTEM | |
65a045da | 30 | AM_INIT_AUTOMAKE(spl, 0.3.1) |
f4b37741 | 31 | AC_CONFIG_HEADERS([config.h]) |
f1ca4da6 | 32 | |
33 | AC_PROG_INSTALL | |
34 | AC_PROG_CC | |
564f6d15 | 35 | AC_PROG_LIBTOOL |
f1ca4da6 | 36 | |
f1ca4da6 | 37 | kernelsrc= |
38 | kernelbuild= | |
cc7449cc | 39 | |
40 | AC_DEFUN([SPL_AC_KERNEL], [ | |
41 | ver=`uname -r` | |
42 | ||
43 | AC_ARG_WITH([linux], | |
44 | AS_HELP_STRING([--with-linux=PATH], | |
45 | [Path to kernel source]), | |
46 | [kernelsrc="$withval"; kernelbuild="$withval"]) | |
47 | ||
b2585b36 | 48 | AC_ARG_WITH([linux-obj], |
cc7449cc | 49 | AS_HELP_STRING([--with-linux-obj=PATH], |
50 | [Path to kernel build objects]), | |
51 | [kernelbuild="$withval"]) | |
52 | ||
53 | AC_MSG_CHECKING([kernel source directory]) | |
f1ca4da6 | 54 | if test -z "$kernelsrc"; then |
cc7449cc | 55 | kernelbuild= |
56 | sourcelink=/lib/modules/${ver}/source | |
57 | buildlink=/lib/modules/${ver}/build | |
58 | ||
59 | if test -e $sourcelink; then | |
60 | kernelsrc=`(cd $sourcelink; /bin/pwd)` | |
61 | fi | |
62 | if test -e $buildlink; then | |
63 | kernelbuild=`(cd $buildlink; /bin/pwd)` | |
64 | fi | |
65 | if test -z "$kernelsrc"; then | |
66 | kernelsrc=$kernelbuild | |
67 | fi | |
68 | if test -z "$kernelsrc" -o -z "$kernelbuild"; then | |
69 | AC_MSG_RESULT([Not found]) | |
70 | AC_MSG_ERROR([ | |
f1ca4da6 | 71 | *** Please specify the location of the kernel source |
72 | *** with the '--with-kernel=PATH' option]) | |
cc7449cc | 73 | fi |
f1ca4da6 | 74 | fi |
f1ca4da6 | 75 | |
cc7449cc | 76 | AC_MSG_RESULT([$kernelsrc]) |
77 | AC_MSG_CHECKING([kernel build directory]) | |
78 | AC_MSG_RESULT([$kernelbuild]) | |
f1ca4da6 | 79 | |
cc7449cc | 80 | AC_MSG_CHECKING([kernel source version]) |
81 | if test -r $kernelbuild/include/linux/version.h && | |
82 | fgrep -q UTS_RELEASE $kernelbuild/include/linux/version.h; then | |
f1ca4da6 | 83 | |
cc7449cc | 84 | kernsrcver=`(echo "#include <linux/version.h>"; |
85 | echo "kernsrcver=UTS_RELEASE") | | |
86 | cpp -I $kernelbuild/include | | |
87 | grep "^kernsrcver=" | cut -d \" -f 2` | |
f1ca4da6 | 88 | |
cc7449cc | 89 | elif test -r $kernelbuild/include/linux/utsrelease.h && |
90 | fgrep -q UTS_RELEASE $kernelbuild/include/linux/utsrelease.h; then | |
f1ca4da6 | 91 | |
cc7449cc | 92 | kernsrcver=`(echo "#include <linux/utsrelease.h>"; |
93 | echo "kernsrcver=UTS_RELEASE") | | |
94 | cpp -I $kernelbuild/include | | |
95 | grep "^kernsrcver=" | cut -d \" -f 2` | |
96 | fi | |
f1ca4da6 | 97 | |
cc7449cc | 98 | if test -z "$kernsrcver"; then |
99 | AC_MSG_RESULT([Not found]) | |
100 | AC_MSG_ERROR([ | |
f1ca4da6 | 101 | *** Cannot determine the version of the linux kernel source. |
102 | *** Please prepare the kernel before running this script]) | |
cc7449cc | 103 | fi |
f1ca4da6 | 104 | |
cc7449cc | 105 | AC_MSG_RESULT([$kernsrcver]) |
106 | kmoduledir=${INSTALL_MOD_PATH}/lib/modules/$kernsrcver | |
107 | AC_SUBST(kernelsrc) | |
108 | AC_SUBST(kmoduledir) | |
109 | ]) | |
110 | ||
111 | AC_DEFUN([SPL_AC_DEBUG], [ | |
112 | AC_MSG_CHECKING([whether debugging is enabled]) | |
113 | AC_ARG_ENABLE( [debug], | |
114 | AS_HELP_STRING([--enable-debug], | |
115 | [Enable generic debug support (default off)]), | |
116 | [ case "$enableval" in | |
117 | yes) spl_ac_debug=yes ;; | |
118 | no) spl_ac_debug=no ;; | |
119 | *) AC_MSG_RESULT([Error!]) | |
120 | AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;; | |
121 | esac ] | |
122 | ) | |
123 | if test "$spl_ac_debug" = yes; then | |
124 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG" | |
125 | else | |
126 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG" | |
127 | AC_DEFINE([NDEBUG], [1], | |
128 | [Define to 1 to disable debug tracing]) | |
129 | fi | |
130 | AC_MSG_RESULT([${spl_ac_debug=no}]) | |
131 | ]) | |
132 | ||
133 | AC_DEFUN([SPL_AC_DEBUG_KMEM], [ | |
134 | AC_MSG_CHECKING([whether kmem debugging is enabled]) | |
135 | AC_ARG_ENABLE( [debug-kmem], | |
136 | AS_HELP_STRING([--enable-debug-kmem], | |
137 | [Enable kmem debug support (default off)]), | |
138 | [ case "$enableval" in | |
139 | yes) spl_ac_debug=yes ;; | |
140 | no) spl_ac_debug=no ;; | |
141 | *) AC_MSG_RESULT([Error!]) | |
142 | AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kmem]) ;; | |
143 | esac ] | |
144 | ) | |
145 | if test "$spl_ac_debug" = yes; then | |
146 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KMEM" | |
147 | AC_DEFINE([DEBUG_KMEM], [1], | |
148 | [Define to 1 to enable kmem debugging]) | |
149 | fi | |
150 | AC_MSG_RESULT([${spl_ac_debug=no}]) | |
151 | ]) | |
152 | ||
153 | AC_DEFUN([SPL_AC_DEBUG_MUTEX], [ | |
154 | AC_MSG_CHECKING([whether mutex debugging is enabled]) | |
155 | AC_ARG_ENABLE( [debug-mutex], | |
156 | AS_HELP_STRING([--enable-debug-mutex], | |
157 | [Enable mutex debug support (default off)]), | |
158 | [ case "$enableval" in | |
159 | yes) spl_ac_debug=yes ;; | |
160 | no) spl_ac_debug=no ;; | |
161 | *) AC_MSG_RESULT([Error!]) | |
162 | AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-mutex]) ;; | |
163 | esac ] | |
164 | ) | |
165 | if test "$spl_ac_debug" = yes; then | |
166 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_MUTEX" | |
167 | AC_DEFINE([DEBUG_MUTEX], [1], | |
168 | [Define to 1 to enable mutex debugging]) | |
169 | fi | |
170 | AC_MSG_RESULT([${spl_ac_debug=no}]) | |
171 | ]) | |
172 | ||
173 | AC_DEFUN([SPL_AC_DEBUG_KSTAT], [ | |
174 | AC_MSG_CHECKING([whether kstat debugging is enabled]) | |
175 | AC_ARG_ENABLE( [debug-kstat], | |
176 | AS_HELP_STRING([--enable-debug-kstat], | |
177 | [Enable kstat debug support (default off)]), | |
178 | [ case "$enableval" in | |
179 | yes) spl_ac_debug=yes ;; | |
180 | no) spl_ac_debug=no ;; | |
181 | *) AC_MSG_RESULT([Error!]) | |
182 | AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-kstat]) ;; | |
183 | esac ] | |
184 | ) | |
185 | if test "$spl_ac_debug" = yes; then | |
186 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_KSTAT" | |
187 | AC_DEFINE([DEBUG_KSTAT], [1], | |
188 | [Define to 1 to enable kstat debugging]) | |
189 | fi | |
190 | AC_MSG_RESULT([${spl_ac_debug=no}]) | |
191 | ]) | |
192 | ||
193 | AC_DEFUN([SPL_AC_DEBUG_CALLB], [ | |
194 | AC_MSG_CHECKING([whether callb debugging is enabled]) | |
195 | AC_ARG_ENABLE( [debug-callb], | |
196 | AS_HELP_STRING([--enable-debug-callb], | |
197 | [Enable callb debug support (default off)]), | |
198 | [ case "$enableval" in | |
199 | yes) spl_ac_debug=yes ;; | |
200 | no) spl_ac_debug=no ;; | |
201 | *) AC_MSG_RESULT([Error!]) | |
202 | AC_MSG_ERROR([Bad value "$enableval" for --enable-debug-callb]) ;; | |
203 | esac ] | |
204 | ) | |
205 | if test "$spl_ac_debug" = yes; then | |
206 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG_CALLB" | |
207 | AC_DEFINE([DEBUG_CALLB], [1], | |
208 | [Define to 1 to enable callb debugging]) | |
209 | fi | |
210 | AC_MSG_RESULT([${spl_ac_debug=no}]) | |
211 | ]) | |
f1ca4da6 | 212 | |
cc7449cc | 213 | SPL_AC_KERNEL |
214 | SPL_AC_DEBUG | |
215 | SPL_AC_DEBUG_KMEM | |
216 | SPL_AC_DEBUG_MUTEX | |
217 | SPL_AC_DEBUG_KSTAT | |
218 | SPL_AC_DEBUG_CALLB | |
f1ca4da6 | 219 | |
d5f087ad | 220 | TOPDIR=`/bin/pwd` |
221 | ||
3d4ea0ce | 222 | # Add "V=1" to KERNELMAKE_PARAMS to enable verbose module build |
223 | KERNELMAKE_PARAMS= | |
cc7449cc | 224 | KERNELCPPFLAGS="${KERNELCPPFLAGS} -I$TOPDIR -I$TOPDIR/include" |
3d4ea0ce | 225 | |
f1ca4da6 | 226 | if test "$kernelbuild" != "$kernelsrc"; then |
227 | KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$kernelbuild" | |
228 | fi | |
229 | ||
230 | AC_SUBST(KERNELMAKE_PARAMS) | |
231 | AC_SUBST(KERNELCPPFLAGS) | |
232 | AC_SUBST(KERNELCFLAGS) | |
233 | ||
234 | AC_CONFIG_FILES([ Makefile | |
a0aadf56 | 235 | lib/Makefile |
236 | cmd/Makefile | |
237 | modules/Makefile | |
238 | modules/spl/Makefile | |
239 | modules/splat/Makefile | |
f1ca4da6 | 240 | include/Makefile |
f4b37741 | 241 | include/sys/Makefile |
f1ca4da6 | 242 | scripts/Makefile |
243 | scripts/spl.spec | |
244 | ]) | |
245 | ||
246 | AC_OUTPUT |