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