Whamcloud - gitweb
5d1e4c15eaf48fe41db46868e6a50057024a9d7d
[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_PATH_LIBSYSIO
62 #
63 # Handle internal/external libsysio
64 #
65 AC_DEFUN([LB_PATH_LIBSYSIO],
66 [AC_ARG_WITH([sysio],
67         AC_HELP_STRING([--with-sysio=path],
68                         [set path to libsysio source (default is included libsysio)]),
69         [],[
70                 case $lb_target_os in
71                         linux)
72                                 with_sysio='yes'
73                                 ;;
74                         *)
75                                 with_sysio='no'
76                                 ;;
77                 esac
78         ])
79 AC_MSG_CHECKING([location of libsysio])
80 enable_sysio="$with_sysio"
81 case x$with_sysio in
82         xyes)
83                 AC_MSG_RESULT([internal])
84                 LB_CHECK_FILE([$srcdir/libsysio/src/rmdir.c],[],[
85                         AC_MSG_ERROR([A complete internal libsysio was not found.])
86                 ])
87                 LIBSYSIO_SUBDIR="libsysio"
88                 SYSIO="$PWD/libsysio"
89                 ;;
90         xno)
91                 AC_MSG_RESULT([disabled])
92                 ;;
93         *)
94                 AC_MSG_RESULT([$with_sysio])
95                 LB_CHECK_FILE([$with_sysio/lib/libsysio.a],[],[
96                         AC_MSG_ERROR([A complete (built) external libsysio was not found.])
97                 ])
98                 SYSIO=$with_sysio
99                 with_sysio="yes"
100                 ;;
101 esac
102
103 # We have to configure even if we don't build here for make dist to
104 # work
105 AC_CONFIG_SUBDIRS(libsysio)
106 ])
107
108 #
109 # LB_PATH_CRAY_PORTALS
110 #
111 # Support for external Cray portals
112 #
113 AC_DEFUN([LB_PATH_CRAY_PORTALS],
114 [AC_MSG_CHECKING([for Cray portals])
115 AC_ARG_WITH([cray-portals],
116         AC_HELP_STRING([--with-cray-portals=path],
117                        [path to cray portals]),
118         [
119                 if test "$with_cray_portals" != no; then
120                         CRAY_PORTALS_PATH=$with_cray_portals
121                         CRAY_PORTALS_INCLUDES="$with_cray_portals/include"
122                         CRAY_PORTALS_LIBS="$with_cray_portals"
123                 fi
124         ],[with_cray_portals=no])
125 AC_SUBST(CRAY_PORTALS_PATH)
126 AC_MSG_RESULT([$CRAY_PORTALS_PATH])
127
128 AC_MSG_CHECKING([for Cray portals includes])
129 AC_ARG_WITH([cray-portals-includes],
130         AC_HELP_STRING([--with-cray-portals-includes=path],
131                        [path to cray portals includes]),
132         [
133                 if test "$with_cray_portals_includes" != no; then
134                         CRAY_PORTALS_INCLUDES="$with_cray_portals_includes"
135                 fi
136         ])
137 AC_SUBST(CRAY_PORTALS_INCLUDES)
138 AC_MSG_RESULT([$CRAY_PORTALS_INCLUDES])
139
140 AC_MSG_CHECKING([for Cray portals libs])
141 AC_ARG_WITH([cray-portals-libs],
142         AC_HELP_STRING([--with-cray-portals-libs=path],
143                        [path to cray portals libs]),
144         [
145                 if test "$with_cray_portals_libs" != no; then
146                         CRAY_PORTALS_LIBS="$with_cray_portals_libs"
147                 fi
148         ])
149 AC_SUBST(CRAY_PORTALS_LIBS)
150 AC_MSG_RESULT([$CRAY_PORTALS_LIBS])
151
152 if test x$CRAY_PORTALS_INCLUDES != x ; then
153         if test ! -r $CRAY_PORTALS_INCLUDES/portals/api.h ; then
154                 AC_MSG_ERROR([Cray portals headers were not found in $CRAY_PORTALS_INCLUDES.  Please check the paths passed to --with-cray-portals or --with-cray-portals-includes.])
155         fi
156 fi
157 if test x$CRAY_PORTALS_LIBS != x ; then
158         if test ! -r $CRAY_PORTALS_LIBS/libportals.a ; then
159                 AC_MSG_ERROR([Cray portals libraries were not found in $CRAY_PORTALS_LIBS.  Please check the paths passed to --with-cray-portals or --with-cray-portals-libs.])
160         fi
161 fi
162
163 AC_MSG_CHECKING([whether to use Cray portals])
164 if test x$CRAY_PORTALS_INCLUDES != x -a x$CRAY_PORTALS_LIBS != x ; then
165         with_cray_portals=yes
166         AC_DEFINE(CRAY_PORTALS, 1, [Building with Cray Portals])
167         CPPFLAGS="-I$CRAY_PORTALS_INCLUDES $CPPFLAGS"
168         EXTRA_KCFLAGS="-I$CRAY_PORTALS_INCLUDES $EXTRA_KCFLAGS"
169 else
170         with_cray_portals=no
171 fi
172 AC_MSG_RESULT([$with_cray_portals])
173 ])
174
175 #
176 # LB_CONFIG_MODULES
177 #
178 # Build kernel modules?
179 #
180 AC_DEFUN([LB_CONFIG_MODULES],
181 [AC_MSG_CHECKING([whether to build kernel modules])
182 AC_ARG_ENABLE([modules],
183         AC_HELP_STRING([--disable-modules],
184                         [disable building of Lustre kernel modules]),
185         [],[
186                 LC_TARGET_SUPPORTED([
187                         enable_modules='yes'
188                 ],[
189                         enable_modules='no'
190                 ])
191         ])
192 AC_MSG_RESULT([$enable_modules ($target_os)])
193
194 if test x$enable_modules = xyes ; then
195         case $target_os in
196                 linux*)
197                         LB_PROG_LINUX
198                         ;;
199                 darwin*)
200                         LB_PROG_DARWIN
201                         ;;
202                 *)
203                         # This is strange - Lustre supports a target we don't
204                         AC_MSG_ERROR([Modules are not supported on $target_os])
205                         ;;
206         esac
207 fi
208 ])
209
210 #
211 # LB_CONFIG_UTILS
212 #
213 # Build utils?
214 #
215 AC_DEFUN([LB_CONFIG_UTILS],
216 [AC_MSG_CHECKING([whether to build utilities])
217 AC_ARG_ENABLE([utils],
218         AC_HELP_STRING([--disable-utils],
219                         [disable building of Lustre utility programs]),
220         [],[enable_utils='yes'])
221 if test x$with_cray_portals = xyes ; then
222         enable_utils='no'
223 fi
224 AC_MSG_RESULT([$enable_utils])
225 if test x$enable_utils = xyes ; then 
226         LB_CONFIG_INIT_SCRIPTS
227 fi
228 ])
229
230 #
231 # LB_CONFIG_TESTS
232 #
233 # Build tests?
234 #
235 AC_DEFUN([LB_CONFIG_TESTS],
236 [AC_MSG_CHECKING([whether to build Lustre tests])
237 AC_ARG_ENABLE([tests],
238         AC_HELP_STRING([--disable-tests],
239                         [disable building of Lustre tests]),
240         [],[enable_tests='yes'])
241 if test x$with_cray_portals = xyes ; then
242         enable_tests='no'
243 fi
244 AC_MSG_RESULT([$enable_tests])
245 ])
246
247 #
248 # LB_CONFIG_DOCS
249 #
250 # Build docs?
251 #
252 AC_DEFUN([LB_CONFIG_DOCS],
253 [AC_MSG_CHECKING([whether to build docs])
254 AC_ARG_ENABLE(doc,
255         AC_HELP_STRING([--disable-doc],
256                         [skip creation of pdf documentation]),
257         [
258                 if test x$enable_doc = xyes ; then
259                     ENABLE_DOC=1           
260                 else
261                     ENABLE_DOC=0
262                 fi
263         ],[
264                 ENABLE_DOC=0
265                 enable_doc='no'
266         ])
267 AC_MSG_RESULT([$enable_doc])
268 AC_SUBST(ENABLE_DOC)
269 ])
270
271 #
272 # LB_CONFIG_INIT_SCRIPTS
273 #
274 # our init scripts only work on red hat linux
275 #
276 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS],
277 [ENABLE_INIT_SCRIPTS=0
278 if test x$enable_utils = xyes ; then
279         AC_MSG_CHECKING([whether to install init scripts])
280         # our scripts only work on red hat systems
281         if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
282                 ENABLE_INIT_SCRIPTS=1
283                 AC_MSG_RESULT([yes])
284         else
285                 AC_MSG_RESULT([no])
286         fi
287 fi
288 AC_SUBST(ENABLE_INIT_SCRIPTS)
289 ])
290
291 #
292 # LB_CONFIG_HEADERS
293 #
294 # add -include config.h
295 #
296 AC_DEFUN([LB_CONFIG_HEADERS],
297 [AC_CONFIG_HEADERS([config.h])
298 CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
299 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
300 AC_SUBST(EXTRA_KCFLAGS)
301 ])
302
303 #
304 # LB_INCLUDE_RULES
305 #
306 # defines for including the toplevel Rules
307 #
308 AC_DEFUN([LB_INCLUDE_RULES],
309 [INCLUDE_RULES="include $PWD/build/Rules"
310 AC_SUBST(INCLUDE_RULES)
311 ])
312
313 #
314 # LB_PATH_DEFAULTS
315 #
316 # 'fixup' default paths
317 #
318 AC_DEFUN([LB_PATH_DEFAULTS],
319 [# directories for binaries
320 AC_PREFIX_DEFAULT([/usr])
321
322 sysconfdir='/etc'
323 AC_SUBST(sysconfdir)
324
325 # Directories for documentation and demos.
326 docdir='${datadir}/doc/$(PACKAGE)'
327 AC_SUBST(docdir)
328
329 LP_PATH_DEFAULTS
330 LC_PATH_DEFAULTS
331 ])
332
333 #
334 # LB_PROG_CC
335 #
336 # checks on the C compiler
337 #
338 AC_DEFUN([LB_PROG_CC],
339 [AC_PROG_RANLIB
340 AC_MSG_CHECKING([for buggy compiler])
341 CC_VERSION=`$CC -v 2>&1 | grep "^gcc version"`
342 bad_cc() {
343         AC_MSG_RESULT([buggy compiler found!])
344         echo
345         echo "   '$CC_VERSION'"
346         echo "  has been known to generate bad code, "
347         echo "  please get an updated compiler."
348         AC_MSG_ERROR([sorry])
349 }
350 case "$CC_VERSION" in
351         "gcc version 2.95"*)
352                 bad_cc
353                 ;;
354         # ost_pack_niobuf putting 64bit NTOH temporaries on the stack
355         # without "sub    $0xc,%esp" to protect the stack from being
356         # stomped on by interrupts (bug 606)
357         "gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)")
358                 bad_cc
359                 ;;
360         # mandrake's similar sub 0xc compiler bug
361         # http://marc.theaimsgroup.com/?l=linux-kernel&m=104748366226348&w=2
362         "gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)")
363                 bad_cc
364                 ;;
365         *)
366                 AC_MSG_RESULT([no known problems])
367                 ;;
368 esac
369
370 # ---------  unsigned long long sane? -------
371 AC_CHECK_SIZEOF(unsigned long long, 0)
372 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
373 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
374 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
375         AC_MSG_ERROR([** we assume that sizeof(long long) == 8.  Tell phil@clusterfs.com])
376 fi
377
378 AC_MSG_CHECKING([if $CC accepts -m64])
379 CC_save="$CC"
380 CC="$CC -m64"
381 AC_TRY_COMPILE([],[],[
382         AC_MSG_RESULT([yes])
383 ],[
384         AC_MSG_RESULT([no])
385         CC="$CC_save"
386 ])
387
388 CPPFLAGS="-I\$(top_builddir)/portals/include -I\$(top_srcdir)/portals/include -I\$(top_builddir)/lustre/include -I\$(top_srcdir)/lustre/include $CPPFLAGS"
389
390 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
391 AC_SUBST(LLCPPFLAGS)
392
393 LLCFLAGS="-g -Wall -fPIC"
394 AC_SUBST(LLCFLAGS)
395
396 # everyone builds against portals and lustre
397 EXTRA_KCFLAGS="$EXTRA_KCFLAGS -g -I$PWD/portals/include -I$PWD/lustre/include"
398 AC_SUBST(EXTRA_KCFLAGS)
399 ])
400
401 #
402 # LB_CONTITIONALS
403 #
404 # AM_CONDITIONAL instances for everything
405 # (so that portals/lustre can disable some if needed)
406 AC_DEFUN([LB_CONDITIONALS],
407 [AM_CONDITIONAL(MODULES, test x$enable_modules = xyes)
408 AM_CONDITIONAL(UTILS, test x$enable_utils = xyes)
409 AM_CONDITIONAL(TESTS, test x$enable_tests = xyes)
410 AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
411 AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno)
412 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
413 AM_CONDITIONAL(LINUX, test x$lb_target_os = "xlinux")
414 AM_CONDITIONAL(DARWIN, test x$lb_target_os = "xdarwin")
415
416 # this lets lustre cancel libsysio, per-branch or if liblustre is
417 # disabled
418 if test "x$LIBSYSIO_SUBDIR" = xlibsysio ; then
419         if test "x$with_sysio" != xyes ; then
420                 SYSIO=""
421                 LIBSYSIO_SUBDIR=""
422         fi
423 fi
424 AC_SUBST(LIBSYSIO_SUBDIR)
425 AC_SUBST(SYSIO)
426
427 LB_LINUX_CONDITIONALS
428 LB_DARWIN_CONDITIONALS
429
430 LP_CONDITIONALS
431 LC_CONDITIONALS
432 ])
433
434 #
435 # LB_CONFIGURE
436 #
437 # main configure steps
438 #
439 AC_DEFUN([LB_CONFIGURE],
440 [LB_CANONICAL_SYSTEM
441
442 LB_INCLUDE_RULES
443
444 LB_PATH_DEFAULTS
445
446 LB_PROG_CC
447
448 LB_PATH_LIBSYSIO
449 LB_PATH_CRAY_PORTALS
450
451 LB_CONFIG_DOCS
452 LB_CONFIG_UTILS
453 LB_CONFIG_TESTS
454
455 LB_CONFIG_MODULES
456
457 LC_CONFIG_LIBLUSTRE
458
459 LP_CONFIGURE
460 LC_CONFIGURE
461
462 LB_CONDITIONALS
463 LB_CONFIG_HEADERS
464
465 AC_CONFIG_FILES(
466 [Makefile:build/Makefile.in.toplevel]
467 [autoMakefile
468 build/autoMakefile
469 build/autoconf/Makefile
470 build/Rules
471 build/lustre.spec
472 ])
473
474 LP_CONFIG_FILES
475 LC_CONFIG_FILES
476
477 AC_OUTPUT
478
479 cat <<_ACEOF
480
481 CC:            $CC
482 LD:            $LD
483 CPPFLAGS:      $CPPFLAGS
484 LLCPPFLAGS:    $LLCPPFLAGS
485 CFLAGS:        $CFLAGS
486 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
487 LLCFLAGS:      $LLCFLAGS
488
489 Type 'make' to build Lustre.
490 _ACEOF
491 ])