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