Whamcloud - gitweb
build: explicitly declare AC_KERBEROS_V5 be a valid macro.
[fs/lustre-release.git] / build / autoconf / lustre-build-linux.m4
1 m4_pattern_allow(AC_KERBEROS_V5)
2
3 #
4 # LB_LINUX_VERSION
5 #
6 # Set things accordingly for a 2.5 kernel
7 #
8 AC_DEFUN([LB_LINUX_VERSION],
9 [LB_CHECK_FILE([$LINUX/include/linux/namei.h],
10         [
11                 linux25="yes"
12                 KMODEXT=".ko"
13         ],[
14                 KMODEXT=".o"
15                 linux25="no"
16         ])
17 AC_MSG_CHECKING([if you are using Linux 2.6])
18 AC_MSG_RESULT([$linux25])
19
20 MODULE_TARGET="SUBDIRS"
21 if test $linux25 = "yes" ; then
22         makerule="$PWD/build"
23         AC_MSG_CHECKING([for external module build support])
24         rm -f build/conftest.i
25         LB_LINUX_TRY_MAKE([],[],
26                 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
27                 [test -s build/conftest.i],
28                 [
29                         AC_MSG_RESULT([no])
30                 ],[
31                         makerule="_module_$makerule"
32                         MODULE_TARGET="M"
33                         LB_LINUX_TRY_MAKE([],[],
34                                 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
35                                 [test -s build/conftest.i],
36                                 [
37                                         AC_MSG_RESULT([yes])
38                                 ],[
39                                         AC_MSG_ERROR([unknown; check config.log for details])
40                                 ])
41                 ])
42 else
43         makerule="_dir_$PWD/build"
44 fi
45
46 AC_SUBST(MODULE_TARGET)
47 AC_SUBST(linux25)
48 AC_SUBST(KMODEXT)
49 ])
50
51 #
52 # LB_LINUX_RELEASE
53 #
54 # get the release version of linux
55 #
56 AC_DEFUN([LB_LINUX_RELEASE],
57 [LINUXRELEASE=
58 rm -f build/conftest.i
59 AC_MSG_CHECKING([for Linux release])
60 if test -s $LINUX_OBJ/include/linux/utsrelease.h ; then
61         LINUXRELEASEHEADER=utsrelease.h
62 else
63         LINUXRELEASEHEADER=version.h
64 fi
65 LB_LINUX_TRY_MAKE([
66         #include <linux/$LINUXRELEASEHEADER>
67 ],[
68         char *LINUXRELEASE;
69         LINUXRELEASE=UTS_RELEASE;
70 ],[
71         $makerule LUSTRE_KERNEL_TEST=conftest.i
72 ],[
73         test -s build/conftest.i
74 ],[
75         # LINUXRELEASE="UTS_RELEASE"
76         eval $(grep "LINUXRELEASE=" build/conftest.i)
77 ],[
78         AC_MSG_RESULT([unknown])
79         AC_MSG_ERROR([Could not preprocess test program.  Consult config.log for details.])
80 ])
81 rm -f build/conftest.i
82 if test x$LINUXRELEASE = x ; then
83         AC_MSG_RESULT([unknown])
84         AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
85 fi
86 AC_MSG_RESULT([$LINUXRELEASE])
87 AC_SUBST(LINUXRELEASE)
88
89 moduledir='/lib/modules/'$LINUXRELEASE/kernel
90 AC_SUBST(moduledir)
91
92 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
93 AC_SUBST(modulefsdir)
94
95 modulenetdir='$(moduledir)/net/$(PACKAGE)'
96 AC_SUBST(modulenetdir)
97
98 # ------------ RELEASE --------------------------------
99 AC_MSG_CHECKING([for Lustre release])
100 RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
101 AC_MSG_RESULT($RELEASE)
102 AC_SUBST(RELEASE)
103 ])
104
105 #
106 # LB_LINUX_PATH
107 #
108 # Find paths for linux, handling kernel-source rpms
109 #
110 AC_DEFUN([LB_LINUX_PATH],
111 [AC_MSG_CHECKING([for Linux sources])
112 AC_ARG_WITH([linux],
113         AC_HELP_STRING([--with-linux=path],
114                        [set path to Linux source (default=/usr/src/linux)]),
115         [LINUX=$with_linux],
116         [LINUX=/usr/src/linux])
117 AC_MSG_RESULT([$LINUX])
118 AC_SUBST(LINUX)
119
120 # -------- check for linux --------
121 LB_CHECK_FILE([$LINUX],[],
122         [AC_MSG_ERROR([Kernel source $LINUX could not be found.])])
123
124 # -------- linux objects (for 2.6) --
125 AC_MSG_CHECKING([for Linux objects dir])
126 AC_ARG_WITH([linux-obj],
127         AC_HELP_STRING([--with-linux-obj=path],
128                         [set path to Linux objects dir (default=$LINUX)]),
129         [LINUX_OBJ=$with_linux_obj],
130         [LINUX_OBJ=$LINUX])
131 AC_MSG_RESULT([$LINUX_OBJ])
132 AC_SUBST(LINUX_OBJ)
133
134 # -------- check for .config --------
135 AC_ARG_WITH([linux-config],
136         [AC_HELP_STRING([--with-linux-config=path],
137                         [set path to Linux .conf (default=$LINUX_OBJ/.config)])],
138         [LINUX_CONFIG=$with_linux_config],
139         [LINUX_CONFIG=$LINUX_OBJ/.config])
140 AC_SUBST(LINUX_CONFIG)
141
142 LB_CHECK_FILE([/boot/kernel.h],
143         [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
144         [LB_CHECK_FILE([/var/adm/running-kernel.h],
145                 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h'])])
146
147 AC_ARG_WITH([kernel-source-header],
148         AC_HELP_STRING([--with-kernel-source-header=path],
149                         [Use a different kernel version header.  Consult build/README.kernel-source for details.]),
150         [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
151
152 # ------------ .config exists ----------------
153 LB_CHECK_FILE([$LINUX_CONFIG],[],
154         [AC_MSG_ERROR([Kernel config could not be found.  If you are building from a kernel-source rpm consult build/README.kernel-source])])
155
156 # ----------- make dep run? ------------------
157 LB_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
158                 $LINUX_OBJ/include/linux/version.h
159                 $LINUX/include/linux/config.h],[],
160         [AC_MSG_ERROR([Run make config in $LINUX.])])
161
162 # ------------ rhconfig.h includes runtime-generated bits --
163 # red hat kernel-source checks
164
165 # we know this exists after the check above.  if the user
166 # tarred up the tree and ran make dep etc. in it, then
167 # version.h gets overwritten with a standard linux one.
168
169 if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then
170         # This is a clean kernel-source tree, we need to
171         # enable extensive workarounds to get this to build
172         # modules
173         LB_CHECK_FILE([$KERNEL_SOURCE_HEADER],
174                 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
175                         AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
176                         AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
177                         AC_MSG_WARN([Consult build/README.kernel-source for details.])
178                 fi],
179                 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found.  Consult build/README.kernel-source for details.])])
180         EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
181 fi
182
183 # this is needed before we can build modules
184 LB_LINUX_UML
185 LB_LINUX_VERSION
186
187 # --- check that we can build modules at all
188 AC_MSG_CHECKING([that modules can be built at all])
189 LB_LINUX_TRY_COMPILE([],[],[
190         AC_MSG_RESULT([yes])
191 ],[
192         AC_MSG_RESULT([no])
193         AC_MSG_WARN([Consult config.log for details.])
194         AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult build/README.kernel-source])
195         AC_MSG_ERROR([Kernel modules cannot be build.])
196 ])
197
198 LB_LINUX_RELEASE
199 ])
200
201 #
202 # LB_LINUX_UML
203 #
204 # check for a uml kernel
205 #
206 AC_DEFUN([LB_LINUX_UML],
207 [ARCH_UM=
208 UML_CFLAGS=
209
210 AC_MSG_CHECKING([if you are running user mode linux for $target_cpu])
211 if test -e $LINUX/include/asm-um ; then
212         if test  X`ls -id $LINUX/include/asm/ 2>/dev/null | awk '{print [$]1}'` = X`ls -id $LINUX/include/asm-um 2>/dev/null | awk '{print [$]1}'` ; then
213                 ARCH_UM='ARCH=um'
214                 # see notes in Rules.in
215                 UML_CFLAGS='-O0'
216                 AC_MSG_RESULT(yes)
217         else
218                 AC_MSG_RESULT([no (asm doesn't point at asm-um)])
219         fi
220 else
221         AC_MSG_RESULT([no (asm-um missing)])
222 fi
223 AC_SUBST(ARCH_UM)
224 AC_SUBST(UML_CFLAGS)
225 ])
226
227 # these are like AC_TRY_COMPILE, but try to build modules against the
228 # kernel, inside the build directory
229
230 #
231 # LB_LINUX_CONFTEST
232 #
233 # create a conftest.c file
234 #
235 AC_DEFUN([LB_LINUX_CONFTEST],
236 [cat >conftest.c <<_ACEOF
237 $1
238 _ACEOF
239 ])
240
241 #
242 # LB_LINUX_COMPILE_IFELSE
243 #
244 # like AC_COMPILE_IFELSE
245 #
246 AC_DEFUN([LB_LINUX_COMPILE_IFELSE],
247 [m4_ifvaln([$1], [LB_LINUX_CONFTEST([$1])])dnl
248 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
249 AS_IF([AC_TRY_COMMAND(cp conftest.c build && make [$2] CC="$CC" -f $PWD/build/Makefile LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -o tmp_include_depends -o scripts -o include/config/MARKER -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM $MODULE_TARGET=$PWD/build) >/dev/null && AC_TRY_COMMAND([$3])],
250         [$4],
251         [_AC_MSG_LOG_CONFTEST
252 m4_ifvaln([$5],[$5])dnl])dnl
253 rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest.ko m4_ifval([$1], [build/conftest.c conftest.c])[]dnl
254 ])
255
256 #
257 # LB_LINUX_TRY_COMPILE
258 #
259 # like AC_TRY_COMPILE
260 #
261 AC_DEFUN([LB_LINUX_TRY_COMPILE],
262 [LB_LINUX_COMPILE_IFELSE(
263         [AC_LANG_PROGRAM([[$1]], [[$2]])],
264         [modules],
265         [test -s build/conftest.o],
266         [$3], [$4])])
267
268 #
269 # LB_LINUX_CONFIG
270 #
271 # check if a given config option is defined
272 #
273 AC_DEFUN([LB_LINUX_CONFIG],
274 [AC_MSG_CHECKING([if Linux was built with CONFIG_$1])
275 LB_LINUX_TRY_COMPILE([#include <linux/config.h>],[
276 #ifndef CONFIG_$1
277 #error CONFIG_$1 not #defined
278 #endif
279 ],[
280 AC_MSG_RESULT([yes])
281 $2
282 ],[
283 AC_MSG_RESULT([no])
284 $3
285 ])
286 ])
287
288 #
289 # LB_LINUX_CONFIG_IM
290 #
291 # check if a given config option is builtin or as module
292 #
293 AC_DEFUN([LB_LINUX_CONFIG_IM],
294 [AC_MSG_CHECKING([if Linux was built with CONFIG_$1 in or as module])
295 LB_LINUX_TRY_COMPILE([#include <linux/config.h>],[
296 #if !(defined(CONFIG_$1) || defined(CONFIG_$1_MODULE))
297 #error CONFIG_$1 and CONFIG_$1_MODULE not #defined
298 #endif
299 ],[
300 AC_MSG_RESULT([yes])
301 $2
302 ],[
303 AC_MSG_RESULT([no])
304 $3
305 ])
306 ])
307
308 #
309 # LB_LINUX_TRY_MAKE
310 #
311 # like LB_LINUX_TRY_COMPILE, but with different arguments
312 #
313 AC_DEFUN([LB_LINUX_TRY_MAKE],
314 [LB_LINUX_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
315
316 #
317 # LB_LINUX_CONFIG_BIG_STACK
318 #
319 # check for big stack patch
320 #
321 AC_DEFUN([LB_LINUX_CONFIG_BIG_STACK],
322 [if test "x$ARCH_UM" = "x" -a "x$linux25" = "xno" ; then
323         case $target_cpu in
324                 i?86 | x86_64)
325                         LB_LINUX_CONFIG([STACK_SIZE_16KB],[],[
326                                 LB_LINUX_CONFIG([STACK_SIZE_32KB],[],[
327                                         LB_LINUX_CONFIG([STACK_SIZE_64KB],[],[
328                                                 AC_MSG_ERROR([Lustre requires that Linux is configured with at least a 16KB stack.])
329                                         ])
330                                 ])
331                         ])
332                         ;;
333         esac
334 fi
335 ])
336
337 #
338 # LB_PROG_LINUX
339 #
340 # linux tests
341 #
342 AC_DEFUN([LB_PROG_LINUX],
343 [LB_LINUX_PATH
344
345 LB_LINUX_CONFIG([MODULES],[],[
346         AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
347 ])
348
349 LB_LINUX_CONFIG([MODVERSIONS])
350
351 LB_LINUX_CONFIG([PREEMPT],[
352         AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
353 ])
354
355 LB_LINUX_CONFIG([KALLSYMS],[],[
356 if test "x$ARCH_UM" = "x" ; then
357         AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
358 fi
359 ])
360
361 LB_LINUX_CONFIG([KMOD],[],[
362         AC_MSG_WARN([])
363         AC_MSG_WARN([Kernel module loading support is highly recommended.])
364         AC_MSG_WARN([])
365 ])
366
367 #
368 # following CRYPTO related are required by capability
369 #
370 LB_LINUX_CONFIG_IM([CRYPTO],[],[
371         AC_MSG_ERROR([Lustre require that CONFIG_CRYPTO is enabled in your kernel.])
372 ])
373
374 LB_LINUX_CONFIG_IM([CRYPTO_HMAC],[],[
375         AC_MSG_ERROR([Lustre require that CONFIG_CRYPTO_HMAC is enabled in your kernel.])
376 ])
377
378 LB_LINUX_CONFIG_IM([CRYPTO_SHA1],[],[
379         AC_MSG_ERROR([Lustre require that CONFIG_CRYPTO_SHA1 is enabled in your kernel.])
380 ])
381
382 #LB_LINUX_CONFIG_BIG_STACK
383
384 # LNet tests
385 LN_PROG_LINUX
386
387 # Lustre tests
388 LC_PROG_LINUX
389
390 # Portals tests
391 if test "$PORTALS" ; then
392         LP_PROG_LINUX
393 fi
394 ])
395
396 #
397 # LB_LINUX_CONDITIONALS
398 #
399 # AM_CONDITIONALS for linux
400 #
401 AC_DEFUN([LB_LINUX_CONDITIONALS],
402 [AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
403 AM_CONDITIONAL(GSS, test x$enable_gss = xyes)
404 ])
405
406 #
407 # LC_LINUX_CONFIG_GSS
408 #
409 # Build gss and related tools of Lustre. Currently both kernel and user space
410 # parts are depend on linux platform.
411 #
412 AC_DEFUN([LC_LINUX_CONFIG_GSS],
413 [AC_MSG_CHECKING([whether to enable gss/krb5 support])
414 AC_ARG_ENABLE([gss], 
415         AC_HELP_STRING([--enable-gss], [enable gss/krb5 support]),
416         [],[enable_gss='no'])
417 AC_MSG_RESULT([$enable_gss])
418
419 if test x$enable_gss == xyes; then
420         LB_LINUX_CONFIG_IM([SUNRPC],[],[
421                 AC_MSG_ERROR([GSS require that CONFIG_SUNRPC is enabled in your kernel.])
422         ])
423         LB_LINUX_CONFIG_IM([CRYPTO_DES],[],[
424                 AC_MSG_WARN([DES support is recommended by using GSS.])
425         ])
426         LB_LINUX_CONFIG_IM([CRYPTO_MD5],[],[
427                 AC_MSG_WARN([MD5 support is recommended by using GSS.])
428         ])
429         LB_LINUX_CONFIG_IM([CRYPTO_SHA256],[],[
430                 AC_MSG_WARN([SHA256 support is recommended by using GSS.])
431         ])
432         LB_LINUX_CONFIG_IM([CRYPTO_SHA512],[],[
433                 AC_MSG_WARN([SHA512 support is recommended by using GSS.])
434         ])
435         LB_LINUX_CONFIG_IM([CRYPTO_ARC4],[],[
436                 AC_MSG_WARN([ARC4 support is recommended by using GSS.])
437         ])
438         #
439         # unfortunately AES symbol is depend (optimized) on arch
440         #
441
442         AC_CHECK_LIB(gssapi, gss_init_sec_context, [
443                 GSSAPI_LIBS="$GSSAPI_LDFLAGS -lgssapi"
444                 ], [
445                 AC_MSG_ERROR([libgssapi is not found, consider --disable-gss.])
446                 ], 
447         )
448
449         AC_SUBST(GSSAPI_LIBS)
450         AC_KERBEROS_V5
451 fi
452 ])
453