1 dnl Process this file with autoconf to produce a configure script
4 AC_CONFIG_SRCDIR([xmalloc.c])
5 AC_CONFIG_MACRO_DIRS([../config])
7 # This works around the fact that libtool configuration may change LD
8 # for this particular configuration, but some shells, instead of
9 # keeping the changes in LD private, export them just because LD is
10 # exported. We don't use libtool yet, but some day we might, so...
11 ORIGINAL_LD_FOR_MULTILIBS=$LD
13 dnl We use these options to decide which functions to include.
14 AC_ARG_WITH(target-subdir,
15 [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
16 AC_ARG_WITH(build-subdir,
17 [ --with-build-subdir=SUBDIR Configuring in a subdirectory for build])
18 AC_ARG_WITH(cross-host,
19 [ --with-cross-host=HOST Configuring with a cross compiler])
21 [ --with-newlib Configuring with newlib])
23 if test "${srcdir}" = "."; then
24 if test -n "${with_build_subdir}"; then
25 libiberty_topdir="${srcdir}/../.."
27 elif test -z "${with_target_subdir}"; then
28 libiberty_topdir="${srcdir}/.."
30 if test "${with_target_subdir}" != "."; then
31 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
33 libiberty_topdir="${srcdir}/${with_multisrctop}.."
37 libiberty_topdir="${srcdir}/.."
39 AC_SUBST(libiberty_topdir)
40 AC_CONFIG_AUX_DIR($libiberty_topdir)
42 dnl Very limited version of automake's enable-maintainer-mode
44 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
45 dnl maintainer-mode is disabled by default
46 AC_ARG_ENABLE(maintainer-mode,
47 [ --enable-maintainer-mode
48 enable make rules and dependencies not useful
49 (and sometimes confusing) to the casual installer],
50 maintainer_mode=$enableval,
53 AC_MSG_RESULT($maintainer_mode)
55 if test "$maintainer_mode" = "yes"; then
65 if test -z "$ETAGS"; then
70 # Do we have a single-tree copy of texinfo? Even if we do, we can't
71 # rely on it - libiberty is built before texinfo.
72 AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
73 if test "x$MAKEINFO" = "x"; then
74 MAKEINFO="@echo makeinfo missing; true"
82 *** Makeinfo is missing. Info documentation will not be built.])
85 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
87 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
90 *** Makeinfo is too old. Info documentation will not be built.])
99 AC_CHECK_PROG(PERL, perl, perl, )
100 if test x"$PERL" = x""; then
109 dnl When we start using automake:
110 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
112 dnl These must be called before AM_PROG_LIBTOOL, because it may want
113 dnl to call AC_CHECK_PROG.
114 AC_CHECK_TOOL(AR, ar)
115 AC_CHECK_TOOL(RANLIB, ranlib, :)
117 GCC_PLUGIN_OPTION(PLUGIN_OPTION)
118 if test -n "$PLUGIN_OPTION"; then
119 if $AR --help 2>&1 | grep -q "\--plugin"; then
120 AR_PLUGIN_OPTION="$PLUGIN_OPTION"
121 AC_SUBST(AR_PLUGIN_OPTION)
123 if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
124 RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
125 AC_SUBST(RANLIB_PLUGIN_OPTION)
129 dnl When switching to automake, replace the following with AM_ENABLE_MULTILIB.
130 # Add --enable-multilib to configure.
131 # Default to --enable-multilib
132 AC_ARG_ENABLE(multilib,
133 [ --enable-multilib build many library versions (default)],
134 [case "$enableval" in
137 *) AC_MSG_ERROR([bad value $enableval for multilib option]) ;;
141 # Even if the default multilib is not a cross compilation,
142 # it may be that some of the other multilibs are.
143 if test $cross_compiling = no && test $multilib = yes \
144 && test "x${with_multisubdir}" != x ; then
145 cross_compiling=maybe
148 # We may wish to install the target headers somewhere.
149 AC_MSG_CHECKING([whether to install libiberty headers and static library])
150 dnl install-libiberty is disabled by default
152 AC_ARG_ENABLE(install-libiberty,
153 [ --enable-install-libiberty Install headers and library for end users],
154 enable_install_libiberty=$enableval,
155 enable_install_libiberty=no)dnl
157 # Option parsed, now set things appropriately.
158 case x"$enable_install_libiberty" in
160 target_header_dir=libiberty
166 # This could be sanity-checked in various ways...
167 target_header_dir="${enable_install_libiberty}"
170 AC_MSG_RESULT($enable_install_libiberty)
171 AC_MSG_NOTICE([target_header_dir = $target_header_dir])
179 ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wc++-compat \
180 -Wstrict-prototypes \
181 -Wshadow=local], [ac_libiberty_warn_cflags])
182 ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([], [ac_libiberty_warn_cflags])
185 # autoconf is lame and doesn't give us any substitution variable for this.
186 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
187 NO_MINUS_C_MINUS_O=yes
189 OUTPUT_OPTION='-o $@'
191 AC_SUBST(NO_MINUS_C_MINUS_O)
192 AC_SUBST(OUTPUT_OPTION)
198 dnl When we start using libtool:
199 dnl Default to a non shared library. This may be overridden by the
200 dnl configure option --enable-shared.
201 dnl AM_DISABLE_SHARED
203 dnl When we start using libtool:
206 dnl When we start using automake:
207 dnl AM_CONFIG_HEADER(config.h:config.in)
208 AC_CONFIG_HEADER(config.h:config.in)
210 dnl When we start using automake:
211 dnl AM_MAINTAINER_MODE
214 dnl When we start using automake:
218 # Don't build the shared library for build.
219 if [[ -n "${with_build_subdir}" ]]; then
225 rs6000-ibm-aix3.1 | rs6000-ibm-aix)
227 *-*-cxux7*) frag=mh-cxux7 ;;
228 *-*-freebsd2.1.*) frag=mh-fbsd21 ;;
229 *-*-freebsd2.2.[[012]]) frag=mh-fbsd21 ;;
230 i370-*-opened*) frag=mh-openedition ;;
231 i[[34567]]86-*-windows*) frag=mh-windows ;;
234 if [[ -n "${frag}" ]]; then
235 frag=${libiberty_topdir}/libiberty/config/$frag
240 # If they didn't specify --enable-shared, don't generate shared libs.
241 case "${enable_shared}" in
248 # ...unless --enable-host-shared was passed from top-level config:
249 if [[ "${enable_host_shared}" = "yes" ]]; then
253 if [[ "${shared}" != "yes" ]]; then
259 case " ${CFLAGS} " in
260 *\ -fsanitize=address\ *) NOASANFLAG=-fno-sanitize=address ;;
261 *\ -fsanitize=hwaddress\ *) NOASANFLAG=-fno-sanitize=hwaddress ;;
265 GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
266 AC_SUBST(CET_HOST_FLAGS)
268 echo "# Warning: this fragment is automatically generated" > temp-frag
270 if [[ -n "${frag}" ]] && [[ -f "${frag}" ]]; then
271 echo "Appending ${frag} to xhost-mkfrag"
272 echo "# Following fragment copied from ${frag}" >> temp-frag
273 cat ${frag} >> temp-frag
276 # record if we want to build shared libs.
277 if [[ "${shared}" = "yes" ]]; then
278 echo enable_shared = yes >> temp-frag
280 echo enable_shared = no >> temp-frag
284 ${CONFIG_SHELL-/bin/sh} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag
286 host_makefile_frag=${frag}
287 AC_SUBST_FILE(host_makefile_frag)
289 # It's OK to check for header files. Although the compiler may not be
290 # able to link anything, it had better be able to at least compile
292 AC_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 stdio_ext.h process.h sys/prctl.h)
296 libiberty_AC_DECLARE_ERRNO
298 # Determine sizes of some types.
299 AC_CHECK_SIZEOF([int])
300 AC_CHECK_SIZEOF([long])
301 AC_CHECK_SIZEOF([size_t])
303 # Check for presense of long long
304 AC_CHECK_TYPE([long long],
305 [AC_DEFINE(HAVE_LONG_LONG, 1, [Define if you have the `long long' type.]) AC_CHECK_SIZEOF([long long])],
308 # Look for a 64-bit type.
309 AC_MSG_CHECKING([for a 64-bit type])
310 AC_CACHE_VAL(liberty_cv_uint64,
312 [#ifdef HAVE_STDINT_H
315 [extern uint64_t foo;],
316 liberty_cv_uint64=uint64_t,
318 [#ifdef HAVE_LIMITS_H
324 [extern char foo[sizeof(long) * CHAR_BIT >= 64 ? 1 : -1];],
325 liberty_cv_uint64="unsigned long",
327 [#ifdef HAVE_LIMITS_H
333 [extern char foo[sizeof(long long) * CHAR_BIT >= 64 ? 1 : -1];],
334 liberty_cv_uint64="unsigned long long", liberty_cv_uint64=none)])])])
335 AC_MSG_RESULT($liberty_cv_uint64)
336 if test "$liberty_cv_uint64" != none; then
337 AC_DEFINE_UNQUOTED(UNSIGNED_64BIT_TYPE, $liberty_cv_uint64,
338 [Define to an unsigned 64-bit type available in the compiler.])
345 # Given the above check, we always have uintptr_t or a fallback
346 # definition. So define HAVE_UINTPTR_T in case any imported code
348 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
352 # This is the list of functions which libiberty will provide if they
353 # are not available on the host.
356 funcs="$funcs atexit"
357 funcs="$funcs basename"
360 funcs="$funcs bsearch"
362 funcs="$funcs calloc"
365 funcs="$funcs getcwd"
366 funcs="$funcs getpagesize"
367 funcs="$funcs gettimeofday"
369 funcs="$funcs insque"
370 funcs="$funcs memchr"
371 funcs="$funcs memcmp"
372 funcs="$funcs memcpy"
373 funcs="$funcs memmem"
374 funcs="$funcs memmove"
375 funcs="$funcs mempcpy"
376 funcs="$funcs memset"
377 funcs="$funcs mkstemps"
378 funcs="$funcs putenv"
379 funcs="$funcs random"
380 funcs="$funcs rename"
381 funcs="$funcs rindex"
382 funcs="$funcs setenv"
383 funcs="$funcs snprintf"
384 funcs="$funcs sigsetmask"
385 funcs="$funcs stpcpy"
386 funcs="$funcs stpncpy"
387 funcs="$funcs strcasecmp"
388 funcs="$funcs strchr"
389 funcs="$funcs strdup"
390 funcs="$funcs strncasecmp"
391 funcs="$funcs strndup"
392 funcs="$funcs strnlen"
393 funcs="$funcs strrchr"
394 funcs="$funcs strstr"
395 funcs="$funcs strtod"
396 funcs="$funcs strtol"
397 funcs="$funcs strtoul"
398 funcs="$funcs strtoll"
399 funcs="$funcs strtoull"
400 funcs="$funcs strverscmp"
401 funcs="$funcs tmpnam"
402 funcs="$funcs vasprintf"
403 funcs="$funcs vfprintf"
404 funcs="$funcs vprintf"
405 funcs="$funcs vsnprintf"
406 funcs="$funcs vsprintf"
407 funcs="$funcs waitpid"
408 funcs="$funcs setproctitle"
410 # Also in the old function.def file: alloca, vfork, getopt.
412 vars="sys_errlist sys_nerr sys_siglist"
414 checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \
415 getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \
416 realpath setrlimit spawnve spawnvpe strerror strsignal sysconf sysctl \
417 sysmp table times wait3 wait4"
419 #Â Darwin has sbrk, but it is deprecated and that produces build-time warnings
420 #Â so do not check for it.
423 *) checkfuncs="$checkfuncs sbrk"
426 # These are neither executed nor required, but they help keep
427 # autoheader happy without adding a bunch of text to acconfig.h.
428 if test "x" = "y"; then
429 AC_CHECK_FUNCS(asprintf atexit \
430 basename bcmp bcopy bsearch bzero \
431 calloc canonicalize_file_name clock \
434 getcwd getpagesize getrlimit getrusage getsysinfo gettimeofday \
436 memchr memcmp memcpy memmem memmove memset mkstemps \
438 pipe2 psignal pstat_getdynamic pstat_getstatic putenv \
439 random realpath rename rindex \
440 sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \
441 stpcpy stpncpy strcasecmp strchr strdup \
442 strerror strncasecmp strndup strnlen strrchr strsignal strstr strtod \
443 strtol strtoul strtoll strtoull strverscmp sysconf sysctl sysmp \
445 vasprintf vfprintf vprintf vsprintf \
447 AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf, strtol, strtoul, strtoll, strtoull, strnlen])
448 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
449 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
450 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
453 # For each of these functions, if the host does not provide the
454 # function we want to put FN.o in LIBOBJS, and if the host does
455 # provide the function, we want to define HAVE_FN in config.h.
459 if test -n "${with_target_subdir}"; then
461 # We are being configured as a target library. AC_REPLACE_FUNCS
462 # may not work correctly, because the compiler may not be able to
463 # link executables. Note that we may still be being configured
466 # If we are being configured for newlib, we know which functions
467 # newlib provide and which ones we will be expected to provide.
469 if test "x${with_newlib}" = "xyes"; then
470 AC_LIBOBJ([asprintf])
471 AC_LIBOBJ([basename])
475 AC_LIBOBJ([vasprintf])
479 asprintf | basename | insque | random | strdup | vasprintf)
482 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
483 AC_DEFINE_UNQUOTED($n)
488 # newlib doesnt provide any of the variables in $vars, so we
489 # dont have to check them here.
491 # Of the functions in $checkfuncs, newlib only has strerror.
492 AC_DEFINE(HAVE_STRERROR)
498 # If we are being configured for Mingw, we know which functions
499 # Mingw provides and which ones we will be expected to provide.
503 AC_LIBOBJ([asprintf])
504 AC_LIBOBJ([basename])
510 AC_LIBOBJ([getpagesize])
514 AC_LIBOBJ([mkstemps])
517 AC_LIBOBJ([sigsetmask])
522 AC_LIBOBJ([strverscmp])
523 AC_LIBOBJ([vasprintf])
528 asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid)
531 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
532 AC_DEFINE_UNQUOTED($n)
537 # Mingw doesnt provide any of the variables in $vars, so we
538 # dont have to check them here.
540 # Of the functions in $checkfuncs, Mingw only has strerror.
541 AC_DEFINE(HAVE_STRERROR)
547 AC_LIBOBJ([vasprintf])
548 AC_LIBOBJ([vsnprintf])
549 AC_LIBOBJ([snprintf])
550 AC_LIBOBJ([asprintf])
552 for f in atexit basename bcmp bcopy bsearch bzero calloc clock ffs \
553 getcwd getpagesize getrusage gettimeofday \
554 index insque memchr memcmp memcpy memmove memset psignal \
555 putenv random rename rindex sbrk setenv stpcpy strcasecmp \
556 strchr strdup strerror strncasecmp strrchr strstr strtod \
557 strtol strtoul sysconf times tmpnam vfprintf vprintf \
560 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
561 AC_DEFINE_UNQUOTED($n)
572 # Not a target library, so we set things up to run the test suite.
578 AC_SUBST(target_header_dir)
581 *-*-cygwin* | *-*-mingw*)
582 AC_DEFINE(HAVE_SYS_ERRLIST)
583 AC_DEFINE(HAVE_SYS_NERR)
587 if test -z "${setobjs}"; then
591 # Handle VxWorks configuration specially, since on VxWorks the
592 # libraries are actually on the target board, not in the file
594 AC_LIBOBJ([basename])
595 AC_LIBOBJ([getpagesize])
598 AC_LIBOBJ([strcasecmp])
599 AC_LIBOBJ([strncasecmp])
603 AC_LIBOBJ([vasprintf])
606 basename | getpagesize | insque | random | strcasecmp)
608 strncasecmp | strdup | vfork | waitpid | vasprintf)
611 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
612 AC_DEFINE_UNQUOTED($n)
617 # VxWorks doesn't provide any of the variables in $vars, so we
618 # don't have to check them here.
620 # Of the functions in $checkfuncs, VxWorks only has strerror.
621 AC_DEFINE(HAVE_STRERROR)
629 if test -z "${setobjs}"; then
634 # On android, getpagesize is defined in unistd.h as a static inline
635 # function, which AC_CHECK_FUNCS does not handle properly.
636 ac_cv_func_getpagesize=yes
640 # Replace system snprintf and vsnprintf with libiberty implementations.
641 AC_LIBOBJ([snprintf])
642 AC_LIBOBJ([vsnprintf])
646 # Under mingw32, sys_nerr and sys_errlist exist, but they are
647 # macros, so the test below won't find them.
648 libiberty_cv_var_sys_nerr=yes
649 libiberty_cv_var_sys_errlist=yes
653 # vfork and fork are stubs.
654 ac_cv_func_vfork_works=no
658 # Under some versions of uwin, vfork is notoriously buggy and the test
659 # can hang configure; on other versions, vfork exists just as a stub.
660 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
661 ac_cv_func_vfork_works=no
662 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
663 # macros (actually, these are imported from a DLL, but the end effect
664 # is the same), so the test below won't find them.
665 libiberty_cv_var_sys_nerr=yes
666 libiberty_cv_var_sys_errlist=yes
670 # Under VMS, vfork works very different than on Unix. The standard test
671 # won't work, and it isn't easily adaptable. It makes more sense to
673 ac_cv_func_vfork_works=yes
678 # We haven't set the list of objects yet. Use the standard autoconf
679 # tests. This will only work if the compiler works.
681 AC_REPLACE_FUNCS($funcs)
682 libiberty_AC_FUNC_C_ALLOCA
684 if test $ac_cv_func_vfork_works = no; then
687 # We only need _doprnt if we might use it to implement v*printf.
688 if test $ac_cv_func_vprintf != yes \
689 || test $ac_cv_func_vfprintf != yes \
690 || test $ac_cv_func_vsprintf != yes; then
691 AC_REPLACE_FUNCS(_doprnt)
693 AC_CHECK_FUNCS(_doprnt)
697 AC_MSG_CHECKING([for $v])
698 AC_CACHE_VAL(libiberty_cv_var_$v,
699 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int $v [];]],[[if ($v [0]) return 1;]])],
700 [eval "libiberty_cv_var_$v=yes"],
701 [eval "libiberty_cv_var_$v=no"])])
702 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
704 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
705 AC_DEFINE_UNQUOTED($n)
711 # special check for _system_configuration because AIX <4.3.2 do not
712 # contain the `physmem' member.
713 AC_MSG_CHECKING([for external symbol _system_configuration])
714 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/systemcfg.h>]],
715 [[double x = _system_configuration.physmem;]])],
716 [AC_MSG_RESULT([yes])
717 AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1,
718 [Define if you have the _system_configuration variable.])],
719 [AC_MSG_RESULT([no])])
721 AC_CHECK_FUNCS($checkfuncs)
722 AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf])
723 AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc])
725 *-*-darwin*) ;; # Darwin's sbrk implementation is deprecated.
726 *) AC_CHECK_DECLS([sbrk]);;
728 AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoull])
729 AC_CHECK_DECLS([strverscmp])
730 AC_CHECK_DECLS([strnlen])
731 libiberty_NEED_DECLARATION(canonicalize_file_name)
734 # Figure out which version of pexecute to use.
736 *-*-mingw* | *-*-winnt*) pexecute=pex-win32 ;;
737 *-*-msdosdjgpp*) pexecute=pex-djgpp ;;
738 *-*-msdos*) pexecute=pex-msdos ;;
739 *) pexecute=pex-unix ;;
743 libiberty_AC_FUNC_STRNCMP
745 # Install a library built with a cross compiler in $(tooldir) rather
747 if test -z "${with_cross_host}"; then
752 AC_SUBST(INSTALL_DEST)
754 m4_pattern_allow(LIBOBJS)
756 for l in x $LIBOBJS; do
764 dnl Required by html and install-html
765 AC_SUBST(datarootdir)
769 # We need multilib support, but only if configuring for the target.
770 AC_CONFIG_FILES([Makefile testsuite/Makefile])
771 AC_CONFIG_COMMANDS([default],
772 [[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
773 if test -n "$CONFIG_FILES"; then
774 if test -n "${with_target_subdir}"; then
775 # FIXME: We shouldn't need to set ac_file
777 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
778 . ${libiberty_topdir}/config-ml.in
784 with_target_subdir=${with_target_subdir}
785 with_multisubdir=${with_multisubdir}
786 ac_configure_args="--enable-multilib ${ac_configure_args}"
787 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
788 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
789 libiberty_topdir=${libiberty_topdir}