4 # Verify that LUSTRE_VERSION was defined properly
6 AC_DEFUN([LB_CHECK_VERSION],
7 [if test "LUSTRE_VERSION" = "LUSTRE""_VERSION" ; then
8 AC_MSG_ERROR([This script was not built with a version number.])
15 # fixup $target_os for use in other places
17 AC_DEFUN([LB_CANONICAL_SYSTEM],
29 AC_SUBST(lb_target_os)
33 # LB_DOWNSTREAM_RELEASE
35 AC_DEFUN([LB_DOWNSTREAM_RELEASE],
36 [AC_ARG_WITH([downstream-release],
37 AC_HELP_STRING([--with-downstream-release=string],
38 [set a string in the BUILD_VERSION and RPM Release: (default is nothing)]),
39 [DOWNSTREAM_RELEASE=$with_downstream_release],
41 # if not specified, see if it's in the META file
43 DOWNSTREAM_RELEASE=$(sed -ne '/^LOCAL_VERSION =/s/.*= *//p' META)
46 AC_SUBST(DOWNSTREAM_RELEASE)
52 # Check if the source is a GA release and if not, set a "BUILDID"
54 # Currently there are at least two ways/modes of/for doing this. One
55 # is if we are in a valid git repository, the other is if we are in a
56 # non-git source tree of some form. Building the latter from the former
57 # will be handled here.
58 AC_DEFUN([LB_BUILDID],
60 AC_MSG_CHECKING([for buildid])
62 if git branch >/dev/null 2>&1; then
65 ver=$(git describe --match v[[0-9]]_*_[[0-9]]* --tags)
66 if [[[ $ver = *-*-* ]]]; then
72 # it's tempting to use [[ $ver =~ ^v([0-9]+_)+([0-9]+|RC[0-9]+)$ ]]
73 # here but the portability of the regex on the right is dismal
75 if echo "$ver" | egrep -q "^v([[0-9]]+_)+([[0-9]]+|RC[[0-9]]+)$"; then
76 ver=$(echo $ver | sed -e 's/^v\(.*\)/\1/' \
77 -e 's/_RC[[0-9]].*$//' -e 's/_/./g')
80 # a "lustre fix" value of .0 should be truncated
81 if [[[ $ver = *.*.*.0 ]]]; then
84 # ditto for a "lustre fix" value of _0
85 if [[[ $ver = v*_*_*_0 ]]]; then
88 if [[[ $ver = v*_*_* ]]]; then
93 if test "$ver" != "$VERSION"; then
94 AC_MSG_WARN([most recent tag found: $ver does not match current version $VERSION.])
97 if test "$ffw" != "0"; then
99 msg="$BUILDID (ahead by $ffw commits)"
100 AC_MSG_RESULT([$msg])
102 AC_MSG_RESULT([none... congratulations, you must be on a tag])
104 elif test -f META; then
105 BUILDID=$(sed -ne '/^BUILDID =/s/.*= *//p' META)
106 msg="$BUILDID (from META file)"
107 AC_MSG_RESULT([$msg])
109 AC_MSG_RESULT([none])
112 FIXME: I don't know how to deal with source trees outside of git that
113 don't have a META file. Not setting a buildid.
122 # Check for file existance even when cross compiling
124 AC_DEFUN([LB_CHECK_FILE],
125 [AS_VAR_PUSHDEF([lb_File], [lb_cv_file_$1])dnl
126 AC_CACHE_CHECK([for $1], lb_File,
127 [if test -r "$1"; then
128 AS_VAR_SET(lb_File, yes)
130 AS_VAR_SET(lb_File, no)
132 AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
133 AS_VAR_POPDEF([lb_File])dnl
138 # LB_ARG_LIBS_INCLUDES
140 # support for --with-foo, --with-foo-includes, and --with-foo-libs in
141 # a single magical macro
143 AC_DEFUN([LB_ARG_LIBS_INCLUDES],
144 [lb_pathvar="m4_bpatsubst([$2], -, _)"
145 AC_MSG_CHECKING([for $1])
147 AC_HELP_STRING([--with-$2=path],
151 if test x$withval = xyes ; then
152 eval "$lb_pathvar='$3'"
154 eval "$lb_pathvar='$withval'"
156 AC_MSG_RESULT([${!lb_pathvar:-no}])
158 if test x${!lb_pathvar} != x -a x${!lb_pathvar} != xno ; then
159 AC_MSG_CHECKING([for $1 includes])
160 AC_ARG_WITH([$2-includes],
161 AC_HELP_STRING([--with-$2-includes=path],
162 [path to $1 includes]),
165 lb_includevar="${lb_pathvar}_includes"
166 if test x$withval = xyes ; then
167 eval "${lb_includevar}='${!lb_pathvar}/include'"
169 eval "${lb_includevar}='$withval'"
171 AC_MSG_RESULT([${!lb_includevar}])
173 AC_MSG_CHECKING([for $1 libs])
174 AC_ARG_WITH([$2-libs],
175 AC_HELP_STRING([--with-$2-libs=path],
179 lb_libvar="${lb_pathvar}_libs"
180 if test x$withval = xyes ; then
181 eval "${lb_libvar}='${!lb_pathvar}/lib'"
183 eval "${lb_libvar}='$withval'"
185 AC_MSG_RESULT([${!lb_libvar}])
193 # Handle internal/external libsysio
195 AC_DEFUN([LB_PATH_LIBSYSIO],
196 [AC_ARG_WITH([sysio],
197 AC_HELP_STRING([--with-sysio=path],
198 [set path to libsysio source (default is included libsysio)]),
200 case $lb_target_os in
209 AC_MSG_CHECKING([location of libsysio])
210 enable_sysio="$with_sysio"
213 AC_MSG_RESULT([internal])
214 LB_CHECK_FILE([$srcdir/libsysio/src/rmdir.c],[],[
215 AC_MSG_ERROR([A complete internal libsysio was not found.])
217 LIBSYSIO_SUBDIR="libsysio"
218 SYSIO="$PWD/libsysio"
221 AC_MSG_RESULT([disabled])
224 AC_MSG_RESULT([$with_sysio])
225 LB_CHECK_FILE([$with_sysio/lib/libsysio.a],[],[
226 AC_MSG_ERROR([A complete (built) external libsysio was not found.])
233 # We have to configure even if we don't build here for make dist to work
234 AC_CONFIG_SUBDIRS([libsysio])
238 # LB_PATH_LUSTREIOKIT
240 # We no longer handle external lustre-iokit
242 AC_DEFUN([LB_PATH_LUSTREIOKIT],
243 [AC_ARG_ENABLE([iokit],
244 AC_HELP_STRING([--disable-iokit],
245 [disable iokit (default is enable)]),
249 AC_MSG_CHECKING([whether to build iokit])
250 AC_MSG_RESULT([$enable_iokit])
251 AS_IF([test "x$enable_iokit" = xyes], [LUSTREIOKIT_SUBDIR="lustre-iokit"], [LUSTREIOKIT_SUBDIR=""])[]dnl
252 AC_SUBST(LUSTREIOKIT_SUBDIR)
253 AM_CONDITIONAL(BUILD_LUSTREIOKIT, [test "x$enable_iokit" = xyes])
256 # Define no libcfs by default.
257 AC_DEFUN([LB_LIBCFS_DIR],
259 case x$libcfs_is_module in
261 LIBCFS_INCLUDE_DIR="libcfs/include"
262 LIBCFS_SUBDIR="libcfs"
265 LIBCFS_INCLUDE_DIR="lnet/include"
269 AC_SUBST(LIBCFS_SUBDIR)
270 AC_SUBST(LIBCFS_INCLUDE_DIR)
276 # check for in-tree snmp support
278 AC_DEFUN([LB_PATH_SNMP],
279 [LB_CHECK_FILE([$srcdir/snmp/lustre-snmp.c],[SNMP_DIST_SUBDIR="snmp"])
280 AC_SUBST(SNMP_DIST_SUBDIR)
281 AC_SUBST(SNMP_SUBDIR)
287 # Build kernel modules?
289 AC_DEFUN([LB_CONFIG_MODULES],
290 [AC_MSG_CHECKING([whether to build kernel modules])
291 AC_ARG_ENABLE([modules],
292 AC_HELP_STRING([--disable-modules],
293 [disable building of Lustre kernel modules]),
295 LC_TARGET_SUPPORTED([
301 AC_MSG_RESULT([$enable_modules ($target_os)])
303 if test x$enable_modules = xyes ; then
309 if test x$enable_server != xno; then
319 # This is strange - Lustre supports a target we don't
320 AC_MSG_ERROR([Modules are not supported on $target_os])
331 AC_DEFUN([LB_CONFIG_UTILS],
332 [AC_MSG_CHECKING([whether to build utilities])
333 AC_ARG_ENABLE([utils],
334 AC_HELP_STRING([--disable-utils],
335 [disable building of Lustre utility programs]),
336 [],[enable_utils='yes'])
337 AC_MSG_RESULT([$enable_utils])
338 if test x$enable_utils = xyes ; then
339 LB_CONFIG_INIT_SCRIPTS
348 AC_DEFUN([LB_CONFIG_TESTS],
349 [AC_MSG_CHECKING([whether to build Lustre tests])
350 AC_ARG_ENABLE([tests],
351 AC_HELP_STRING([--disable-tests],
352 [disable building of Lustre tests]),
357 AC_MSG_RESULT([$enable_tests])
363 # Just enough configure so that "make dist" is useful
365 # this simply re-adjusts some defaults, which of course can be overridden
366 # on the configure line after the --for-dist option
368 AC_DEFUN([LB_CONFIG_DIST],
369 [AC_MSG_CHECKING([whether to configure just enough for make dist])
370 AC_ARG_ENABLE([dist],
371 AC_HELP_STRING([--enable-dist],
372 [only configure enough for make dist]),
373 [enable_dist='yes'],[enable_dist='no'])
374 AC_MSG_RESULT([$enable_dist])
375 if test x$enable_dist != xno; then
378 enable_liblustre='no'
389 AC_DEFUN([LB_CONFIG_DOCS],
390 [AC_MSG_CHECKING([whether to build docs])
392 AC_HELP_STRING([--disable-doc],
393 [skip creation of pdf documentation]),
395 if test x$enable_doc = xyes ; then
404 AC_MSG_RESULT([$enable_doc])
409 # LB_CONFIG_INIT_SCRIPTS
411 # our init scripts only work on red hat linux
413 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS],
414 [ENABLE_INIT_SCRIPTS=0
415 if test x$enable_utils = xyes ; then
416 AC_MSG_CHECKING([whether to install init scripts])
417 # our scripts only work on red hat systems
418 if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
419 ENABLE_INIT_SCRIPTS=1
425 AC_SUBST(ENABLE_INIT_SCRIPTS)
431 # add -include config.h
433 AC_DEFUN([LB_CONFIG_HEADERS],[
434 AC_CONFIG_HEADERS([config.h])
435 CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
436 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
437 AC_SUBST(EXTRA_KCFLAGS)
443 # defines for including the toplevel Rules
445 AC_DEFUN([LB_INCLUDE_RULES],[
446 INCLUDE_RULES="include $PWD/Rules"
447 AC_SUBST(INCLUDE_RULES)
453 # 'fixup' default paths
455 AC_DEFUN([LB_PATH_DEFAULTS],
456 [# directories for binaries
457 AC_PREFIX_DEFAULT([/usr])
459 sysconfdir='$(CROSS_PATH)/etc'
462 # Directories for documentation and demos.
463 docdir='$(datadir)/doc/$(PACKAGE)'
475 # checks on the C compiler
477 AC_DEFUN([LB_PROG_CC],
479 AC_CHECK_TOOL(LD, ld, [no])
480 AC_CHECK_TOOL(OBJDUMP, objdump, [no])
481 AC_CHECK_TOOL(STRIP, strip, [no])
483 # --------- unsigned long long sane? -------
484 AC_CHECK_SIZEOF(unsigned long long, 0)
485 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
486 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
487 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
488 AC_MSG_ERROR([** we assume that sizeof(long long) == 8.])
491 if test $target_cpu == "powerpc64"; then
492 AC_MSG_WARN([set compiler with -m64])
493 CFLAGS="$CFLAGS -m64"
497 CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
499 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
502 # Add _GNU_SOURCE for strnlen on linux
503 LLCFLAGS="-g -Wall -fPIC -D_GNU_SOURCE"
506 CCASFLAGS="-Wall -fPIC -D_GNU_SOURCE"
509 # everyone builds against lnet and lustre
510 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include"
511 AC_SUBST(EXTRA_KCFLAGS)
517 # AM_CONDITIONAL instances for everything
518 # (so that portals/lustre can disable some if needed)
519 AC_DEFUN([LB_CONDITIONALS],
520 [AM_CONDITIONAL(MODULES, test x$enable_modules = xyes)
521 AM_CONDITIONAL(UTILS, test x$enable_utils = xyes)
522 AM_CONDITIONAL(TESTS, test x$enable_tests = xyes)
523 AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
524 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
525 AM_CONDITIONAL(LINUX, test x$lb_target_os = "xlinux")
526 AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
527 AM_CONDITIONAL(SUNOS, test x$lb_target_os = "xSunOS")
528 AM_CONDITIONAL(USES_DPKG, test x$uses_dpkg = "xyes")
529 AM_CONDITIONAL([USE_QUILT], [test x$use_quilt = xyes])
531 # Sanity check for PCLMULQDQ instruction availability
532 # PCLMULQDQ instruction is a new instruction available beginning with
533 # the all new Core processor family based on the 32nm microarchitecture
534 # codename Westmere. So, $target_cpu = x86_64 should have this instruction
535 # except MIC microarchitecture (k1om).
536 AM_CONDITIONAL(HAVE_PCLMULQDQ, test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om")
537 if test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om" ; then
538 AC_DEFINE(HAVE_PCLMULQDQ, 1, [have PCLMULQDQ instruction])
541 # this lets lustre cancel libsysio, per-branch or if liblustre is
543 if test "x$LIBSYSIO_SUBDIR" = xlibsysio ; then
544 if test "x$with_sysio" != xyes ; then
549 AC_SUBST(LIBSYSIO_SUBDIR)
552 LB_DARWIN_CONDITIONALS
562 # build-specific config files
564 AC_DEFUN([LB_CONFIG_FILES],
570 [Rules:build/Rules.in]
571 AC_PACKAGE_TARNAME[.spec]
572 AC_PACKAGE_TARNAME[-dkms.spec]
574 contrib/lbuild/Makefile
575 contrib/scripts/Makefile
578 lustre-iokit/Makefile
579 lustre-iokit/obdfilter-survey/Makefile
580 lustre-iokit/ost-survey/Makefile
581 lustre-iokit/sgpdd-survey/Makefile
582 lustre-iokit/mds-survey/Makefile
583 lustre-iokit/ior-survey/Makefile
584 lustre-iokit/stats-collect/Makefile
591 AC_DEFUN([LB_CONFIG_SERVERS],
593 AC_ARG_ENABLE([server],
594 AC_HELP_STRING([--disable-server],
595 [disable Lustre server support]),
596 [AS_IF([test x$enable_server != xyes -a x$enable_server != xno],
597 [AC_MSG_ERROR([server valid options are "yes" or "no"])])
598 AS_IF([test x$enable_server = xyes -a x$enable_dist = xyes],
599 [AC_MSG_ERROR([--enable-server cannot be used with --enable-dist])])
601 [AS_IF([test x$enable_dist = xyes],
603 [enable_server=maybe])
607 # There are at least two good reasons why we should really run
608 # LB_CONFIG_MODULES elsewhere before the call to LB_CONFIG_SERVERS:
609 # LB_CONFIG_MODULES needs to be run for client support even when
610 # servers are disabled, and because module support is actually a
611 # prerequisite of server support. However, some things under
612 # LB_CONFIG_MODULES need us to already have checked for --disable-server,
613 # before running, so until LB_CONFIG_MODULES can be reorganized, we
616 AS_IF([test x$enable_modules = xno],[enable_server=no])
620 # If no backends were configured, and the user did not explicitly
621 # require servers to be enabled, we just disable servers.
622 AS_IF([test x$enable_ldiskfs = xno -a x$enable_zfs = xno],
623 [AS_CASE([$enable_server],
624 [maybe], [enable_server=no],
625 [yes], [AC_MSG_ERROR([cannot enable servers, no backends were configured])])
627 [AS_IF([test x$enable_server = xmaybe], [enable_server=yes])]
630 AC_MSG_CHECKING([whether to build Lustre server support])
631 AC_MSG_RESULT([$enable_server])
632 AS_IF([test x$enable_server = xyes],
633 [AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])]
639 # LB_CONFIG_RPMBUILD_OPTIONS
641 # The purpose of this function is to assemble command line options
642 # for the rpmbuild command based on the options passed to the configure
643 # script, and also upon the descisions that configure makes based on
644 # the tests that it runs.
645 # These strings can be passed to rpmbuild on the command line
646 # in the Make targets named "rpms" and "srpm".
648 AC_DEFUN([LB_CONFIG_RPMBUILD_OPTIONS],[
652 eval set -- $ac_configure_args
655 --with-release=* ) ;;
656 --with-kmp-moddir=* ) ;;
657 --with-linux=* | --with-linux-obj=* ) ;;
658 --enable-tests | --disable-tests ) ;;
659 --enable-modules | --disable-modules ) ;;
660 * ) CONFIGURE_ARGS="$CONFIGURE_ARGS '$arg'" ;;
663 if test -n "$CONFIGURE_ARGS" ; then
664 RPMBINARGS="$RPMBINARGS --define \"configure_args $CONFIGURE_ARGS\""
666 if test -n "$LINUX" ; then
667 RPMBINARGS="$RPMBINARGS --define \"kdir $LINUX\""
668 if test -n "$LINUX_OBJ" -a "$LINUX_OBJ" != x"$LINUX" ; then
669 RPMBINARGS="$RPMBINARGS --define \"kobjdir $LINUX_OBJ\""
672 if test -n "$KMP_MODDIR" ; then
673 RPMBINARGS="$RPMBINARGS --define \"kmoddir $KMP_MODDIR\""
675 if test -n "$CROSS_PATH" ; then
676 if test x$enable_server = xyes ; then
678 "*** Don't support cross compilation for the Intel(R) Xeon Phi(TM) card.\n"
682 RPMBINARGS="$RPMBINARGS --define \"post_script build/gen_filelist.sh\""
683 RPMBINARGS="$RPMBINARGS --define \"cross_path $CROSS_PATH\""
684 RPMBINARGS="$RPMBINARGS --define \"rootdir %{cross_path}\""
685 RPMBINARGS="$RPMBINARGS --define \"_prefix %{cross_path}/usr\""
686 RPMBINARGS="$RPMBINARGS --define \"_mandir %{_prefix}/share/man\""
687 RPMBINARGS="$RPMBINARGS --define \"_sysconfdir %{cross_path}/etc\""
688 RPMBINARGS="$RPMBINARGS --define \"make_args $CROSS_VARS\""
689 if test x$CC_TARGET_ARCH = x"x86_64-k1om-linux" ; then
690 RPMBINARGS="$RPMBINARGS --define \"cross_requires intel-mic-gpl\""
693 if test x$enable_modules != xyes ; then
694 RPMBINARGS="$RPMBINARGS --without lustre_modules"
696 if test x$enable_tests != xyes ; then
697 RPMBINARGS="$RPMBINARGS --without lustre_tests"
698 RPMSRCARGS="$RPMSRCARGS --without lustre_tests"
700 if test x$enable_server != xyes ; then
701 RPMBINARGS="$RPMBINARGS --without servers"
702 if test -n "$CROSS_SUFFIX" ; then
703 RPMBINARGS="$RPMBINARGS --define \"lustre_name lustre-client$CROSS_SUFFIX\""
706 if test x$enable_ldiskfs != xyes ; then
707 RPMBINARGS="$RPMBINARGS --without ldiskfs"
709 if test x$enable_zfs = xyes ; then
710 RPMBINARGS="$RPMBINARGS --with zfs"
712 if test x$enable_iokit != xyes ; then
713 RPMBINARGS="$RPMBINARGS --without lustre_iokit"
714 RPMSRCARGS="$RPMSRCARGS --without lustre_iokit"
717 RPMBUILD_BINARY_ARGS=$RPMBINARGS
718 RPMBUILD_SOURCE_ARGS=$RPMSRCARGS
720 AC_SUBST(RPMBUILD_BINARY_ARGS)
721 AC_SUBST(RPMBUILD_SOURCE_ARGS)
727 # main configure steps
729 AC_DEFUN([LB_CONFIGURE],
734 LB_DOWNSTREAM_RELEASE
754 # two macros for cmd3
755 m4_ifdef([LC_CONFIG_SPLIT], [LC_CONFIG_SPLIT])
756 m4_ifdef([LC_NODEMAP_PROC_DEBUG], [LC_NODEMAP_PROC_DEBUG])
766 LB_DEFINE_E2FSPROGS_NAMES
774 if test "$SNMP_DIST_SUBDIR" ; then
786 if test "$SNMP_DIST_SUBDIR" ; then
790 AC_SUBST(ac_configure_args)
792 MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.* Modules.symvers Module.symvers'
793 AC_SUBST(MOSTLYCLEANFILES)
795 LB_CONFIG_RPMBUILD_OPTIONS
804 LLCPPFLAGS: $LLCPPFLAGS
806 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
809 Type 'make' to build Lustre.