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