merge from gcc
[binutils-gdb.git] / libiberty / configure.in
1 dnl Process this file with autoconf to produce a configure script
2
3 AC_PREREQ(2.13)
4 AC_INIT(pexecute.c)
5
6 dnl We use these options to decide which functions to include.
7 AC_ARG_WITH(target-subdir,
8 [ --with-target-subdir=SUBDIR Configuring in a subdirectory])
9 AC_ARG_WITH(cross-host,
10 [ --with-cross-host=HOST Configuring with a cross compiler])
11 AC_ARG_WITH(newlib,
12 [ --with-newlib Configuring with newlib])
13
14 if test "${srcdir}" = "."; then
15 if test -z "${with_target_subdir}"; then
16 libiberty_topdir="${srcdir}/.."
17 else
18 if test "${with_target_subdir}" != "."; then
19 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
20 else
21 libiberty_topdir="${srcdir}/${with_multisrctop}.."
22 fi
23 fi
24 else
25 libiberty_topdir="${srcdir}/.."
26 fi
27 AC_CONFIG_AUX_DIR($libiberty_topdir)
28
29 AC_CANONICAL_HOST
30
31 dnl When we start using automake:
32 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
33
34 dnl These must be called before AM_PROG_LIBTOOL, because it may want
35 dnl to call AC_CHECK_PROG.
36 AC_CHECK_TOOL(AR, ar)
37 AC_CHECK_TOOL(RANLIB, ranlib, :)
38
39 LIB_AC_PROG_CC
40
41 AC_ISC_POSIX
42 AC_C_CONST
43 AC_C_INLINE
44
45 dnl When we start using libtool:
46 dnl Default to a non shared library. This may be overridden by the
47 dnl configure option --enable-shared.
48 dnl AM_DISABLE_SHARED
49
50 dnl When we start using libtool:
51 dnl AM_PROG_LIBTOOL
52
53 dnl When we start using automake:
54 dnl AM_CONFIG_HEADER(config.h:config.in)
55 AC_CONFIG_HEADER(config.h:config.in)
56
57 dnl When we start using automake:
58 dnl AM_MAINTAINER_MODE
59 dnl AC_EXEEXT
60
61 dnl When we start using automake:
62 dnl AM_PROG_INSTALL
63 AC_PROG_INSTALL
64
65 . ${srcdir}/config.table
66 host_makefile_frag=${frag}
67 AC_SUBST_FILE(host_makefile_frag)
68
69 # It's OK to check for header files. Although the compiler may not be
70 # able to link anything, it had better be able to at least compile
71 # something.
72 AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h)
73 AC_HEADER_SYS_WAIT
74 AC_HEADER_TIME
75
76 libiberty_AC_DECLARE_ERRNO
77
78 # This is the list of functions which libiberty will provide if they
79 # are not available on the host.
80
81 funcs="asprintf"
82 funcs="$funcs atexit"
83 funcs="$funcs basename"
84 funcs="$funcs bcmp"
85 funcs="$funcs bcopy"
86 funcs="$funcs bsearch"
87 funcs="$funcs bzero"
88 funcs="$funcs calloc"
89 funcs="$funcs clock"
90 funcs="$funcs ffs"
91 funcs="$funcs getcwd"
92 funcs="$funcs getpagesize"
93 funcs="$funcs index"
94 funcs="$funcs insque"
95 funcs="$funcs memchr"
96 funcs="$funcs memcmp"
97 funcs="$funcs memcpy"
98 funcs="$funcs memmove"
99 funcs="$funcs memset"
100 funcs="$funcs mkstemps"
101 funcs="$funcs putenv"
102 funcs="$funcs random"
103 funcs="$funcs rename"
104 funcs="$funcs rindex"
105 funcs="$funcs setenv"
106 funcs="$funcs sigsetmask"
107 funcs="$funcs strcasecmp"
108 funcs="$funcs strchr"
109 funcs="$funcs strdup"
110 funcs="$funcs strncasecmp"
111 funcs="$funcs strrchr"
112 funcs="$funcs strstr"
113 funcs="$funcs strtod"
114 funcs="$funcs strtol"
115 funcs="$funcs strtoul"
116 funcs="$funcs tmpnam"
117 funcs="$funcs vasprintf"
118 funcs="$funcs vfprintf"
119 funcs="$funcs vprintf"
120 funcs="$funcs vsprintf"
121 funcs="$funcs waitpid"
122
123 # Also in the old function.def file: alloca, vfork, getopt.
124
125 vars="sys_errlist sys_nerr sys_siglist"
126
127 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
128
129 # These are neither executed nor required, but they help keep
130 # autoheader happy without adding a bunch of text to acconfig.h.
131 if test "x" = "y"; then
132 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock)
133 AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy)
134 AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask)
135 AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
136 AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
137 AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
138 AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
139 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
140 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
141 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
142 fi
143
144 # For each of these functions, if the host does not provide the
145 # function we want to put FN.o in LIBOBJS, and if the host does
146 # provide the function, we want to define HAVE_FN in config.h.
147
148 setobjs=
149 CHECK=
150 if test -n "${with_target_subdir}"; then
151
152 # We are being configured as a target library. AC_REPLACE_FUNCS
153 # may not work correctly, because the compiler may not be able to
154 # link executables. Note that we may still be being configured
155 # native.
156
157 # If we are being configured for newlib, we know which functions
158 # newlib provide and which ones we will be expected to provide.
159
160 if test "x${with_newlib}" = "xyes"; then
161 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
162
163 for f in $funcs; do
164 case "$f" in
165 asprintf | basename | insque | random | strdup | vasprintf)
166 ;;
167 *)
168 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
169 AC_DEFINE_UNQUOTED($n)
170 ;;
171 esac
172 done
173
174 # newlib doesnt provide any of the variables in $vars, so we
175 # dont have to check them here.
176
177 # Of the functions in $checkfuncs, newlib only has strerror.
178 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
179
180 case "${host}" in
181 *-*-cygwin*)
182 AC_DEFINE(HAVE_SYS_ERRLIST)
183 ;;
184 esac
185
186 setobjs=yes
187
188 fi
189
190 else
191
192 # Not a target library, so we set things up to run the test suite.
193 CHECK=check-cplus-dem
194
195 fi
196
197 AC_SUBST(CHECK)
198
199 if test -z "${setobjs}"; then
200 case "${host}" in
201
202 *-*-vxworks*)
203 # Handle VxWorks configuration specially, since on VxWorks the
204 # libraries are actually on the target board, not in the file
205 # system.
206 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
207 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
208 for f in $funcs; do
209 case "$f" in
210 basename | getpagesize | insque | random | strcasecmp)
211 ;;
212 strncasecmp | strdup | vfork | waitpid | vasprintf)
213 ;;
214 *)
215 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
216 AC_DEFINE_UNQUOTED($n)
217 ;;
218 esac
219 done
220
221 # VxWorks doesn't provide any of the variables in $vars, so we
222 # don't have to check them here.
223
224 # Of the functions in $checkfuncs, VxWorks only has strerror.
225 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
226
227 setobjs=yes
228 ;;
229
230 esac
231 fi
232
233 if test -z "${setobjs}"; then
234
235 case "${host}" in
236
237 *-*-cygwin*)
238 # The Cygwin library actually uses a couple of files from
239 # libiberty when it is built. If we are building a native
240 # Cygwin, and we run the tests, we will appear to have these
241 # files. However, when we go on to build winsup, we will wind up
242 # with a library which does not have the files, since they should
243 # have come from libiberty.
244
245 # We handle this by removing the functions the winsup library
246 # provides from our shell variables, so that they appear to be
247 # missing.
248
249 # DJ - only if we're *building* cygwin, not just building *with* cygwin
250
251 if test -n "${with_target_subdir}"
252 then
253 funcs="`echo $funcs | sed -e 's/random//'`"
254 LIBOBJS="$LIBOBJS random.o"
255 vars="`echo $vars | sed -e 's/sys_siglist//'`"
256 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
257 fi
258 ;;
259
260 *-*-mingw32*)
261 # Under mingw32, sys_nerr and sys_errlist exist, but they are
262 # macros, so the test below won't find them.
263 libiberty_cv_var_sys_nerr=yes
264 libiberty_cv_var_sys_errlist=yes
265 ;;
266
267 *-*-uwin*)
268 # Under some versions of uwin, vfork is notoriously buggy and the test
269 # can hang configure; on other versions, vfork exists just as a stub.
270 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
271 ac_cv_func_vfork_works=no
272 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
273 # macros (actually, these are imported from a DLL, but the end effect
274 # is the same), so the test below won't find them.
275 libiberty_cv_var_sys_nerr=yes
276 libiberty_cv_var_sys_errlist=yes
277 ;;
278
279 esac
280
281 # We haven't set the list of objects yet. Use the standard autoconf
282 # tests. This will only work if the compiler works.
283 AC_PROG_CC_WORKS
284 AC_REPLACE_FUNCS($funcs)
285 libiberty_AC_FUNC_C_ALLOCA
286 AC_FUNC_VFORK
287 if test $ac_cv_func_vfork_works = no; then
288 LIBOBJS="$LIBOBJS vfork.o"
289 fi
290 for v in $vars; do
291 AC_MSG_CHECKING([for $v])
292 AC_CACHE_VAL(libiberty_cv_var_$v,
293 [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
294 [eval "libiberty_cv_var_$v=yes"],
295 [eval "libiberty_cv_var_$v=no"])])
296 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
297 AC_MSG_RESULT(yes)
298 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
299 AC_DEFINE_UNQUOTED($n)
300 else
301 AC_MSG_RESULT(no)
302 fi
303 done
304 AC_CHECK_FUNCS($checkfuncs)
305 fi
306
307 libiberty_AC_FUNC_STRNCMP
308
309 # Install a library built with a cross compiler in $(tooldir) rather
310 # than $(libdir).
311 if test -z "${with_cross_host}"; then
312 INSTALL_DEST=libdir
313 else
314 INSTALL_DEST=tooldir
315 fi
316 AC_SUBST(INSTALL_DEST)
317
318 # We need multilib support, but only if configuring for the target.
319 AC_OUTPUT(Makefile testsuite/Makefile,
320 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
321 if test -n "$CONFIG_FILES"; then
322 if test -n "${with_target_subdir}"; then
323 # FIXME: We shouldn't need to set ac_file
324 ac_file=Makefile
325 . ${libiberty_topdir}/config-ml.in
326 fi
327 fi],
328 srcdir=${srcdir}
329 host=${host}
330 target=${target}
331 with_target_subdir=${with_target_subdir}
332 with_multisubdir=${with_multisubdir}
333 ac_configure_args="--enable-multilib ${ac_configure_args}"
334 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
335 libiberty_topdir=${libiberty_topdir}
336 )