1 # Four main targets: lustre kernel modules, utilities, tests, and liblustre
2 AC_MSG_CHECKING([whether to build kernel modules])
3 AC_ARG_ENABLE([modules],
4 AC_HELP_STRING([--disable-modules],
5 [disable building of Lustre kernel modules]),
6 [],[enable_modules='yes'])
7 AC_MSG_RESULT([$enable_modules])
8 AM_CONDITIONAL(MODULES, test x$enable_modules = xyes)
10 AC_MSG_CHECKING([whether to build utilities])
11 AC_ARG_ENABLE([utils],
12 AC_HELP_STRING([--disable-utils],
13 [disable building of Lustre utility programs]),
14 [],[enable_utils='yes'])
15 AC_MSG_RESULT([$enable_utils])
17 AC_MSG_CHECKING([whether to build Lustre tests])
18 AC_ARG_ENABLE([tests],
19 AC_HELP_STRING([--disable-tests],
20 [disable building of Lustre tests]),
21 [],[enable_tests='yes'])
22 AC_MSG_RESULT([$enable_tests])
24 # specify wether to build doc or not
25 AC_MSG_CHECKING([whether to build docs])
27 AC_HELP_STRING([--disable-doc],
28 [skip creation of pdf documentation]),
30 if test x$enable_doc = xyes ; then
39 AC_MSG_RESULT([$enable_doc])
40 AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
43 # we need to pass a full path here for kernel makefiles
44 INCLUDE_RULES="include $PWD/build/Rules"
45 AC_SUBST(INCLUDE_RULES)
47 # directories for binaries
48 AC_PREFIX_DEFAULT([/usr])
53 # Directories for documentation and demos.
54 docdir='${datadir}/doc/$(PACKAGE)'
57 # ---------- BAD gcc? ------------
60 AC_MSG_CHECKING([for buggy compiler])
61 CC_VERSION=`$CC -v 2>&1 | grep "^gcc version"`
63 AC_MSG_RESULT([buggy compiler found!])
66 echo " has been known to generate bad code, "
67 echo " please get an updated compiler."
70 TMP_VERSION=`echo $CC_VERSION | cut -c 1-16`
71 if test "$TMP_VERSION" = "gcc version 2.95"; then
75 # ost_pack_niobuf putting 64bit NTOH temporaries on the stack
76 # without "sub $0xc,%esp" to protect the stack from being
77 # stomped on by interrupts (bug 606)
78 "gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)")
81 # mandrake's similar sub 0xc compiler bug
82 # http://marc.theaimsgroup.com/?l=linux-kernel&m=104748366226348&w=2
83 "gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)")
87 AC_MSG_RESULT([no known problems])
90 # end ------ BAD gcc? ------------
92 # --------- unsigned long long sane? -------
94 AC_CHECK_SIZEOF(unsigned long long, 0)
95 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
96 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
97 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
98 AC_MSG_ERROR([** we assume that sizeof(long long) == 8. Tell phil@clusterfs.com])
101 # -------- we can't build modules unless srcdir = builddir
102 if test x$enable_modules != xno ; then
103 AC_CHECK_FILE([autoMakefile.am],[],
104 [AC_MSG_ERROR([At this time, Lustre does not support building kernel modules with srcdir != buildir.])])
107 # -------- in kernel compilation? (2.5 only) -------------
108 AC_MSG_CHECKING([if inkernel build support is requested])
109 AC_ARG_ENABLE([inkernel],
110 AC_HELP_STRING([--enable-inkernel],
111 [set up 2.5 kernel makefiles]),
112 [],[enable_inkernel=no])
113 AC_MSG_RESULT([$enable_inkernel])
114 AM_CONDITIONAL(INKERNEL, test x$enable_inkernel = xyes)
116 if test x$enable_inkernel = xyes ; then
117 find portals lustre -name Makefile.mk | sed 's/.mk$//' | xargs -n 1 \
118 sh -e -x -c '(cp -f $0.mk $0.in)'
121 if test x$enable_modules != xno ; then
122 # -------- set linuxdir ------------
123 AC_MSG_CHECKING([for Linux sources])
125 AC_HELP_STRING([--with-linux=path],
126 [set path to Linux source (default=/usr/src/linux)]),
128 [LINUX=/usr/src/linux])
129 AC_MSG_RESULT([$LINUX])
131 if test x$enable_inkernel = xyes ; then
132 echo ln -s `pwd` $LINUX/fs/lustre
134 ln -s `pwd` $LINUX/fs/lustre
137 # -------- linux objects (for 2.6) --
138 AC_MSG_CHECKING([for Linux objects dir])
139 AC_ARG_WITH([linux-obj],
140 AC_HELP_STRING([--with-linux-obj=path],
141 [set path to Linux objects dir (default=\$LINUX)]),
142 [LINUX_OBJ=$with_linux_obj],
144 AC_MSG_RESULT([$LINUX_OBJ])
147 # -------- check for .confg --------
148 AC_ARG_WITH([linux-config],
149 [AC_HELP_STRING([--with-linux-config=path],
150 [set path to Linux .conf (default=\$LINUX_OBJ/.config)])],
151 [LINUX_CONFIG=$with_linux_config],
152 [LINUX_CONFIG=$LINUX_OBJ/.config])
153 AC_SUBST(LINUX_CONFIG)
155 AC_CHECK_FILE([/boot/kernel.h],
156 [KERNEL_SOURCE_HEADER='/boot/kernel.h'],
157 [AC_CHECK_FILE([/var/adm/running-kernel.h]),
158 [KERNEL_SOURCE_HEADER='/var/adm/running-kernel.h']])
160 AC_ARG_WITH([kernel-source-header],
161 AC_HELP_STRING([--with-kernel-source-header=path],
162 [Use a different kernel version header. Consult README.kernel-source for details.]),
163 [KERNEL_SOURCE_HEADER=$with_kernel_source_header])
165 # --------------------
169 AC_MSG_CHECKING([if you are running user mode linux for $host_cpu])
170 if test -e $LINUX/include/asm-um ; then
171 if test X`ls -id $LINUX/include/asm/ | awk '{print $1}'` = X`ls -id $LINUX/include/asm-um | awk '{print $1}'` ; then
173 # see notes in Rules.in
177 AC_MSG_RESULT([no (asm doesn't point at asm-um)])
180 AC_MSG_RESULT([no (asm-um missing)])
186 # --------- Linux 25 ------------------
187 AC_CHECK_FILE([$LINUX/include/linux/namei.h],
195 AC_MSG_CHECKING([if you are using Linux 2.6])
196 AC_MSG_RESULT([$linux25])
201 AM_CONDITIONAL(LINUX25, test x$linux25 = xyes)
204 # ------- Makeflags ------------------
206 CPPFLAGS="$CPPFLAGS $CRAY_PORTALS_INCLUDES -I\$(top_srcdir)/lustre/include -I\$(top_srcdir)/portals/include"
208 # liblustre are all the same
209 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
212 LLCFLAGS="-g -Wall -fPIC"
215 # everyone builds against portals and lustre
217 EXTRA_KCFLAGS="-g $CRAY_PORTALS_INCLUDES -I$PWD/portals/include -I$PWD/lustre/include"
219 # these are like AC_TRY_COMPILE, but try to build modules against the
220 # kernel, inside the kernel-tests directory
222 AC_DEFUN([LUSTRE_MODULE_CONFTEST],
223 [cat >conftest.c <<_ACEOF
228 AC_DEFUN([LUSTRE_MODULE_COMPILE_IFELSE],
229 [m4_ifvaln([$1], [LUSTRE_MODULE_CONFTEST([$1])])dnl
230 rm -f build/conftest.o build/conftest.mod.c build/conftest.ko
231 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])],
233 [_AC_MSG_LOG_CONFTEST
234 m4_ifvaln([$5],[$5])dnl])dnl
235 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
238 AC_DEFUN([LUSTRE_MODULE_TRY_COMPILE],
239 [LUSTRE_MODULE_COMPILE_IFELSE(
240 [AC_LANG_PROGRAM([[$1]], [[$2]])],
242 [test -s build/conftest.o],
245 AC_DEFUN([LUSTRE_MODULE_TRY_MAKE],
246 [LUSTRE_MODULE_COMPILE_IFELSE([AC_LANG_PROGRAM([[$1]], [[$2]])], [$3], [$4], [$5], [$6])])
248 # ------------ include paths ------------------
250 if test x$enable_modules != xno ; then
251 # ------------ .config exists ----------------
252 AC_CHECK_FILE([$LINUX_CONFIG],[],
253 [AC_MSG_ERROR([Kernel config could not be found. If you are building from a kernel-source rpm consult README.kernel-source])])
255 # ----------- make dep run? ------------------
256 AC_CHECK_FILES([$LINUX_OBJ/include/linux/autoconf.h
257 $LINUX_OBJ/include/linux/version.h
258 $LINUX/include/linux/config.h],[],
259 [AC_MSG_ERROR([Run make config in $LINUX.])])
261 # ------------ rhconfig.h includes runtime-generated bits --
262 # red hat kernel-source checks
264 # we know this exists after the check above. if the user
265 # tarred up the tree and ran make dep etc. in it, then
266 # version.h gets overwritten with a standard linux one.
268 if grep rhconfig $LINUX_OBJ/include/linux/version.h >/dev/null ; then
269 # This is a clean kernel-source tree, we need to
270 # enable extensive workarounds to get this to build
272 AC_CHECK_FILE([$KERNEL_SOURCE_HEADER],
273 [if test $KERNEL_SOURCE_HEADER = '/boot/kernel.h' ; then
274 AC_MSG_WARN([Using /boot/kernel.h from RUNNING kernel.])
275 AC_MSG_WARN([If this is not what you want, use --with-kernel-source-header.])
276 AC_MSG_WARN([Consult README.kernel-source for details.])
278 [AC_MSG_ERROR([$KERNEL_SOURCE_HEADER not found. Consult README.kernel-source for details.])])
279 EXTRA_KCFLAGS="-include $KERNEL_SOURCE_HEADER $EXTRA_KCFLAGS"
282 # ------------ external module support ---------------------
283 MODULE_TARGET="SUBDIRS"
284 if test $linux25 = 'yes' ; then
285 makerule="$PWD/build"
286 AC_MSG_CHECKING([for external module build support])
287 rm -f build/conftest.i
288 LUSTRE_MODULE_TRY_MAKE([],[],
289 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
290 [test -s build/conftest.i],
295 makerule="_module_$makerule"
299 makerule="_dir_$PWD/build"
301 AC_SUBST(MODULE_TARGET)
303 # --- check that we can build modules at all
304 AC_MSG_CHECKING([that modules can be built])
305 LUSTRE_MODULE_TRY_COMPILE([],[],
310 AC_MSG_WARN([Consult config.log for details.])
311 AC_MSG_WARN([If you are trying to build with a kernel-source rpm, consult README.kernel-source])
312 AC_MSG_ERROR([Kernel modules could not be built.])
315 # ------------ LINUXRELEASE and moduledir ------------------
317 rm -f build/conftest.i
318 AC_MSG_CHECKING([for Linux release])
319 LUSTRE_MODULE_TRY_MAKE(
320 [#include <linux/version.h>],
322 LINUXRELEASE=UTS_RELEASE;],
323 [$makerule LUSTRE_KERNEL_TEST=conftest.i],
324 [test -s build/conftest.i],
326 # LINUXRELEASE="UTS_RELEASE"
327 eval $(grep "LINUXRELEASE=" build/conftest.i)
329 AC_MSG_RESULT([unknown])
330 AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.])
332 rm -f build/conftest.i
333 if test x$LINUXRELEASE = x ; then
334 AC_MSG_RESULT([unknown])
335 AC_MSG_ERROR([Could not determine Linux release version from linux/version.h.])
337 AC_MSG_RESULT([$LINUXRELEASE])
338 AC_SUBST(LINUXRELEASE)
340 moduledir='/lib/modules/'$LINUXRELEASE/kernel
341 modulefsdir='$(moduledir)/fs/$(PACKAGE)'
342 modulenetdir='$(moduledir)/net/$(PACKAGE)'
345 AC_SUBST(modulefsdir)
346 AC_SUBST(modulenetdir)
348 # ------------ RELEASE --------------------------------
349 AC_MSG_CHECKING([for Lustre release])
350 RELEASE="`echo ${LINUXRELEASE} | tr '-' '_'`_`date +%Y%m%d%H%M`"
351 AC_MSG_RESULT($RELEASE)
354 # ---------- modules? ------------------------
355 AC_MSG_CHECKING([for module support])
356 LUSTRE_MODULE_TRY_COMPILE(
358 #include <linux/config.h>
360 #ifndef CONFIG_MODULES
361 #error CONFIG_MODULES not #defined
367 AC_MSG_ERROR([module support is required to build Lustre kernel modules.])
370 # ---------- modversions? --------------------
371 AC_MSG_CHECKING([for MODVERSIONS])
372 LUSTRE_MODULE_TRY_COMPILE(
374 #include <linux/config.h>
376 #ifndef CONFIG_MODVERSIONS
377 #error CONFIG_MODVERSIONS not #defined
385 # ------------ preempt -----------------------
386 AC_MSG_CHECKING([if preempt is enabled])
387 LUSTRE_MODULE_TRY_COMPILE(
389 #include <linux/config.h>
391 #ifndef CONFIG_PREEMPT
392 #error CONFIG_PREEMPT is not #defined
396 AC_MSG_ERROR([Lustre does not support kernels with preempt enabled.])
401 # ------------ kallsyms (so software watchdogs produce useful stacks)
402 AC_MSG_CHECKING([if kallsyms is enabled])
403 LUSTRE_MODULE_TRY_COMPILE(
405 #include <linux/config.h>
407 #ifndef CONFIG_KALLSYMS
408 #error CONFIG_KALLSYMS is not #defined
414 if test "x$ARCH_UM" = "x" ; then
415 AC_MSG_ERROR([Lustre requires that CONFIG_KALLSYMS is enabled in your kernel.])
420 ENABLE_INIT_SCRIPTS=0
421 if test x$enable_utils = xyes ; then
422 AC_MSG_CHECKING([whether to install init scripts])
423 # our scripts only work on red hat systems
424 if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
425 ENABLE_INIT_SCRIPTS=1
431 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
432 AC_SUBST(ENABLE_INIT_SCRIPTS)