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], [
22 AC_SUBST(lb_target_os)
23 ]) # LB_CANONICAL_SYSTEM
26 # LB_DOWNSTREAM_RELEASE
28 AC_DEFUN([LB_DOWNSTREAM_RELEASE],
29 [AC_ARG_WITH([downstream-release],
30 AC_HELP_STRING([--with-downstream-release=string],
31 [set a string in the BUILD_VERSION and RPM Release: (default is nothing)]),
32 [DOWNSTREAM_RELEASE=$with_downstream_release],
33 [ # if not specified, see if it's in the META file
35 [DOWNSTREAM_RELEASE=$(sed -ne '/^LOCAL_VERSION =/s/.*= *//p' META)])
37 AC_SUBST(DOWNSTREAM_RELEASE)
38 ]) # LB_DOWNSTREAM_RELEASE
43 # Check if the source is a GA release and if not, set a "BUILDID"
45 # Currently there are at least two ways/modes of/for doing this. One
46 # is if we are in a valid git repository, the other is if we are in a
47 # non-git source tree of some form. Building the latter from the former
48 # will be handled here.
49 AC_DEFUN([LB_BUILDID], [
50 AC_CACHE_CHECK([for buildid], [lb_cv_buildid], [
52 AS_IF([git branch >/dev/null 2>&1], [
55 ver=$(git describe --match v[[0-9]]_*_[[0-9]]* --tags)
56 if [[[ $ver = *-*-* ]]]; then
62 # it's tempting to use [[ $ver =~ ^v([0-9]+_)+([0-9]+|RC[0-9]+)$ ]]
63 # here but the portability of the regex on the right is dismal
65 if echo "$ver" | egrep -q "^v([[0-9]]+_)+([[0-9]]+|RC[[0-9]]+)$"; then
66 ver=$(echo $ver | sed -e 's/^v\(.*\)/\1/' \
67 -e 's/_RC[[0-9]].*$//' -e 's/_/./g')
70 # a "lustre fix" value of .0 should be truncated
71 if [[[ $ver = *.*.*.0 ]]]; then
74 # ditto for a "lustre fix" value of _0
75 if [[[ $ver = v*_*_*_0 ]]]; then
78 if [[[ $ver = v*_*_* ]]]; then
83 if test "$ver" != "$VERSION"; then
84 AC_MSG_WARN([most recent tag found: $ver does not match current version $VERSION.])
87 if test "$ffw" != "0"; then
91 lb_cv_buildid=$(sed -ne '/^BUILDID =/s/.*= *//p' META)
94 AS_IF([test -z "$lb_cv_buildid"], [
97 FIXME: I don't know how to deal with source trees outside of git that
98 don't have a META file. Not setting a buildid.
101 BUILDID=$lb_cv_buildid
108 # Check for file existence even when cross compiling
113 AC_DEFUN([LB_CHECK_FILE], [
114 AS_VAR_PUSHDEF([lb_file], [lb_cv_file_$1])dnl
115 AC_CACHE_CHECK([for $1], lb_file, [
116 AS_IF([test -r "$1"],
117 [AS_VAR_SET(lb_file, [yes])],
118 [AS_VAR_SET(lb_file, [no])])
120 AS_VAR_IF([lb_file], [yes], [$2], [$3])[]dnl
121 AS_VAR_POPDEF([lb_file])dnl
125 # LB_ARG_LIBS_INCLUDES
127 # support for --with-foo, --with-foo-includes, and --with-foo-libs in
128 # a single magical macro
130 AC_DEFUN([LB_ARG_LIBS_INCLUDES], [
131 lb_pathvar="m4_bpatsubst([$2], -, _)"
132 AC_MSG_CHECKING([for $1])
134 AC_HELP_STRING([--with-$2=path],
137 AS_IF([test "x$withval" = xyes],
138 [eval "$lb_pathvar='$3'"],
139 [eval "$lb_pathvar='$withval'"])
140 AC_MSG_RESULT([${!lb_pathvar:-no}])
142 AS_IF([test "x${!lb_pathvar}" != x -a "x${!lb_pathvar}" != xno], [
143 AC_MSG_CHECKING([for $1 includes])
144 AC_ARG_WITH([$2-includes],
145 AC_HELP_STRING([--with-$2-includes=path],
146 [path to $1 includes]),
149 lb_includevar="${lb_pathvar}_includes"
150 AS_IF([test "x$withval" = xyes],
151 [eval "${lb_includevar}='${!lb_pathvar}/include'"],
152 [eval "${lb_includevar}='$withval'"])
153 AC_MSG_RESULT([${!lb_includevar}])
155 AC_MSG_CHECKING([for $1 libs])
156 AC_ARG_WITH([$2-libs],
157 AC_HELP_STRING([--with-$2-libs=path],
161 lb_libvar="${lb_pathvar}_libs"
162 AS_IF([test "x$withval" = xyes],
163 [eval "${lb_libvar}='${!lb_pathvar}/lib'"],
164 [eval "${lb_libvar}='$withval'"])
165 AC_MSG_RESULT([${!lb_libvar}])
167 ]) # LB_ARG_LIBS_INCLUDES
170 # LB_PATH_LUSTREIOKIT
172 # We no longer handle external lustre-iokit
174 AC_DEFUN([LB_PATH_LUSTREIOKIT], [
175 AC_MSG_CHECKING([whether to build iokit])
176 AC_ARG_ENABLE([iokit],
177 AC_HELP_STRING([--disable-iokit],
178 [disable iokit (default is enable)]),
179 [], [enable_iokit="yes"])
180 AC_MSG_RESULT([$enable_iokit])
181 AS_IF([test "x$enable_iokit" = xyes],
182 [LUSTREIOKIT_SUBDIR="lustre-iokit"],
183 [LUSTREIOKIT_SUBDIR=""])
184 AC_SUBST(LUSTREIOKIT_SUBDIR)
185 AM_CONDITIONAL([BUILD_LUSTREIOKIT], [test "x$enable_iokit" = xyes])
186 ]) # LB_PATH_LUSTREIOKIT
188 # Define no libcfs by default.
189 AC_DEFUN([LB_LIBCFS_DIR], [
190 AS_IF([test "x$libcfs_is_module" = xyes], [
191 LIBCFS_INCLUDE_DIR="libcfs/include"
192 LIBCFS_SUBDIR="libcfs"
194 LIBCFS_INCLUDE_DIR="lnet/include"
197 AC_SUBST(LIBCFS_INCLUDE_DIR)
198 AC_SUBST(LIBCFS_SUBDIR)
204 # check for in-tree snmp support
206 AC_DEFUN([LB_PATH_SNMP], [
207 LB_CHECK_FILE([$srcdir/snmp/lustre-snmp.c], [SNMP_DIST_SUBDIR="snmp"])
208 AC_SUBST(SNMP_DIST_SUBDIR)
209 AC_SUBST(SNMP_SUBDIR)
215 # Build kernel modules?
217 AC_DEFUN([LB_CONFIG_MODULES], [
218 AC_MSG_CHECKING([whether to build Linux kernel modules])
219 AC_ARG_ENABLE([modules],
220 AC_HELP_STRING([--disable-modules],
221 [disable building of Lustre kernel modules]),
223 LC_TARGET_SUPPORTED([enable_modules="yes"],
224 [enable_modules="no"])
226 AC_MSG_RESULT([$enable_modules ($target_os)])
228 AS_IF([test "x$enable_modules" = xyes], [
229 AS_CASE([$target_os],
234 AS_IF([test "x$enable_server" != xno], [LB_EXT4_SRC_DIR])
237 # This is strange - Lustre supports a target we don't
238 AC_MSG_ERROR([Modules are not supported on $target_os])
241 ]) # LB_CONFIG_MODULES
248 AC_DEFUN([LB_CONFIG_UTILS], [
249 AC_MSG_CHECKING([whether to build Lustre utilities])
250 AC_ARG_ENABLE([utils],
251 AC_HELP_STRING([--disable-utils],
252 [disable building of Lustre utility programs]),
253 [], [enable_utils="yes"])
254 AC_MSG_RESULT([$enable_utils])
262 AC_DEFUN([LB_CONFIG_TESTS], [
263 AC_MSG_CHECKING([whether to build Lustre tests])
264 AC_ARG_ENABLE([tests],
265 AC_HELP_STRING([--disable-tests],
266 [disable building of Lustre tests]),
267 [], [enable_tests="yes"])
268 AC_MSG_RESULT([$enable_tests])
274 # Just enough configure so that "make dist" is useful
276 # this simply re-adjusts some defaults, which of course can be overridden
277 # on the configure line after the --for-dist option
279 AC_DEFUN([LB_CONFIG_DIST], [
280 AC_MSG_CHECKING([whether to configure just enough for make dist])
281 AC_ARG_ENABLE([dist],
282 AC_HELP_STRING([--enable-dist],
283 [only configure enough for make dist]),
284 [], [enable_dist="no"])
285 AC_MSG_RESULT([$enable_dist])
286 AS_IF([test "x$enable_dist" != xno], [
299 AC_DEFUN([LB_CONFIG_DOCS], [
300 AC_MSG_CHECKING([whether to build Lustre docs])
302 AC_HELP_STRING([--disable-doc],
303 [skip creation of pdf documentation]),
304 [], [enable_doc="no"])
305 AC_MSG_RESULT([$enable_doc])
306 AS_IF([test "x$enable_doc" = xyes],
307 [ENABLE_DOC=1], [ENABLE_DOC=0])
316 AC_DEFUN([LB_CONFIG_MANPAGES], [
317 AC_MSG_CHECKING([whether to build Lustre manpages])
318 AC_ARG_ENABLE([manpages],
319 AC_HELP_STRING([--disable-manpages],
320 [skip creation and inclusion of man pages (default is enable)]),
321 [], [enable_manpages="yes"])
322 AC_MSG_RESULT([$enable_manpages])
323 AS_IF([test "x$enable_manpages" = xyes], [
324 AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], [])
325 if test "x$RST2MAN" = "x"; then
327 [rst2man is needed to build the man pages. Install python-docutils.])
330 ]) # LB_CONFIG_MANPAGES
335 # add -include config.h
337 AC_DEFUN([LB_CONFIG_HEADERS], [
338 AC_CONFIG_HEADERS([config.h])
339 CPPFLAGS="-include $PWD/config.h $CPPFLAGS"
340 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
341 AC_SUBST(EXTRA_KCFLAGS)
342 ]) # LB_CONFIG_HEADERS
347 # defines for including the toplevel Rules
349 AC_DEFUN([LB_INCLUDE_RULES], [
350 INCLUDE_RULES="include $PWD/Rules"
351 AC_SUBST(INCLUDE_RULES)
352 ]) # LB_INCLUDE_RULES
357 # 'fixup' default paths
359 AC_DEFUN([LB_PATH_DEFAULTS], [
360 # directories for binaries
361 AC_PREFIX_DEFAULT([/usr])
363 sysconfdir='$(CROSS_PATH)/etc'
366 # Directories for documentation and demos.
367 docdir='$(datadir)/doc/$(PACKAGE)'
373 ]) # LB_PATH_DEFAULTS
378 # checks on the C compiler
380 AC_DEFUN([LB_PROG_CC], [
382 AC_CHECK_TOOL(LD, [ld], [no])
383 AC_CHECK_TOOL(OBJDUMP, [objdump], [no])
384 AC_CHECK_TOOL(STRIP, [strip], [no])
386 # --------- unsigned long long sane? -------
387 AC_CHECK_SIZEOF(unsigned long long, 0)
388 AS_IF([test $ac_cv_sizeof_unsigned_long_long != 8],
389 [AC_MSG_ERROR([we assume that sizeof(unsigned long long) == 8.])])
391 AS_IF([test $target_cpu = powerpc64], [
392 AC_MSG_WARN([set compiler with -m64])
393 CFLAGS="$CFLAGS -m64"
397 CPPFLAGS="-I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include $CPPFLAGS"
399 CCASFLAGS="-Wall -fPIC -D_GNU_SOURCE"
402 # everyone builds against lnet and lustre
403 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include"
404 AC_SUBST(EXTRA_KCFLAGS)
410 # AM_CONDITIONAL instances for everything
411 # (so that portals/lustre can disable some if needed)
413 AC_DEFUN([LB_CONDITIONALS], [
414 AM_CONDITIONAL([MODULES], [test x$enable_modules = xyes])
415 AM_CONDITIONAL([UTILS], [test x$enable_utils = xyes])
416 AM_CONDITIONAL([TESTS], [test x$enable_tests = xyes])
417 AM_CONDITIONAL([DOC], [test x$ENABLE_DOC = x1])
418 AM_CONDITIONAL([MANPAGES], [test x$enable_manpages = xyes])
419 AM_CONDITIONAL([LINUX], [test x$lb_target_os = xlinux])
420 AM_CONDITIONAL([USES_DPKG], [test x$uses_dpkg = xyes])
421 AM_CONDITIONAL([USE_QUILT], [test x$use_quilt = xyes])
422 AM_CONDITIONAL([RHEL], [test x$RHEL_KERNEL = xyes])
423 AM_CONDITIONAL([SUSE], [test x$SUSE_KERNEL = xyes])
425 # Sanity check for PCLMULQDQ instruction availability
426 # PCLMULQDQ instruction is a new instruction available beginning with
427 # the all new Core processor family based on the 32nm microarchitecture
428 # codename Westmere. So, $target_cpu = x86_64 should have this instruction
429 # except MIC microarchitecture (k1om).
430 AM_CONDITIONAL(HAVE_PCLMULQDQ, test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om")
431 AS_IF([test x$target_cpu = "xx86_64" -a x$target_vendor != "xk1om"],
432 [AC_DEFINE(HAVE_PCLMULQDQ, 1, [have PCLMULQDQ instruction])])
442 # build-specific config files
444 AC_DEFUN([LB_CONFIG_FILES], [
449 [Rules:build/Rules.in]
450 AC_PACKAGE_TARNAME[.spec]
451 AC_PACKAGE_TARNAME[-dkms.spec]
453 contrib/lbuild/Makefile
454 contrib/scripts/Makefile
457 lustre-iokit/Makefile
458 lustre-iokit/obdfilter-survey/Makefile
459 lustre-iokit/ost-survey/Makefile
460 lustre-iokit/sgpdd-survey/Makefile
461 lustre-iokit/mds-survey/Makefile
462 lustre-iokit/ior-survey/Makefile
463 lustre-iokit/stats-collect/Makefile
470 AC_DEFUN([LB_CONFIG_SERVERS], [
471 AC_ARG_ENABLE([server],
472 AC_HELP_STRING([--disable-server],
473 [disable Lustre server support]), [
474 AS_IF([test x$enable_server != xyes -a x$enable_server != xno],
475 [AC_MSG_ERROR([server valid options are "yes" or "no"])])
476 AS_IF([test x$enable_server = xyes -a x$enable_dist = xyes],
477 [AC_MSG_ERROR([--enable-server cannot be used with --enable-dist])])
479 AS_IF([test x$enable_dist = xyes],
480 [enable_server=no], [enable_server=maybe])
483 # There are at least two good reasons why we should really run
484 # LB_CONFIG_MODULES elsewhere before the call to LB_CONFIG_SERVERS:
485 # LB_CONFIG_MODULES needs to be run for client support even when
486 # servers are disabled, and because module support is actually a
487 # prerequisite of server support. However, some things under
488 # LB_CONFIG_MODULES need us to already have checked for --disable-server,
489 # before running, so until LB_CONFIG_MODULES can be reorganized, we
492 AS_IF([test x$enable_modules = xno], [enable_server=no])
496 # If no backends were configured, and the user did not explicitly
497 # require servers to be enabled, we just disable servers.
498 AS_IF([test x$enable_ldiskfs = xno -a x$enable_zfs = xno], [
499 AS_CASE([$enable_server],
500 [maybe], [enable_server=no],
501 [yes], [AC_MSG_ERROR([cannot enable servers, no backends were configured])])
503 AS_IF([test x$enable_server = xmaybe], [enable_server=yes])
506 AC_MSG_CHECKING([whether to build Lustre server support])
507 AC_MSG_RESULT([$enable_server])
508 AS_IF([test x$enable_server = xyes],
509 [AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])])
510 ]) # LB_CONFIG_SERVERS
513 # LB_CONFIG_RPMBUILD_OPTIONS
515 # The purpose of this function is to assemble command line options
516 # for the rpmbuild command based on the options passed to the configure
517 # script, and also upon the decisions that configure makes based on
518 # the tests that it runs.
519 # These strings can be passed to rpmbuild on the command line
520 # in the Make targets named "rpms" and "srpm".
522 AC_DEFUN([LB_CONFIG_RPMBUILD_OPTIONS], [
525 eval set -- $ac_configure_args
529 -C | --cache-file=* ) ;;
530 --prefix=* | --*-prefix=* ) ;;
532 --with-release=* ) ;;
533 --with-kmp-moddir=* ) ;;
534 --with-linux=* | --with-linux-obj=* ) ;;
535 --enable-ldiskfs | --disable-ldiskfs ) ;;
536 --enable-modules | --disable-modules ) ;;
537 --enable-server | --disable-server ) ;;
538 --enable-tests | --disable-tests ) ;;
539 --enable-utils | --disable-utils ) ;;
540 --enable-iokit | --disable-iokit ) ;;
541 --enable-dlc | --disable-dlc ) ;;
542 --enable-manpages | --disable-manpages ) ;;
543 * ) CONFIGURE_ARGS="$CONFIGURE_ARGS '$arg'" ;;
546 if test -n "$CONFIGURE_ARGS" ; then
547 RPMBINARGS="$RPMBINARGS --define \"configure_args $CONFIGURE_ARGS\""
549 if test -n "$LINUX" ; then
550 RPMBINARGS="$RPMBINARGS --define \"kdir $LINUX\""
551 if test -n "$LINUX_OBJ" -a "$LINUX_OBJ" != x"$LINUX" ; then
552 RPMBINARGS="$RPMBINARGS --define \"kobjdir $LINUX_OBJ\""
555 if test -n "$KMP_MODDIR" ; then
556 RPMBINARGS="$RPMBINARGS --define \"kmoddir $KMP_MODDIR\""
558 if test -n "$CROSS_PATH" ; then
559 if test x$enable_server = xyes ; then
561 "*** Don't support cross compilation for the Intel(R) Xeon Phi(TM) card.\n"
565 RPMBINARGS="$RPMBINARGS --define \"post_script build/gen_filelist.sh\""
566 RPMBINARGS="$RPMBINARGS --define \"cross_path $CROSS_PATH\""
567 RPMBINARGS="$RPMBINARGS --define \"rootdir %{cross_path}\""
568 RPMBINARGS="$RPMBINARGS --define \"_prefix %{cross_path}/usr\""
569 RPMBINARGS="$RPMBINARGS --define \"_mandir %{_prefix}/share/man\""
570 RPMBINARGS="$RPMBINARGS --define \"_sysconfdir %{cross_path}/etc\""
571 RPMBINARGS="$RPMBINARGS --define \"make_args $CROSS_VARS\""
572 if test x$CC_TARGET_ARCH = x"x86_64-k1om-linux" ; then
573 RPMBINARGS="$RPMBINARGS --define \"cross_requires intel-mic-gpl\""
576 if test x$enable_modules != xyes ; then
577 RPMBINARGS="$RPMBINARGS --without lustre_modules"
579 if test x$enable_tests != xyes ; then
580 RPMBINARGS="$RPMBINARGS --without lustre_tests"
582 if test x$enable_utils != xyes ; then
583 RPMBINARGS="$RPMBINARGS --without lustre_utils"
585 if test x$enable_server != xyes ; then
586 RPMBINARGS="$RPMBINARGS --without servers"
587 if test -n "$CROSS_SUFFIX" ; then
588 RPMBINARGS="$RPMBINARGS --define \"lustre_name lustre-client$CROSS_SUFFIX\""
591 if test x$enable_ldiskfs != xyes ; then
592 RPMBINARGS="$RPMBINARGS --without ldiskfs"
594 if test x$enable_zfs = xyes ; then
595 RPMBINARGS="$RPMBINARGS --with zfs"
597 if test x$enable_iokit != xyes ; then
598 RPMBINARGS="$RPMBINARGS --without lustre_iokit"
600 if test x$USE_DLC = xyes ; then
601 RPMBINARGS="$RPMBINARGS --with lnet_dlc"
603 if test x$enable_manpages != xyes ; then
604 RPMBINARGS="$RPMBINARGS --without manpages"
607 RPMBUILD_BINARY_ARGS=$RPMBINARGS
609 AC_SUBST(RPMBUILD_BINARY_ARGS)
610 ]) # LB_CONFIG_RPMBUILD_OPTIONS
615 # main configure steps
617 AC_DEFUN([LB_CONFIGURE], [
618 AC_MSG_NOTICE([Lustre base checks
619 ==============================================================================])
624 LB_DOWNSTREAM_RELEASE
646 # Tests depends from utils (multiop from liblustreapi)
647 AS_IF([test "x$enable_utils" = xno], [enable_tests="no"])
649 m4_ifdef([LC_NODEMAP_PROC_DEBUG], [LC_NODEMAP_PROC_DEBUG])
656 LB_DEFINE_E2FSPROGS_NAMES
661 AS_IF([test -n "$SNMP_DIST_SUBDIR"], [LS_CONFIGURE])
670 AS_IF([test -n "$SNMP_DIST_SUBDIR"], [LS_CONFIG_FILES])
672 AC_SUBST(ac_configure_args)
674 MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.* Modules.symvers Module.symvers'
675 AC_SUBST(MOSTLYCLEANFILES)
677 LB_CONFIG_RPMBUILD_OPTIONS
687 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
689 Type 'make' to build Lustre.