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