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