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