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