4 # Verify that LUSTRE_VERSION was defined properly
6 AC_DEFUN([LB_CHECK_VERSION], [
7 AS_IF([test "LUSTRE_VERSION" = "LUSTRE""_VERSION"],
8 [AC_MSG_ERROR([This script was not built with a version number.])])
14 # fixup $target_os for use in other places
16 AC_DEFUN([LB_CANONICAL_SYSTEM], [
28 AC_SUBST(lb_target_os)
29 ]) # LB_CANONICAL_SYSTEM
32 # LB_DOWNSTREAM_RELEASE
34 AC_DEFUN([LB_DOWNSTREAM_RELEASE],
35 [AC_ARG_WITH([downstream-release],
36 AC_HELP_STRING([--with-downstream-release=string],
37 [set a string in the BUILD_VERSION and RPM Release: (default is nothing)]),
38 [DOWNSTREAM_RELEASE=$with_downstream_release],
39 [ # if not specified, see if it's in the META file
41 [DOWNSTREAM_RELEASE=$(sed -ne '/^LOCAL_VERSION =/s/.*= *//p' META)])
43 AC_SUBST(DOWNSTREAM_RELEASE)
44 ]) # LB_DOWNSTREAM_RELEASE
49 # Check if the source is a GA release and if not, set a "BUILDID"
51 # Currently there are at least two ways/modes of/for doing this. One
52 # is if we are in a valid git repository, the other is if we are in a
53 # non-git source tree of some form. Building the latter from the former
54 # will be handled here.
55 AC_DEFUN([LB_BUILDID], [
56 AC_CACHE_CHECK([for buildid], [lb_cv_buildid], [
58 AS_IF([git branch >/dev/null 2>&1], [
61 ver=$(git describe --match v[[0-9]]_*_[[0-9]]* --tags)
62 if [[[ $ver = *-*-* ]]]; then
68 # it's tempting to use [[ $ver =~ ^v([0-9]+_)+([0-9]+|RC[0-9]+)$ ]]
69 # here but the portability of the regex on the right is dismal
71 if echo "$ver" | egrep -q "^v([[0-9]]+_)+([[0-9]]+|RC[[0-9]]+)$"; then
72 ver=$(echo $ver | sed -e 's/^v\(.*\)/\1/' \
73 -e 's/_RC[[0-9]].*$//' -e 's/_/./g')
76 # a "lustre fix" value of .0 should be truncated
77 if [[[ $ver = *.*.*.0 ]]]; then
80 # ditto for a "lustre fix" value of _0
81 if [[[ $ver = v*_*_*_0 ]]]; then
84 if [[[ $ver = v*_*_* ]]]; then
89 if test "$ver" != "$VERSION"; then
90 AC_MSG_WARN([most recent tag found: $ver does not match current version $VERSION.])
93 if test "$ffw" != "0"; then
97 lb_cv_buildid=$(sed -ne '/^BUILDID =/s/.*= *//p' META)
100 AS_IF([test -z "$lb_cv_buildid"], [
103 FIXME: I don't know how to deal with source trees outside of git that
104 don't have a META file. Not setting a buildid.
107 BUILDID=$lb_cv_buildid
114 # Check for file existance even when cross compiling
119 AC_DEFUN([LB_CHECK_FILE], [
120 AS_VAR_PUSHDEF([lb_file], [lb_cv_file_$1])dnl
121 AC_CACHE_CHECK([for $1], lb_file, [
122 AS_IF([test -r "$1"],
123 [AS_VAR_SET(lb_file, [yes])],
124 [AS_VAR_SET(lb_file, [no])])
126 AS_VAR_IF([lb_file], [yes], [$2], [$3])[]dnl
127 AS_VAR_POPDEF([lb_file])dnl
131 # LB_ARG_LIBS_INCLUDES
133 # support for --with-foo, --with-foo-includes, and --with-foo-libs in
134 # a single magical macro
136 AC_DEFUN([LB_ARG_LIBS_INCLUDES], [
137 lb_pathvar="m4_bpatsubst([$2], -, _)"
138 AC_MSG_CHECKING([for $1])
140 AC_HELP_STRING([--with-$2=path],
143 AS_IF([test "x$withval" = xyes],
144 [eval "$lb_pathvar='$3'"],
145 [eval "$lb_pathvar='$withval'"])
146 AC_MSG_RESULT([${!lb_pathvar:-no}])
148 AS_IF([test "x${!lb_pathvar}" != x -a "x${!lb_pathvar}" != xno], [
149 AC_MSG_CHECKING([for $1 includes])
150 AC_ARG_WITH([$2-includes],
151 AC_HELP_STRING([--with-$2-includes=path],
152 [path to $1 includes]),
155 lb_includevar="${lb_pathvar}_includes"
156 AS_IF([test "x$withval" = xyes],
157 [eval "${lb_includevar}='${!lb_pathvar}/include'"],
158 [eval "${lb_includevar}='$withval'"])
159 AC_MSG_RESULT([${!lb_includevar}])
161 AC_MSG_CHECKING([for $1 libs])
162 AC_ARG_WITH([$2-libs],
163 AC_HELP_STRING([--with-$2-libs=path],
167 lb_libvar="${lb_pathvar}_libs"
168 AS_IF([test "x$withval" = xyes],
169 [eval "${lb_libvar}='${!lb_pathvar}/lib'"],
170 [eval "${lb_libvar}='$withval'"])
171 AC_MSG_RESULT([${!lb_libvar}])
173 ]) # LB_ARG_LIBS_INCLUDES
176 # LB_PATH_LUSTREIOKIT
178 # We no longer handle external lustre-iokit
180 AC_DEFUN([LB_PATH_LUSTREIOKIT], [
181 AC_MSG_CHECKING([whether to build iokit])
182 AC_ARG_ENABLE([iokit],
183 AC_HELP_STRING([--disable-iokit],
184 [disable iokit (default is enable)]),
185 [], [enable_iokit="yes"])
186 AC_MSG_RESULT([$enable_iokit])
187 AS_IF([test "x$enable_iokit" = xyes],
188 [LUSTREIOKIT_SUBDIR="lustre-iokit"],
189 [LUSTREIOKIT_SUBDIR=""])
190 AC_SUBST(LUSTREIOKIT_SUBDIR)
191 AM_CONDITIONAL([BUILD_LUSTREIOKIT], [test "x$enable_iokit" = xyes])
192 ]) # LB_PATH_LUSTREIOKIT
194 # Define no libcfs by default.
195 AC_DEFUN([LB_LIBCFS_DIR], [
196 AS_IF([test "x$libcfs_is_module" = xyes], [
197 LIBCFS_INCLUDE_DIR="libcfs/include"
198 LIBCFS_SUBDIR="libcfs"
200 LIBCFS_INCLUDE_DIR="lnet/include"
203 AC_SUBST(LIBCFS_INCLUDE_DIR)
204 AC_SUBST(LIBCFS_SUBDIR)
210 # check for in-tree snmp support
212 AC_DEFUN([LB_PATH_SNMP], [
213 LB_CHECK_FILE([$srcdir/snmp/lustre-snmp.c], [SNMP_DIST_SUBDIR="snmp"])
214 AC_SUBST(SNMP_DIST_SUBDIR)
215 AC_SUBST(SNMP_SUBDIR)
221 # Build kernel modules?
223 AC_DEFUN([LB_CONFIG_MODULES], [
224 AC_MSG_CHECKING([whether to build Linux kernel modules])
225 AC_ARG_ENABLE([modules],
226 AC_HELP_STRING([--disable-modules],
227 [disable building of Lustre kernel modules]),
229 LC_TARGET_SUPPORTED([enable_modules="yes"],
230 [enable_modules="no"])
232 AC_MSG_RESULT([$enable_modules ($target_os)])
234 AS_IF([test "x$enable_modules" = xyes], [
235 AS_CASE([$target_os],
240 AS_IF([test "x$enable_server" != xno], [LB_EXT4_SRC_DIR])
246 # This is strange - Lustre supports a target we don't
247 AC_MSG_ERROR([Modules are not supported on $target_os])
250 ]) # LB_CONFIG_MODULES
257 AC_DEFUN([LB_CONFIG_UTILS], [
258 AC_MSG_CHECKING([whether to build Lustre utilities])
259 AC_ARG_ENABLE([utils],
260 AC_HELP_STRING([--disable-utils],
261 [disable building of Lustre utility programs]),
262 [], [enable_utils="yes"])
263 AC_MSG_RESULT([$enable_utils])
264 AS_IF([test "x$enable_utils" = xyes], [LB_CONFIG_INIT_SCRIPTS])
272 AC_DEFUN([LB_CONFIG_TESTS], [
273 AC_MSG_CHECKING([whether to build Lustre tests])
274 AC_ARG_ENABLE([tests],
275 AC_HELP_STRING([--disable-tests],
276 [disable building of Lustre tests]),
277 [], [enable_tests="yes"])
278 AC_MSG_RESULT([$enable_tests])
284 # Just enough configure so that "make dist" is useful
286 # this simply re-adjusts some defaults, which of course can be overridden
287 # on the configure line after the --for-dist option
289 AC_DEFUN([LB_CONFIG_DIST], [
290 AC_MSG_CHECKING([whether to configure just enough for make dist])
291 AC_ARG_ENABLE([dist],
292 AC_HELP_STRING([--enable-dist],
293 [only configure enough for make dist]),
294 [], [enable_dist="no"])
295 AC_MSG_RESULT([$enable_dist])
296 AS_IF([test "x$enable_dist" != xno], [
309 AC_DEFUN([LB_CONFIG_DOCS], [
310 AC_MSG_CHECKING([whether to build Lustre docs])
312 AC_HELP_STRING([--disable-doc],
313 [skip creation of pdf documentation]),
314 [], [enable_doc="no"])
315 AC_MSG_RESULT([$enable_doc])
316 AS_IF([test "x$enable_doc" = xyes],
317 [ENABLE_DOC=1], [ENABLE_DOC=0])
322 # LB_CONFIG_INIT_SCRIPTS
324 # our init scripts only work on red hat linux
326 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS], [
327 ENABLE_INIT_SCRIPTS=0
328 AS_IF([test x$enable_utils = xyes], [
329 AC_CACHE_CHECK([whether to install init scripts], [lb_cv_enable_init_scripts], [
330 # our scripts only work on red hat systems
331 AS_IF([test -f /etc/init.d/functions -a -f /etc/sysconfig/network],
332 [lb_cv_enable_init_scripts="yes"],
333 [lb_cv_enable_init_scripts="no"])
335 AS_IF([test "x$lb_cv_enable_init_scripts" = xyes],
336 [ENABLE_INIT_SCRIPTS=1])
338 AC_SUBST(ENABLE_INIT_SCRIPTS)
344 # add -include config.h
346 AC_DEFUN([LB_CONFIG_HEADERS], [
347 AC_CONFIG_HEADERS([config.h])
348 CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
349 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
350 AC_SUBST(EXTRA_KCFLAGS)
351 ]) # LB_CONFIG_HEADERS
356 # defines for including the toplevel Rules
358 AC_DEFUN([LB_INCLUDE_RULES], [
359 INCLUDE_RULES="include $PWD/Rules"
360 AC_SUBST(INCLUDE_RULES)
361 ]) # LB_INCLUDE_RULES
366 # 'fixup' default paths
368 AC_DEFUN([LB_PATH_DEFAULTS], [
369 # directories for binaries
370 AC_PREFIX_DEFAULT([/usr])
372 sysconfdir='$(CROSS_PATH)/etc'
375 # Directories for documentation and demos.
376 docdir='$(datadir)/doc/$(PACKAGE)'
382 ]) # LB_PATH_DEFAULTS
387 # checks on the C compiler
389 AC_DEFUN([LB_PROG_CC], [
391 AC_CHECK_TOOL(LD, [ld], [no])
392 AC_CHECK_TOOL(OBJDUMP, [objdump], [no])
393 AC_CHECK_TOOL(STRIP, [strip], [no])
395 # --------- unsigned long long sane? -------
396 AC_CHECK_SIZEOF(unsigned long long, 0)
397 AS_IF([test $ac_cv_sizeof_unsigned_long_long != 8],
398 [AC_MSG_ERROR([we assume that sizeof(unsigned long long) == 8.])])
400 AS_IF([test $target_cpu = powerpc64], [
401 AC_MSG_WARN([set compiler with -m64])
402 CFLAGS="$CFLAGS -m64"
406 CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
408 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
411 # Add _GNU_SOURCE for strnlen on linux
412 LLCFLAGS="-g -Wall -fPIC -D_GNU_SOURCE"
415 CCASFLAGS="-Wall -fPIC -D_GNU_SOURCE"
418 # everyone builds against lnet and lustre
419 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include"
420 AC_SUBST(EXTRA_KCFLAGS)
426 # AM_CONDITIONAL instances for everything
427 # (so that portals/lustre can disable some if needed)
429 AC_DEFUN([LB_CONDITIONALS], [
430 AM_CONDITIONAL([MODULES], [test x$enable_modules = xyes])
431 AM_CONDITIONAL([UTILS], [test x$enable_utils = xyes])
432 AM_CONDITIONAL([TESTS], [test x$enable_tests = xyes])
433 AM_CONDITIONAL([DOC], [test x$ENABLE_DOC = x1])
434 AM_CONDITIONAL([INIT_SCRIPTS], [test x$ENABLE_INIT_SCRIPTS = x1])
435 AM_CONDITIONAL([LINUX], [test x$lb_target_os = xlinux])
436 AM_CONDITIONAL([DARWIN], [test x$lb_target_os = xdarwin])
437 AM_CONDITIONAL([SUNOS], [test x$lb_target_os = xSunOS])
438 AM_CONDITIONAL([USES_DPKG], [test x$uses_dpkg = xyes])
439 AM_CONDITIONAL([USE_QUILT], [test x$use_quilt = xyes])
441 # Sanity check for PCLMULQDQ instruction availability
442 # PCLMULQDQ instruction is a new instruction available beginning with
443 # the all new Core processor family based on the 32nm microarchitecture
444 # codename Westmere. So, $target_cpu = x86_64 should have this instruction
445 # except MIC microarchitecture (k1om).
446 AM_CONDITIONAL(HAVE_PCLMULQDQ, test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om")
447 AS_IF([test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om"],
448 [AC_DEFINE(HAVE_PCLMULQDQ, 1, [have PCLMULQDQ instruction])])
450 LB_DARWIN_CONDITIONALS
460 # build-specific config files
462 AC_DEFUN([LB_CONFIG_FILES], [
467 [Rules:build/Rules.in]
468 AC_PACKAGE_TARNAME[.spec]
469 AC_PACKAGE_TARNAME[-dkms.spec]
471 contrib/lbuild/Makefile
472 contrib/scripts/Makefile
475 lustre-iokit/Makefile
476 lustre-iokit/obdfilter-survey/Makefile
477 lustre-iokit/ost-survey/Makefile
478 lustre-iokit/sgpdd-survey/Makefile
479 lustre-iokit/mds-survey/Makefile
480 lustre-iokit/ior-survey/Makefile
481 lustre-iokit/stats-collect/Makefile
488 AC_DEFUN([LB_CONFIG_SERVERS], [
489 AC_ARG_ENABLE([server],
490 AC_HELP_STRING([--disable-server],
491 [disable Lustre server support]), [
492 AS_IF([test x$enable_server != xyes -a x$enable_server != xno],
493 [AC_MSG_ERROR([server valid options are "yes" or "no"])])
494 AS_IF([test x$enable_server = xyes -a x$enable_dist = xyes],
495 [AC_MSG_ERROR([--enable-server cannot be used with --enable-dist])])
497 AS_IF([test x$enable_dist = xyes],
498 [enable_server=no], [enable_server=maybe])
501 # There are at least two good reasons why we should really run
502 # LB_CONFIG_MODULES elsewhere before the call to LB_CONFIG_SERVERS:
503 # LB_CONFIG_MODULES needs to be run for client support even when
504 # servers are disabled, and because module support is actually a
505 # prerequisite of server support. However, some things under
506 # LB_CONFIG_MODULES need us to already have checked for --disable-server,
507 # before running, so until LB_CONFIG_MODULES can be reorganized, we
510 AS_IF([test x$enable_modules = xno], [enable_server=no])
514 # If no backends were configured, and the user did not explicitly
515 # require servers to be enabled, we just disable servers.
516 AS_IF([test x$enable_ldiskfs = xno -a x$enable_zfs = xno], [
517 AS_CASE([$enable_server],
518 [maybe], [enable_server=no],
519 [yes], [AC_MSG_ERROR([cannot enable servers, no backends were configured])])
521 AS_IF([test x$enable_server = xmaybe], [enable_server=yes])
524 AC_MSG_CHECKING([whether to build Lustre server support])
525 AC_MSG_RESULT([$enable_server])
526 AS_IF([test x$enable_server = xyes],
527 [AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])])
528 ]) # LB_CONFIG_SERVERS
531 # LB_CONFIG_RPMBUILD_OPTIONS
533 # The purpose of this function is to assemble command line options
534 # for the rpmbuild command based on the options passed to the configure
535 # script, and also upon the descisions that configure makes based on
536 # the tests that it runs.
537 # These strings can be passed to rpmbuild on the command line
538 # in the Make targets named "rpms" and "srpm".
540 AC_DEFUN([LB_CONFIG_RPMBUILD_OPTIONS], [
544 eval set -- $ac_configure_args
547 --with-release=* ) ;;
548 --with-kmp-moddir=* ) ;;
549 --with-linux=* | --with-linux-obj=* ) ;;
550 --enable-tests | --disable-tests ) ;;
551 --enable-modules | --disable-modules ) ;;
552 * ) CONFIGURE_ARGS="$CONFIGURE_ARGS '$arg'" ;;
555 if test -n "$CONFIGURE_ARGS" ; then
556 RPMBINARGS="$RPMBINARGS --define \"configure_args $CONFIGURE_ARGS\""
558 if test -n "$LINUX" ; then
559 RPMBINARGS="$RPMBINARGS --define \"kdir $LINUX\""
560 if test -n "$LINUX_OBJ" -a "$LINUX_OBJ" != x"$LINUX" ; then
561 RPMBINARGS="$RPMBINARGS --define \"kobjdir $LINUX_OBJ\""
564 if test -n "$KMP_MODDIR" ; then
565 RPMBINARGS="$RPMBINARGS --define \"kmoddir $KMP_MODDIR\""
567 if test -n "$CROSS_PATH" ; then
568 if test x$enable_server = xyes ; then
570 "*** Don't support cross compilation for the Intel(R) Xeon Phi(TM) card.\n"
574 RPMBINARGS="$RPMBINARGS --define \"post_script build/gen_filelist.sh\""
575 RPMBINARGS="$RPMBINARGS --define \"cross_path $CROSS_PATH\""
576 RPMBINARGS="$RPMBINARGS --define \"rootdir %{cross_path}\""
577 RPMBINARGS="$RPMBINARGS --define \"_prefix %{cross_path}/usr\""
578 RPMBINARGS="$RPMBINARGS --define \"_mandir %{_prefix}/share/man\""
579 RPMBINARGS="$RPMBINARGS --define \"_sysconfdir %{cross_path}/etc\""
580 RPMBINARGS="$RPMBINARGS --define \"make_args $CROSS_VARS\""
581 if test x$CC_TARGET_ARCH = x"x86_64-k1om-linux" ; then
582 RPMBINARGS="$RPMBINARGS --define \"cross_requires intel-mic-gpl\""
585 if test x$enable_modules != xyes ; then
586 RPMBINARGS="$RPMBINARGS --without lustre_modules"
588 if test x$enable_tests != xyes ; then
589 RPMBINARGS="$RPMBINARGS --without lustre_tests"
590 RPMSRCARGS="$RPMSRCARGS --without lustre_tests"
592 if test x$enable_server != xyes ; then
593 RPMBINARGS="$RPMBINARGS --without servers"
594 if test -n "$CROSS_SUFFIX" ; then
595 RPMBINARGS="$RPMBINARGS --define \"lustre_name lustre-client$CROSS_SUFFIX\""
598 if test x$enable_ldiskfs != xyes ; then
599 RPMBINARGS="$RPMBINARGS --without ldiskfs"
601 if test x$enable_zfs = xyes ; then
602 RPMBINARGS="$RPMBINARGS --with zfs"
604 if test x$enable_iokit != xyes ; then
605 RPMBINARGS="$RPMBINARGS --without lustre_iokit"
606 RPMSRCARGS="$RPMSRCARGS --without lustre_iokit"
609 RPMBUILD_BINARY_ARGS=$RPMBINARGS
610 RPMBUILD_SOURCE_ARGS=$RPMSRCARGS
612 AC_SUBST(RPMBUILD_BINARY_ARGS)
613 AC_SUBST(RPMBUILD_SOURCE_ARGS)
614 ]) # LB_CONFIG_RPMBUILD_OPTIONS
619 # main configure steps
621 AC_DEFUN([LB_CONFIGURE], [
622 AC_MSG_NOTICE([Lustre base checks
623 ==============================================================================])
628 LB_DOWNSTREAM_RELEASE
648 # two macros for cmd3
649 m4_ifdef([LC_CONFIG_SPLIT], [LC_CONFIG_SPLIT])
650 m4_ifdef([LC_NODEMAP_PROC_DEBUG], [LC_NODEMAP_PROC_DEBUG])
659 LB_DEFINE_E2FSPROGS_NAMES
664 AS_IF([test -n "$SNMP_DIST_SUBDIR"], [LS_CONFIGURE])
673 AS_IF([test -n "$SNMP_DIST_SUBDIR"], [LS_CONFIG_FILES])
675 AC_SUBST(ac_configure_args)
677 MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.* Modules.symvers Module.symvers'
678 AC_SUBST(MOSTLYCLEANFILES)
680 LB_CONFIG_RPMBUILD_OPTIONS
689 LLCPPFLAGS: $LLCPPFLAGS
691 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
694 Type 'make' to build Lustre.