Whamcloud - gitweb
4ed6794460a834deb66a9e08ef25bc64ffe3e50f
[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(defer-init-cwd,
105   AC_HELP_STRING([--with-defer-init-cwd],
106     [defer initialization of current working directory]),
107   [     case "${withval}" in
108          yes) DEFER_INIT_CWD=-DDEFER_INIT_CWD=1 ;;
109          no) ;;
110          *) AC_MSG_ERROR(bad value ${withval} for --with-defer-init-cwd) ;;
111         esac],
112   [with_defer_init_cwd=no])
113 AC_SUBST(DEFER_INIT_CWD)
114
115 AC_ARG_WITH(cplant_yod,
116    AC_HELP_STRING([--with-cplant-yod],[build cplant yod I/O driver]),
117    [    case "${withval}" in    
118         yes) if test x${with_stdfd_dev} != xyes; then
119                 with_stdfd_dev=yes
120                 AM_CONDITIONAL(WITH_STDFD_DEV, test x$with_stdfd_dev = xyes)
121              fi ;;
122         no) ;;
123         *) AC_MSG_ERROR(bad value ${withval} for --with-cplant-yod);;
124         esac],
125     [with_cplant_yod=no])
126 AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes)
127
128 AC_ARG_WITH(cplant_tests,
129    AC_HELP_STRING([--with-cplant-tests=<cplant-build-path>],
130      [build libsysio tests for cplant platform]),
131    [    case "${withval}" in
132         yes) AC_MSG_ERROR(need path to compiler for --with-cplant-tests);;
133         no)  with_cplant_tests=no;;
134         *) CC=${withval}
135            CCDEPMODE=${CC} 
136            CPP="${CC} -E"
137            AC_CHECK_FILE(${CC},
138                 [ if test x${with_cplant_yod} != xyes; then
139                         with_cplant_yod=yes
140                         AM_CONDITIONAL(WITH_CPLANT_YOD, test x$with_cplant_yod = xyes)
141                   fi],
142                 [ AC_MSG_ERROR(path not found ${CC} for --with-cplant-tests) ]);;
143         esac],
144     [with_cplant_tests=no])
145 AM_CONDITIONAL(WITH_CPLANT_TESTS, test x$with_cplant_tests != xno)
146
147 AC_ARG_WITH(sockets,
148   AC_HELP_STRING([--with-sockets],
149     [build sockets interface driver (EXPERIMENTAL)]),
150   [     case "${withval}" in
151          yes) ;;
152          no) ;;
153          *) AC_MSG_ERROR(bad value ${withval} for --with-sockets) ;;
154         esac],
155   [with_sockets=no])
156 AM_CONDITIONAL(WITH_SOCKETS_DRIVER, test x$with_sockets = xyes)
157
158 AC_ARG_WITH(lustre-hack,
159   AC_HELP_STRING([--with-lustre-hack],
160     [have hacking code which needed to support liblustre driver (EXPERIMENTAL)]),
161   [     case "${withval}" in
162          yes) ;;
163          no) ;;
164          *) AC_MSG_ERROR(bad value ${withval} for --with-lustre-hack) ;;
165         esac],
166   [with_lustre_hack=no])
167 AM_CONDITIONAL(WITH_LUSTRE_HACK, test x$with_lustre_hack = xyes)
168 if test x$with_lustre_hack = xyes; then
169         AC_DEFINE(HAVE_LUSTRE_HACK)
170 fi
171
172 # We keep the original values in `$config_*' and never modify them, so we
173 # can write them unchanged into config.make.  Everything else uses
174 # $machine, $vendor, and $os, and changes them whenever convenient.
175 config_machine=$host_cpu config_vendor=$host_vendor config_os=$host_os
176
177 # Don't allow vendor == "unknown"
178 test "$config_vendor" = unknown && config_vendor=
179 config_os="`echo $config_os | sed 's/^unknown-//'`"
180
181 # Some configurations imply other options.
182 case "$host_os" in
183   gnu* | linux* | bsd4.4* | netbsd* | freebsd*)
184         # These systems always use GNU tools.
185         gnu_ld=yes gnu_as=yes ;;
186 esac
187 case "$host_os" in
188   # i586-linuxaout is mangled into i586-pc-linux-gnuaout
189   linux*ecoff* | linux*aout* | gnu*aout* | gnu*ecoff*)
190         ;;
191   gnu* | linux* | freebsd* | netbsd* | sysv4* | solaris2* | irix6*)
192         # These systems (almost) always use the ELF format.
193         elf=yes
194         ;;
195   aix*)
196         # These systems are always xcoff
197         xcoff=yes
198         elf=no
199         ;;
200 esac
201
202 machine=$config_machine
203 vendor=$config_vendor
204 os=$config_os
205
206 # config.guess on some IBM machines says `rs6000' instead of `powerpc'.
207 # Unify this here.
208 if test "$machine" = rs6000; then
209         machine="powerpc"
210 fi
211
212 AC_MSG_CHECKING(if readlink returns ssize_t)
213 AC_TRY_COMPILE([
214         include <unistd.h>
215 ],[
216         ssize_t readlink(const char *, char *, size_t);
217 ],
218         readlink_returns_ssize_t="yes",
219         readlink_returns_ssize_t="yes"
220 )
221 AC_MSG_RESULT($readlink_returns_ssize_t)
222 if test x$readlink_returns_ssize_t = xyes; then
223         AC_DEFINE(HAVE_POSIX_1003_READLINK, 1, [readlink returns ssize_t])
224 fi
225
226 # If we can't provoke the declaration of stat64 then we assume the
227 # environment supports 64-bit file support naturally. Beware!
228 AC_MSG_CHECKING(whether _LARGEFILE64_SOURCE definition is required)
229 AC_TRY_COMPILE([
230 #include <sys/types.h>
231 #include <sys/stat.h>
232 #include <unistd.h>], [
233 struct stat64 st64;],
234 sysio_largefile64_source_required=no,
235 sysio_largefile64_source_required=maybe)
236 if test x$sysio_largefile64_source_required = xmaybe; then
237         AC_TRY_COMPILE([
238 #define _LARGEFILE64_SOURCE
239 #include <sys/types.h>
240 #include <sys/stat.h>
241 #include <unistd.h>], [
242 struct stat64 st64;],
243                        sysio_largefile64_source_required=yes,
244                        sysio_largefile64_source_required=no)
245 fi
246 AC_MSG_RESULT($sysio_largefile64_source_required)
247 if test x$sysio_largefile64_source_required = xyes; then
248         AC_DEFINE(_LARGEFILE64_SOURCE)
249 fi
250
251 # Alpha linux defines 
252
253 AC_MSG_CHECKING(for alpha linux)
254 alpha_linux_env=no
255 if test `expr ${machine} : "alpha"` = 5 && \
256    test `expr ${os} : "linux"` = 5; then
257         alpha_linux_env=yes
258         AC_DEFINE(ALPHA_LINUX)
259 fi
260 AC_MSG_RESULT($alpha_linux_env)
261 AM_CONDITIONAL(TEST_ALPHA_ARG, test x$alpha_linux_env = xyes)
262
263 # Check for __st_ino 
264 #
265 AC_MSG_CHECKING(for __st_ino)
266 AC_TRY_COMPILE([
267 #include <sys/stat.h>],
268 [struct stat st;
269 st.__st_ino = 0;],
270         have__st_ino=yes,
271         have__st_ino=no)
272 AC_MSG_RESULT($have__st_ino)
273 if test x$have__st_ino = xyes; then
274         AC_DEFINE(HAVE__ST_INO)
275 fi
276
277 # Check for st_gen 
278 #
279 AC_MSG_CHECKING(for st_gen)
280 AC_TRY_COMPILE([
281 #include <sys/stat.h>],
282 [struct stat st;
283 st.st_gen = 0;],
284         have_st_gen=yes,
285         have_st_gen=no)
286 AC_MSG_RESULT($have_st_gen)
287 if test x$have_st_gen = xyes; then
288         AC_DEFINE(HAVE_GENERATION)
289 fi
290
291 AC_MSG_CHECKING(whether .text pseudo-op must be used)
292 AC_CACHE_VAL(sysio_asm_dot_text, [dnl
293 cat > conftest.s <<EOF
294         .text
295 EOF
296         sysio_asm_dot_text=
297         if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
298                 sysio_asm_dot_text=.text
299         fi
300         rm -f conftest*])
301 if test -z "$sysio_dot_text"; then
302         AC_MSG_RESULT(no)
303 else
304         AC_MSG_RESULT(yes)
305 fi
306
307 AC_CACHE_CHECK(for assembler global-symbol directive,
308   sysio_asm_global_directive, [dnl
309 sysio_asm_global_directive=UNKNOWN
310 for ac_globl in .globl .global .EXPORT; do
311         cat > conftest.s <<EOF
312                 ${sysio_asm_dot_text}
313                 ${ac_globl} foo
314 foo:
315 EOF
316         if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
317         sysio_asm_global_directive=${ac_globl}
318         fi
319         rm -f conftest*
320         test $sysio_asm_global_directive != UNKNOWN && break
321 done])
322 if test $sysio_asm_global_directive = UNKNOWN; then
323         AC_MSG_ERROR(cannot determine asm global directive)
324 #else
325 #       AC_DEFINE_UNQUOTED(ASM_GLOBAL_DIRECTIVE, ${sysio_asm_global_directive})
326 fi
327
328 AC_CACHE_CHECK(for .set assembler directive,
329   sysio_asm_set_directive, [dnl
330 cat > conftest.s<<EOF
331 ${sysio_asm_dot_text}
332 foo:
333 .set bar, foo
334 ${sysio_asm_global_directive} bar
335 EOF
336         # The alpha-dec-osf1 assembler gives only a warning for `.set'
337         # (but it doesn't work), so we must do a linking check to be sure.
338 cat > conftest1.c <<EOF
339 extern int bar;
340 main () { printf ("%d\n", bar); }
341 EOF
342         if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
343            -o conftest conftest.s conftest1.c 1>&AC_FD_CC 2>&AC_FD_CC; then
344                 sysio_asm_set_directive=yes
345         else
346                 sysio_asm_set_directive=no
347         fi
348         rm -f conftest*])
349 #if test $sysio_asm_set_directive = yes; then
350 #       AC_DEFINE(HAVE_ASM_SET_DIRECTIVE)
351 #fi
352
353 AC_CACHE_CHECK(for assembler .weak directive, sysio_asm_weak_directive,
354                [dnl
355 cat > conftest.s <<EOF
356 ${sysio_dot_text}
357 foo:
358 .weak foo
359 EOF
360         if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
361                 sysio_asm_weak_directive=yes
362         else
363                 sysio_asm_weak_directive=no
364         fi
365         rm -f conftest*])
366
367 if test $sysio_asm_weak_directive = no; then
368         AC_CACHE_CHECK(for assembler .weakext directive,
369                        sysio_asm_weakext_directive, [dnl
370 cat > conftest.s <<EOF
371 ${sysio_dot_text}
372 ${sysio_asm_global_directive} foo
373 foo:
374 .weakext bar foo
375 .weakext baz
376 ${sysio_asm_global_directive} baz
377 baz:
378 EOF
379                 if ${CC-cc} $CFLAGS -c conftest.s 2>/dev/null; then
380                         sysio_asm_weakext_directive=yes
381                 else
382                         sysio_asm_weakext_directive=no
383                 fi
384                 rm -f conftest*])
385 fi # no .weak
386
387 if test x$sysio_asm_weak_directive = xyes; then
388         AC_DEFINE(HAVE_ASM_WEAK_DIRECTIVE)
389 fi
390 if test x$sysio_asm_weakext_directive = xyes; then
391         AC_DEFINE(HAVE_ASM_WEAKEXT_DIRECTIVE)
392 fi
393
394 AC_OUTPUT(
395         Makefile
396         tests/Makefile)
397