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