* aclocal.m4 (libiberty_AC_DECLARE_ERRNO): New macro.
[deliverable/binutils-gdb.git] / libiberty / configure.in
CommitLineData
252b5132
RH
1dnl Process this file with autoconf to produce a configure script
2
0c0a36a4 3AC_PREREQ(2.13)
252b5132
RH
4AC_INIT(pexecute.c)
5
6dnl We use these options to decide which functions to include.
7AC_ARG_WITH(target-subdir,
8[ --with-target-subdir=SUBDIR Configuring in a subdirectory])
9AC_ARG_WITH(cross-host,
10[ --with-cross-host=HOST Configuring with a cross compiler])
11AC_ARG_WITH(newlib,
12[ --with-newlib Configuring with newlib])
13
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
eb383413 58 ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic'
252b5132
RH
59dnl Check whether -g works, even if CFLAGS is set, in case the package
60dnl plays around with CFLAGS (such as to build both debugging and
61dnl normal versions of a library), tasteless as that idea is.
62 ac_test_CFLAGS="${CFLAGS+set}"
63 ac_save_CFLAGS="$CFLAGS"
64 CFLAGS=
65 AC_PROG_CC_G
66 if test "$ac_test_CFLAGS" = set; then
67 CFLAGS="$ac_save_CFLAGS"
68 elif test $ac_cv_prog_cc_g = yes; then
69 CFLAGS="-g -O2"
70 else
71 CFLAGS="-O2"
72 fi
73else
74 GCC=
0c0a36a4 75 ac_libiberty_warn_cflags=
252b5132
RH
76 test "${CFLAGS+set}" = set || CFLAGS="-g"
77fi
78])
0c0a36a4 79AC_SUBST(ac_libiberty_warn_cflags)
252b5132
RH
80
81LIB_AC_PROG_CC
82
83AC_ISC_POSIX
84
85dnl When we start using libtool:
86dnl Default to a non shared library. This may be overridden by the
87dnl configure option --enable-shared.
88dnl AM_DISABLE_SHARED
89
90dnl When we start using libtool:
91dnl AM_PROG_LIBTOOL
92
93dnl When we start using automake:
94dnl AM_CONFIG_HEADER(config.h:config.in)
95AC_CONFIG_HEADER(config.h:config.in)
96
97dnl When we start using automake:
98dnl AM_MAINTAINER_MODE
99dnl AC_EXEEXT
100
101dnl When we start using automake:
102dnl AM_PROG_INSTALL
103AC_PROG_INSTALL
104
105. ${srcdir}/config.table
106host_makefile_frag=${frag}
107AC_SUBST_FILE(host_makefile_frag)
108
109# It's OK to check for header files. Although the compiler may not be
110# able to link anything, it had better be able to at least compile
111# something.
eb383413 112AC_CHECK_HEADERS(sys/file.h sys/param.h stdlib.h string.h unistd.h strings.h sys/time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h)
252b5132
RH
113AC_HEADER_SYS_WAIT
114
7d3ffcaf
JL
115libiberty_AC_DECLARE_ERRNO
116
252b5132
RH
117# This is the list of functions which libiberty will provide if they
118# are not available on the host.
119
120funcs="asprintf"
121funcs="$funcs atexit"
122funcs="$funcs basename"
123funcs="$funcs bcmp"
124funcs="$funcs bcopy"
125funcs="$funcs bzero"
126funcs="$funcs calloc"
127funcs="$funcs clock"
128funcs="$funcs getcwd"
129funcs="$funcs getpagesize"
130funcs="$funcs index"
131funcs="$funcs insque"
132funcs="$funcs memchr"
133funcs="$funcs memcmp"
134funcs="$funcs memcpy"
135funcs="$funcs memmove"
136funcs="$funcs memset"
137funcs="$funcs mkstemps"
0c0a36a4 138funcs="$funcs putenv"
252b5132
RH
139funcs="$funcs random"
140funcs="$funcs rename"
141funcs="$funcs rindex"
0c0a36a4 142funcs="$funcs setenv"
252b5132
RH
143funcs="$funcs sigsetmask"
144funcs="$funcs strcasecmp"
145funcs="$funcs strchr"
146funcs="$funcs strdup"
147funcs="$funcs strncasecmp"
148funcs="$funcs strrchr"
149funcs="$funcs strstr"
150funcs="$funcs strtod"
151funcs="$funcs strtol"
152funcs="$funcs strtoul"
153funcs="$funcs tmpnam"
154funcs="$funcs vasprintf"
155funcs="$funcs vfprintf"
156funcs="$funcs vprintf"
157funcs="$funcs vsprintf"
158funcs="$funcs waitpid"
159
160# Also in the old function.def file: alloca, vfork, getopt.
161
162vars="sys_errlist sys_nerr sys_siglist"
163
0c0a36a4 164checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
252b5132
RH
165
166# These are neither executed nor required, but they help keep
167# autoheader happy without adding a bunch of text to acconfig.h.
168if test "x" = "y"; then
169 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bzero calloc clock getcwd)
170 AC_CHECK_FUNCS(getpagesize index insque mkstemps memchr memcmp memcpy memmove)
0c0a36a4
ILT
171 AC_CHECK_FUNCS(memset putenv random rename rindex sigsetmask strcasecmp)
172 AC_CHECK_FUNCS(setenv strchr strdup strncasecmp strrchr strstr strtod strtol)
252b5132
RH
173 AC_CHECK_FUNCS(strtoul tmpnam vasprintf vfprintf vprintf vsprintf waitpid)
174 AC_DEFINE(HAVE_SYS_ERRLIST)
175 AC_DEFINE(HAVE_SYS_NERR)
176 AC_DEFINE(HAVE_SYS_SIGLIST)
177 AC_CHECK_FUNCS(getrusage on_exit psignal strerror strsignal sysconf times)
0c0a36a4 178 AC_CHECK_FUNCS(sbrk gettimeofday)
252b5132
RH
179fi
180
181# For each of these functions, if the host does not provide the
182# function we want to put FN.o in LIBOBJS, and if the host does
183# provide the function, we want to define HAVE_FN in config.h. Also,
184# if the host does not provide alloca, we set ALLOCA to alloca.o
185
186setobjs=
0c0a36a4 187CHECK=
252b5132
RH
188if test -n "${with_target_subdir}"; then
189
190 # We are being configured as a target library. AC_REPLACE_FUNCS
191 # may not work correctly, because the compiler may not be able to
192 # link executables. Note that we may still be being configured
193 # native.
194
195 # If we are being configured for newlib, we know which functions
196 # newlib provide and which ones we will be expected to provide.
197
198 if test "x${with_newlib}" = "xyes"; then
199 ALLOCA="alloca.o"
200 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
201
202 for f in $funcs; do
203 case "$f" in
204 asprintf | basename | insque | random | strdup | vasprintf)
205 ;;
206 *)
207 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
208 AC_DEFINE_UNQUOTED($n)
209 ;;
210 esac
211 done
212
213 # newlib doesnt provide any of the variables in $vars, so we
214 # dont have to check them here.
215
216 # Of the functions in $checkfuncs, newlib only has strerror.
217 AC_DEFINE(HAVE_STRERROR)
218
219 setobjs=yes
220
221 fi
0c0a36a4
ILT
222
223else
224
225 # Not a target library, so we set things up to run the test suite.
226 CHECK=check-cplus-dem
227
252b5132
RH
228fi
229
0c0a36a4
ILT
230AC_SUBST(CHECK)
231
252b5132
RH
232if test -z "${setobjs}"; then
233 case "${host}" in
234
235 *-*-vxworks*)
236 # Handle VxWorks configuration specially, since on VxWorks the
237 # libraries are actually on the target board, not in the file
238 # system.
239 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
240 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
241 for f in $funcs; do
242 case "$f" in
243 basename | getpagesize | insque | random | strcasecmp)
244 ;;
245 strncasecmp | strdup | vfork | waitpid | vasprintf)
246 ;;
247 *)
248 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
249 AC_DEFINE_UNQUOTED($n)
250 ;;
251 esac
252 done
253
254 # VxWorks doesn't provide any of the variables in $vars, so we
255 # don't have to check them here.
256
257 # Of the functions in $checkfuncs, VxWorks only has strerror.
258 AC_DEFINE(HAVE_STRERROR)
259
260 setobjs=yes
261 ;;
262
263 esac
264fi
265
266if test -z "${setobjs}"; then
267
268 case "${host}" in
269
270 *-*-cygwin*)
271 # The Cygwin library actually uses a couple of files from
272 # libiberty when it is built. If we are building a native
273 # Cygwin, and we run the tests, we will appear to have these
274 # files. However, when we go on to build winsup, we will wind up
275 # with a library which does not have the files, since they should
276 # have come from libiberty.
277
278 # We handle this by removing the functions the winsup library
279 # provides from our shell variables, so that they appear to be
280 # missing.
281
eb383413
L
282 funcs="`echo $funcs | sed -e 's/random//'`"
283 LIBOBJS="$LIBOBJS random.o"
284 vars="`echo $vars | sed -e 's/sys_siglist//'`"
285 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
252b5132
RH
286 ;;
287
288 *-*-mingw32*)
289 # Under mingw32, sys_nerr and sys_errlist exist, but they are
290 # macros, so the test below won't find them.
291 vars="`echo $vars | sed -e 's/sys_nerr//' -e 's/sys_errlist//'`"
292 AC_DEFINE(HAVE_SYS_NERR)
293 AC_DEFINE(HAVE_SYS_ERRLIST)
294 ;;
295
296 *-*-uwin*)
297 # Under some versions of uwin, vfork is notoriously buggy and the test
298 # can hang configure; on other versions, vfork exists just as a stub.
299 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
300 ac_cv_func_vfork_works=no
0c0a36a4
ILT
301 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
302 # macros (actually, these are imported from a DLL, but the end effect
303 # is the same), so the test below won't find them.
304 AC_DEFINE(HAVE_SYS_NERR)
305 AC_DEFINE(HAVE_SYS_ERRLIST)
252b5132
RH
306 ;;
307
308 esac
309
310 # We haven't set the list of objects yet. Use the standard autoconf
311 # tests. This will only work if the compiler works.
312 AC_PROG_CC_WORKS
313 AC_REPLACE_FUNCS($funcs)
0c0a36a4
ILT
314
315 case "${host}" in
316 *-*-interix)
317 # On Interix, it wrongly concludes that the MSVC compiler supports alloca.
318 # (MSVC does on Win32, not on Interix.)
319 # This should be temporary.
320
321 ac_cv_header_alloca_h=no
322 ac_cv_func_alloca_works=no
323 ALLOCA=alloca.o
324 cat >> confdefs.h <<\EOF
325#define C_ALLOCA 1
326EOF
327 cat >> confdefs.h <<EOF
328#define STACK_DIRECTION -1
329EOF
330 ;;
331 *)
332 AC_FUNC_ALLOCA
333 ;;
334 esac
335
252b5132
RH
336 AC_FUNC_VFORK
337 if test $ac_cv_func_vfork_works = no; then
338 LIBOBJS="$LIBOBJS vfork.o"
339 fi
340 for v in $vars; do
341 AC_MSG_CHECKING([for $v])
342 AC_CACHE_VAL(libiberty_cv_var_$v,
343 [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
344 [eval "libiberty_cv_var_$v=yes"],
345 [eval "libiberty_cv_var_$v=no"])])
346 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
347 AC_MSG_RESULT(yes)
348 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
349 AC_DEFINE_UNQUOTED($n)
350 else
351 AC_MSG_RESULT(no)
352 fi
353 done
354 AC_CHECK_FUNCS($checkfuncs)
355fi
356
eb383413
L
357libiberty_AC_FUNC_STRNCMP
358
252b5132
RH
359# Install a library built with a cross compiler in $(tooldir) rather
360# than $(libdir).
361if test -z "${with_cross_host}"; then
362 INSTALL_DEST=libdir
363else
364 INSTALL_DEST=tooldir
365fi
366AC_SUBST(INSTALL_DEST)
367
368# We need multilib support, but only if configuring for the target.
0c0a36a4 369AC_OUTPUT(Makefile testsuite/Makefile,
252b5132
RH
370[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
371if test -n "$CONFIG_FILES"; then
372 if test -n "${with_target_subdir}"; then
373 # FIXME: We shouldn't need to set ac_file
374 ac_file=Makefile
375 . ${libiberty_topdir}/config-ml.in
376 fi
377fi],
378srcdir=${srcdir}
379host=${host}
380target=${target}
381with_target_subdir=${with_target_subdir}
382with_multisubdir=${with_multisubdir}
383ac_configure_args="--enable-multilib ${ac_configure_args}"
384CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
385libiberty_topdir=${libiberty_topdir}
386)
This page took 0.072294 seconds and 4 git commands to generate.