Whamcloud - gitweb
b=11879
[fs/lustre-release.git] / build / autoconf / lustre-build.m4
1 #
2 # LB_CHECK_VERSION
3 #
4 # Verify that LUSTRE_VERSION was defined properly
5 #
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.])
9 fi
10 ])
11
12 #
13 # LB_CANONICAL_SYSTEM
14 #
15 # fixup $target_os for use in other places
16 #
17 AC_DEFUN([LB_CANONICAL_SYSTEM],
18 [case $target_os in
19         linux*)
20                 lb_target_os="linux"
21                 ;;
22         darwin*)
23                 lb_target_os="darwin"
24                 ;;
25         solaris2.11*)
26                 lb_target_os="SunOS"
27                 ;;esac
28 AC_SUBST(lb_target_os)
29 ])
30
31 #
32 # LB_CHECK_FILE
33 #
34 # Check for file existance even when cross compiling
35 #
36 AC_DEFUN([LB_CHECK_FILE],
37 [AS_VAR_PUSHDEF([lb_File], [lb_cv_file_$1])dnl
38 AC_CACHE_CHECK([for $1], lb_File,
39 [if test -r "$1"; then
40   AS_VAR_SET(lb_File, yes)
41 else
42   AS_VAR_SET(lb_File, no)
43 fi])
44 AS_IF([test AS_VAR_GET(lb_File) = yes], [$2], [$3])[]dnl
45 AS_VAR_POPDEF([lb_File])dnl
46 ])# LB_CHECK_FILE
47
48 #
49 # LB_CHECK_FILES
50 #
51 # LB_CHECK_FILE over multiple files
52 #
53 AC_DEFUN([LB_CHECK_FILES],
54 [AC_FOREACH([AC_FILE_NAME], [$1],
55   [LB_CHECK_FILE(AC_FILE_NAME,
56                  [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_FILE_NAME), 1,
57                                     [Define to 1 if you have the
58                                      file `]AC_File['.])
59 $2],
60                  [$3])])])
61
62 #
63 # LB_ARG_LIBS_INCLUDES
64 #
65 # support for --with-foo, --with-foo-includes, and --with-foo-libs in
66 # a single magical macro
67 #
68 AC_DEFUN([LB_ARG_LIBS_INCLUDES],
69 [lb_pathvar="m4_bpatsubst([$2], -, _)"
70 AC_MSG_CHECKING([for $1])
71 AC_ARG_WITH([$2],
72         AC_HELP_STRING([--with-$2=path],
73                 [path to $1]),
74         [],[withval=$4])
75
76 if test x$withval = xyes ; then
77         eval "$lb_pathvar='$3'"
78 else
79         eval "$lb_pathvar='$withval'"
80 fi
81 AC_MSG_RESULT([${!lb_pathvar:-no}])
82
83 if test x${!lb_pathvar} != x -a x${!lb_pathvar} != xno ; then
84         AC_MSG_CHECKING([for $1 includes])
85         AC_ARG_WITH([$2-includes],
86                 AC_HELP_STRING([--with-$2-includes=path],
87                         [path to $1 includes]),
88                 [],[withval='yes'])
89
90         lb_includevar="${lb_pathvar}_includes"
91         if test x$withval = xyes ; then
92                 eval "${lb_includevar}='${!lb_pathvar}/include'"
93         else
94                 eval "${lb_includevar}='$withval'"
95         fi
96         AC_MSG_RESULT([${!lb_includevar}])
97
98         AC_MSG_CHECKING([for $1 libs])
99         AC_ARG_WITH([$2-libs],
100                 AC_HELP_STRING([--with-$2-libs=path],
101                         [path to $1 libs]),
102                 [],[withval='yes'])
103
104         lb_libvar="${lb_pathvar}_libs"
105         if test x$withval = xyes ; then
106                 eval "${lb_libvar}='${!lb_pathvar}/lib'"
107         else
108                 eval "${lb_libvar}='$withval'"
109         fi
110         AC_MSG_RESULT([${!lb_libvar}])
111 fi
112 ])
113 ])
114
115 #
116 # LB_PATH_DMU
117 # Support for --with-dmu
118 #
119 AC_DEFUN([LB_PATH_DMU],
120 [AC_ARG_WITH([dmu],
121         AC_HELP_STRING([--with-dmu=path],
122                        [set path to a built dmu]),
123         [
124                 DMU_SRC=$with_dmu
125                 dmu=true
126         ],
127         [
128                 dmu=false
129                 DMU_SRC=""
130         ])
131 AM_CONDITIONAL([ENABLE_DMU], [test x$dmu = xtrue])
132 AC_SUBST(DMU_SRC)
133 ])
134
135 #
136 # LB_PATH_LIBSYSIO
137 #
138 # Handle internal/external libsysio
139 #
140 AC_DEFUN([LB_PATH_LIBSYSIO],
141 [AC_ARG_WITH([sysio],
142         AC_HELP_STRING([--with-sysio=path],
143                         [set path to libsysio source (default is included libsysio)]),
144         [],[
145                 case $lb_target_os in
146                         linux)
147                                 with_sysio='yes'
148                                 ;;
149                         *)
150                                 with_sysio='no'
151                                 ;;
152                 esac
153         ])
154 AC_MSG_CHECKING([location of libsysio])
155 enable_sysio="$with_sysio"
156 case x$with_sysio in
157         xyes)
158                 AC_MSG_RESULT([internal])
159                 LB_CHECK_FILE([$srcdir/libsysio/src/rmdir.c],[],[
160                         AC_MSG_ERROR([A complete internal libsysio was not found.])
161                 ])
162                 LIBSYSIO_SUBDIR="libsysio"
163                 SYSIO="$PWD/libsysio"
164                 ;;
165         xno)
166                 AC_MSG_RESULT([disabled])
167                 ;;
168         *)
169                 AC_MSG_RESULT([$with_sysio])
170                 LB_CHECK_FILE([$with_sysio/lib/libsysio.a],[],[
171                         AC_MSG_ERROR([A complete (built) external libsysio was not found.])
172                 ])
173                 SYSIO=$with_sysio
174                 with_sysio="yes"
175                 ;;
176 esac
177
178 # We have to configure even if we don't build here for make dist to work
179 AC_CONFIG_SUBDIRS(libsysio)
180 ])
181
182 #
183 # LB_PATH_LDISKFS
184 #
185 # Handle internal/external ldiskfs
186 #
187 AC_DEFUN([LB_PATH_LDISKFS],
188 [AC_ARG_WITH([ldiskfs],
189         AC_HELP_STRING([--with-ldiskfs=path],
190                         [set path to ldiskfs source (default is included ldiskfs)]),
191         [],[
192                 if test x$linux25$enable_server = xyesyes ; then
193                         with_ldiskfs=yes
194                 else
195                         with_ldiskfs=no
196                 fi
197         ])
198 AC_MSG_CHECKING([location of ldiskfs])
199 case x$with_ldiskfs in
200         xyes)
201                 AC_MSG_RESULT([internal])
202                 LB_CHECK_FILE([$srcdir/ldiskfs/lustre-ldiskfs.spec.in],[],[
203                         AC_MSG_ERROR([A complete internal ldiskfs was not found.])
204                 ])
205                 LDISKFS_SUBDIR="ldiskfs"
206                 LDISKFS_DIR="$PWD/ldiskfs"
207                 ;;
208         xno)
209                 AC_MSG_RESULT([disabled])
210                 ;;
211         *)
212                 AC_MSG_RESULT([$with_ldiskfs])
213                 LB_CHECK_FILE([$with_ldiskfs/ldiskfs/linux/ldiskfs_fs.h],[],[
214                         AC_MSG_ERROR([A complete (built) external ldiskfs was not found.])
215                 ])
216                 LDISKFS_DIR=$with_ldiskfs
217                 ;;
218 esac
219 AC_SUBST(LDISKFS_DIR)
220 AC_SUBST(LDISKFS_SUBDIR)
221
222 # We have to configure even if we don't build here for make dist to work
223 AC_CONFIG_SUBDIRS(ldiskfs)
224 ])
225
226 #
227 # LB_DEFINE_LDISKFS_OPTIONS
228 #
229 # Enable config options related to ldiskfs.  These are used both by ldiskfs
230 # and lvfs (which includes ldiskfs headers.)
231 #
232 AC_DEFUN([LB_DEFINE_LDISKFS_OPTIONS],
233 [
234         AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
235         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
236         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
237         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security for ldiskfs])
238 ])
239
240 #
241 # LB_CONFIG_CRAY_XT3
242 #
243 # Enable Cray XT3 features
244 #
245 AC_DEFUN([LB_CONFIG_CRAY_XT3],
246 [AC_MSG_CHECKING([whether to build Cray XT3 features])
247 AC_ARG_ENABLE([cray_xt3],
248         AC_HELP_STRING([--enable-cray-xt3],
249                         [enable building of Cray XT3 features]),
250         [enable_cray_xt3='yes'],[enable_cray_xt3='no'])
251 AC_MSG_RESULT([$enable_cray_xt3])
252 if test x$enable_cray_xt3 != xno; then
253         AC_DEFINE(CRAY_XT3, 1, Enable Cray XT3 Features)
254 fi
255 ])
256
257 #
258 # LB_CONFIG_BGL
259 #
260 # Enable BGL features
261 #
262 AC_DEFUN([LB_CONFIG_BGL],
263 [AC_MSG_CHECKING([whether to build BGL features])
264 AC_ARG_ENABLE([bgl],
265         AC_HELP_STRING([--enable-bgl],
266                         [enable building of BGL features]),
267         [enable_bgl='yes'],[enable_bgl='no'])
268 AC_MSG_RESULT([$enable_bgl])
269 if test x$enable_bgl != xno; then
270         AC_DEFINE(BGL_SUPPORT, 1, Enable BGL Features)
271         enable_doc='no'
272         enable_tests='no'
273         enable_server='no'
274         enable_liblustre='no'
275         enable_libreadline='no'
276 fi
277 ])
278
279
280 #
281 # LB_CONFIG_UOSS
282 #
283 #
284 AC_DEFUN([LB_CONFIG_UOSS],
285 [AC_MSG_CHECKING([whether to build user-level oss])
286 AC_ARG_ENABLE([uoss],
287         AC_HELP_STRING([--enable-uoss],
288                         [enable building of user-level oss]),
289         [enable_uoss='yes'],[enable_uoss='no'])
290 if test x$enable_uoss != xno; then
291         AC_DEFINE(UOSS_SUPPORT, 1, Enable user-level OSS)
292         AC_DEFINE(LUSTRE_ULEVEL_MT, 1, Multi-threaded user-level lustre port)
293         enable_ulevel_mt='yes'
294         enable_modules='no'
295 fi
296 ])
297
298
299 #
300 # LB_PATH_SNMP
301 #
302 # check for in-tree snmp support
303 #
304 AC_DEFUN([LB_PATH_SNMP],
305 [LB_CHECK_FILE([$srcdir/snmp/lustre-snmp.c],[SNMP_DIST_SUBDIR="snmp"])
306 AC_SUBST(SNMP_DIST_SUBDIR)
307 AC_SUBST(SNMP_SUBDIR)
308 ])
309
310 #
311 # LB_CONFIG_MODULES
312 #
313 # Build kernel modules?
314 #
315 AC_DEFUN([LB_CONFIG_MODULES],
316 [AC_MSG_CHECKING([whether to build kernel modules])
317 AC_ARG_ENABLE([modules],
318         AC_HELP_STRING([--disable-modules],
319                         [disable building of Lustre kernel modules]),
320         [],[
321                 LC_TARGET_SUPPORTED([
322                         enable_modules='yes'
323                 ],[
324                         enable_modules='no'
325                 ])
326         ])
327 AC_MSG_RESULT([$enable_modules ($target_os)])
328
329 if test x$enable_modules = xyes ; then
330         case $target_os in
331                 linux*)
332                         LB_PROG_LINUX
333                         LN_PROG_LINUX
334                         LC_PROG_LINUX
335                         ;;
336                 darwin*)
337                         LB_PROG_DARWIN
338                         ;;
339                 *)
340                         # This is strange - Lustre supports a target we don't
341                         AC_MSG_ERROR([Modules are not supported on $target_os])
342                         ;;
343         esac
344 fi
345 ])
346
347 #
348 # LB_CONFIG_UTILS
349 #
350 # Build utils?
351 #
352 AC_DEFUN([LB_CONFIG_UTILS],
353 [AC_MSG_CHECKING([whether to build utilities])
354 AC_ARG_ENABLE([utils],
355         AC_HELP_STRING([--disable-utils],
356                         [disable building of Lustre utility programs]),
357         [],[enable_utils='yes'])
358 AC_MSG_RESULT([$enable_utils])
359 if test x$enable_utils = xyes ; then 
360         LB_CONFIG_INIT_SCRIPTS
361 fi
362 ])
363
364 #
365 # LB_CONFIG_TESTS
366 #
367 # Build tests?
368 #
369 AC_DEFUN([LB_CONFIG_TESTS],
370 [AC_MSG_CHECKING([whether to build Lustre tests])
371 AC_ARG_ENABLE([tests],
372         AC_HELP_STRING([--disable-tests],
373                         [disable building of Lustre tests]),
374         [],
375         [
376                 enable_tests='yes'
377         ])
378 AC_MSG_RESULT([$enable_tests])
379 ])
380
381 #
382 # LB_CONFIG_DOCS
383 #
384 # Build docs?
385 #
386 AC_DEFUN([LB_CONFIG_DOCS],
387 [AC_MSG_CHECKING([whether to build docs])
388 AC_ARG_ENABLE(doc,
389         AC_HELP_STRING([--disable-doc],
390                         [skip creation of pdf documentation]),
391         [
392                 if test x$enable_doc = xyes ; then
393                     ENABLE_DOC=1           
394                 else
395                     ENABLE_DOC=0
396                 fi
397         ],[
398                 ENABLE_DOC=0
399                 enable_doc='no'
400         ])
401 AC_MSG_RESULT([$enable_doc])
402 AC_SUBST(ENABLE_DOC)
403 ])
404
405 #
406 # LB_CONFIG_INIT_SCRIPTS
407 #
408 # our init scripts only work on red hat linux
409 #
410 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS],
411 [ENABLE_INIT_SCRIPTS=0
412 if test x$enable_utils = xyes ; then
413         AC_MSG_CHECKING([whether to install init scripts])
414         # our scripts only work on red hat systems
415         if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
416                 ENABLE_INIT_SCRIPTS=1
417                 AC_MSG_RESULT([yes])
418         else
419                 AC_MSG_RESULT([no])
420         fi
421 fi
422 AC_SUBST(ENABLE_INIT_SCRIPTS)
423 ])
424
425 #
426 # LB_CONFIG_HEADERS
427 #
428 # add -include config.h
429 #
430 AC_DEFUN([LB_CONFIG_HEADERS],
431 [AC_CONFIG_HEADERS([config.h])
432 CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
433 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
434 AC_SUBST(EXTRA_KCFLAGS)
435 ])
436
437 #
438 # LB_INCLUDE_RULES
439 #
440 # defines for including the toplevel Rules
441 #
442 AC_DEFUN([LB_INCLUDE_RULES],
443 [INCLUDE_RULES="include $PWD/Rules"
444 AC_SUBST(INCLUDE_RULES)
445 ])
446
447 #
448 # LB_PATH_DEFAULTS
449 #
450 # 'fixup' default paths
451 #
452 AC_DEFUN([LB_PATH_DEFAULTS],
453 [# directories for binaries
454 AC_PREFIX_DEFAULT([/usr])
455
456 sysconfdir='/etc'
457 AC_SUBST(sysconfdir)
458
459 # Directories for documentation and demos.
460 docdir='${datadir}/doc/$(PACKAGE)'
461 AC_SUBST(docdir)
462
463 LN_PATH_DEFAULTS
464 LC_PATH_DEFAULTS
465
466 ])
467
468 #
469 # LB_PROG_CC
470 #
471 # checks on the C compiler
472 #
473 AC_DEFUN([LB_PROG_CC],
474 [AC_PROG_RANLIB
475 AC_MSG_CHECKING([for buggy compiler])
476 CC_VERSION=`$CC -v 2>&1 | grep "^gcc version"`
477 bad_cc() {
478         AC_MSG_RESULT([buggy compiler found!])
479         echo
480         echo "   '$CC_VERSION'"
481         echo "  has been known to generate bad code, "
482         echo "  please get an updated compiler."
483         AC_MSG_ERROR([sorry])
484 }
485 case "$CC_VERSION" in
486         "gcc version 2.95"*)
487                 bad_cc
488                 ;;
489         # ost_pack_niobuf putting 64bit NTOH temporaries on the stack
490         # without "sub    $0xc,%esp" to protect the stack from being
491         # stomped on by interrupts (bug 606)
492         "gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)")
493                 bad_cc
494                 ;;
495         # mandrake's similar sub 0xc compiler bug
496         # http://marc.theaimsgroup.com/?l=linux-kernel&m=104748366226348&w=2
497         "gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)")
498                 bad_cc
499                 ;;
500         *)
501                 AC_MSG_RESULT([no known problems])
502                 ;;
503 esac
504
505 # ---------  unsigned long long sane? -------
506 AC_CHECK_SIZEOF(unsigned long long, 0)
507 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
508 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
509 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
510         AC_MSG_ERROR([** we assume that sizeof(long long) == 8.  Tell phil@clusterfs.com])
511 fi
512
513 # FIXME
514 AC_CHECK_DECL([__i386__], [], [
515
516 if test x$enable_bgl != xyes; then
517 AC_MSG_CHECKING([if $CC accepts -m64])
518 CC_save="$CC"
519 CC="$CC -m64"
520 AC_TRY_COMPILE([],[],[
521         AC_MSG_RESULT([yes])
522 ],[
523         AC_MSG_RESULT([no])
524         CC="$CC_save"
525 ])
526 fi
527
528 ])
529
530 CPPFLAGS="-I\$(top_builddir)/lnet/include -I\$(top_srcdir)/lnet/include -I\$(top_builddir)/lustre/include -I\$(top_srcdir)/lustre/include $CPPFLAGS"
531
532 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
533 AC_SUBST(LLCPPFLAGS)
534
535 LLCFLAGS="-g -Wall -fPIC"
536 AC_SUBST(LLCFLAGS)
537
538 # everyone builds against lnet and lustre
539 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/lnet/include -I$PWD/lustre/include"
540 AC_SUBST(EXTRA_KCFLAGS)
541 ])
542
543 #
544 # LB_CONTITIONALS
545 #
546 # AM_CONDITIONAL instances for everything
547 # (so that portals/lustre can disable some if needed)
548 AC_DEFUN([LB_CONDITIONALS],
549 [AM_CONDITIONAL(MODULES, test x$enable_modules = xyes)
550 AM_CONDITIONAL(UTILS, test x$enable_utils = xyes)
551 AM_CONDITIONAL(TESTS, test x$enable_tests = xyes)
552 AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
553 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
554 AM_CONDITIONAL(LINUX, test x$lb_target_os = "xlinux")
555 AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
556 AM_CONDITIONAL(CRAY_XT3, test x$enable_cray_xt3 = "xyes")
557 AM_CONDITIONAL(SUNOS, test x$lb_target_os = "xSunOS")
558
559 # this lets lustre cancel libsysio, per-branch or if liblustre is
560 # disabled
561 if test "x$LIBSYSIO_SUBDIR" = xlibsysio ; then
562         if test "x$with_sysio" != xyes ; then
563                 SYSIO=""
564                 LIBSYSIO_SUBDIR=""
565         fi
566 fi
567 AC_SUBST(LIBSYSIO_SUBDIR)
568 AC_SUBST(SYSIO)
569
570 LB_LINUX_CONDITIONALS
571 LB_DARWIN_CONDITIONALS
572
573 LN_CONDITIONALS
574 LC_CONDITIONALS
575 ])
576
577 #
578 # LB_CONFIG_FILES
579 #
580 # build-specific config files
581 #
582 AC_DEFUN([LB_CONFIG_FILES],
583 [
584 AC_CONFIG_FILES(
585 [Makefile
586 autoMakefile
587 ]
588 [Rules:build/Rules.in]
589 AC_PACKAGE_TARNAME[.spec]
590 )
591 ])
592
593 #
594 # LB_CONFIGURE
595 #
596 # main configure steps
597 #
598 AC_DEFUN([LB_CONFIGURE],
599 [LB_CANONICAL_SYSTEM
600
601 LB_INCLUDE_RULES
602
603 LB_CONFIG_CRAY_XT3
604 LB_CONFIG_BGL
605 LB_PATH_DEFAULTS
606
607 LB_PROG_CC
608
609 LB_CONFIG_DOCS
610 LB_CONFIG_UTILS
611 LB_CONFIG_TESTS
612 LC_CONFIG_CLIENT_SERVER
613
614 # three macros for cmd3 
615 LC_CONFIG_SPLIT
616 LC_CONFIG_LDISKFS
617 LN_CONFIG_CDEBUG
618
619 LB_CONFIG_MODULES
620
621 LB_PATH_DMU
622 LB_CONFIG_UOSS
623
624 LB_PATH_LIBSYSIO
625 LB_PATH_SNMP
626 LB_PATH_LDISKFS
627
628 LC_CONFIG_LIBLUSTRE
629 LN_CONFIGURE
630
631 LC_CONFIGURE
632
633 if test "$SNMP_DIST_SUBDIR" ; then
634         LS_CONFIGURE
635 fi
636
637 LB_CONDITIONALS
638 LB_CONFIG_HEADERS
639
640 LB_CONFIG_FILES
641 LN_CONFIG_FILES
642 LC_CONFIG_FILES
643 if test "$SNMP_DIST_SUBDIR" ; then
644         LS_CONFIG_FILES
645 fi
646
647 AC_SUBST(ac_configure_args)
648
649 MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.*'
650 AC_SUBST(MOSTLYCLEANFILES)
651
652 AC_OUTPUT
653
654 cat <<_ACEOF
655
656 CC:            $CC
657 LD:            $LD
658 CPPFLAGS:      $CPPFLAGS
659 LLCPPFLAGS:    $LLCPPFLAGS
660 CFLAGS:        $CFLAGS
661 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
662 LLCFLAGS:      $LLCFLAGS
663
664 Type 'make' to build Lustre.
665 _ACEOF
666 ])