Whamcloud - gitweb
Temp fix: gcc with 64-bit support (like in debian) doesn't mean the target is 64...
[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
157 # work
158 AC_CONFIG_SUBDIRS(libsysio)
159 ])
160
161 #
162 # LB_CONFIG_PORTALS
163 #
164 # configure support for Cray Portals
165 #
166 AC_DEFUN([LB_CONFIG_PORTALS],
167 [AC_MSG_CHECKING([for external Portals])
168 AC_ARG_WITH([portals],
169         AC_HELP_STRING([--with-portals=path],
170                        [set path to portals]),
171         [
172                 case $with_portals in
173                         no)     PORTALS=""
174                                 enable_portals=no
175                                 ;;
176                         *)      if test x$with_portals != x ; then
177                                         PORTALS="$with_portals"
178                                         enable_portals=yes
179                                 else
180                                         AC_MSG_ERROR([Path to portals must be specified])
181                                         enable_portals=no
182                                 fi
183                                 ;;
184                 esac
185                 
186         ], [enable_portals=no])
187 AC_MSG_CHECKING([location of portals])
188 case x$enable_portals in
189         xyes)
190                 AC_MSG_RESULT([$PORTALS])
191                 LB_CHECK_FILE([$PORTALS/include/portals/api.h],[],
192                               AC_MSG_ERROR([Cannot find portals headers]))
193                 ;;
194         *)
195                 AC_MSG_RESULT([no external portals])
196                 ;;
197 esac
198
199 AC_SUBST(PORTALS)
200 ])
201
202 #
203 # LB_CONFIG_LUSTRE_PORTALS
204 #
205 # configure support for Lustre Portals
206 #
207 AC_DEFUN([LB_CONFIG_LUSTRE_PORTALS],
208 [AC_MSG_CHECKING([for Lustre Portals])
209 AC_ARG_WITH([lustre-portals],
210         AC_HELP_STRING([--with-lustre-portals=path],
211                        [set path to Lustre portals]),
212         [
213                 case $with_lustre_portals in
214                         yes)    LUSTRE_PORTALS="$PWD/portals"
215                                 enable_lustre_portals=yes
216                                 ;;
217                         no)     LUSTRE_PORTALS=""
218                                 enable_lustre_portals=no
219                                 ;;
220                         *)      if test x$with_lustre_portals != x ; then
221                                         LUSTRE_PORTALS="$with_lustre_portals"
222                                 else
223                                         LUSTRE_PORTALS="$PWD/portals"
224                                 fi
225                                 enable_lustre_portals=yes
226                                 ;;
227                 esac
228                 
229         ], [enable_lustre_portals=no])
230
231 AC_MSG_CHECKING([location of Lustre portals])
232 case x$enable_lustre_portals in
233         xyes)
234                 AC_MSG_RESULT([$LUSTRE_PORTALS])
235                 LB_CHECK_FILE([$LUSTRE_PORTALS/include/portals/api.h],[LUSTRE_PORTALS_SUBDIR="portals"],
236                               AC_MSG_ERROR([Cannot find Lustre portals headers]))
237                 ;;
238         *)
239                 AC_MSG_RESULT([disable Lustre portals])
240                 ;;
241 esac
242
243 AC_SUBST(LUSTRE_PORTALS_SUBDIR)
244 AC_SUBST(LUSTRE_PORTALS)
245 ])
246
247 #
248 # LB_CONFIG_CRAY_XT3
249 #
250 # Enable Cray XT3 features
251 #
252 AC_DEFUN([LB_CONFIG_CRAY_XT3],
253 [AC_MSG_CHECKING([whether to build Cray XT3 features])
254 AC_ARG_ENABLE([cray_xt3],
255         AC_HELP_STRING([--enable-cray-xt3],
256                         [enable building of Cray XT3 features]),
257         [enable_cray_xt3='yes'],[enable_cray_xt3='no'])
258 AC_MSG_RESULT([$enable_cray_xt3])
259 if test x$enable_cray_xt3 != xno; then
260         AC_DEFINE(CRAY_XT3, 1, Enable Cray XT3 Features)
261 fi
262 ])
263
264 #
265 # LB_CONFIG_BGL
266 #
267 # Enable BGL features
268 #
269 AC_DEFUN([LB_CONFIG_BGL],
270 [AC_MSG_CHECKING([whether to build BGL features])
271 AC_ARG_ENABLE([bgl],
272         AC_HELP_STRING([--enable-bgl],
273                         [enable building of BGL features]),
274         [enable_bgl='yes'],[enable_bgl='no'])
275 AC_MSG_RESULT([$enable_bgl])
276 if test x$enable_bgl != xno; then
277         AC_DEFINE(BGL_SUPPORT, 1, Enable BGL Features)
278         enable_doc='no'
279         enable_tests='no'
280         enable_server='no'
281         enable_liblustre='no'
282         enable_libreadline='no'
283 fi
284 ])
285
286 #
287 # LB_PATH_SNMP
288 #
289 # check for in-tree snmp support
290 #
291 AC_DEFUN([LB_PATH_SNMP],
292 [LB_CHECK_FILE([$srcdir/snmp/lustre-snmp.c],[SNMP_DIST_SUBDIR="snmp"])
293 AC_SUBST(SNMP_DIST_SUBDIR)
294 AC_SUBST(SNMP_SUBDIR)
295 ])
296
297 #
298 # LB_CONFIG_MODULES
299 #
300 # Build kernel modules?
301 #
302 AC_DEFUN([LB_CONFIG_MODULES],
303 [AC_MSG_CHECKING([whether to build kernel modules])
304 AC_ARG_ENABLE([modules],
305         AC_HELP_STRING([--disable-modules],
306                         [disable building of Lustre kernel modules]),
307         [],[
308                 LC_TARGET_SUPPORTED([
309                         enable_modules='yes'
310                 ],[
311                         enable_modules='no'
312                 ])
313         ])
314 AC_MSG_RESULT([$enable_modules ($target_os)])
315
316 if test x$enable_modules = xyes ; then
317         case $target_os in
318                 linux*)
319                         LB_PROG_LINUX
320                         ;;
321                 darwin*)
322                         LB_PROG_DARWIN
323                         ;;
324                 *)
325                         # This is strange - Lustre supports a target we don't
326                         AC_MSG_ERROR([Modules are not supported on $target_os])
327                         ;;
328         esac
329 fi
330 ])
331
332 #
333 # LB_CONFIG_UTILS
334 #
335 # Build utils?
336 #
337 AC_DEFUN([LB_CONFIG_UTILS],
338 [AC_MSG_CHECKING([whether to build utilities])
339 AC_ARG_ENABLE([utils],
340         AC_HELP_STRING([--disable-utils],
341                         [disable building of Lustre utility programs]),
342         [],[enable_utils='yes'])
343 AC_MSG_RESULT([$enable_utils])
344 if test x$enable_utils = xyes ; then 
345         LB_CONFIG_INIT_SCRIPTS
346 fi
347 ])
348
349 #
350 # LB_CONFIG_TESTS
351 #
352 # Build tests?
353 #
354 AC_DEFUN([LB_CONFIG_TESTS],
355 [AC_MSG_CHECKING([whether to build Lustre tests])
356 AC_ARG_ENABLE([tests],
357         AC_HELP_STRING([--disable-tests],
358                         [disable building of Lustre tests]),
359         [],
360         [
361                 enable_tests='yes'
362         ])
363 AC_MSG_RESULT([$enable_tests])
364 ])
365
366 #
367 # LB_CONFIG_DOCS
368 #
369 # Build docs?
370 #
371 AC_DEFUN([LB_CONFIG_DOCS],
372 [AC_MSG_CHECKING([whether to build docs])
373 AC_ARG_ENABLE(doc,
374         AC_HELP_STRING([--disable-doc],
375                         [skip creation of pdf documentation]),
376         [
377                 if test x$enable_doc = xyes ; then
378                     ENABLE_DOC=1           
379                 else
380                     ENABLE_DOC=0
381                 fi
382         ],[
383                 ENABLE_DOC=0
384                 enable_doc='no'
385         ])
386 AC_MSG_RESULT([$enable_doc])
387 AC_SUBST(ENABLE_DOC)
388 ])
389
390 #
391 # LB_CONFIG_INIT_SCRIPTS
392 #
393 # our init scripts only work on red hat linux
394 #
395 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS],
396 [ENABLE_INIT_SCRIPTS=0
397 if test x$enable_utils = xyes ; then
398         AC_MSG_CHECKING([whether to install init scripts])
399         # our scripts only work on red hat systems
400         if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
401                 ENABLE_INIT_SCRIPTS=1
402                 AC_MSG_RESULT([yes])
403         else
404                 AC_MSG_RESULT([no])
405         fi
406 fi
407 AC_SUBST(ENABLE_INIT_SCRIPTS)
408 ])
409
410 #
411 # LB_CONFIG_HEADERS
412 #
413 # add -include config.h
414 #
415 AC_DEFUN([LB_CONFIG_HEADERS],
416 [AC_CONFIG_HEADERS([config.h])
417 CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
418 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
419 AC_SUBST(EXTRA_KCFLAGS)
420 ])
421
422 #
423 # LB_INCLUDE_RULES
424 #
425 # defines for including the toplevel Rules
426 #
427 AC_DEFUN([LB_INCLUDE_RULES],
428 [INCLUDE_RULES="include $PWD/build/Rules"
429 AC_SUBST(INCLUDE_RULES)
430 ])
431
432 #
433 # LB_PATH_DEFAULTS
434 #
435 # 'fixup' default paths
436 #
437 AC_DEFUN([LB_PATH_DEFAULTS],
438 [# directories for binaries
439 AC_PREFIX_DEFAULT([/usr])
440
441 sysconfdir='/etc'
442 AC_SUBST(sysconfdir)
443
444 # Directories for documentation and demos.
445 docdir='${datadir}/doc/$(PACKAGE)'
446 AC_SUBST(docdir)
447
448 LN_PATH_DEFAULTS
449 LC_PATH_DEFAULTS
450
451 ])
452
453 #
454 # LB_PROG_CC
455 #
456 # checks on the C compiler
457 #
458 AC_DEFUN([LB_PROG_CC],
459 [AC_PROG_RANLIB
460 AC_MSG_CHECKING([for buggy compiler])
461 CC_VERSION=`$CC -v 2>&1 | grep "^gcc version"`
462 bad_cc() {
463         AC_MSG_RESULT([buggy compiler found!])
464         echo
465         echo "   '$CC_VERSION'"
466         echo "  has been known to generate bad code, "
467         echo "  please get an updated compiler."
468         AC_MSG_ERROR([sorry])
469 }
470 case "$CC_VERSION" in
471         "gcc version 2.95"*)
472                 bad_cc
473                 ;;
474         # ost_pack_niobuf putting 64bit NTOH temporaries on the stack
475         # without "sub    $0xc,%esp" to protect the stack from being
476         # stomped on by interrupts (bug 606)
477         "gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)")
478                 bad_cc
479                 ;;
480         # mandrake's similar sub 0xc compiler bug
481         # http://marc.theaimsgroup.com/?l=linux-kernel&m=104748366226348&w=2
482         "gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)")
483                 bad_cc
484                 ;;
485         *)
486                 AC_MSG_RESULT([no known problems])
487                 ;;
488 esac
489
490 # ---------  unsigned long long sane? -------
491 AC_CHECK_SIZEOF(unsigned long long, 0)
492 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
493 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
494 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
495         AC_MSG_ERROR([** we assume that sizeof(long long) == 8.  Tell phil@clusterfs.com])
496 fi
497
498 # FIXME
499 AC_CHECK_DECL([__i386__], [], [
500
501 if test x$enable_bgl != xyes; then
502 AC_MSG_CHECKING([if $CC accepts -m64])
503 CC_save="$CC"
504 CC="$CC -m64"
505 AC_TRY_COMPILE([],[],[
506         AC_MSG_RESULT([yes])
507 ],[
508         AC_MSG_RESULT([no])
509         CC="$CC_save"
510 ])
511 fi
512
513 ])
514
515 CPPFLAGS="-I\$(top_builddir)/lnet/include -I\$(top_srcdir)/lnet/include -I\$(top_builddir)/lustre/include -I\$(top_srcdir)/lustre/include $CPPFLAGS"
516
517 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
518 AC_SUBST(LLCPPFLAGS)
519
520 LLCFLAGS="-g -Wall -fPIC"
521 AC_SUBST(LLCFLAGS)
522
523 # everyone builds against lnet and lustre
524 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/lnet/include -I$PWD/lustre/include"
525 AC_SUBST(EXTRA_KCFLAGS)
526 ])
527
528 #
529 # LB_CONTITIONALS
530 #
531 # AM_CONDITIONAL instances for everything
532 # (so that portals/lustre can disable some if needed)
533 AC_DEFUN([LB_CONDITIONALS],
534 [AM_CONDITIONAL(MODULES, test x$enable_modules = xyes)
535 AM_CONDITIONAL(UTILS, test x$enable_utils = xyes)
536 AM_CONDITIONAL(TESTS, test x$enable_tests = xyes)
537 AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
538 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
539 AM_CONDITIONAL(BUILD_PORTALS, test x$LUSTRE_PORTALS_SUBDIR = "xportals")
540 AM_CONDITIONAL(LINUX, test x$lb_target_os = "xlinux")
541 AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
542
543 # this lets lustre cancel libsysio, per-branch or if liblustre is
544 # disabled
545 if test "x$LIBSYSIO_SUBDIR" = xlibsysio ; then
546         if test "x$with_sysio" != xyes ; then
547                 SYSIO=""
548                 LIBSYSIO_SUBDIR=""
549         fi
550 fi
551 AC_SUBST(LIBSYSIO_SUBDIR)
552 AC_SUBST(SYSIO)
553
554 LB_LINUX_CONDITIONALS
555 LB_DARWIN_CONDITIONALS
556
557 LN_CONDITIONALS
558 LC_CONDITIONALS
559 #if test "$LUSTRE_PORTALS" ; then
560         LP_CONDITIONALS
561 #fi
562 ])
563
564 #
565 # LB_CONFIGURE
566 #
567 # main configure steps
568 #
569 AC_DEFUN([LB_CONFIGURE],
570 [LB_CANONICAL_SYSTEM
571
572 LB_INCLUDE_RULES
573
574 LB_CONFIG_PORTALS
575 if ! test "$PORTALS" ; then
576 # if portals is configured, Lustre portals will be ignored
577         LB_CONFIG_LUSTRE_PORTALS
578 fi
579 LB_CONFIG_CRAY_XT3
580 LB_CONFIG_BGL
581 LB_PATH_DEFAULTS
582
583 LB_PROG_CC
584
585 LB_PATH_LIBSYSIO
586 LB_PATH_SNMP
587
588 if test "$LUSTRE_PORTALS" ; then
589         LP_PROG_CC
590 fi
591
592 LB_CONFIG_DOCS
593 LB_CONFIG_UTILS
594 LB_CONFIG_TESTS
595 LC_CONFIG_CLIENT_SERVER
596 LC_CONFIG_GSS
597
598 LB_CONFIG_MODULES
599
600 LC_CONFIG_LIBLUSTRE
601
602 LN_CONFIGURE
603
604 LC_CONFIGURE
605 if test "$LUSTRE_PORTALS" ; then
606         LP_CONFIGURE
607 fi
608 if test "$SNMP_DIST_SUBDIR" ; then
609         LS_CONFIGURE
610 fi
611
612 LB_CONDITIONALS
613 LB_CONFIG_HEADERS
614
615 AC_CONFIG_FILES(
616 [Makefile:build/Makefile.in.toplevel]
617 [autoMakefile
618 build/autoMakefile
619 build/autoconf/Makefile
620 build/Rules
621 build/lustre.spec
622 ])
623
624 LN_CONFIG_FILES
625 LC_CONFIG_FILES
626 if test "$LUSTRE_PORTALS" ; then
627         LP_CONFIG_FILES
628 fi
629 if test "$SNMP_DIST_SUBDIR" ; then
630         LS_CONFIG_FILES
631 fi
632
633 AC_SUBST(ac_configure_args)
634
635 MOSTLYCLEANFILES='.*.cmd .*.flags *.o *.ko *.mod.c .depend .*.1.*'
636 AC_SUBST(MOSTLYCLEANFILES)
637
638 AC_OUTPUT
639
640 cat <<_ACEOF
641
642 CC:            $CC
643 LD:            $LD
644 CPPFLAGS:      $CPPFLAGS
645 LLCPPFLAGS:    $LLCPPFLAGS
646 CFLAGS:        $CFLAGS
647 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
648 LLCFLAGS:      $LLCFLAGS
649
650 Type 'make' to build Lustre.
651 _ACEOF
652 ])