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