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