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