2003-10-01 Chris Demetriou <cgd@broadcom.com>
[deliverable/binutils-gdb.git] / libiberty / configure.in
CommitLineData
252b5132
RH
1dnl Process this file with autoconf to produce a configure script
2
2299a76d 3AC_PREREQ(2.57)
5a17353c 4AC_INIT(xmalloc.c)
252b5132 5
52d98c2d
DD
6# This works around the fact that libtool configuration may change LD
7# for this particular configuration, but some shells, instead of
8# keeping the changes in LD private, export them just because LD is
9# exported. We don't use libtool yet, but some day we might, so...
10ORIGINAL_LD_FOR_MULTILIBS=$LD
11
252b5132
RH
12dnl We use these options to decide which functions to include.
13AC_ARG_WITH(target-subdir,
cfed0715
DD
14[ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
15AC_ARG_WITH(build-subdir,
16[ --with-build-subdir=SUBDIR Configuring in a subdirectory for build])
252b5132
RH
17AC_ARG_WITH(cross-host,
18[ --with-cross-host=HOST Configuring with a cross compiler])
19AC_ARG_WITH(newlib,
20[ --with-newlib Configuring with newlib])
21
22if test "${srcdir}" = "."; then
cfed0715
DD
23 if test -n "${with_build_subdir}"; then
24 libiberty_topdir="${srcdir}/../.."
25 with_target_subdir=
26 elif test -z "${with_target_subdir}"; then
252b5132
RH
27 libiberty_topdir="${srcdir}/.."
28 else
29 if test "${with_target_subdir}" != "."; then
30 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
31 else
32 libiberty_topdir="${srcdir}/${with_multisrctop}.."
33 fi
34 fi
35else
36 libiberty_topdir="${srcdir}/.."
37fi
85b9a938 38AC_SUBST(libiberty_topdir)
252b5132
RH
39AC_CONFIG_AUX_DIR($libiberty_topdir)
40
39423523
DD
41dnl Very limited version of automake's enable-maintainer-mode
42
43AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
44 dnl maintainer-mode is disabled by default
45 AC_ARG_ENABLE(maintainer-mode,
46[ --enable-maintainer-mode
47 enable make rules and dependencies not useful
48 (and sometimes confusing) to the casual installer],
49 maintainer_mode=$enableval,
50 maintainer_mode=no)
51
52AC_MSG_RESULT($maintainer_mode)
53
54if test "$maintainer_mode" = "yes"; then
55 MAINT=''
56 NOTMAINT='#'
57else
58 MAINT='#'
59 NOTMAINT=''
60fi
61AC_SUBST(MAINT)dnl
62AC_SUBST(NOTMAINT)dnl
63
fa9f0e33
DD
64# Do we have a single-tree copy of texinfo? Even if we do, we can't
65# rely on it - libiberty is built before texinfo.
66AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
1a78a35a
DD
67if test "x$MAKEINFO" = "x"; then
68 MAKEINFO="@echo makeinfo missing; true"
fa9f0e33 69 BUILD_INFO=
1a78a35a
DD
70else
71 BUILD_INFO=info
72 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
73 x*\ [[1-3]].* )
74 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
75 BUILD_INFO=
76 AC_MSG_WARN([
fa9f0e33 77*** Makeinfo is too old. Info documentation will not be built.])
1a78a35a
DD
78 ;;
79 esac
80fi
fa9f0e33 81AC_SUBST(MAKEINFO)
39423523
DD
82AC_SUBST(BUILD_INFO)
83
84AC_CHECK_PROG(PERL, perl, perl, )
85if test x"$PERL" = x""; then
86 HAVE_PERL='#'
87else
88 HAVE_PERL=''
89fi
90AC_SUBST(HAVE_PERL)
91
252b5132
RH
92AC_CANONICAL_HOST
93
94dnl When we start using automake:
95dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
96
97dnl These must be called before AM_PROG_LIBTOOL, because it may want
98dnl to call AC_CHECK_PROG.
99AC_CHECK_TOOL(AR, ar)
100AC_CHECK_TOOL(RANLIB, ranlib, :)
101
2299a76d
DJ
102GCC_NO_EXECUTABLES
103AC_PROG_CC
8ddbb593 104AC_PROG_CPP_WERROR
2299a76d
DJ
105
106if test x$GCC = xyes; then
107 ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic'
108fi
109AC_SUBST(ac_libiberty_warn_cflags)
252b5132 110
b39b76b8
DD
111AC_PROG_CC_C_O
112# autoconf is lame and doesn't give us any substitution variable for this.
113if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
114 NO_MINUS_C_MINUS_O=yes
115else
116 OUTPUT_OPTION='-o $@'
117fi
118AC_SUBST(NO_MINUS_C_MINUS_O)
119AC_SUBST(OUTPUT_OPTION)
120
2ea7befd
DD
121AC_C_CONST
122AC_C_INLINE
7108c5dc 123AC_C_BIGENDIAN_CROSS
252b5132
RH
124
125dnl When we start using libtool:
126dnl Default to a non shared library. This may be overridden by the
127dnl configure option --enable-shared.
128dnl AM_DISABLE_SHARED
129
130dnl When we start using libtool:
131dnl AM_PROG_LIBTOOL
132
133dnl When we start using automake:
134dnl AM_CONFIG_HEADER(config.h:config.in)
135AC_CONFIG_HEADER(config.h:config.in)
136
137dnl When we start using automake:
138dnl AM_MAINTAINER_MODE
139dnl AC_EXEEXT
140
141dnl When we start using automake:
142dnl AM_PROG_INSTALL
143AC_PROG_INSTALL
144
145. ${srcdir}/config.table
146host_makefile_frag=${frag}
147AC_SUBST_FILE(host_makefile_frag)
148
149# It's OK to check for header files. Although the compiler may not be
150# able to link anything, it had better be able to at least compile
151# something.
5f73c378 152AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.h malloc.h string.h unistd.h strings.h sys/time.h time.h sys/resource.h sys/stat.h sys/mman.h fcntl.h alloca.h sys/pstat.h sys/sysmp.h sys/sysinfo.h machine/hal_sysinfo.h sys/table.h sys/sysctl.h sys/systemcfg.h)
252b5132 153AC_HEADER_SYS_WAIT
62df2065 154AC_HEADER_TIME
252b5132 155
7d3ffcaf
JL
156libiberty_AC_DECLARE_ERRNO
157
15ae9e71 158AC_CHECK_TYPE(uintptr_t, unsigned long)
daf7c4ad
DD
159# Given the above check, we always have uintptr_t or a fallback
160# definition. So define HAVE_UINTPTR_T in case any imported code
161# relies on it.
162AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
dc579051 163
cafa3917
DD
164AC_TYPE_PID_T
165
252b5132
RH
166# This is the list of functions which libiberty will provide if they
167# are not available on the host.
168
169funcs="asprintf"
170funcs="$funcs atexit"
171funcs="$funcs basename"
172funcs="$funcs bcmp"
173funcs="$funcs bcopy"
c6da642e 174funcs="$funcs bsearch"
252b5132
RH
175funcs="$funcs bzero"
176funcs="$funcs calloc"
177funcs="$funcs clock"
7b78baae 178funcs="$funcs ffs"
252b5132
RH
179funcs="$funcs getcwd"
180funcs="$funcs getpagesize"
181funcs="$funcs index"
182funcs="$funcs insque"
183funcs="$funcs memchr"
184funcs="$funcs memcmp"
185funcs="$funcs memcpy"
186funcs="$funcs memmove"
10b57b38 187funcs="$funcs mempcpy"
252b5132
RH
188funcs="$funcs memset"
189funcs="$funcs mkstemps"
0c0a36a4 190funcs="$funcs putenv"
252b5132
RH
191funcs="$funcs random"
192funcs="$funcs rename"
193funcs="$funcs rindex"
0c0a36a4 194funcs="$funcs setenv"
2ed1e5cc 195funcs="$funcs snprintf"
252b5132 196funcs="$funcs sigsetmask"
10b57b38
DD
197funcs="$funcs stpcpy"
198funcs="$funcs stpncpy"
252b5132
RH
199funcs="$funcs strcasecmp"
200funcs="$funcs strchr"
201funcs="$funcs strdup"
202funcs="$funcs strncasecmp"
203funcs="$funcs strrchr"
204funcs="$funcs strstr"
205funcs="$funcs strtod"
206funcs="$funcs strtol"
207funcs="$funcs strtoul"
208funcs="$funcs tmpnam"
209funcs="$funcs vasprintf"
210funcs="$funcs vfprintf"
211funcs="$funcs vprintf"
2ed1e5cc 212funcs="$funcs vsnprintf"
252b5132
RH
213funcs="$funcs vsprintf"
214funcs="$funcs waitpid"
215
216# Also in the old function.def file: alloca, vfork, getopt.
217
e69f6c8c 218vars="sys_errlist sys_nerr sys_siglist"
252b5132 219
0c0a36a4 220checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
192cbe66 221checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic sysmp"
cc529274 222checkfuncs="$checkfuncs getsysinfo table sysctl"
252b5132
RH
223
224# These are neither executed nor required, but they help keep
225# autoheader happy without adding a bunch of text to acconfig.h.
226if test "x" = "y"; then
0b555173
DD
227 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock \
228 getcwd getpagesize index insque mkstemps memchr memcmp memcpy \
229 memmove mempcpy memset putenv random rename rindex sigsetmask \
230 strcasecmp setenv stpcpy stpncpy strchr strdup strncasecmp strrchr strstr \
231 strtod strtol strtoul tmpnam vasprintf vfprintf vprintf \
232 vsprintf waitpid getrusage on_exit psignal strerror strsignal \
233 sysconf times sbrk gettimeofday ffs snprintf vsnprintf \
234 pstat_getstatic pstat_getdynamic sysmp getsysinfo table sysctl \
235 realpath canonicalize_file_name)
2ea7befd
DD
236 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
237 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
238 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
252b5132
RH
239fi
240
241# For each of these functions, if the host does not provide the
242# function we want to put FN.o in LIBOBJS, and if the host does
30673bf5 243# provide the function, we want to define HAVE_FN in config.h.
252b5132
RH
244
245setobjs=
0c0a36a4 246CHECK=
50d4562d 247target_header_dir=
252b5132
RH
248if test -n "${with_target_subdir}"; then
249
250 # We are being configured as a target library. AC_REPLACE_FUNCS
251 # may not work correctly, because the compiler may not be able to
252 # link executables. Note that we may still be being configured
253 # native.
254
255 # If we are being configured for newlib, we know which functions
256 # newlib provide and which ones we will be expected to provide.
257
258 if test "x${with_newlib}" = "xyes"; then
2299a76d
DJ
259 AC_LIBOBJ([asprintf])
260 AC_LIBOBJ([basename])
261 AC_LIBOBJ([insque])
262 AC_LIBOBJ([random])
263 AC_LIBOBJ([strdup])
264 AC_LIBOBJ([vasprintf])
252b5132
RH
265
266 for f in $funcs; do
267 case "$f" in
268 asprintf | basename | insque | random | strdup | vasprintf)
269 ;;
270 *)
271 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
272 AC_DEFINE_UNQUOTED($n)
273 ;;
274 esac
275 done
276
277 # newlib doesnt provide any of the variables in $vars, so we
278 # dont have to check them here.
279
280 # Of the functions in $checkfuncs, newlib only has strerror.
2ea7befd 281 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
252b5132
RH
282
283 setobjs=yes
284
285 fi
0c0a36a4 286
50d4562d
DD
287 # We may wish to install the target headers somewhere.
288 AC_ARG_ENABLE(install-libiberty,
289 [ --enable-install-libiberty Install headers for end users],
290 enable_install_libiberty=$enableval,
291 enable_install_libiberty=no)dnl
292
293 # Option parsed, now set things appropriately.
294 case x"$enable_install_libiberty" in
295 xyes|x)
296 target_header_dir=libiberty
297 ;;
298 xno)
299 target_header_dir=
300 ;;
301 *)
302 # This could be sanity-checked in various ways...
303 target_header_dir="${enable_install_libiberty}"
304 ;;
305 esac
306
307
0c0a36a4
ILT
308else
309
310 # Not a target library, so we set things up to run the test suite.
311 CHECK=check-cplus-dem
312
252b5132
RH
313fi
314
0c0a36a4 315AC_SUBST(CHECK)
50d4562d 316AC_SUBST(target_header_dir)
0c0a36a4 317
f01b59ed 318case "${host}" in
bef8b55d 319 *-*-cygwin* | *-*-mingw*)
24acd898
DD
320 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
321 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
f01b59ed
DD
322 ;;
323esac
324
252b5132
RH
325if test -z "${setobjs}"; then
326 case "${host}" in
327
328 *-*-vxworks*)
329 # Handle VxWorks configuration specially, since on VxWorks the
330 # libraries are actually on the target board, not in the file
331 # system.
2299a76d
DJ
332 AC_LIBOBJ([basename])
333 AC_LIBOBJ([getpagesize])
334 AC_LIBOBJ([insque])
335 AC_LIBOBJ([random])
336 AC_LIBOBJ([strcasecmp])
337 AC_LIBOBJ([strncasecmp])
338 AC_LIBOBJ([strdup])
339 AC_LIBOBJ([vfork])
340 AC_LIBOBJ([waitpid])
341 AC_LIBOBJ([vasprintf])
252b5132
RH
342 for f in $funcs; do
343 case "$f" in
344 basename | getpagesize | insque | random | strcasecmp)
345 ;;
346 strncasecmp | strdup | vfork | waitpid | vasprintf)
347 ;;
348 *)
349 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
350 AC_DEFINE_UNQUOTED($n)
351 ;;
352 esac
353 done
354
355 # VxWorks doesn't provide any of the variables in $vars, so we
356 # don't have to check them here.
357
358 # Of the functions in $checkfuncs, VxWorks only has strerror.
2ea7befd 359 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
252b5132
RH
360
361 setobjs=yes
362 ;;
363
364 esac
365fi
366
367if test -z "${setobjs}"; then
368
369 case "${host}" in
370
371 *-*-cygwin*)
372 # The Cygwin library actually uses a couple of files from
373 # libiberty when it is built. If we are building a native
374 # Cygwin, and we run the tests, we will appear to have these
375 # files. However, when we go on to build winsup, we will wind up
376 # with a library which does not have the files, since they should
377 # have come from libiberty.
378
379 # We handle this by removing the functions the winsup library
380 # provides from our shell variables, so that they appear to be
381 # missing.
382
64e3a659
DD
383 # DJ - only if we're *building* cygwin, not just building *with* cygwin
384
385 if test -n "${with_target_subdir}"
386 then
387 funcs="`echo $funcs | sed -e 's/random//'`"
2299a76d 388 AC_LIBOBJ([random])
64e3a659
DD
389 vars="`echo $vars | sed -e 's/sys_siglist//'`"
390 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
391 fi
252b5132
RH
392 ;;
393
394 *-*-mingw32*)
395 # Under mingw32, sys_nerr and sys_errlist exist, but they are
396 # macros, so the test below won't find them.
2ea7befd
DD
397 libiberty_cv_var_sys_nerr=yes
398 libiberty_cv_var_sys_errlist=yes
252b5132
RH
399 ;;
400
401 *-*-uwin*)
402 # Under some versions of uwin, vfork is notoriously buggy and the test
403 # can hang configure; on other versions, vfork exists just as a stub.
404 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
405 ac_cv_func_vfork_works=no
0c0a36a4
ILT
406 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
407 # macros (actually, these are imported from a DLL, but the end effect
408 # is the same), so the test below won't find them.
2ea7befd
DD
409 libiberty_cv_var_sys_nerr=yes
410 libiberty_cv_var_sys_errlist=yes
252b5132
RH
411 ;;
412
c0eb281b
DD
413 *-*-*vms*)
414 # Under VMS, vfork works very different than on Unix. The standard test
415 # won't work, and it isn't easily adaptable. It makes more sense to
416 # just force it.
417 ac_cv_func_vfork_works=yes
418 ;;
419
252b5132
RH
420 esac
421
422 # We haven't set the list of objects yet. Use the standard autoconf
423 # tests. This will only work if the compiler works.
2299a76d 424 AC_ISC_POSIX
252b5132 425 AC_REPLACE_FUNCS($funcs)
30673bf5 426 libiberty_AC_FUNC_C_ALLOCA
252b5132
RH
427 AC_FUNC_VFORK
428 if test $ac_cv_func_vfork_works = no; then
2299a76d 429 AC_LIBOBJ([vfork])
252b5132 430 fi
24acd898
DD
431 # We only need _doprnt if we might use it to implement v*printf.
432 if test $ac_cv_func_vprintf != yes \
433 || test $ac_cv_func_vfprintf != yes \
434 || test $ac_cv_func_vsprintf != yes; then
435 AC_REPLACE_FUNCS(_doprnt)
cc096b71
DD
436 else
437 AC_CHECK_FUNCS(_doprnt)
24acd898
DD
438 fi
439
252b5132
RH
440 for v in $vars; do
441 AC_MSG_CHECKING([for $v])
442 AC_CACHE_VAL(libiberty_cv_var_$v,
18893690 443 [AC_TRY_LINK([int *p;], [extern int $v []; p = $v;],
252b5132
RH
444 [eval "libiberty_cv_var_$v=yes"],
445 [eval "libiberty_cv_var_$v=no"])])
446 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
447 AC_MSG_RESULT(yes)
448 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
449 AC_DEFINE_UNQUOTED($n)
450 else
451 AC_MSG_RESULT(no)
452 fi
453 done
e69f6c8c
DD
454
455 # special check for _system_configuration because AIX <4.3.2 do not
456 # contain the `physmem' member.
457 AC_MSG_CHECKING([for external symbol _system_configuration])
458 AC_TRY_COMPILE([#include <sys/systemcfg.h>],
459 [double x = _system_configuration.physmem;],
460 [AC_MSG_RESULT([yes])
461 AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1,
462 [Define if you have the _system_configuration variable.])],
463 [AC_MSG_RESULT([no])])
464
252b5132 465 AC_CHECK_FUNCS($checkfuncs)
ba61a412 466 libiberty_NEED_DECLARATION(canonicalize_file_name)
252b5132
RH
467fi
468
5a17353c
DD
469# Figure out which version of pexecute to use.
470case "${host}" in
5a17353c
DD
471 *-*-mingw* | *-*-winnt*) pexecute=pex-win32.o ;;
472 *-*-msdosdjgpp*) pexecute=pex-djgpp.o ;;
473 *-*-msdos*) pexecute=pex-msdos.o ;;
474 *-*-os2-emx*) pexecute=pex-os2.o ;;
475 *) pexecute=pex-unix.o ;;
476esac
477AC_SUBST(pexecute)
478
eb383413
L
479libiberty_AC_FUNC_STRNCMP
480
252b5132
RH
481# Install a library built with a cross compiler in $(tooldir) rather
482# than $(libdir).
483if test -z "${with_cross_host}"; then
484 INSTALL_DEST=libdir
485else
486 INSTALL_DEST=tooldir
487fi
488AC_SUBST(INSTALL_DEST)
489
490# We need multilib support, but only if configuring for the target.
0c0a36a4 491AC_OUTPUT(Makefile testsuite/Makefile,
252b5132
RH
492[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
493if test -n "$CONFIG_FILES"; then
cfed0715 494 if test -n "${with_build_subdir}" || test -n "${with_target_subdir}"; then
252b5132
RH
495 # FIXME: We shouldn't need to set ac_file
496 ac_file=Makefile
52d98c2d 497 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
252b5132
RH
498 . ${libiberty_topdir}/config-ml.in
499 fi
500fi],
501srcdir=${srcdir}
502host=${host}
503target=${target}
504with_target_subdir=${with_target_subdir}
cfed0715 505with_build_subdir=${with_build_subdir}
252b5132
RH
506with_multisubdir=${with_multisubdir}
507ac_configure_args="--enable-multilib ${ac_configure_args}"
508CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
8b90eef4 509ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
252b5132
RH
510libiberty_topdir=${libiberty_topdir}
511)
This page took 0.19147 seconds and 4 git commands to generate.