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