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