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