Whamcloud - gitweb
- add missing files to EXTRA_DIST
[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                 case $target_os in
129                         linux* | darwin*)
130                                 enable_modules='yes'
131                                 ;;
132                         *)
133                                 enable_modules='no'
134                                 ;;
135                 esac
136         ])
137 AC_MSG_RESULT([$enable_modules ($target_os)])
138
139 if test x$enable_modules = xyes ; then
140         case $target_os in
141                 linux*)
142                         LC_LINUX_SUPPORTED([LB_PROG_LINUX],
143                                 [AC_MSG_ERROR([Modules are not supported on $target_os])])
144                         ;;
145                 darwin*)
146                         LC_DARWIN_SUPPORTED([LB_PROG_DARWIN],
147                                 [AC_MSG_ERROR([Modules are not supported on $target_os])])
148                         ;;
149                 *)
150                         AC_MSG_ERROR([Modules are not supported on $target_os])
151                         ;;
152         esac
153 fi
154 ])
155
156 #
157 # LB_CONFIG_UTILS
158 #
159 # Build utils?
160 #
161 AC_DEFUN([LB_CONFIG_UTILS],
162 [AC_MSG_CHECKING([whether to build utilities])
163 AC_ARG_ENABLE([utils],
164         AC_HELP_STRING([--disable-utils],
165                         [disable building of Lustre utility programs]),
166         [],[enable_utils='yes'])
167 if test x$with_cray_portals = xyes ; then
168         enable_utils='no'
169 fi
170 AC_MSG_RESULT([$enable_utils])
171 if test x$enable_utils = xyes ; then 
172         LB_CONFIG_INIT_SCRIPTS
173 fi
174 ])
175
176 #
177 # LB_CONFIG_TESTS
178 #
179 # Build tests?
180 #
181 AC_DEFUN([LB_CONFIG_TESTS],
182 [AC_MSG_CHECKING([whether to build Lustre tests])
183 AC_ARG_ENABLE([tests],
184         AC_HELP_STRING([--disable-tests],
185                         [disable building of Lustre tests]),
186         [],[enable_tests='yes'])
187 if test x$with_cray_portals = xyes ; then
188         enable_tests='no'
189 fi
190 AC_MSG_RESULT([$enable_tests])
191 ])
192
193 #
194 # LB_CONFIG_DOCS
195 #
196 # Build docs?
197 #
198 AC_DEFUN([LB_CONFIG_DOCS],
199 [AC_MSG_CHECKING([whether to build docs])
200 AC_ARG_ENABLE(doc,
201         AC_HELP_STRING([--disable-doc],
202                         [skip creation of pdf documentation]),
203         [
204                 if test x$enable_doc = xyes ; then
205                     ENABLE_DOC=1           
206                 else
207                     ENABLE_DOC=0
208                 fi
209         ],[
210                 ENABLE_DOC=0
211                 enable_doc='no'
212         ])
213 AC_MSG_RESULT([$enable_doc])
214 AC_SUBST(ENABLE_DOC)
215 ])
216
217 #
218 # LB_CONFIG_INIT_SCRIPTS
219 #
220 # our init scripts only work on red hat linux
221 #
222 AC_DEFUN([LB_CONFIG_INIT_SCRIPTS],
223 [ENABLE_INIT_SCRIPTS=0
224 if test x$enable_utils = xyes ; then
225         AC_MSG_CHECKING([whether to install init scripts])
226         # our scripts only work on red hat systems
227         if test -f /etc/init.d/functions -a -f /etc/sysconfig/network ; then
228                 ENABLE_INIT_SCRIPTS=1
229                 AC_MSG_RESULT([yes])
230         else
231                 AC_MSG_RESULT([no])
232         fi
233 fi
234 AC_SUBST(ENABLE_INIT_SCRIPTS)
235 ])
236
237 #
238 # LB_CONFIG_HEADERS
239 #
240 # add -include config.h
241 #
242 AC_DEFUN([LB_CONFIG_HEADERS],
243 [AC_CONFIG_HEADERS([config.h])
244 CPPFLAGS="-include \$(top_builddir)/config.h $CPPFLAGS"
245 EXTRA_KCFLAGS="-include $PWD/config.h $EXTRA_KCFLAGS"
246 AC_SUBST(EXTRA_KCFLAGS)
247 ])
248
249 #
250 # LB_INCLUDE_RULES
251 #
252 # defines for including the toplevel Rules
253 #
254 AC_DEFUN([LB_INCLUDE_RULES],
255 [INCLUDE_RULES="include $PWD/build/Rules"
256 AC_SUBST(INCLUDE_RULES)
257 ])
258
259 #
260 # LB_PATH_DEFAULTS
261 #
262 # 'fixup' default paths
263 #
264 AC_DEFUN([LB_PATH_DEFAULTS],
265 [# directories for binaries
266 AC_PREFIX_DEFAULT([/usr])
267
268 sysconfdir='/etc'
269 AC_SUBST(sysconfdir)
270
271 # Directories for documentation and demos.
272 docdir='${datadir}/doc/$(PACKAGE)'
273 AC_SUBST(docdir)
274
275 LP_PATH_DEFAULTS
276 LC_PATH_DEFAULTS
277 ])
278
279 #
280 # LB_PROG_CC
281 #
282 # checks on the C compiler
283 #
284 AC_DEFUN([LB_PROG_CC],
285 [AC_PROG_RANLIB
286 AC_MSG_CHECKING([for buggy compiler])
287 CC_VERSION=`$CC -v 2>&1 | grep "^gcc version"`
288 bad_cc() {
289         AC_MSG_RESULT([buggy compiler found!])
290         echo
291         echo "   '$CC_VERSION'"
292         echo "  has been known to generate bad code, "
293         echo "  please get an updated compiler."
294         AC_MSG_ERROR([sorry])
295 }
296 case "$CC_VERSION" in
297         "gcc version 2.95"*)
298                 bad_cc
299                 ;;
300         # ost_pack_niobuf putting 64bit NTOH temporaries on the stack
301         # without "sub    $0xc,%esp" to protect the stack from being
302         # stomped on by interrupts (bug 606)
303         "gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)")
304                 bad_cc
305                 ;;
306         # mandrake's similar sub 0xc compiler bug
307         # http://marc.theaimsgroup.com/?l=linux-kernel&m=104748366226348&w=2
308         "gcc version 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)")
309                 bad_cc
310                 ;;
311         *)
312                 AC_MSG_RESULT([no known problems])
313                 ;;
314 esac
315
316 # ---------  unsigned long long sane? -------
317 AC_CHECK_SIZEOF(unsigned long long, 0)
318 echo "---> size SIZEOF $SIZEOF_unsigned_long_long"
319 echo "---> size SIZEOF $ac_cv_sizeof_unsigned_long_long"
320 if test $ac_cv_sizeof_unsigned_long_long != 8 ; then
321         AC_MSG_ERROR([** we assume that sizeof(long long) == 8.  Tell phil@clusterfs.com])
322 fi
323
324 CPPFLAGS="-I\$(top_srcdir)/lustre/include -I\$(top_srcdir)/portals/include $CPPFLAGS"
325
326 LLCPPFLAGS="-D__arch_lib__ -D_LARGEFILE64_SOURCE=1"
327 AC_SUBST(LLCPPFLAGS)
328
329 LLCFLAGS="-g -Wall -fPIC"
330 AC_SUBST(LLCFLAGS)
331
332 # everyone builds against portals and lustre
333 EXTRA_KCFLAGS="-g -I$PWD/portals/include -I$PWD/lustre/include"
334 AC_SUBST(EXTRA_KCFLAGS)
335 ])
336
337 #
338 # LB_CONTITIONALS
339 #
340 # AM_CONDITIONAL instances for everything
341 # (so that portals/lustre can disable some if needed)
342 AC_DEFUN([LB_CONDITIONALS],
343 [AM_CONDITIONAL(MODULES, test x$enable_modules = xyes)
344 AM_CONDITIONAL(UTILS, test x$enable_utils = xyes)
345 AM_CONDITIONAL(TESTS, test x$enable_tests = xyes)
346 AM_CONDITIONAL(DOC, test x$ENABLE_DOC = x1)
347 AM_CONDITIONAL(CRAY_PORTALS, test x$with_cray_portals != xno)
348 AM_CONDITIONAL(INIT_SCRIPTS, test x$ENABLE_INIT_SCRIPTS = "x1")
349
350 LB_LINUX_CONDITIONALS
351 LB_DARWIN_CONDITIONALS
352
353 LP_CONDITIONALS
354 LC_CONDITIONALS
355 ])
356
357 #
358 # LB_CONFIGURE
359 #
360 # main configure steps
361 #
362 AC_DEFUN([LB_CONFIGURE],
363 [LB_INCLUDE_RULES
364
365 LB_PATH_DEFAULTS
366
367 LB_PROG_CC
368
369 LB_PATH_LIBSYSIO
370 LB_PATH_CRAY_PORTALS
371
372 LB_CONFIG_DOCS
373 LB_CONFIG_UTILS
374 LB_CONFIG_TESTS
375
376 LB_CONFIG_MODULES
377
378 LC_CONFIG_LIBLUSTRE
379
380 LP_CONFIGURE
381 LC_CONFIGURE
382
383 LB_CONDITIONALS
384 LB_CONFIG_HEADERS
385
386 AC_CONFIG_FILES(
387 [Makefile:build/Makefile.in.toplevel]
388 [autoMakefile
389 build/autoMakefile
390 build/autoconf/Makefile
391 build/Rules
392 build/lustre.spec
393 ])
394
395 LP_CONFIG_FILES
396 LC_CONFIG_FILES
397
398 AC_OUTPUT
399
400 cat <<_ACEOF
401
402 CPPFLAGS: $CPPFLAGS
403 LLCPPFLAGS: $LLCPPFLAGS
404 CFLAGS: $CFLAGS
405 EXTRA_KCFLAGS: $EXTRA_KCFLAGS
406 LLCFLAGS: $LLCFLAGS
407
408 Type 'make' to build Lustre.
409 _ACEOF
410 ])