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