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