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_WARN([FIXME: I don't know how to deal with source trees outside of git that don't have a META file. Not setting a buildid.])
117 # 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 [if test -r "$1"; then
123 AS_VAR_SET(lb_File, yes)
125 AS_VAR_SET(lb_File, no)
127 AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
128 AS_VAR_POPDEF([lb_File])dnl
133 # LB_ARG_LIBS_INCLUDES
135 # support for --with-foo, --with-foo-includes, and --with-foo-libs in
136 # a single magical macro
138 AC_DEFUN([LB_ARG_LIBS_INCLUDES],
139 [lb_pathvar="m4_bpatsubst([$2], -, _)"
140 AC_MSG_CHECKING([for $1])
142 AC_HELP_STRING([--with-$2=path],
146 if test x$withval = xyes ; then
147 eval "$lb_pathvar='$3'"
149 eval "$lb_pathvar='$withval'"
151 AC_MSG_RESULT([${!lb_pathvar:-no}])
153 if test x${!lb_pathvar} != x -a x${!lb_pathvar} != xno ; then
154 AC_MSG_CHECKING([for $1 includes])
155 AC_ARG_WITH([$2-includes],
156 AC_HELP_STRING([--with-$2-includes=path],
157 [path to $1 includes]),
160 lb_includevar="${lb_pathvar}_includes"
161 if test x$withval = xyes ; then
162 eval "${lb_includevar}='${!lb_pathvar}/include'"
164 eval "${lb_includevar}='$withval'"
166 AC_MSG_RESULT([${!lb_includevar}])
168 AC_MSG_CHECKING([for $1 libs])
169 AC_ARG_WITH([$2-libs],
170 AC_HELP_STRING([--with-$2-libs=path],
174 lb_libvar="${lb_pathvar}_libs"
175 if test x$withval = xyes ; then
176 eval "${lb_libvar}='${!lb_pathvar}/lib'"
178 eval "${lb_libvar}='$withval'"
180 AC_MSG_RESULT([${!lb_libvar}])
188 # Handle internal/external libsysio
190 AC_DEFUN([LB_PATH_LIBSYSIO],
191 [AC_ARG_WITH([sysio],
192 AC_HELP_STRING([--with-sysio=path],
193 [set path to libsysio source (default is included libsysio)]),
195 case $lb_target_os in
204 AC_MSG_CHECKING([location of libsysio])
205 enable_sysio="$with_sysio"
208 AC_MSG_RESULT([internal])
209 LB_CHECK_FILE([$srcdir/libsysio/src/rmdir.c],[],[
210 AC_MSG_ERROR([A complete internal libsysio was not found.])
212 LIBSYSIO_SUBDIR="libsysio"
213 SYSIO="$PWD/libsysio"
216 AC_MSG_RESULT([disabled])
219 AC_MSG_RESULT([$with_sysio])
220 LB_CHECK_FILE([$with_sysio/lib/libsysio.a],[],[
221 AC_MSG_ERROR([A complete (built) external libsysio was not found.])
228 # We have to configure even if we don't build here for make dist to work
229 AC_CONFIG_SUBDIRS([libsysio])
233 # LB_PATH_LUSTREIOKIT
235 # We no longer handle external lustre-iokit
237 AC_DEFUN([LB_PATH_LUSTREIOKIT],
238 [AC_ARG_ENABLE([iokit],
239 AC_HELP_STRING([--disable-iokit],
240 [disable iokit (default is enable)]),
244 AC_MSG_CHECKING([whether to build iokit])
245 AC_MSG_RESULT([$enable_iokit])
246 AS_IF([test "x$enable_iokit" = xyes], [LUSTREIOKIT_SUBDIR="lustre-iokit"], [LUSTREIOKIT_SUBDIR=""])[]dnl
247 AC_SUBST(LUSTREIOKIT_SUBDIR)
248 AM_CONDITIONAL(BUILD_LUSTREIOKIT, [test "x$enable_iokit" = xyes])
251 # Define no libcfs by default.
252 AC_DEFUN([LB_LIBCFS_DIR],
254 case x$libcfs_is_module in
256 LIBCFS_INCLUDE_DIR="libcfs/include"
257 LIBCFS_SUBDIR="libcfs"
260 LIBCFS_INCLUDE_DIR="lnet/include"
264 AC_SUBST(LIBCFS_SUBDIR)
265 AC_SUBST(LIBCFS_INCLUDE_DIR)
271 # check for in-tree snmp support
273 AC_DEFUN([LB_PATH_SNMP],
274 [LB_CHECK_FILE([$srcdir/snmp/lustre-snmp.c],[SNMP_DIST_SUBDIR="snmp"])
275 AC_SUBST(SNMP_DIST_SUBDIR)
276 AC_SUBST(SNMP_SUBDIR)
282 # Build kernel modules?
284 AC_DEFUN([LB_CONFIG_MODULES],
285 [AC_MSG_CHECKING([whether to build kernel modules])
286 AC_ARG_ENABLE([modules],
287 AC_HELP_STRING([--disable-modules],
288 [disable building of Lustre kernel modules]),
290 LC_TARGET_SUPPORTED([
296 AC_MSG_RESULT([$enable_modules ($target_os)])
298 if test x$enable_modules = xyes ; then
304 if test x$enable_server != xno; then
314 # This is strange - Lustre supports a target we don't
315 AC_MSG_ERROR([Modules are not supported on $target_os])
326 AC_DEFUN([LB_CONFIG_UTILS],
327 [AC_MSG_CHECKING([whether to build utilities])
328 AC_ARG_ENABLE([utils],
329 AC_HELP_STRING([--disable-utils],
330 [disable building of Lustre utility programs]),
331 [],[enable_utils='yes'])
332 AC_MSG_RESULT([$enable_utils])
333 if test x$enable_utils = xyes ; then
334 LB_CONFIG_INIT_SCRIPTS
343 AC_DEFUN([LB_CONFIG_TESTS],
344 [AC_MSG_CHECKING([whether to build Lustre tests])
345 AC_ARG_ENABLE([tests],
346 AC_HELP_STRING([--disable-tests],
347 [disable building of Lustre tests]),
352 AC_MSG_RESULT([$enable_tests])
358 # Just enough configure so that "make dist" is useful
360 # this simply re-adjusts some defaults, which of course can be overridden
361 # on the configure line after the --for-dist option
363 AC_DEFUN([LB_CONFIG_DIST],
364 [AC_MSG_CHECKING([whether to configure just enough for make dist])
365 AC_ARG_ENABLE([dist],
366 AC_HELP_STRING([--enable-dist],
367 [only configure enough for make dist]),
368 [enable_dist='yes'],[enable_dist='no'])
369 AC_MSG_RESULT([$enable_dist])
370 if test x$enable_dist != xno; then
373 enable_liblustre='no'
384 AC_DEFUN([LB_CONFIG_DOCS],
385 [AC_MSG_CHECKING([whether to build docs])
387 AC_HELP_STRING([--disable-doc],
388 [skip creation of pdf documentation]),
390 if test x$enable_doc = xyes ; then
399 AC_MSG_RESULT([$enable_doc])
404 # LB_CONFIG_INIT_SCRIPTS
406 # our init scripts only work on red hat linux
408 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS],
409 [ENABLE_INIT_SCRIPTS=0
410 if test x$enable_utils = xyes ; then
411 AC_MSG_CHECKING([whether to install init scripts])
412 # our scripts only work on red hat systems
413 if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
414 ENABLE_INIT_SCRIPTS=1
420 AC_SUBST(ENABLE_INIT_SCRIPTS)
426 # add -include config.h
428 AC_DEFUN([LB_CONFIG_HEADERS],[
429 AC_CONFIG_HEADERS([config.h])
430 CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
431 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
432 AC_SUBST(EXTRA_KCFLAGS)
438 # defines for including the toplevel Rules
440 AC_DEFUN([LB_INCLUDE_RULES],[
441 INCLUDE_RULES="include $PWD/Rules"
442 AC_SUBST(INCLUDE_RULES)
448 # 'fixup' default paths
450 AC_DEFUN([LB_PATH_DEFAULTS],
451 [# directories for binaries
452 AC_PREFIX_DEFAULT([/usr])
454 sysconfdir='$(CROSS_PATH)/etc'
457 # Directories for documentation and demos.
458 docdir='$(datadir)/doc/$(PACKAGE)'
470 # checks on the C compiler
472 AC_DEFUN([LB_PROG_CC],
474 AC_CHECK_TOOL(LD, ld, [no])
475 AC_CHECK_TOOL(OBJDUMP, objdump, [no])
476 AC_CHECK_TOOL(STRIP, strip, [no])
478 # --------- unsigned long long sane? -------
479 AC_CHECK_SIZEOF(unsigned long long, 0)
480 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
481 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
482 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
483 AC_MSG_ERROR([** we assume that sizeof(long long) == 8.])
486 if test $target_cpu == "powerpc64"; then
487 AC_MSG_WARN([set compiler with -m64])
488 CFLAGS="$CFLAGS -m64"
492 CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
494 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
497 # Add _GNU_SOURCE for strnlen on linux
498 LLCFLAGS="-g -Wall -fPIC -D_GNU_SOURCE"
501 CCASFLAGS="-Wall -fPIC -D_GNU_SOURCE"
504 # everyone builds against lnet and lustre
505 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include"
506 AC_SUBST(EXTRA_KCFLAGS)
512 # AM_CONDITIONAL instances for everything
513 # (so that portals/lustre can disable some if needed)
514 AC_DEFUN([LB_CONDITIONALS],
515 [AM_CONDITIONAL(MODULES, test x$enable_modules = xyes)
516 AM_CONDITIONAL(UTILS, test x$enable_utils = xyes)
517 AM_CONDITIONAL(TESTS, test x$enable_tests = xyes)
518 AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
519 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
520 AM_CONDITIONAL(LINUX, test x$lb_target_os = "xlinux")
521 AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
522 AM_CONDITIONAL(SUNOS, test x$lb_target_os = "xSunOS")
523 AM_CONDITIONAL(USES_DPKG, test x$uses_dpkg = "xyes")
524 AM_CONDITIONAL([USE_QUILT], [test x$use_quilt = xyes])
526 # Sanity check for PCLMULQDQ instruction availability
527 # PCLMULQDQ instruction is a new instruction available beginning with
528 # the all new Core processor family based on the 32nm microarchitecture
529 # codename Westmere. So, $target_cpu = x86_64 should have this instruction
530 # except MIC microarchitecture (k1om).
531 AM_CONDITIONAL(HAVE_PCLMULQDQ, test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om")
532 if test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om" ; then
533 AC_DEFINE(HAVE_PCLMULQDQ, 1, [have PCLMULQDQ instruction])
536 # this lets lustre cancel libsysio, per-branch or if liblustre is
538 if test "x$LIBSYSIO_SUBDIR" = xlibsysio ; then
539 if test "x$with_sysio" != xyes ; then
544 AC_SUBST(LIBSYSIO_SUBDIR)
547 LB_DARWIN_CONDITIONALS
557 # build-specific config files
559 AC_DEFUN([LB_CONFIG_FILES],
565 [Rules:build/Rules.in]
566 AC_PACKAGE_TARNAME[.spec]
567 AC_PACKAGE_TARNAME[-dkms.spec]
569 contrib/lbuild/Makefile
570 contrib/scripts/Makefile
573 lustre-iokit/Makefile
574 lustre-iokit/obdfilter-survey/Makefile
575 lustre-iokit/ost-survey/Makefile
576 lustre-iokit/sgpdd-survey/Makefile
577 lustre-iokit/mds-survey/Makefile
578 lustre-iokit/ior-survey/Makefile
579 lustre-iokit/stats-collect/Makefile
586 AC_DEFUN([LB_CONFIG_SERVERS],
588 AC_ARG_ENABLE([server],
589 AC_HELP_STRING([--disable-server],
590 [disable Lustre server support]),
591 [AS_IF([test x$enable_server != xyes -a x$enable_server != xno],
592 [AC_MSG_ERROR([server valid options are "yes" or "no"])])
593 AS_IF([test x$enable_server = xyes -a x$enable_dist = xyes],
594 [AC_MSG_ERROR([--enable-server cannot be used with --enable-dist])])
596 [AS_IF([test x$enable_dist = xyes],
598 [enable_server=maybe])
602 # There are at least two good reasons why we should really run
603 # LB_CONFIG_MODULES elsewhere before the call to LB_CONFIG_SERVERS:
604 # LB_CONFIG_MODULES needs to be run for client support even when
605 # servers are disabled, and because module support is actually a
606 # prerequisite of server support. However, some things under
607 # LB_CONFIG_MODULES need us to already have checked for --disable-server,
608 # before running, so until LB_CONFIG_MODULES can be reorganized, we
611 AS_IF([test x$enable_modules = xno],[enable_server=no])
615 # If no backends were configured, and the user did not explicitly
616 # require servers to be enabled, we just disable servers.
617 AS_IF([test x$enable_ldiskfs = xno -a x$enable_zfs = xno],
618 [AS_CASE([$enable_server],
619 [maybe], [enable_server=no],
620 [yes], [AC_MSG_ERROR([cannot enable servers, no backends were configured])])
622 [AS_IF([test x$enable_server = xmaybe], [enable_server=yes])]
625 AC_MSG_CHECKING([whether to build Lustre server support])
626 AC_MSG_RESULT([$enable_server])
627 AS_IF([test x$enable_server = xyes],
628 [AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])]
634 # LB_CONFIG_RPMBUILD_OPTIONS
636 # The purpose of this function is to assemble command line options
637 # for the rpmbuild command based on the options passed to the configure
638 # script, and also upon the descisions that configure makes based on
639 # the tests that it runs.
640 # These strings can be passed to rpmbuild on the command line
641 # in the Make targets named "rpms" and "srpm".
643 AC_DEFUN([LB_CONFIG_RPMBUILD_OPTIONS],[
647 eval set -- $ac_configure_args
650 --with-release=* ) ;;
651 --with-kmp-moddir=* ) ;;
652 --enable-tests | --disable-tests ) ;;
653 --with-linux=* | --with-linux-obj=* ) ;;
654 * ) CONFIGURE_ARGS="$CONFIGURE_ARGS '$arg'" ;;
657 if test -n "$CONFIGURE_ARGS" ; then
658 RPMBINARGS="$RPMBINARGS --define \"configure_args $CONFIGURE_ARGS\""
660 if test -n "$LINUX" ; then
661 RPMBINARGS="$RPMBINARGS --define \"kdir $LINUX\""
662 if test -n "$LINUX_OBJ" -a "$LINUX_OBJ" != x"$LINUX" ; then
663 RPMBINARGS="$RPMBINARGS --define \"kobjdir $LINUX_OBJ\""
666 if test -n "$KMP_MODDIR" ; then
667 RPMBINARGS="$RPMBINARGS --define \"kmoddir $KMP_MODDIR\""
669 if test -n "$CROSS_PATH" ; then
670 if test x$enable_server = xyes ; then
672 "*** Don't support cross compilation for the Intel(R) Xeon Phi(TM) card.\n"
676 RPMBINARGS="$RPMBINARGS --define \"post_script build/gen_filelist.sh\""
677 RPMBINARGS="$RPMBINARGS --define \"cross_path $CROSS_PATH\""
678 RPMBINARGS="$RPMBINARGS --define \"rootdir %{cross_path}\""
679 RPMBINARGS="$RPMBINARGS --define \"_prefix %{cross_path}/usr\""
680 RPMBINARGS="$RPMBINARGS --define \"_mandir %{_prefix}/share/man\""
681 RPMBINARGS="$RPMBINARGS --define \"_sysconfdir %{cross_path}/etc\""
682 RPMBINARGS="$RPMBINARGS --define \"make_args $CROSS_VARS\""
683 if test x$CC_TARGET_ARCH = x"x86_64-k1om-linux" ; then
684 RPMBINARGS="$RPMBINARGS --define \"cross_requires intel-mic-gpl\""
687 if test x$enable_tests != xyes ; then
688 RPMBINARGS="$RPMBINARGS --without lustre_tests"
689 RPMSRCARGS="$RPMSRCARGS --without lustre_tests";
691 if test x$enable_server != xyes ; then
692 RPMBINARGS="$RPMBINARGS --without servers"
693 if test -n "$CROSS_SUFFIX" ; then
694 RPMBINARGS="$RPMBINARGS --define \"lustre_name lustre-client$CROSS_SUFFIX\""
697 if test x$enable_ldiskfs != xyes ; then
698 RPMBINARGS="$RPMBINARGS --without ldiskfs"
700 if test x$enable_zfs = xyes ; then
701 RPMBINARGS="$RPMBINARGS --with zfs"
703 if test x$enable_iokit != xyes ; then
704 RPMBINARGS="$RPMBINARGS --without lustre_iokit"
705 RPMSRCARGS="$RPMSRCARGS --without lustre_iokit"
708 RPMBUILD_BINARY_ARGS=$RPMBINARGS
709 RPMBUILD_SOURCE_ARGS=$RPMSRCARGS
711 AC_SUBST(RPMBUILD_BINARY_ARGS)
712 AC_SUBST(RPMBUILD_SOURCE_ARGS)
718 # main configure steps
720 AC_DEFUN([LB_CONFIGURE],
725 LB_DOWNSTREAM_RELEASE
745 # two macros for cmd3
746 m4_ifdef([LC_CONFIG_SPLIT], [LC_CONFIG_SPLIT])
747 m4_ifdef([LC_NODEMAP_PROC_DEBUG], [LC_NODEMAP_PROC_DEBUG])
757 LB_DEFINE_E2FSPROGS_NAMES
765 if test "$SNMP_DIST_SUBDIR" ; then
777 if test "$SNMP_DIST_SUBDIR" ; then
781 AC_SUBST(ac_configure_args)
783 MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.* Modules.symvers Module.symvers'
784 AC_SUBST(MOSTLYCLEANFILES)
786 LB_CONFIG_RPMBUILD_OPTIONS
795 LLCPPFLAGS: $LLCPPFLAGS
797 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
800 Type 'make' to build Lustre.