Whamcloud - gitweb
Branch b1_8
[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         solaris*)
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 #
50 # LB_ARG_LIBS_INCLUDES
51 #
52 # support for --with-foo, --with-foo-includes, and --with-foo-libs in
53 # a single magical macro
54 #
55 AC_DEFUN([LB_ARG_LIBS_INCLUDES],
56 [lb_pathvar="m4_bpatsubst([$2], -, _)"
57 AC_MSG_CHECKING([for $1])
58 AC_ARG_WITH([$2],
59         AC_HELP_STRING([--with-$2=path],
60                 [path to $1]),
61         [],[withval=$4])
62
63 if test x$withval = xyes ; then
64         eval "$lb_pathvar='$3'"
65 else
66         eval "$lb_pathvar='$withval'"
67 fi
68 AC_MSG_RESULT([${!lb_pathvar:-no}])
69
70 if test x${!lb_pathvar} != x -a x${!lb_pathvar} != xno ; then
71         AC_MSG_CHECKING([for $1 includes])
72         AC_ARG_WITH([$2-includes],
73                 AC_HELP_STRING([--with-$2-includes=path],
74                         [path to $1 includes]),
75                 [],[withval='yes'])
76
77         lb_includevar="${lb_pathvar}_includes"
78         if test x$withval = xyes ; then
79                 eval "${lb_includevar}='${!lb_pathvar}/include'"
80         else
81                 eval "${lb_includevar}='$withval'"
82         fi
83         AC_MSG_RESULT([${!lb_includevar}])
84
85         AC_MSG_CHECKING([for $1 libs])
86         AC_ARG_WITH([$2-libs],
87                 AC_HELP_STRING([--with-$2-libs=path],
88                         [path to $1 libs]),
89                 [],[withval='yes'])
90
91         lb_libvar="${lb_pathvar}_libs"
92         if test x$withval = xyes ; then
93                 eval "${lb_libvar}='${!lb_pathvar}/lib'"
94         else
95                 eval "${lb_libvar}='$withval'"
96         fi
97         AC_MSG_RESULT([${!lb_libvar}])
98 fi
99 ])
100 ])
101
102 #
103 # LB_PATH_LIBSYSIO
104 #
105 # Handle internal/external libsysio
106 #
107 AC_DEFUN([LB_PATH_LIBSYSIO],
108 [AC_ARG_WITH([sysio],
109         AC_HELP_STRING([--with-sysio=path],
110                         [set path to libsysio source (default is included libsysio)]),
111         [],[
112                 case $lb_target_os in
113                         linux)
114                                 with_sysio='yes'
115                                 ;;
116                         *)
117                                 with_sysio='no'
118                                 ;;
119                 esac
120         ])
121 AC_MSG_CHECKING([location of libsysio])
122 enable_sysio="$with_sysio"
123 case x$with_sysio in
124         xyes)
125                 AC_MSG_RESULT([internal])
126                 LB_CHECK_FILE([$srcdir/libsysio/src/rmdir.c],[],[
127                         AC_MSG_ERROR([A complete internal libsysio was not found.])
128                 ])
129                 LIBSYSIO_SUBDIR="libsysio"
130                 SYSIO="$PWD/libsysio"
131                 ;;
132         xno)
133                 AC_MSG_RESULT([disabled])
134                 ;;
135         *)
136                 AC_MSG_RESULT([$with_sysio])
137                 LB_CHECK_FILE([$with_sysio/lib/libsysio.a],[],[
138                         AC_MSG_ERROR([A complete (built) external libsysio was not found.])
139                 ])
140                 SYSIO=$with_sysio
141                 with_sysio="yes"
142                 ;;
143 esac
144
145 # We have to configure even if we don't build here for make dist to work
146 AC_CONFIG_SUBDIRS(libsysio)
147 ])
148
149 #
150 # LB_PATH_LUSTREIOKIT
151 #
152 # Handle internal/external lustre-iokit
153 #
154 AC_DEFUN([LB_PATH_LUSTREIOKIT],
155 [AC_ARG_WITH([],
156         AC_HELP_STRING([--with-lustre-iokit=path],
157                         [set path to lustre-iokit source (default is included lustre-iokit)]),
158         [],[
159                         with_lustre_iokit='yes'
160         ])
161 AC_MSG_CHECKING([location of lustre-iokit])
162 enable_lustre_iokit="$with_lustre_iokit"
163 case x$with_lustre_iokit in
164         xyes)
165                 AC_MSG_RESULT([internal])
166                 LB_CHECK_FILE([$srcdir/lustre-iokit/ior-survey/ior-survey],[],[
167                         AC_MSG_ERROR([A complete internal lustre-iokit was not found.])
168                 ])
169                 LUSTREIOKIT_SUBDIR="lustre-iokit"
170                 LUSTREIOKIT="$PWD/lustre-iokit"
171                 ;;
172         xno)
173                 AC_MSG_RESULT([disabled])
174                 ;;
175         *)
176                 AC_MSG_RESULT([$with_lustre_iokit])
177                 LB_CHECK_FILE([$with_lustre_iokit/ior-survey/ior_survey],[],[
178                         AC_MSG_ERROR([A complete (built) external lustre-iokit was not found.])
179                 ])
180                 LUSTREIOKIT="$with_lustre_iokit"
181                 with_lustre_iokit="yes"
182                 ;;
183 esac
184 AC_SUBST(LUSTREIOKIT_SUBDIR)
185 # We have to configure even if we don't build here for make dist to work
186 AC_CONFIG_SUBDIRS(lustre-iokit)
187 ])
188
189 #
190 # LB_PATH_LDISKFS
191 #
192 # Handle internal/external ldiskfs
193 #
194 AC_DEFUN([LB_PATH_LDISKFS],
195 [AC_ARG_WITH([ldiskfs],
196         AC_HELP_STRING([--with-ldiskfs=path],
197                         [set path to ldiskfs source (default is included ldiskfs)]),
198         [],[
199                 if test x$linux25$enable_server = xyesyes ; then
200                         with_ldiskfs=yes
201                 else
202                         with_ldiskfs=no
203                 fi
204         ])
205 AC_MSG_CHECKING([location of ldiskfs])
206 case x$with_ldiskfs in
207         xyes)
208                 AC_MSG_RESULT([internal])
209                 LB_CHECK_FILE([$srcdir/ldiskfs/lustre-ldiskfs.spec.in],[],[
210                         AC_MSG_ERROR([A complete internal ldiskfs was not found.])
211                 ])
212                 LDISKFS_SUBDIR="ldiskfs"
213                 LDISKFS_DIR="$PWD/ldiskfs"
214                 ;;
215         xno)
216                 AC_MSG_RESULT([disabled])
217                 ;;
218         *)
219                 AC_MSG_RESULT([$with_ldiskfs])
220                 LB_CHECK_FILE([$with_ldiskfs/ldiskfs/linux/ldiskfs_fs.h],[],[
221                         AC_MSG_ERROR([A complete (built) external ldiskfs was not found.])
222                 ])
223                 LDISKFS_DIR=$with_ldiskfs
224                 ;;
225 esac
226 AC_SUBST(LDISKFS_DIR)
227 AC_SUBST(LDISKFS_SUBDIR)
228 AM_CONDITIONAL(LDISKFS_ENABLED, test x$with_ldiskfs != xno)
229
230 # We have to configure even if we don't build here for make dist to work
231 AC_CONFIG_SUBDIRS(ldiskfs)
232 ])
233
234 # Define no libcfs by default.
235 AC_DEFUN([LB_LIBCFS_DIR],
236 [
237 case x$libcfs_is_module in
238         xyes)
239           LIBCFS_INCLUDE_DIR="libcfs/include"
240           LIBCFS_SUBDIR="libcfs"
241           ;;
242         x*)
243           LIBCFS_INCLUDE_DIR="lnet/include"
244           LIBCFS_SUBDIR=""
245           ;;
246 esac
247 AC_SUBST(LIBCFS_SUBDIR)
248 AC_SUBST(LIBCFS_INCLUDE_DIR)
249 ])
250
251 #
252 # LB_DEFINE_LDISKFS_OPTIONS
253 #
254 # Enable config options related to ldiskfs.  These are used both by ldiskfs
255 # and lvfs (which includes ldiskfs headers.)
256 #
257 AC_DEFUN([LB_DEFINE_LDISKFS_OPTIONS],
258 [
259         AC_DEFINE(CONFIG_LDISKFS_FS_MODULE, 1, [build ldiskfs as a module])
260         AC_DEFINE(CONFIG_LDISKFS_FS_XATTR, 1, [enable extended attributes for ldiskfs])
261         AC_DEFINE(CONFIG_LDISKFS_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
262         AC_DEFINE(CONFIG_LDISKFS_FS_SECURITY, 1, [enable fs security for ldiskfs])
263         AC_DEFINE(CONFIG_LDISKFSDEV_FS_POSIX_ACL, 1, [enable posix acls for ldiskfs])
264         AC_DEFINE(CONFIG_LDISKFSDEV_FS_XATTR, 1, [enable extented attributes for ldiskfs])
265         AC_DEFINE(CONFIG_LDISKFSDEV_FS_SECURITY, 1, [enable fs security for ldiskfs])
266 ])
267
268 #
269 # LB_DEFINE_E2FSPROGS_NAMES
270 #
271 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
272 #
273 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
274 [AC_ARG_WITH([ldiskfsprogs],
275         AC_HELP_STRING([--with-ldiskfsprogs],
276                        [use alternate names for ldiskfs-enabled e2fsprogs]),
277         [],[withval='no'])
278
279 if test x$withval = xyes ; then
280         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
281         E2FSPROGS="ldiskfsprogs"
282         MKE2FS="mkfs.ldiskfs"
283         DEBUGFS="debug.ldiskfs"
284         TUNE2FS="tune.ldiskfs"
285         E2LABEL="label.ldiskfs"
286         DUMPE2FS="dump.ldiskfs"
287         E2FSCK="fsck.ldiskfs"
288         AC_MSG_RESULT([enabled])
289 else
290         E2FSPROGS="e2fsprogs"
291         MKE2FS="mke2fs"
292         DEBUGFS="debugfs"
293         TUNE2FS="tune2fs"
294         E2LABEL="e2label"
295         DUMPE2FS="dumpe2fs"
296         E2FSCK="e2fsck"
297         AC_MSG_RESULT([disabled])
298 fi
299         AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
300         AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
301         AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
302         AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
303         AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
304         AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
305         AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
306 ])
307
308 #
309 # LB_DEFINE_E2FSPROGS_NAMES
310 #
311 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
312 #
313 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
314 [AC_ARG_WITH([ldiskfsprogs],
315         AC_HELP_STRING([--with-ldiskfsprogs],
316                        [use alternate names for ldiskfs-enabled e2fsprogs]),
317         [],[withval='no'])
318
319 if test x$withval = xyes ; then
320         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
321         E2FSPROGS="ldiskfsprogs"
322         MKE2FS="mkfs.ldiskfs"
323         DEBUGFS="debug.ldiskfs"
324         TUNE2FS="tune.ldiskfs"
325         E2LABEL="label.ldiskfs"
326         DUMPE2FS="dump.ldiskfs"
327         E2FSCK="fsck.ldiskfs"
328         AC_MSG_RESULT([enabled])
329 else
330         E2FSPROGS="e2fsprogs"
331         MKE2FS="mke2fs"
332         DEBUGFS="debugfs"
333         TUNE2FS="tune2fs"
334         E2LABEL="e2label"
335         DUMPE2FS="dumpe2fs"
336         E2FSCK="e2fsck"
337         AC_MSG_RESULT([disabled])
338 fi
339         AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
340         AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
341         AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
342         AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
343         AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
344         AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
345         AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
346 ])
347
348 #
349 # LB_DEFINE_E2FSPROGS_NAMES
350 #
351 # Enable the use of alternate naming of ldiskfs-enabled e2fsprogs package.
352 #
353 AC_DEFUN([LB_DEFINE_E2FSPROGS_NAMES],
354 [AC_ARG_WITH([ldiskfsprogs],
355         AC_HELP_STRING([--with-ldiskfsprogs],
356                        [use alternate names for ldiskfs-enabled e2fsprogs]),
357         [],[withval='no'])
358
359 if test x$withval = xyes ; then
360         AC_DEFINE(HAVE_LDISKFSPROGS, 1, [enable use of ldiskfsprogs package])
361         E2FSPROGS="ldiskfsprogs"
362         MKE2FS="mkfs.ldiskfs"
363         DEBUGFS="debug.ldiskfs"
364         TUNE2FS="tune.ldiskfs"
365         E2LABEL="label.ldiskfs"
366         DUMPE2FS="dump.ldiskfs"
367         E2FSCK="fsck.ldiskfs"
368         AC_MSG_RESULT([enabled])
369 else
370         E2FSPROGS="e2fsprogs"
371         MKE2FS="mke2fs"
372         DEBUGFS="debugfs"
373         TUNE2FS="tune2fs"
374         E2LABEL="e2label"
375         DUMPE2FS="dumpe2fs"
376         E2FSCK="e2fsck"
377         AC_MSG_RESULT([disabled])
378 fi
379         AC_DEFINE_UNQUOTED(E2FSPROGS, "$E2FSPROGS", [name of ldiskfs e2fsprogs package])
380         AC_DEFINE_UNQUOTED(MKE2FS, "$MKE2FS", [name of ldiskfs mkfs program])
381         AC_DEFINE_UNQUOTED(DEBUGFS, "$DEBUGFS", [name of ldiskfs debug program])
382         AC_DEFINE_UNQUOTED(TUNE2FS, "$TUNE2FS", [name of ldiskfs tune program])
383         AC_DEFINE_UNQUOTED(E2LABEL, "$E2LABEL", [name of ldiskfs label program])
384         AC_DEFINE_UNQUOTED(DUMPE2FS,"$DUMPE2FS", [name of ldiskfs dump program])
385         AC_DEFINE_UNQUOTED(E2FSCK, "$E2FSCK", [name of ldiskfs fsck program])
386 ])
387
388 #
389 # LB_CONFIG_CRAY_XT3
390 #
391 # Enable Cray XT3 features
392 #
393 AC_DEFUN([LB_CONFIG_CRAY_XT3],
394 [AC_MSG_CHECKING([whether to build Cray XT3 features])
395 AC_ARG_ENABLE([cray_xt3],
396         AC_HELP_STRING([--enable-cray-xt3],
397                         [enable building of Cray XT3 features]),
398         [enable_cray_xt3='yes'],[enable_cray_xt3='no'])
399 AC_MSG_RESULT([$enable_cray_xt3])
400 if test x$enable_cray_xt3 != xno; then
401         AC_DEFINE(CRAY_XT3, 1, Enable Cray XT3 Features)
402 fi
403 ])
404
405 #
406 # LB_CONFIG_BGL
407 #
408 # Enable BGL features
409 #
410 AC_DEFUN([LB_CONFIG_BGL],
411 [AC_MSG_CHECKING([whether to build BGL features])
412 AC_ARG_ENABLE([bgl],
413         AC_HELP_STRING([--enable-bgl],
414                         [enable building of BGL features]),
415         [enable_bgl='yes'],[enable_bgl='no'])
416 AC_MSG_RESULT([$enable_bgl])
417 if test x$enable_bgl != xno; then
418         AC_DEFINE(HAVE_BGL_SUPPORT, 1, Enable BGL Features)
419         enable_doc='no'
420         enable_tests='no'
421         enable_server='no'
422         enable_liblustre='no'
423         enable_libreadline='no'
424 fi
425 ])
426
427 #
428 # Support for --enable-uoss
429 #
430 AC_DEFUN([LB_UOSS],
431 [AC_MSG_CHECKING([whether to enable uoss])
432 AC_ARG_ENABLE([uoss],
433         AC_HELP_STRING([--enable-uoss],
434                         [enable userspace OSS]),
435         [enable_uoss='yes'],[enable_uoss='no'])
436 AC_MSG_RESULT([$enable_uoss])
437 if test x$enable_uoss = xyes; then
438         AC_DEFINE(UOSS_SUPPORT, 1, Enable user-level OSS)
439         AC_DEFINE(LUSTRE_ULEVEL_MT, 1, Multi-threaded user-level lustre port)
440         enable_uoss='yes'
441         enable_ulevel_mt='yes'
442         enable_modules='no'
443         enable_client='no'
444         enable_tests='no'
445         enable_liblustre='no'
446         with_ldiskfs='no'
447 fi
448 AC_SUBST(enable_uoss)
449 ])
450
451 #
452 # Support for --enable-posix-osd
453 #
454 AC_DEFUN([LB_POSIX_OSD],
455 [AC_MSG_CHECKING([whether to enable posix osd])
456 AC_ARG_ENABLE([posix-osd],
457         AC_HELP_STRING([--enable-posix-osd],
458                         [enable using of posix osd]),
459         [enable_posix_osd='yes'],[enable_posix_osd='no'])
460 AC_MSG_RESULT([$enable_posix_osd])
461 if test x$enable_uoss = xyes -a x$enable_posix_osd = xyes ; then
462         AC_DEFINE(POSIX_OSD, 1, Enable POSIX OSD)
463         posix_osd='yes'
464 fi
465 AM_CONDITIONAL(POSIX_OSD_ENABLED, test x$posix_osd = xyes)
466 ])
467
468 #
469 # LB_PATH_DMU
470 #
471 AC_DEFUN([LB_PATH_DMU],
472 [AC_ARG_ENABLE([dmu],
473         AC_HELP_STRING([--enable-dmu],
474                        [enable the DMU backend]),
475         [],[with_dmu='default'])
476 AC_MSG_CHECKING([whether to enable DMU])
477 case x$with_dmu in
478         xyes)
479                 dmu_osd='yes'
480                 ;;
481         xno)
482                 dmu_osd='no'
483                 ;;
484         xdefault)
485                 if test x$enable_uoss = xyes -a x$posix_osd != xyes; then
486                         # Enable the DMU if we're configuring a userspace server
487                         dmu_osd='yes'
488                 else
489                         # Enable the DMU by default on the b_hd_kdmu branch
490                         if test -d $PWD/zfs -a x$linux25$enable_server = xyesyes; then
491                                 dmu_osd='yes'
492                         else
493                                 dmu_osd='no'
494                         fi
495                 fi
496                 ;;
497         *)
498                 dmu_osd='yes'
499                 ;;
500 esac
501 AC_MSG_RESULT([$dmu_osd])
502 if test x$dmu_osd = xyes; then
503         AC_DEFINE(DMU_OSD, 1, Enable DMU OSD)
504         if test x$enable_uoss = xyes; then
505                 # Userspace DMU
506                 DMU_SRC="$PWD/lustre/zfs-lustre"
507                 AC_SUBST(DMU_SRC)
508                 LB_CHECK_FILE([$DMU_SRC/src/.patched],[],[
509                         AC_MSG_ERROR([A complete (patched) DMU tree was not found.])
510                 ])
511                 AC_CONFIG_SUBDIRS(lustre/zfs-lustre)
512         else
513                 # Kernel DMU
514                 SPL_SUBDIR="spl"
515                 ZFS_SUBDIR="zfs"
516
517                 SPL_DIR="$PWD/$SPL_SUBDIR"
518                 ZFS_DIR="$PWD/$ZFS_SUBDIR"
519
520                 LB_CHECK_FILE([$SPL_DIR/module/spl/spl-generic.c],[],[
521                         AC_MSG_ERROR([A complete SPL tree was not found in $SPL_DIR.])
522                 ])
523
524                 LB_CHECK_FILE([$ZFS_DIR/module/zfs/dmu.c],[],[
525                         AC_MSG_ERROR([A complete kernel DMU tree was not found in $ZFS_DIR.])
526                 ])
527
528                 AC_CONFIG_SUBDIRS(spl)
529                 ac_configure_args="$ac_configure_args --with-spl=$SPL_DIR"
530                 AC_CONFIG_SUBDIRS(zfs)
531         fi
532 fi
533 AC_SUBST(SPL_SUBDIR)
534 AC_SUBST(ZFS_SUBDIR)
535 AC_SUBST(SPL_DIR)
536 AC_SUBST(ZFS_DIR)
537 AM_CONDITIONAL(DMU_OSD_ENABLED, test x$dmu_osd = xyes)
538 AM_CONDITIONAL(KDMU, test x$dmu_osd$enable_uoss = xyesno)
539 ])
540
541 #
542 # LB_PATH_SNMP
543 #
544 # check for in-tree snmp support
545 #
546 AC_DEFUN([LB_PATH_SNMP],
547 [LB_CHECK_FILE([$srcdir/snmp/lustre-snmp.c],[SNMP_DIST_SUBDIR="snmp"])
548 AC_SUBST(SNMP_DIST_SUBDIR)
549 AC_SUBST(SNMP_SUBDIR)
550 ])
551
552 #
553 # LB_CONFIG_MODULES
554 #
555 # Build kernel modules?
556 #
557 AC_DEFUN([LB_CONFIG_MODULES],
558 [AC_MSG_CHECKING([whether to build kernel modules])
559 AC_ARG_ENABLE([modules],
560         AC_HELP_STRING([--disable-modules],
561                         [disable building of Lustre kernel modules]),
562         [],[
563                 LC_TARGET_SUPPORTED([
564                         enable_modules='yes'
565                 ],[
566                         enable_modules='no'
567                 ])
568         ])
569 AC_MSG_RESULT([$enable_modules ($target_os)])
570
571 if test x$enable_modules = xyes ; then
572         case $target_os in
573                 linux*)
574                         LB_PROG_LINUX
575                         LIBCFS_PROG_LINUX
576                         LN_PROG_LINUX
577                         LC_PROG_LINUX
578                         ;;
579                 darwin*)
580                         LB_PROG_DARWIN
581                         LIBCFS_PROG_DARWIN
582                         ;;
583                 *)
584                         # This is strange - Lustre supports a target we don't
585                         AC_MSG_ERROR([Modules are not supported on $target_os])
586                         ;;
587         esac
588 fi
589 ])
590
591 #
592 # LB_CONFIG_UTILS
593 #
594 # Build utils?
595 #
596 AC_DEFUN([LB_CONFIG_UTILS],
597 [AC_MSG_CHECKING([whether to build utilities])
598 AC_ARG_ENABLE([utils],
599         AC_HELP_STRING([--disable-utils],
600                         [disable building of Lustre utility programs]),
601         [],[enable_utils='yes'])
602 AC_MSG_RESULT([$enable_utils])
603 if test x$enable_utils = xyes ; then 
604         LB_CONFIG_INIT_SCRIPTS
605 fi
606 ])
607
608 #
609 # LB_CONFIG_TESTS
610 #
611 # Build tests?
612 #
613 AC_DEFUN([LB_CONFIG_TESTS],
614 [AC_MSG_CHECKING([whether to build Lustre tests])
615 AC_ARG_ENABLE([tests],
616         AC_HELP_STRING([--disable-tests],
617                         [disable building of Lustre tests]),
618         [],
619         [
620                 enable_tests='yes'
621         ])
622 AC_MSG_RESULT([$enable_tests])
623 ])
624
625 #
626 # LB_CONFIG_DOCS
627 #
628 # Build docs?
629 #
630 AC_DEFUN([LB_CONFIG_DOCS],
631 [AC_MSG_CHECKING([whether to build docs])
632 AC_ARG_ENABLE(doc,
633         AC_HELP_STRING([--disable-doc],
634                         [skip creation of pdf documentation]),
635         [
636                 if test x$enable_doc = xyes ; then
637                     ENABLE_DOC=1           
638                 else
639                     ENABLE_DOC=0
640                 fi
641         ],[
642                 ENABLE_DOC=0
643                 enable_doc='no'
644         ])
645 AC_MSG_RESULT([$enable_doc])
646 AC_SUBST(ENABLE_DOC)
647 ])
648
649 #
650 # LB_CONFIG_INIT_SCRIPTS
651 #
652 # our init scripts only work on red hat linux
653 #
654 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS],
655 [ENABLE_INIT_SCRIPTS=0
656 if test x$enable_utils = xyes ; then
657         AC_MSG_CHECKING([whether to install init scripts])
658         # our scripts only work on red hat systems
659         if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
660                 ENABLE_INIT_SCRIPTS=1
661                 AC_MSG_RESULT([yes])
662         else
663                 AC_MSG_RESULT([no])
664         fi
665 fi
666 AC_SUBST(ENABLE_INIT_SCRIPTS)
667 ])
668
669 #
670 # LB_CONFIG_HEADERS
671 #
672 # add -include config.h
673 #
674 AC_DEFUN([LB_CONFIG_HEADERS],
675 [AC_CONFIG_HEADERS([config.h])
676 CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
677 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
678 AC_SUBST(EXTRA_KCFLAGS)
679 ])
680
681 #
682 # LB_INCLUDE_RULES
683 #
684 # defines for including the toplevel Rules
685 #
686 AC_DEFUN([LB_INCLUDE_RULES],
687 [INCLUDE_RULES="include $PWD/Rules"
688 AC_SUBST(INCLUDE_RULES)
689 ])
690
691 #
692 # LB_PATH_DEFAULTS
693 #
694 # 'fixup' default paths
695 #
696 AC_DEFUN([LB_PATH_DEFAULTS],
697 [# directories for binaries
698 AC_PREFIX_DEFAULT([/usr])
699
700 sysconfdir='/etc'
701 AC_SUBST(sysconfdir)
702
703 # Directories for documentation and demos.
704 docdir='${datadir}/doc/$(PACKAGE)'
705 AC_SUBST(docdir)
706
707 LIBCFS_PATH_DEFAULTS
708 LN_PATH_DEFAULTS
709 LC_PATH_DEFAULTS
710
711 ])
712
713 #
714 # LB_PROG_CC
715 #
716 # checks on the C compiler
717 #
718 AC_DEFUN([LB_PROG_CC],
719 [AC_PROG_RANLIB
720 AC_MSG_CHECKING([for buggy compiler])
721 CC_VERSION=`$CC -v 2>&1 | grep "^gcc version"`
722 bad_cc() {
723         AC_MSG_RESULT([buggy compiler found!])
724         echo
725         echo "   '$CC_VERSION'"
726         echo "  has been known to generate bad code, "
727         echo "  please get an updated compiler."
728         AC_MSG_ERROR([sorry])
729 }
730 case "$CC_VERSION" in
731         "gcc version 2.95"*)
732                 bad_cc
733                 ;;
734         # ost_pack_niobuf putting 64bit NTOH temporaries on the stack
735         # without "sub    $0xc,%esp" to protect the stack from being
736         # stomped on by interrupts (bug 606)
737         "gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)")
738                 bad_cc
739                 ;;
740         # mandrake's similar sub 0xc compiler bug
741         # http://marc.theaimsgroup.com/?l=linux-kernel&m=104748366226348&w=2
742         "gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)")
743                 bad_cc
744                 ;;
745         *)
746                 AC_MSG_RESULT([no known problems])
747                 ;;
748 esac
749
750 # ---------  unsigned long long sane? -------
751 AC_CHECK_SIZEOF(unsigned long long, 0)
752 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
753 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
754 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
755         AC_MSG_ERROR([** we assume that sizeof(long long) == 8.  Tell phil@clusterfs.com])
756 fi
757
758 if test $target_cpu == "powerpc64"; then
759         AC_MSG_WARN([set compiler with -m64])
760         CFLAGS="$CFLAGS -m64"
761         CC="$CC -m64"
762 fi
763
764 CPPFLAGS="-I\$(top_builddir)/$LIBCFS_INCLUDE_DIR -I\$(top_srcdir)/$LIBCFS_INCLUDE_DIR-I\$(top_builddir)/lnet/include -I\$(top_srcdir)/lnet/include -I\$(top_builddir)/lustre/include -I\$(top_srcdir)/lustre/include $CPPFLAGS"
765
766 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
767 AC_SUBST(LLCPPFLAGS)
768
769 # Add _GNU_SOURCE for strnlen on linux
770 LLCFLAGS="-g -Wall -fPIC -D_GNU_SOURCE"
771 AC_SUBST(LLCFLAGS)
772
773 # everyone builds against lnet and lustre
774 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/$LIBCFS_INCLUDE_DIR -I$PWD/lnet/include -I$PWD/lustre/include"
775 AC_SUBST(EXTRA_KCFLAGS)
776 ])
777
778 #
779 # LB_CONTITIONALS
780 #
781 # AM_CONDITIONAL instances for everything
782 # (so that portals/lustre can disable some if needed)
783 AC_DEFUN([LB_CONDITIONALS],
784 [AM_CONDITIONAL(MODULES, test x$enable_modules = xyes)
785 AM_CONDITIONAL(UTILS, test x$enable_utils = xyes)
786 AM_CONDITIONAL(TESTS, test x$enable_tests = xyes)
787 AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
788 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
789 AM_CONDITIONAL(LINUX, test x$lb_target_os = "xlinux")
790 AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
791 AM_CONDITIONAL(CRAY_XT3, test x$enable_cray_xt3 = "xyes")
792 AM_CONDITIONAL(SUNOS, test x$lb_target_os = "xSunOS")
793
794 # this lets lustre cancel libsysio, per-branch or if liblustre is
795 # disabled
796 if test "x$LIBSYSIO_SUBDIR" = xlibsysio ; then
797         if test "x$with_sysio" != xyes ; then
798                 SYSIO=""
799                 LIBSYSIO_SUBDIR=""
800         fi
801 fi
802 AC_SUBST(LIBSYSIO_SUBDIR)
803 AC_SUBST(SYSIO)
804
805 LB_LINUX_CONDITIONALS
806 LB_DARWIN_CONDITIONALS
807
808 LIBCFS_CONDITIONALS
809 LN_CONDITIONALS
810 LC_CONDITIONALS
811 ])
812
813 #
814 # LB_CONFIG_FILES
815 #
816 # build-specific config files
817 #
818 AC_DEFUN([LB_CONFIG_FILES],
819 [
820 AC_CONFIG_FILES(
821 [Makefile
822 autoMakefile
823 ]
824 [Rules:build/Rules.in]
825 AC_PACKAGE_TARNAME[.spec]
826 )
827 ])
828
829 #
830 # LB_CONFIGURE
831 #
832 # main configure steps
833 #
834 AC_DEFUN([LB_CONFIGURE],
835 [LB_CANONICAL_SYSTEM
836
837 LB_LIBCFS_DIR
838
839 LB_INCLUDE_RULES
840
841 LB_CONFIG_CRAY_XT3
842 LB_CONFIG_BGL
843 LB_PATH_DEFAULTS
844
845 LB_PROG_CC
846
847 LB_UOSS
848 LB_POSIX_OSD
849
850 LB_CONFIG_DOCS
851 LB_CONFIG_UTILS
852 LB_CONFIG_TESTS
853 LC_CONFIG_CLIENT_SERVER
854
855 # two macros for cmd3 
856 m4_ifdef([LC_CONFIG_SPLIT], [LC_CONFIG_SPLIT])
857 LN_CONFIG_CDEBUG
858 LC_QUOTA
859
860 LB_CONFIG_MODULES
861
862 LB_PATH_DMU
863 LB_PATH_LIBSYSIO
864 LB_PATH_SNMP
865 LB_PATH_LDISKFS
866 LB_PATH_LUSTREIOKIT
867
868 LB_DEFINE_E2FSPROGS_NAMES
869
870 LB_DEFINE_E2FSPROGS_NAMES
871
872 LB_DEFINE_E2FSPROGS_NAMES
873
874 LC_CONFIG_LIBLUSTRE
875 LIBCFS_CONFIGURE
876 LN_CONFIGURE
877
878 LC_CONFIGURE
879
880 if test "$SNMP_DIST_SUBDIR" ; then
881         LS_CONFIGURE
882 fi
883
884
885 LB_CONDITIONALS
886 LB_CONFIG_HEADERS
887
888 LIBCFS_CONFIG_FILES
889 LB_CONFIG_FILES
890 LN_CONFIG_FILES
891 LC_CONFIG_FILES
892 if test "$SNMP_DIST_SUBDIR" ; then
893         LS_CONFIG_FILES
894 fi
895
896 AC_SUBST(ac_configure_args)
897
898 MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.* Modules.symvers Module.symvers'
899 AC_SUBST(MOSTLYCLEANFILES)
900
901 AC_OUTPUT
902
903 cat <<_ACEOF
904
905 CC:            $CC
906 LD:            $LD
907 CPPFLAGS:      $CPPFLAGS
908 LLCPPFLAGS:    $LLCPPFLAGS
909 CFLAGS:        $CFLAGS
910 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
911 LLCFLAGS:      $LLCFLAGS
912
913 Type 'make' to build Lustre.
914 _ACEOF
915 ])