Whamcloud - gitweb
5de069aaf09927f57ec1243a36d4c423dc593758
[fs/lustre-release.git] / libsysio / configure.in
1 AC_INIT(libsysio, 0.1)
2
3 AC_CANONICAL_HOST
4
5 case "$host_os" in
6   linux*)
7         ;;
8   *)
9         AC_MSG_WARN('***' ${host_os}: Unsupported OS target)
10         ;;
11 esac
12
13 AM_INIT_AUTOMAKE([subdir-objects])
14 AM_PROG_CC_C_O
15
16 AC_PROG_CC
17 AC_PROG_RANLIB
18 AC_PROG_MAKE_SET
19 AC_HEADER_STDC
20 AC_HEADER_STAT
21 AC_HEADER_TIME
22
23 have_lib_dir=yes;
24 AC_ARG_WITH(lib-dir,
25   AC_HELP_STRING([--with-lib-dir=<sysio lib build directory>],
26   [directory for sysio library]),
27   [     case "${withval}" in
28          "yes"|"no"|"") have_lib_dir=no ;;
29          *) LIBBUILD_DIR=${withval};
30             test -d ${LIBBUILD_DIR} || mkdir ${LIBBUILD_DIR} ||
31                 have_lib_dir=no;;
32         esac;],
33   [ LIBBUILD_DIR=`pwd`/lib;
34     test -d ${LIBBUILD_DIR} || mkdir ${LIBBUILD_DIR} || have_lib_dir=no;])
35 if test x${have_lib_dir} = xyes; then
36   echo "Using sysio library directory ${LIBBUILD_DIR}"
37 else
38   AC_MSG_ERROR(Need writeable path to sysio library directory ${LIBBUILD_DIR})
39 fi
40 AC_SUBST(LIBBUILD_DIR)
41
42 AC_ARG_WITH(native_driver,
43   AC_HELP_STRING([--with-native-driver],[build native test driver]),
44   [     case "${withval}" in
45          yes) ;;
46          no) ;;
47          *) AC_MSG_ERROR(bad value ${withval} for --with-native-driver) ;;
48         esac;],
49   [with_native_driver=yes;])
50 AM_CONDITIONAL(WITH_NATIVE_DRIVER, test x$with_native_driver = xyes)
51
52 AC_ARG_WITH(incore-driver,
53   AC_HELP_STRING([--with-incore-driver],[build incore test driver]),
54   [     case "${withval}" in
55          yes) ;;
56          no) ;;
57          *) AC_MSG_ERROR(bad value ${withval} for --with-incore-driver) ;;
58         esac],
59   [with_incore_driver=yes])
60 AM_CONDITIONAL(WITH_INCORE_DRIVER, test x$with_incore_driver = xyes)
61
62 AC_ARG_WITH(tests,
63   AC_HELP_STRING([--with-tests],[build tests]),
64   [     case "${withval}" in
65          yes) ;;
66          no) ;;
67          *) AC_MSG_ERROR(bad value ${withval} for --with-tests) ;;
68         esac],
69   [with_tests=yes])
70 AM_CONDITIONAL(WITH_TESTS, test x$with_tests = xyes)
71
72 AC_ARG_WITH(automount,
73   AC_HELP_STRING([--with-automount@<:@=<automount-file-name>@:>@],
74     [with automounts @<:@<automount-file-name>=.mount@:>@]),
75   [     if test x${withval} = xyes; then
76          AUTOMOUNT=-DAUTOMOUNT_FILE_NAME="\\\".mount\\\"" 
77         elif test x${withval} != x; then
78          AUTOMOUNT=-DAUTOMOUNT_FILE_NAME="\\\"${withval}\\\""
79         fi])
80 AC_SUBST(AUTOMOUNT)
81
82 AC_ARG_WITH(stdfd-dev,
83   AC_HELP_STRING([--with-stdfd-dev],
84     [build standard file descriptors pseudo-driver]),
85   [     case "${withval}" in
86          yes) ;;
87          no) ;;
88          *) AC_MSG_ERROR(bad value ${withval} for --with-stdfd-dev) ;;
89         esac],
90   [with_stdfd_dev=yes])
91 AM_CONDITIONAL(WITH_STDFD_DEV, test x$with_stdfd_dev = xyes)
92
93 AC_ARG_WITH(zero-sum-memory,
94   AC_HELP_STRING([--with-zero-sum-memory],
95     [free all dynamically allocated memory at the end -- useful for debugging]),
96   [     case "${withval}" in
97          yes) ZERO_SUM_MEMORY=-DZERO_SUM_MEMORY=1 ;;
98          no) ;;
99          *) AC_MSG_ERROR(bad value ${withval} for --with-zero-sum-memory) ;;
100         esac],
101   [with_zero_sum_memory=no])
102 AC_SUBST(ZERO_SUM_MEMORY)
103
104 AC_ARG_WITH(cplant_yod,
105    AC_HELP_STRING([--with-cplant-yod],[build cplant yod I/O driver]),
106    [    case "${withval}" in    
107         yes) if test x${with_stdfd_dev} != xyes; then
108                 with_stdfd_dev=yes
109                 AM_CONDITIONAL(WITH_STDFD_DEV, test x$with_stdfd_dev = xyes)
110              fi ;;
111         no) ;;
112         *) AC_MSG_ERROR(bad value ${withval} for --with-cplant-yod);;
113         esac],
114     [with_cplant_yod=no])
115 AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes)
116
117 AC_ARG_WITH(cplant_tests,
118    AC_HELP_STRING([--with-cplant-tests=<cplant-build-path>],
119      [build libsysio tests for cplant platform]),
120    [    case "${withval}" in
121         yes) AC_MSG_ERROR(need path to compiler for --with-cplant-tests);;
122         no)  with_cplant_tests=no;;
123         *) CC=${withval}
124            CCDEPMODE=${CC} 
125            CPP="${CC} -E"
126            AC_CHECK_FILE(${CC},
127                 [ if test x${with_cplant_yod} != xyes; then
128                         with_cplant_yod=yes
129                         AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes)
130                   fi],
131                 [ AC_MSG_ERROR(path not found ${CC} for --with-cplant-tests) ]);;
132         esac],
133     [with_cplant_tests=no])
134 AM_CONDITIONAL(WITH_CPLANT_TESTS, test x$with_cplant_tests != xno)
135
136 AC_ARG_WITH(sockets,
137   AC_HELP_STRING([--with-sockets],
138     [build sockets interface driver (EXPERIMENTAL)]),
139   [     case "${withval}" in
140          yes) ;;
141          no) ;;
142          *) AC_MSG_ERROR(bad value ${withval} for --with-sockets) ;;
143         esac],
144   [with_sockets=no])
145 AM_CONDITIONAL(WITH_SOCKETS_DRIVER, test x$with_sockets = xyes)
146
147 AC_ARG_WITH(lustre-hack,
148   AC_HELP_STRING([--with-lustre-hack],
149     [have hacking code which needed to support liblustre driver (EXPERIMENTAL)]),
150   [     case "${withval}" in
151          yes) ;;
152          no) ;;
153          *) AC_MSG_ERROR(bad value ${withval} for --with-lustre-hack) ;;
154         esac],
155   [with_lustre_hack=no])
156 AM_CONDITIONAL(WITH_LUSTRE_HACK, test x$with_lustre_hack = xyes)
157 if test x$with_lustre_hack = xyes; then
158         AC_DEFINE(HAVE_LUSTRE_HACK)
159 fi
160
161 # We keep the original values in `$config_*' and never modify them, so we
162 # can write them unchanged into config.make.  Everything else uses
163 # $machine, $vendor, and $os, and changes them whenever convenient.
164 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
165
166 # Don't allow vendor == "unknown"
167 test "$config_vendor" = unknown && config_vendor=
168 config_os="`echo $config_os | sed 's/^unknown-//'`"
169
170 # Some configurations imply other options.
171 case "$host_os" in
172   gnu* | linux* | bsd4.4* | netbsd* | freebsd*)
173         # These systems always use GNU tools.
174         gnu_ld=yes gnu_as=yes ;;
175 esac
176 case "$host_os" in
177   # i586-linuxaout is mangled into i586-pc-linux-gnuaout
178   linux*ecoff* | linux*aout* | gnu*aout* | gnu*ecoff*)
179         ;;
180   gnu* | linux* | freebsd* | netbsd* | sysv4* | solaris2* | irix6*)
181         # These systems (almost) always use the ELF format.
182         elf=yes
183         ;;
184   aix*)
185         # These systems are always xcoff
186         xcoff=yes
187         elf=no
188         ;;
189 esac
190
191 machine=$config_machine
192 vendor=$config_vendor
193 os=$config_os
194
195 # config.guess on some IBM machines says `rs6000' instead of `powerpc'.
196 # Unify this here.
197 if test "$machine" = rs6000; then
198         machine="powerpc"
199 fi
200
201 AC_MSG_CHECKING(if readlink returns ssize_t)
202 AC_TRY_COMPILE([
203   include <unistd.h>
204 ],[
205   ssize_t readlink(const char *, char *, size_t);
206 ],
207   readlink_returns_ssize_t="yes",
208   readlink_returns_ssize_t="yes"
209 )
210 AC_MSG_RESULT($readlink_returns_ssize_t)
211 if test x$readlink_returns_ssize_t = xyes; then
212   AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
213 fi
214
215
216 # If we can't provoke the declaration of stat64 then we assume the
217 # environment supports 64-bit file support naturally. Beware!
218 AC_MSG_CHECKING(whether _LARGEFILE64_SOURCE definition is required)
219 AC_TRY_COMPILE([
220 #include <sys/types.h>
221 #include <sys/stat.h>
222 #include <unistd.h>], [
223 struct stat64 st64;],
224 sysio_largefile64_source_required=no,
225 sysio_largefile64_source_required=maybe)
226 if test x$sysio_largefile64_source_required = xmaybe; then
227         AC_TRY_COMPILE([
228 #define _LARGEFILE64_SOURCE
229 #include <sys/types.h>
230 #include <sys/stat.h>
231 #include <unistd.h>], [
232 struct stat64 st64;],
233                        sysio_largefile64_source_required=yes,
234                        sysio_largefile64_source_required=no)
235 fi
236 AC_MSG_RESULT($sysio_largefile64_source_required)
237 if test x$sysio_largefile64_source_required = xyes; then
238         AC_DEFINE(_LARGEFILE64_SOURCE)
239 fi
240
241 # Alpha linux defines 
242
243 AC_MSG_CHECKING(for alpha linux)
244 alpha_linux_env=no
245 if test `expr ${machine} : "alpha"` = 5 && \
246    test `expr ${os} : "linux"` = 5; then
247         alpha_linux_env=yes
248         AC_DEFINE(ALPHA_LINUX)
249 fi
250 AC_MSG_RESULT($alpha_linux_env)
251 AM_CONDITIONAL(TEST_ALPHA_ARG, test x$alpha_linux_env = xyes)
252
253 # check for 64 bit stat, fstat, truncate, ftruncate syscalls
254
255 AC_MSG_CHECKING(for 64 bit stat and truncate syscalls)
256 AC_TRY_COMPILE([
257 #include <sys/stat.h>
258 #include <syscall.h>
259 extern int syscall();],
260 [char path[] = "/";
261 int fd = 0;
262 struct stat buf;
263 syscall(SYS_stat64,path,&buf);
264 syscall(SYS_fstat64,fd,&buf);
265 syscall(SYS_truncate64, path, buf.st_size);
266 syscall(SYS_ftruncate64, fd, buf.st_size);
267 ],
268         sysstat64_exists=yes,
269         sysstat64_exists=no)
270 AC_MSG_RESULT($sysstat64_exists)
271 if test x$sysstat64_exists = xno; then
272         AC_DEFINE(USE_NATIVE_STAT)
273 fi
274
275 # Check for fdatasync syscall
276 #
277 AC_MSG_CHECKING(for fdatasync system call)
278 if test x$alpha_linux_env = xyes; then
279         _syscallnum=SYS_osf_fdatasync
280 else
281         _syscallnum=SYS_fdatasync
282 fi
283 AC_TRY_COMPILE([
284 #include <syscall.h>
285 extern int syscall();],
286 [int fd = 0;
287 syscall(SYS_fdatasync, fd);],
288         syscall_fdatasync_exists=yes,
289         syscall_fdatasync_exists=no)
290 AC_MSG_RESULT($syscall_fdatasync_exists)
291 if test x$syscall_fdatasync_exists = xyes; then
292         AC_DEFINE_UNQUOTED(NATIVE_FDATASYNC, $_syscallnum)
293 fi
294
295 # Check for SYS_utime
296 #
297 AC_MSG_CHECKING(for utime system call)
298 AC_TRY_COMPILE([
299 #include <syscall.h>
300 extern int syscall();],
301 [syscall(SYS_utime);],
302         syscall_utime_exists=yes,
303         syscall_utime_exists=no)
304 AC_MSG_RESULT($syscall_utime_exists)
305 if test x$syscall_utime_exists = xno; then
306         AC_DEFINE(USE_NATIVE_UTIME)
307 fi
308 # Check for __st_ino 
309 #
310 AC_MSG_CHECKING(for __st_ino)
311 AC_TRY_COMPILE([
312 #include <sys/stat.h>],
313 [struct stat st;
314 st.__st_ino = 0;],
315         have__st_ino=yes,
316         have__st_ino=no)
317 AC_MSG_RESULT($have__st_ino)
318 if test x$have__st_ino = xyes; then
319         AC_DEFINE(HAVE__ST_INO)
320 fi
321
322 # Check for st_gen 
323 #
324 AC_MSG_CHECKING(for st_gen)
325 AC_TRY_COMPILE([
326 #include <sys/stat.h>],
327 [struct stat st;
328 st.st_gen = 0;],
329         have_st_gen=yes,
330         have_st_gen=no)
331 AC_MSG_RESULT($have_st_gen)
332 if test x$have_st_gen = xyes; then
333         AC_DEFINE(HAVE_GENERATION)
334 fi
335
336 AC_MSG_CHECKING(whether .text pseudo-op must be used)
337 AC_CACHE_VAL(sysio_asm_dot_text, [dnl
338 cat > conftest.s <<EOF
339         .text
340 EOF
341         sysio_asm_dot_text=
342         if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
343                 sysio_asm_dot_text=.text
344         fi
345         rm -f conftest*])
346 if test -z "$sysio_dot_text"; then
347         AC_MSG_RESULT(no)
348 else
349         AC_MSG_RESULT(yes)
350 fi
351
352 AC_CACHE_CHECK(for assembler global-symbol directive,
353   sysio_asm_global_directive, [dnl
354 sysio_asm_global_directive=UNKNOWN
355 for ac_globl in .globl .global .EXPORT; do
356         cat > conftest.s <<EOF
357                 ${sysio_asm_dot_text}
358                 ${ac_globl} foo
359 foo:
360 EOF
361         if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
362         sysio_asm_global_directive=${ac_globl}
363         fi
364         rm -f conftest*
365         test $sysio_asm_global_directive != UNKNOWN && break
366 done])
367 if test $sysio_asm_global_directive = UNKNOWN; then
368         AC_MSG_ERROR(cannot determine asm global directive)
369 #else
370 #       AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${sysio_asm_global_directive})
371 fi
372
373 AC_CACHE_CHECK(for .set assembler directive,
374   sysio_asm_set_directive, [dnl
375 cat > conftest.s<<EOF
376 ${sysio_asm_dot_text}
377 foo:
378 .set bar, foo
379 ${sysio_asm_global_directive} bar
380 EOF
381         # The alpha-dec-osf1 assembler gives only a warning for `.set'
382         # (but it doesn't work), so we must do a linking check to be sure.
383 cat > conftest1.c <<EOF
384 extern int bar;
385 main () { printf ("%d\n", bar); }
386 EOF
387         if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
388            -o conftest conftest.s conftest1.c 1>&AC_FD_CC 2>&AC_FD_CC; then
389                 sysio_asm_set_directive=yes
390         else
391                 sysio_asm_set_directive=no
392         fi
393         rm -f conftest*])
394 #if test $sysio_asm_set_directive = yes; then
395 #       AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
396 #fi
397
398 AC_CACHE_CHECK(for assembler .weak directive, sysio_asm_weak_directive,
399                [dnl
400 cat > conftest.s <<EOF
401 ${sysio_dot_text}
402 foo:
403 .weak foo
404 EOF
405         if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
406                 sysio_asm_weak_directive=yes
407         else
408                 sysio_asm_weak_directive=no
409         fi
410         rm -f conftest*])
411
412 if test $sysio_asm_weak_directive = no; then
413         AC_CACHE_CHECK(for assembler .weakext directive,
414                        sysio_asm_weakext_directive, [dnl
415 cat > conftest.s <<EOF
416 ${sysio_dot_text}
417 ${sysio_asm_global_directive} foo
418 foo:
419 .weakext bar foo
420 .weakext baz
421 ${sysio_asm_global_directive} baz
422 baz:
423 EOF
424                 if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
425                         sysio_asm_weakext_directive=yes
426                 else
427                         sysio_asm_weakext_directive=no
428                 fi
429                 rm -f conftest*])
430 fi # no .weak
431
432 if test x$sysio_asm_weak_directive = xyes; then
433         AC_DEFINE(HAVE_ASM_WEAK_DIRECTIVE)
434 fi
435 if test x$sysio_asm_weakext_directive = xyes; then
436         AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE)
437 fi
438
439 AC_OUTPUT(
440         Makefile
441         tests/Makefile)
442