Whamcloud - gitweb
LU-2744 build: fix 'data race condition' issues
[fs/lustre-release.git] / libsysio / configure.in
1 AC_INIT(libsysio, 1.2)
2
3 AC_CANONICAL_SYSTEM
4
5 case "$host_os" in
6         aix*)
7                 ;;
8         linux*)
9                 ;;
10         *)
11                 AC_MSG_WARN('***' ${host_os}: Unsupported OS target)
12                 ;;
13 esac
14
15 AM_INIT_AUTOMAKE([subdir-objects 1.9 tar-ustar])
16 AM_MAINTAINER_MODE([enable])
17 AC_PROG_CC
18 AM_PROG_CC_C_O
19 AC_PROG_RANLIB
20 AC_CHECK_TOOL(CC, gcc, [no])
21 AC_CHECK_TOOL(LD, ld, [no])
22 AC_CHECK_TOOL(AR, ar, [no])
23 AC_CHECK_TOOL(OBJDUMP, objdump, [no])
24 AC_CHECK_TOOL(STRIP, strip, [no])
25 AC_PROG_MAKE_SET
26 AC_HEADER_STDC
27 AC_HEADER_STAT
28 AC_HEADER_TIME
29
30 AS_IF([test "x$cross_compiling" = xyes],
31         [case $host_vendor in
32                 # The K1OM architecture is an extension of the x86 architecture.
33                 # So, the $host_arch is x86_64.
34                 k1om)
35                         CC_TARGET_ARCH=`$CC -v 2>&1 | grep Target: | sed -e 's/Target: //'`
36                         if test $CC_TARGET_ARCH != x86_64-$host_vendor-linux ; then
37                                 AC_MSG_ERROR([Cross compiler not found in PATH.])
38                         fi
39                         CCAS=$CC
40                         ;;
41                 *)
42                         ;;
43         esac]
44 )
45
46 if test ${target_cpu} == "powerpc64"; then
47         AC_MSG_WARN([set compiler with -m64])
48         CC="$CC -m64"
49 fi
50
51 have_lib_dir=yes;
52 AC_ARG_WITH(lib-dir,
53   AC_HELP_STRING([--with-lib-dir=<sysio lib build directory>],
54   [directory for sysio library]),
55   [     case "${withval}" in
56          "yes"|"no"|"") have_lib_dir=no ;;
57          *) LIBBUILD_DIR=${withval};
58             test -d ${LIBBUILD_DIR} || mkdir ${LIBBUILD_DIR} ||
59                 have_lib_dir=no;;
60         esac;],
61   [ LIBBUILD_DIR=`pwd`/lib;
62     test -d ${LIBBUILD_DIR} || mkdir ${LIBBUILD_DIR} || have_lib_dir=no;])
63 if test x${have_lib_dir} = xyes; then
64   echo "Using sysio library directory ${LIBBUILD_DIR}"
65 else
66   AC_MSG_ERROR(Need writeable path to sysio library directory ${LIBBUILD_DIR})
67 fi
68 AC_SUBST(LIBBUILD_DIR)
69
70 AC_ARG_WITH(native_driver,
71   AC_HELP_STRING([--with-native-driver],[build native test driver]),
72   [     case "${withval}" in
73          yes) ;;
74          no) ;;
75          *) AC_MSG_ERROR(bad value ${withval} for --with-native-driver) ;;
76         esac;],
77   [with_native_driver=yes;])
78 AM_CONDITIONAL(WITH_NATIVE_DRIVER, test x$with_native_driver = xyes)
79
80 AC_ARG_WITH(incore-driver,
81   AC_HELP_STRING([--with-incore-driver],[build incore test driver]),
82   [     case "${withval}" in
83          yes) ;;
84          no) ;;
85          *) AC_MSG_ERROR(bad value ${withval} for --with-incore-driver) ;;
86         esac],
87   [with_incore_driver=yes])
88 AM_CONDITIONAL(WITH_INCORE_DRIVER, test x$with_incore_driver = xyes)
89
90 AC_ARG_WITH(tests,
91   AC_HELP_STRING([--with-tests],[build tests]),
92   [     case "${withval}" in
93          yes) ;;
94          no) ;;
95          *) AC_MSG_ERROR(bad value ${withval} for --with-tests) ;;
96         esac],
97   [with_tests=yes])
98 AM_CONDITIONAL(WITH_TESTS, test x$with_tests = xyes)
99
100 AC_ARG_WITH(automount,
101   AC_HELP_STRING([--with-automount@<:@=<automount-file-name>@:>@],
102     [with automounts @<:@<automount-file-name>=.mount@:>@]),
103   [     if test x${withval} = xyes; then
104          AUTOMOUNT=-DAUTOMOUNT_FILE_NAME="\\\".mount\\\"" 
105         elif test x${withval} != x; then
106          AUTOMOUNT=-DAUTOMOUNT_FILE_NAME="\\\"${withval}\\\""
107         fi])
108 AC_SUBST(AUTOMOUNT)
109
110 AC_ARG_WITH(stdfd-dev,
111   AC_HELP_STRING([--with-stdfd-dev],
112     [build standard file descriptors pseudo-driver]),
113   [     case "${withval}" in
114          yes) ;;
115          no) ;;
116          *) AC_MSG_ERROR(bad value ${withval} for --with-stdfd-dev) ;;
117         esac],
118   [with_stdfd_dev=yes])
119 AM_CONDITIONAL(WITH_STDFD_DEV, test x$with_stdfd_dev = xyes)
120
121 AC_ARG_WITH(zero-sum-memory,
122   AC_HELP_STRING([--with-zero-sum-memory],
123     [free all dynamically allocated memory at the end -- useful for debugging]),
124   [     case "${withval}" in
125          yes) ZERO_SUM_MEMORY=-DZERO_SUM_MEMORY=1 ;;
126          no) ;;
127          *) AC_MSG_ERROR(bad value ${withval} for --with-zero-sum-memory) ;;
128         esac],
129   [with_zero_sum_memory=no])
130 AC_SUBST(ZERO_SUM_MEMORY)
131
132 AC_ARG_WITH(defer-init-cwd,
133   AC_HELP_STRING([--with-defer-init-cwd],
134     [defer initialization of current working directory]),
135   [     case "${withval}" in
136          yes) DEFER_INIT_CWD=-DDEFER_INIT_CWD=1 ;;
137          no) ;;
138          *) AC_MSG_ERROR(bad value ${withval} for --with-defer-init-cwd) ;;
139         esac],
140   [with_defer_init_cwd=no])
141 AC_SUBST(DEFER_INIT_CWD)
142
143 AC_ARG_WITH(tracing,
144   AC_HELP_STRING([--with-tracing],
145     [enable tracing support]),
146   [     case "${withval}" in
147          yes) TRACING=-DSYSIO_TRACING=1 ;;
148          no) ;;
149          *) AC_MSG_ERROR(bad value ${withval} for --with-tracing) ;;
150         esac],
151   [TRACING=-DSYSIO_TRACING=1])
152 AC_SUBST(TRACING)
153
154 AC_ARG_WITH(cplant_yod,
155    AC_HELP_STRING([--with-cplant-yod],[build cplant yod I/O driver]),
156    [    case "${withval}" in    
157         yes) if test x${with_stdfd_dev} != xyes; then
158                 with_stdfd_dev=yes
159                 AM_CONDITIONAL(WITH_STDFD_DEV, test x$with_stdfd_dev = xyes)
160              fi ;;
161         no) ;;
162         *) AC_MSG_ERROR(bad value ${withval} for --with-cplant-yod);;
163         esac],
164     [with_cplant_yod=no])
165 AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes)
166
167 AC_ARG_WITH(cplant_tests,
168    AC_HELP_STRING([--with-cplant-tests=<cplant-build-path>],
169      [build libsysio tests for cplant platform]),
170    [    case "${withval}" in
171         yes) AC_MSG_ERROR(need path to compiler for --with-cplant-tests);;
172         no)  with_cplant_tests=no;;
173         *) CC=${withval}
174            CCDEPMODE=${CC} 
175            CPP="${CC} -E"
176            AC_CHECK_FILE(${CC},
177                 [ if test x${with_cplant_yod} != xyes; then
178                         with_cplant_yod=yes
179                         AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes)
180                   fi],
181                 [ AC_MSG_ERROR(path not found ${CC} for --with-cplant-tests) ]);;
182         esac],
183     [with_cplant_tests=no])
184 AM_CONDITIONAL(WITH_CPLANT_TESTS, test x$with_cplant_tests != xno)
185
186 AC_ARG_WITH(sockets,
187   AC_HELP_STRING([--with-sockets],
188     [build sockets interface driver (EXPERIMENTAL)]),
189   [     case "${withval}" in
190          yes) ;;
191          no) ;;
192          *) AC_MSG_ERROR(bad value ${withval} for --with-sockets) ;;
193         esac],
194   [with_sockets=no])
195 AM_CONDITIONAL(WITH_SOCKETS_DRIVER, test x$with_sockets = xyes)
196
197 AC_ARG_WITH(lustre-hack,
198   AC_HELP_STRING([--with-lustre-hack],
199     [have hacking code which needed to support liblustre driver (EXPERIMENTAL)]),
200   [     case "${withval}" in
201          yes) ;;
202          no) ;;
203          *) AC_MSG_ERROR(bad value ${withval} for --with-lustre-hack) ;;
204         esac],
205   [with_lustre_hack=no])
206 AM_CONDITIONAL(WITH_LUSTRE_HACK, test x$with_lustre_hack = xyes)
207 if test x$with_lustre_hack = xyes; then
208         AC_DEFINE(HAVE_LUSTRE_HACK)
209 fi
210
211 AC_ARG_WITH(alternate-symbols,
212   AC_HELP_STRING([--with-alternate-symbols@<:@=<qualifier>@:>@],
213     [Prepend standard, public, symbols with a unique qualifer]),
214   [     case "${withval}" in
215          yes) SYSIO_LABEL_NAMES=-DSYSIO_LABEL_NAMES=sysio_ ;;
216          no) ;;
217          *) SYSIO_LABEL_NAMES=-DSYSIO_LABEL_NAMES="${withval}" ;;
218         esac])
219 AC_SUBST(SYSIO_LABEL_NAMES)
220
221 # We keep the original values in `$config_*' and never modify them, so we
222 # can write them unchanged into config.make.  Everything else uses
223 # $machine, $vendor, and $os, and changes them whenever convenient.
224 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
225
226 # Don't allow vendor == "unknown"
227 test "$config_vendor" = unknown && config_vendor=
228 config_os="`echo $config_os | sed 's/^unknown-//'`"
229
230 # Some configurations imply other options.
231 case "$host_os" in
232   gnu* | linux* | bsd4.4* | netbsd* | freebsd*)
233         # These systems always use GNU tools.
234         gnu_ld=yes gnu_as=yes ;;
235 esac
236 case "$host_os" in
237   # i586-linuxaout is mangled into i586-pc-linux-gnuaout
238   linux*ecoff* | linux*aout* | gnu*aout* | gnu*ecoff*)
239         ;;
240   gnu* | linux* | freebsd* | netbsd* | sysv4* | solaris2* | irix6*)
241         # These systems (almost) always use the ELF format.
242         elf=yes
243         ;;
244   aix*)
245         # These systems are always xcoff
246         xcoff=yes
247         elf=no
248         ;;
249 esac
250
251 machine=$config_machine
252 vendor=$config_vendor
253 os=$config_os
254
255 # config.guess on some IBM machines says `rs6000' instead of `powerpc'.
256 # Unify this here.
257 if test "$machine" = rs6000; then
258         machine="powerpc"
259 fi
260
261 case "$host_os" in
262   gnu* | linux*)
263         AC_DEFINE(_XOPEN_SOURCE, 600)
264         ;;
265   aix*)
266         # ... and always needed...
267         AC_DEFINE(__USE_LARGEFILE64)
268         AC_DEFINE(_LARGE_FILES)
269         AC_DEFINE(_LARGE_FILE_API)
270         AC_DEFINE(_ALL_SOURCE)
271         AC_DEFINE(_XOPEN_SOURCE_EXTENDED)
272         ;;
273 esac
274
275 AC_MSG_CHECKING(for symlink support)
276 AC_TRY_COMPILE([
277 #include <sys/types.h>
278 #include <sys/stat.h>
279 ],[
280 #ifndef S_ISLNK
281 #error
282 #endif
283 ],
284         symlink_support="yes",
285         symlink_support="no"
286 )
287 AC_MSG_RESULT($symlink_support)
288
289 if test x$symlink_support = xyes; then
290         AC_MSG_CHECKING(if readlink returns int)
291         AC_TRY_COMPILE([
292 #include <unistd.h>
293         ],[
294                 extern int readlink(const char *, char *, size_t);
295         ],
296                 readlink_returns_int="yes",
297                 readlink_returns_int="no"
298         )
299         AC_MSG_RESULT($readlink_returns_int)
300         if test x$readlink_returns_int = no; then
301                 AC_DEFINE(HAVE_POSIX_1003_READLINK,
302                           1,
303                           [readlink returns ssize_t])
304         fi
305 fi
306
307 AC_MSG_CHECKING(if readlink returns ssize_t)
308 AC_TRY_COMPILE([
309         #include <unistd.h>
310 ],[
311         ssize_t readlink(const char *, char *, size_t);
312 ],[
313         AC_MSG_RESULT([yes])
314         AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
315 ],[
316         AC_MSG_RESULT([no])
317 ])
318
319 # If we can't provoke the declaration of stat64 then we assume the
320 # environment supports 64-bit file support naturally. Beware!
321 AC_MSG_CHECKING(whether _LARGEFILE64_SOURCE definition is required)
322 AC_TRY_COMPILE([
323 #include <sys/types.h>
324 #include <sys/stat.h>
325 #include <unistd.h>], [
326 struct stat64 st64;],
327 sysio_largefile64_source_required=no,
328 sysio_largefile64_source_required=maybe)
329 if test x$sysio_largefile64_source_required = xmaybe; then
330         AC_TRY_COMPILE([
331 #define _LARGEFILE64_SOURCE
332 #include <sys/types.h>
333 #include <sys/stat.h>
334 #include <unistd.h>], [
335 struct stat64 st64;],
336                        sysio_largefile64_source_required=yes,
337                        sysio_largefile64_source_required=no)
338 fi
339 AC_MSG_RESULT($sysio_largefile64_source_required)
340 if test x$sysio_largefile64_source_required = xyes; then
341         AC_DEFINE(_LARGEFILE64_SOURCE)
342 fi
343
344 # Alpha linux defines 
345
346 AC_MSG_CHECKING(for alpha linux)
347 alpha_linux_env=no
348 if test `expr ${machine} : "alpha"` = 5 && \
349    test `expr ${os} : "linux"` = 5; then
350         alpha_linux_env=yes
351         AC_DEFINE(ALPHA_LINUX)
352 fi
353 AC_MSG_RESULT($alpha_linux_env)
354 AM_CONDITIONAL(TEST_ALPHA_ARG, test x$alpha_linux_env = xyes)
355
356 # Check for __st_ino 
357 #
358 AC_MSG_CHECKING(for __st_ino)
359 AC_TRY_COMPILE([
360 #include <sys/stat.h>],
361 [struct stat st;
362 st.__st_ino = 0;],
363         have__st_ino=yes,
364         have__st_ino=no)
365 AC_MSG_RESULT($have__st_ino)
366 if test x$have__st_ino = xyes; then
367         AC_DEFINE(HAVE__ST_INO)
368 fi
369
370 # Check for st_gen 
371 #
372 AC_MSG_CHECKING(for st_gen)
373 AC_TRY_COMPILE([
374 #include <sys/stat.h>],
375 [struct stat st;
376 st.st_gen = 0;],
377         have_st_gen=yes,
378         have_st_gen=no)
379 AC_MSG_RESULT($have_st_gen)
380 if test x$have_st_gen = xyes; then
381         AC_DEFINE(HAVE_GENERATION)
382 fi
383
384 AC_MSG_CHECKING(for POSIX 2008 preadv)
385 tmp_flags="$CFLAGS"
386 CFLAGS="$CFLAGS -Wall -Werror"
387 AC_TRY_COMPILE([
388 #include <sys/uio.h>
389 ssize_t preadv (int __fd, const struct iovec *__iovec,
390                 int __count, off_t off)
391 {
392     return 0;
393 }
394 ],[
395 ],[
396 AC_DEFINE(HAVE_POSIX2008_PREADV, 1, [POSIX 2008 preadv])
397 AC_MSG_RESULT(yes)
398 ],[
399 AC_MSG_RESULT(no)
400 ])
401 CFLAGS="$tmp_flags"
402
403 AC_MSG_CHECKING(for POSIX 2008 scandir)
404 tmp_flags="$CFLAGS"
405 CFLAGS="$CFLAGS -Wall -Werror"
406 AC_TRY_COMPILE([
407 #define _BSD_SOURCE
408
409 #include <stdio.h>
410 #include <dirent.h>
411
412 int scandir(const char *dir,
413          struct dirent ***namelist,
414          int(*filter)(const struct dirent *),
415          int(*compar)(const struct dirent **,
416                       const struct dirent **)
417         );
418
419 ],[
420 ], [
421 AC_DEFINE(HAVE_POSIX2008_SCANDIR, 1, [POSIX 2008 scandir])
422 AC_MSG_RESULT(yes) 
423 ],[
424 AC_MSG_RESULT(no)
425 ])
426 CFLAGS="$tmp_flags"
427
428
429 AC_MSG_CHECKING(for POSIX 2008 preadv)
430 tmp_flags="$CFLAGS"
431 CFLAGS="$CFLAGS -Wall -Werror"
432 AC_TRY_COMPILE([
433 #include <sys/uio.h>
434 ssize_t preadv (int __fd, const struct iovec *__iovec,
435                 int __count, off_t off)
436 {
437     return 0;
438 }
439 ],[
440 ],[
441 AC_DEFINE(HAVE_POSIX2008_PREADV, 1, [POSIX 2008 preadv])
442 AC_MSG_RESULT(yes)
443 ],[
444 AC_MSG_RESULT(no)
445 ])
446 CFLAGS="$tmp_flags"
447
448 AC_MSG_CHECKING(for POSIX 2008 scandir)
449 tmp_flags="$CFLAGS"
450 CFLAGS="$CFLAGS -Wall -Werror"
451 AC_TRY_COMPILE([
452 #define _BSD_SOURCE
453
454 #include <stdio.h>
455 #include <dirent.h>
456
457 int scandir(const char *dir,
458         struct dirent ***namelist,
459         int(*filter)(const struct dirent *),
460         int(*compar)(const struct dirent **,
461                      const struct dirent **)
462        );
463
464 ],[
465 ], [
466 AC_DEFINE(HAVE_POSIX2008_SCANDIR, 1, [POSIX 2008 scandir])
467 AC_MSG_RESULT(yes) 
468 ],[
469 AC_MSG_RESULT(no)
470 ])
471 CFLAGS="$tmp_flags"
472
473
474 AC_MSG_CHECKING(whether .text pseudo-op must be used)
475 AC_CACHE_VAL(am_cv_sysio_asm_dot_text, [dnl
476 cat > conftest.s <<EOF
477         .text
478 EOF
479         am_cv_sysio_asm_dot_text=
480         if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
481                 am_cv_sysio_asm_dot_text=.text
482         fi
483         rm -f conftest*])
484 if test -z "$am_cv_sysio_asm_dot_text"; then
485         AC_MSG_RESULT(no)
486 else
487         AC_MSG_RESULT(yes)
488 fi
489
490 AC_CACHE_CHECK(for assembler global-symbol directive,
491   am_cv_sysio_asm_global_directive, [dnl
492 am_cv_sysio_asm_global_directive=UNKNOWN
493 for ac_globl in .globl .global .EXPORT; do
494         cat > conftest.s <<EOF
495                 ${am_cv_sysio_asm_dot_text}
496                 ${ac_globl} foo
497 foo:
498 EOF
499         if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
500         am_cv_sysio_asm_global_directive=${ac_globl}
501         fi
502         rm -f conftest*
503         test $am_cv_sysio_asm_global_directive != UNKNOWN && break
504 done])
505 if test $am_cv_sysio_asm_global_directive = UNKNOWN; then
506         AC_MSG_ERROR(cannot determine asm global directive)
507 #else
508 #       AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${am_cv_sysio_asm_global_directive})
509 fi
510
511 AC_CACHE_CHECK(for .set assembler directive,
512   am_cv_sysio_asm_set_directive, [dnl
513 cat > conftest.s<<EOF
514 ${am_cv_sysio_asm_dot_text}
515 foo:
516 .set bar, foo
517 ${am_cv_sysio_asm_global_directive} bar
518 EOF
519         # The alpha-dec-osf1 assembler gives only a warning for `.set'
520         # (but it doesn't work), so we must do a linking check to be sure.
521 cat > conftest1.c <<EOF
522 extern int bar;
523 main () { printf ("%d\n", bar); }
524 EOF
525         if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
526            -o conftest conftest.s conftest1.c 1>&AC_FD_CC 2>&AC_FD_CC; then
527                 am_cv_sysio_asm_set_directive=yes
528         else
529                 am_cv_sysio_asm_set_directive=no
530         fi
531         rm -f conftest*])
532 #if test $am_cv_sysio_asm_set_directive = yes; then
533 #       AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
534 #fi
535
536 AC_CACHE_CHECK(for assembler .weak directive, am_cv_sysio_asm_weak_directive,
537                [dnl
538 cat > conftest.s <<EOF
539 ${am_cv_sysio_asm_dot_text}
540 foo:
541 .weak foo
542 EOF
543         if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
544                 am_cv_sysio_asm_weak_directive=yes
545         else
546                 am_cv_sysio_asm_weak_directive=no
547         fi
548         rm -f conftest*])
549
550 if test $am_cv_sysio_asm_weak_directive = no; then
551         AC_CACHE_CHECK(for assembler .weakext directive,
552                        am_cv_sysio_asm_weakext_directive, [dnl
553 cat > conftest.s <<EOF
554 ${am_cv_sysio_asm_dot_text}
555 ${am_cv_sysio_asm_global_directive} foo
556 foo:
557 .weakext bar foo
558 .weakext baz
559 ${am_cv_sysio_asm_global_directive} baz
560 baz:
561 EOF
562                 if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
563                         am_cv_sysio_asm_weakext_directive=yes
564                 else
565                         am_cv_sysio_asm_weakext_directive=no
566                 fi
567                 rm -f conftest*])
568 fi # no .weak
569
570 if test x$am_cv_sysio_asm_weak_directive = xyes; then
571         AC_DEFINE(HAVE_ASM_WEAK_DIRECTIVE)
572 fi
573 if test x$am_cv_sysio_asm_weakext_directive = xyes; then
574         AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE)
575 fi
576
577 AC_OUTPUT(
578         Makefile
579         tests/Makefile)