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
178 # Handle internal/external libsysio
180 AC_DEFUN([LB_PATH_LIBSYSIO], [
181 AC_MSG_CHECKING([location of libsysio])
183 AC_HELP_STRING([--with-sysio=path],
184 [set path to libsysio source (default is included libsysio)]),
186 AS_IF([test "x$lb_target_os" = xlinux],
190 AS_IF([test "x$with_sysio" = xyes], [
191 AC_MSG_RESULT([internal])
192 LB_CHECK_FILE([$srcdir/libsysio/src/rmdir.c], [], [
193 AC_MSG_ERROR([A complete internal libsysio was not found.])
195 LIBSYSIO_SUBDIR="libsysio"
196 SYSIO="$PWD/libsysio"
197 ], [test "x$with_sysio" = xno], [
198 AC_MSG_RESULT([disabled])
200 AC_MSG_RESULT([$with_sysio])
201 LB_CHECK_FILE([$with_sysio/lib/libsysio.a], [], [
202 AC_MSG_ERROR([A complete (built) external libsysio was not found.])
208 enable_sysio=$with_sysio
209 # We have to configure even if we don't build here for make dist to work
210 AC_CONFIG_SUBDIRS([libsysio])
211 ]) # LB_PATH_LIBSYSIO
214 # LB_PATH_LUSTREIOKIT
216 # We no longer handle external lustre-iokit
218 AC_DEFUN([LB_PATH_LUSTREIOKIT], [
219 AC_MSG_CHECKING([whether to build iokit])
220 AC_ARG_ENABLE([iokit],
221 AC_HELP_STRING([--disable-iokit],
222 [disable iokit (default is enable)]),
223 [], [enable_iokit="yes"])
224 AC_MSG_RESULT([$enable_iokit])
225 AS_IF([test "x$enable_iokit" = xyes],
226 [LUSTREIOKIT_SUBDIR="lustre-iokit"],
227 [LUSTREIOKIT_SUBDIR=""])
228 AC_SUBST(LUSTREIOKIT_SUBDIR)
229 AM_CONDITIONAL([BUILD_LUSTREIOKIT], [test "x$enable_iokit" = xyes])
230 ]) # LB_PATH_LUSTREIOKIT
232 # Define no libcfs by default.
233 AC_DEFUN([LB_LIBCFS_DIR], [
234 AS_IF([test "x$libcfs_is_module" = xyes], [
235 LIBCFS_INCLUDE_DIR="libcfs/include"
236 LIBCFS_SUBDIR="libcfs"
238 LIBCFS_INCLUDE_DIR="lnet/include"
241 AC_SUBST(LIBCFS_INCLUDE_DIR)
242 AC_SUBST(LIBCFS_SUBDIR)
248 # check for in-tree snmp support
250 AC_DEFUN([LB_PATH_SNMP], [
251 LB_CHECK_FILE([$srcdir/snmp/lustre-snmp.c], [SNMP_DIST_SUBDIR="snmp"])
252 AC_SUBST(SNMP_DIST_SUBDIR)
253 AC_SUBST(SNMP_SUBDIR)
259 # Build kernel modules?
261 AC_DEFUN([LB_CONFIG_MODULES], [
262 AC_MSG_CHECKING([whether to build Linux kernel modules])
263 AC_ARG_ENABLE([modules],
264 AC_HELP_STRING([--disable-modules],
265 [disable building of Lustre kernel modules]),
267 LC_TARGET_SUPPORTED([enable_modules="yes"],
268 [enable_modules="no"])
270 AC_MSG_RESULT([$enable_modules ($target_os)])
272 AS_IF([test "x$enable_modules" = xyes], [
273 AS_CASE([$target_os],
278 AS_IF([test "x$enable_server" != xno], [LB_EXT4_SRC_DIR])
284 # This is strange - Lustre supports a target we don't
285 AC_MSG_ERROR([Modules are not supported on $target_os])
288 ]) # LB_CONFIG_MODULES
295 AC_DEFUN([LB_CONFIG_UTILS], [
296 AC_MSG_CHECKING([whether to build Lustre utilities])
297 AC_ARG_ENABLE([utils],
298 AC_HELP_STRING([--disable-utils],
299 [disable building of Lustre utility programs]),
300 [], [enable_utils="yes"])
301 AC_MSG_RESULT([$enable_utils])
302 AS_IF([test "x$enable_utils" = xyes], [LB_CONFIG_INIT_SCRIPTS])
310 AC_DEFUN([LB_CONFIG_TESTS], [
311 AC_MSG_CHECKING([whether to build Lustre tests])
312 AC_ARG_ENABLE([tests],
313 AC_HELP_STRING([--disable-tests],
314 [disable building of Lustre tests]),
315 [], [enable_tests="yes"])
316 AC_MSG_RESULT([$enable_tests])
322 # Just enough configure so that "make dist" is useful
324 # this simply re-adjusts some defaults, which of course can be overridden
325 # on the configure line after the --for-dist option
327 AC_DEFUN([LB_CONFIG_DIST], [
328 AC_MSG_CHECKING([whether to configure just enough for make dist])
329 AC_ARG_ENABLE([dist],
330 AC_HELP_STRING([--enable-dist],
331 [only configure enough for make dist]),
332 [], [enable_dist="no"])
333 AC_MSG_RESULT([$enable_dist])
334 AS_IF([test "x$enable_dist" != xno], [
339 enable_liblustre="no"
348 AC_DEFUN([LB_CONFIG_DOCS], [
349 AC_MSG_CHECKING([whether to build Lustre docs])
351 AC_HELP_STRING([--disable-doc],
352 [skip creation of pdf documentation]),
353 [], [enable_doc="no"])
354 AC_MSG_RESULT([$enable_doc])
355 AS_IF([test "x$enable_doc" = xyes],
356 [ENABLE_DOC=1], [ENABLE_DOC=0])
361 # LB_CONFIG_INIT_SCRIPTS
363 # our init scripts only work on red hat linux
365 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS], [
366 ENABLE_INIT_SCRIPTS=0
367 AS_IF([test x$enable_utils = xyes], [
368 AC_CACHE_CHECK([whether to install init scripts], [lb_cv_enable_init_scripts], [
369 # our scripts only work on red hat systems
370 AS_IF([test -f /etc/init.d/functions -a -f /etc/sysconfig/network],
371 [lb_cv_enable_init_scripts="yes"],
372 [lb_cv_enable_init_scripts="no"])
374 AS_IF([test "x$lb_cv_enable_init_scripts" = xyes],
375 [ENABLE_INIT_SCRIPTS=1])
377 AC_SUBST(ENABLE_INIT_SCRIPTS)
383 # add -include config.h
385 AC_DEFUN([LB_CONFIG_HEADERS], [
386 AC_CONFIG_HEADERS([config.h])
387 CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
388 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
389 AC_SUBST(EXTRA_KCFLAGS)
390 ]) # LB_CONFIG_HEADERS
395 # defines for including the toplevel Rules
397 AC_DEFUN([LB_INCLUDE_RULES], [
398 INCLUDE_RULES="include $PWD/Rules"
399 AC_SUBST(INCLUDE_RULES)
400 ]) # LB_INCLUDE_RULES
405 # 'fixup' default paths
407 AC_DEFUN([LB_PATH_DEFAULTS], [
408 # directories for binaries
409 AC_PREFIX_DEFAULT([/usr])
411 sysconfdir='$(CROSS_PATH)/etc'
414 # Directories for documentation and demos.
415 docdir='$(datadir)/doc/$(PACKAGE)'
421 ]) # LB_PATH_DEFAULTS
426 # checks on the C compiler
428 AC_DEFUN([LB_PROG_CC], [
430 AC_CHECK_TOOL(LD, [ld], [no])
431 AC_CHECK_TOOL(OBJDUMP, [objdump], [no])
432 AC_CHECK_TOOL(STRIP, [strip], [no])
434 # --------- unsigned long long sane? -------
435 AC_CHECK_SIZEOF(unsigned long long, 0)
436 AS_IF([test $ac_cv_sizeof_unsigned_long_long != 8],
437 [AC_MSG_ERROR([we assume that sizeof(unsigned long long) == 8.])])
439 AS_IF([test $target_cpu = powerpc64], [
440 AC_MSG_WARN([set compiler with -m64])
441 CFLAGS="$CFLAGS -m64"
445 CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
447 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
450 # Add _GNU_SOURCE for strnlen on linux
451 LLCFLAGS="-g -Wall -fPIC -D_GNU_SOURCE"
454 CCASFLAGS="-Wall -fPIC -D_GNU_SOURCE"
457 # everyone builds against lnet and lustre
458 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include"
459 AC_SUBST(EXTRA_KCFLAGS)
465 # AM_CONDITIONAL instances for everything
466 # (so that portals/lustre can disable some if needed)
468 AC_DEFUN([LB_CONDITIONALS], [
469 AM_CONDITIONAL([MODULES], [test x$enable_modules = xyes])
470 AM_CONDITIONAL([UTILS], [test x$enable_utils = xyes])
471 AM_CONDITIONAL([TESTS], [test x$enable_tests = xyes])
472 AM_CONDITIONAL([DOC], [test x$ENABLE_DOC = x1])
473 AM_CONDITIONAL([INIT_SCRIPTS], [test x$ENABLE_INIT_SCRIPTS = x1])
474 AM_CONDITIONAL([LINUX], [test x$lb_target_os = xlinux])
475 AM_CONDITIONAL([DARWIN], [test x$lb_target_os = xdarwin])
476 AM_CONDITIONAL([SUNOS], [test x$lb_target_os = xSunOS])
477 AM_CONDITIONAL([USES_DPKG], [test x$uses_dpkg = xyes])
478 AM_CONDITIONAL([USE_QUILT], [test x$use_quilt = xyes])
480 # Sanity check for PCLMULQDQ instruction availability
481 # PCLMULQDQ instruction is a new instruction available beginning with
482 # the all new Core processor family based on the 32nm microarchitecture
483 # codename Westmere. So, $target_cpu = x86_64 should have this instruction
484 # except MIC microarchitecture (k1om).
485 AM_CONDITIONAL(HAVE_PCLMULQDQ, test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om")
486 AS_IF([test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om"],
487 [AC_DEFINE(HAVE_PCLMULQDQ, 1, [have PCLMULQDQ instruction])])
489 # this lets lustre cancel libsysio, per-branch or if liblustre is
491 AS_IF([test "x$LIBSYSIO_SUBDIR" = xlibsysio], [
492 AS_IF([test "x$with_sysio" != xyes], [
497 AC_SUBST(LIBSYSIO_SUBDIR)
500 LB_DARWIN_CONDITIONALS
510 # build-specific config files
512 AC_DEFUN([LB_CONFIG_FILES], [
517 [Rules:build/Rules.in]
518 AC_PACKAGE_TARNAME[.spec]
519 AC_PACKAGE_TARNAME[-dkms.spec]
521 contrib/lbuild/Makefile
522 contrib/scripts/Makefile
525 lustre-iokit/Makefile
526 lustre-iokit/obdfilter-survey/Makefile
527 lustre-iokit/ost-survey/Makefile
528 lustre-iokit/sgpdd-survey/Makefile
529 lustre-iokit/mds-survey/Makefile
530 lustre-iokit/ior-survey/Makefile
531 lustre-iokit/stats-collect/Makefile
538 AC_DEFUN([LB_CONFIG_SERVERS], [
539 AC_ARG_ENABLE([server],
540 AC_HELP_STRING([--disable-server],
541 [disable Lustre server support]), [
542 AS_IF([test x$enable_server != xyes -a x$enable_server != xno],
543 [AC_MSG_ERROR([server valid options are "yes" or "no"])])
544 AS_IF([test x$enable_server = xyes -a x$enable_dist = xyes],
545 [AC_MSG_ERROR([--enable-server cannot be used with --enable-dist])])
547 AS_IF([test x$enable_dist = xyes],
548 [enable_server=no], [enable_server=maybe])
551 # There are at least two good reasons why we should really run
552 # LB_CONFIG_MODULES elsewhere before the call to LB_CONFIG_SERVERS:
553 # LB_CONFIG_MODULES needs to be run for client support even when
554 # servers are disabled, and because module support is actually a
555 # prerequisite of server support. However, some things under
556 # LB_CONFIG_MODULES need us to already have checked for --disable-server,
557 # before running, so until LB_CONFIG_MODULES can be reorganized, we
560 AS_IF([test x$enable_modules = xno], [enable_server=no])
564 # If no backends were configured, and the user did not explicitly
565 # require servers to be enabled, we just disable servers.
566 AS_IF([test x$enable_ldiskfs = xno -a x$enable_zfs = xno], [
567 AS_CASE([$enable_server],
568 [maybe], [enable_server=no],
569 [yes], [AC_MSG_ERROR([cannot enable servers, no backends were configured])])
571 AS_IF([test x$enable_server = xmaybe], [enable_server=yes])
574 AC_MSG_CHECKING([whether to build Lustre server support])
575 AC_MSG_RESULT([$enable_server])
576 AS_IF([test x$enable_server = xyes],
577 [AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])])
578 ]) # LB_CONFIG_SERVERS
581 # LB_CONFIG_RPMBUILD_OPTIONS
583 # The purpose of this function is to assemble command line options
584 # for the rpmbuild command based on the options passed to the configure
585 # script, and also upon the descisions that configure makes based on
586 # the tests that it runs.
587 # These strings can be passed to rpmbuild on the command line
588 # in the Make targets named "rpms" and "srpm".
590 AC_DEFUN([LB_CONFIG_RPMBUILD_OPTIONS], [
594 eval set -- $ac_configure_args
597 --with-release=* ) ;;
598 --with-kmp-moddir=* ) ;;
599 --with-linux=* | --with-linux-obj=* ) ;;
600 --enable-tests | --disable-tests ) ;;
601 --enable-modules | --disable-modules ) ;;
602 * ) CONFIGURE_ARGS="$CONFIGURE_ARGS '$arg'" ;;
605 if test -n "$CONFIGURE_ARGS" ; then
606 RPMBINARGS="$RPMBINARGS --define \"configure_args $CONFIGURE_ARGS\""
608 if test -n "$LINUX" ; then
609 RPMBINARGS="$RPMBINARGS --define \"kdir $LINUX\""
610 if test -n "$LINUX_OBJ" -a "$LINUX_OBJ" != x"$LINUX" ; then
611 RPMBINARGS="$RPMBINARGS --define \"kobjdir $LINUX_OBJ\""
614 if test -n "$KMP_MODDIR" ; then
615 RPMBINARGS="$RPMBINARGS --define \"kmoddir $KMP_MODDIR\""
617 if test -n "$CROSS_PATH" ; then
618 if test x$enable_server = xyes ; then
620 "*** Don't support cross compilation for the Intel(R) Xeon Phi(TM) card.\n"
624 RPMBINARGS="$RPMBINARGS --define \"post_script build/gen_filelist.sh\""
625 RPMBINARGS="$RPMBINARGS --define \"cross_path $CROSS_PATH\""
626 RPMBINARGS="$RPMBINARGS --define \"rootdir %{cross_path}\""
627 RPMBINARGS="$RPMBINARGS --define \"_prefix %{cross_path}/usr\""
628 RPMBINARGS="$RPMBINARGS --define \"_mandir %{_prefix}/share/man\""
629 RPMBINARGS="$RPMBINARGS --define \"_sysconfdir %{cross_path}/etc\""
630 RPMBINARGS="$RPMBINARGS --define \"make_args $CROSS_VARS\""
631 if test x$CC_TARGET_ARCH = x"x86_64-k1om-linux" ; then
632 RPMBINARGS="$RPMBINARGS --define \"cross_requires intel-mic-gpl\""
635 if test x$enable_modules != xyes ; then
636 RPMBINARGS="$RPMBINARGS --without lustre_modules"
638 if test x$enable_tests != xyes ; then
639 RPMBINARGS="$RPMBINARGS --without lustre_tests"
640 RPMSRCARGS="$RPMSRCARGS --without lustre_tests"
642 if test x$enable_server != xyes ; then
643 RPMBINARGS="$RPMBINARGS --without servers"
644 if test -n "$CROSS_SUFFIX" ; then
645 RPMBINARGS="$RPMBINARGS --define \"lustre_name lustre-client$CROSS_SUFFIX\""
648 if test x$enable_ldiskfs != xyes ; then
649 RPMBINARGS="$RPMBINARGS --without ldiskfs"
651 if test x$enable_zfs = xyes ; then
652 RPMBINARGS="$RPMBINARGS --with zfs"
654 if test x$enable_iokit != xyes ; then
655 RPMBINARGS="$RPMBINARGS --without lustre_iokit"
656 RPMSRCARGS="$RPMSRCARGS --without lustre_iokit"
659 RPMBUILD_BINARY_ARGS=$RPMBINARGS
660 RPMBUILD_SOURCE_ARGS=$RPMSRCARGS
662 AC_SUBST(RPMBUILD_BINARY_ARGS)
663 AC_SUBST(RPMBUILD_SOURCE_ARGS)
664 ]) # LB_CONFIG_RPMBUILD_OPTIONS
669 # main configure steps
671 AC_DEFUN([LB_CONFIGURE], [
672 AC_MSG_NOTICE([Lustre base checks
673 ==============================================================================])
678 LB_DOWNSTREAM_RELEASE
698 # two macros for cmd3
699 m4_ifdef([LC_CONFIG_SPLIT], [LC_CONFIG_SPLIT])
700 m4_ifdef([LC_NODEMAP_PROC_DEBUG], [LC_NODEMAP_PROC_DEBUG])
710 LB_DEFINE_E2FSPROGS_NAMES
716 AS_IF([test -n "$SNMP_DIST_SUBDIR"], [LS_CONFIGURE])
725 AS_IF([test -n "$SNMP_DIST_SUBDIR"], [LS_CONFIG_FILES])
727 AC_SUBST(ac_configure_args)
729 MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.* Modules.symvers Module.symvers'
730 AC_SUBST(MOSTLYCLEANFILES)
732 LB_CONFIG_RPMBUILD_OPTIONS
741 LLCPPFLAGS: $LLCPPFLAGS
743 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
746 Type 'make' to build Lustre.