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