16ca2c52aSchristosdnl Process this file with autoconf to produce a configure script 26ca2c52aSchristos 36ca2c52aSchristosAC_INIT 46ca2c52aSchristosAC_CONFIG_SRCDIR([xmalloc.c]) 56ca2c52aSchristos 66ca2c52aSchristos# This works around the fact that libtool configuration may change LD 76ca2c52aSchristos# for this particular configuration, but some shells, instead of 86ca2c52aSchristos# keeping the changes in LD private, export them just because LD is 96ca2c52aSchristos# exported. We don't use libtool yet, but some day we might, so... 106ca2c52aSchristosORIGINAL_LD_FOR_MULTILIBS=$LD 116ca2c52aSchristos 126ca2c52aSchristosdnl We use these options to decide which functions to include. 136ca2c52aSchristosAC_ARG_WITH(target-subdir, 146ca2c52aSchristos[ --with-target-subdir=SUBDIR Configuring in a subdirectory for target]) 156ca2c52aSchristosAC_ARG_WITH(build-subdir, 166ca2c52aSchristos[ --with-build-subdir=SUBDIR Configuring in a subdirectory for build]) 176ca2c52aSchristosAC_ARG_WITH(cross-host, 186ca2c52aSchristos[ --with-cross-host=HOST Configuring with a cross compiler]) 196ca2c52aSchristosAC_ARG_WITH(newlib, 206ca2c52aSchristos[ --with-newlib Configuring with newlib]) 216ca2c52aSchristos 226ca2c52aSchristosif test "${srcdir}" = "."; then 236ca2c52aSchristos if test -n "${with_build_subdir}"; then 246ca2c52aSchristos libiberty_topdir="${srcdir}/../.." 256ca2c52aSchristos with_target_subdir= 266ca2c52aSchristos elif test -z "${with_target_subdir}"; then 276ca2c52aSchristos libiberty_topdir="${srcdir}/.." 286ca2c52aSchristos else 296ca2c52aSchristos if test "${with_target_subdir}" != "."; then 306ca2c52aSchristos libiberty_topdir="${srcdir}/${with_multisrctop}../.." 316ca2c52aSchristos else 326ca2c52aSchristos libiberty_topdir="${srcdir}/${with_multisrctop}.." 336ca2c52aSchristos fi 346ca2c52aSchristos fi 356ca2c52aSchristoselse 366ca2c52aSchristos libiberty_topdir="${srcdir}/.." 376ca2c52aSchristosfi 386ca2c52aSchristosAC_SUBST(libiberty_topdir) 396ca2c52aSchristosAC_CONFIG_AUX_DIR($libiberty_topdir) 406ca2c52aSchristos 416ca2c52aSchristosdnl Very limited version of automake's enable-maintainer-mode 426ca2c52aSchristos 436ca2c52aSchristosAC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) 446ca2c52aSchristos dnl maintainer-mode is disabled by default 456ca2c52aSchristos AC_ARG_ENABLE(maintainer-mode, 466ca2c52aSchristos[ --enable-maintainer-mode 476ca2c52aSchristos enable make rules and dependencies not useful 486ca2c52aSchristos (and sometimes confusing) to the casual installer], 496ca2c52aSchristos maintainer_mode=$enableval, 506ca2c52aSchristos maintainer_mode=no) 516ca2c52aSchristos 526ca2c52aSchristosAC_MSG_RESULT($maintainer_mode) 536ca2c52aSchristos 546ca2c52aSchristosif test "$maintainer_mode" = "yes"; then 556ca2c52aSchristos MAINT='' 566ca2c52aSchristos NOTMAINT='#' 576ca2c52aSchristoselse 586ca2c52aSchristos MAINT='#' 596ca2c52aSchristos NOTMAINT='' 606ca2c52aSchristosfi 616ca2c52aSchristosAC_SUBST(MAINT)dnl 626ca2c52aSchristosAC_SUBST(NOTMAINT)dnl 636ca2c52aSchristos 646ca2c52aSchristos# Do we have a single-tree copy of texinfo? Even if we do, we can't 656ca2c52aSchristos# rely on it - libiberty is built before texinfo. 666ca2c52aSchristosAC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, ) 676ca2c52aSchristosif test "x$MAKEINFO" = "x"; then 686ca2c52aSchristos MAKEINFO="@echo makeinfo missing; true" 696ca2c52aSchristos BUILD_INFO= 706ca2c52aSchristoselse 716ca2c52aSchristos BUILD_INFO=info 726ca2c52aSchristos case "$MAKEINFO" in 736ca2c52aSchristos */missing\ makeinfo*) 746ca2c52aSchristos BUILD_INFO= 756ca2c52aSchristos AC_MSG_WARN([ 766ca2c52aSchristos*** Makeinfo is missing. Info documentation will not be built.]) 776ca2c52aSchristos ;; 786ca2c52aSchristos *) 796ca2c52aSchristos case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in 806ca2c52aSchristos x*\ [[1-3]].* ) 816ca2c52aSchristos MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true" 826ca2c52aSchristos BUILD_INFO= 836ca2c52aSchristos AC_MSG_WARN([ 846ca2c52aSchristos*** Makeinfo is too old. Info documentation will not be built.]) 856ca2c52aSchristos ;; 866ca2c52aSchristos esac 876ca2c52aSchristos ;; 886ca2c52aSchristos esac 896ca2c52aSchristosfi 906ca2c52aSchristosAC_SUBST(MAKEINFO) 916ca2c52aSchristosAC_SUBST(BUILD_INFO) 926ca2c52aSchristos 936ca2c52aSchristosAC_CHECK_PROG(PERL, perl, perl, ) 946ca2c52aSchristosif test x"$PERL" = x""; then 956ca2c52aSchristos HAVE_PERL='#' 966ca2c52aSchristoselse 976ca2c52aSchristos HAVE_PERL='' 986ca2c52aSchristosfi 996ca2c52aSchristosAC_SUBST(HAVE_PERL) 1006ca2c52aSchristos 1016ca2c52aSchristosAC_CANONICAL_HOST 1026ca2c52aSchristos 1036ca2c52aSchristosdnl When we start using automake: 1046ca2c52aSchristosdnl AM_INIT_AUTOMAKE(libiberty, 1.0) 1056ca2c52aSchristos 1066ca2c52aSchristosdnl These must be called before AM_PROG_LIBTOOL, because it may want 1076ca2c52aSchristosdnl to call AC_CHECK_PROG. 1086ca2c52aSchristosAC_CHECK_TOOL(AR, ar) 1096ca2c52aSchristosAC_CHECK_TOOL(RANLIB, ranlib, :) 1106ca2c52aSchristos 1116ca2c52aSchristosdnl When switching to automake, replace the following with AM_ENABLE_MULTILIB. 1126ca2c52aSchristos# Add --enable-multilib to configure. 1136ca2c52aSchristos# Default to --enable-multilib 1146ca2c52aSchristosAC_ARG_ENABLE(multilib, 1156ca2c52aSchristos[ --enable-multilib build many library versions (default)], 1166ca2c52aSchristos[case "$enableval" in 1176ca2c52aSchristos yes) multilib=yes ;; 1186ca2c52aSchristos no) multilib=no ;; 1196ca2c52aSchristos *) AC_MSG_ERROR([bad value $enableval for multilib option]) ;; 1206ca2c52aSchristos esac], 1216ca2c52aSchristos [multilib=yes]) 1226ca2c52aSchristos 1236ca2c52aSchristos# Even if the default multilib is not a cross compilation, 1246ca2c52aSchristos# it may be that some of the other multilibs are. 1256ca2c52aSchristosif test $cross_compiling = no && test $multilib = yes \ 1266ca2c52aSchristos && test "x${with_multisubdir}" != x ; then 1276ca2c52aSchristos cross_compiling=maybe 1286ca2c52aSchristosfi 1296ca2c52aSchristos 1306ca2c52aSchristos# We may wish to install the target headers somewhere. 1316ca2c52aSchristosAC_MSG_CHECKING([whether to install libiberty headers and static library]) 1326ca2c52aSchristosdnl install-libiberty is disabled by default 1336ca2c52aSchristos 1346ca2c52aSchristosAC_ARG_ENABLE(install-libiberty, 1356ca2c52aSchristos[ --enable-install-libiberty Install headers and library for end users], 1366ca2c52aSchristosenable_install_libiberty=$enableval, 1376ca2c52aSchristosenable_install_libiberty=no)dnl 1386ca2c52aSchristos 1396ca2c52aSchristos# Option parsed, now set things appropriately. 1406ca2c52aSchristoscase x"$enable_install_libiberty" in 1416ca2c52aSchristos xyes|x) 1426ca2c52aSchristos target_header_dir=libiberty 1436ca2c52aSchristos ;; 1446ca2c52aSchristos xno) 1456ca2c52aSchristos target_header_dir= 1466ca2c52aSchristos ;; 1476ca2c52aSchristos *) 1486ca2c52aSchristos # This could be sanity-checked in various ways... 1496ca2c52aSchristos target_header_dir="${enable_install_libiberty}" 1506ca2c52aSchristos ;; 1516ca2c52aSchristosesac 1526ca2c52aSchristosAC_MSG_RESULT($enable_install_libiberty) 1536ca2c52aSchristosAC_MSG_NOTICE([target_header_dir = $target_header_dir]) 1546ca2c52aSchristos 1556ca2c52aSchristosGCC_NO_EXECUTABLES 1566ca2c52aSchristosAC_PROG_CC 1576ca2c52aSchristosAC_GNU_SOURCE 1586ca2c52aSchristosAC_SYS_LARGEFILE 1596ca2c52aSchristosAC_PROG_CPP_WERROR 1606ca2c52aSchristos 1616ca2c52aSchristosACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wc++-compat \ 16215d8e94aSchristos -Wstrict-prototypes \ 16315d8e94aSchristos -Wshadow=local], [ac_libiberty_warn_cflags]) 1646ca2c52aSchristosACX_PROG_CC_WARNING_ALMOST_PEDANTIC([], [ac_libiberty_warn_cflags]) 1656ca2c52aSchristos 1666ca2c52aSchristosAC_PROG_CC_C_O 1676ca2c52aSchristos# autoconf is lame and doesn't give us any substitution variable for this. 1686ca2c52aSchristosif eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then 1696ca2c52aSchristos NO_MINUS_C_MINUS_O=yes 1706ca2c52aSchristoselse 1716ca2c52aSchristos OUTPUT_OPTION='-o $@' 1726ca2c52aSchristosfi 1736ca2c52aSchristosAC_SUBST(NO_MINUS_C_MINUS_O) 1746ca2c52aSchristosAC_SUBST(OUTPUT_OPTION) 1756ca2c52aSchristos 1766ca2c52aSchristosAC_C_CONST 1776ca2c52aSchristosAC_C_INLINE 1786ca2c52aSchristosAC_C_BIGENDIAN 1796ca2c52aSchristos 1806ca2c52aSchristosdnl When we start using libtool: 1816ca2c52aSchristosdnl Default to a non shared library. This may be overridden by the 1826ca2c52aSchristosdnl configure option --enable-shared. 1836ca2c52aSchristosdnl AM_DISABLE_SHARED 1846ca2c52aSchristos 1856ca2c52aSchristosdnl When we start using libtool: 1866ca2c52aSchristosdnl AM_PROG_LIBTOOL 1876ca2c52aSchristos 1886ca2c52aSchristosdnl When we start using automake: 1896ca2c52aSchristosdnl AM_CONFIG_HEADER(config.h:config.in) 1906ca2c52aSchristosAC_CONFIG_HEADER(config.h:config.in) 1916ca2c52aSchristos 1926ca2c52aSchristosdnl When we start using automake: 1936ca2c52aSchristosdnl AM_MAINTAINER_MODE 1946ca2c52aSchristosdnl AC_EXEEXT 1956ca2c52aSchristos 1966ca2c52aSchristosdnl When we start using automake: 1976ca2c52aSchristosdnl AM_PROG_INSTALL 1986ca2c52aSchristosAC_PROG_INSTALL 1996ca2c52aSchristos 2006ca2c52aSchristos# Don't build the shared library for build. 2016ca2c52aSchristosif [[ -n "${with_build_subdir}" ]]; then 2026ca2c52aSchristos enable_shared=no 2036ca2c52aSchristosfi 2046ca2c52aSchristos 2056ca2c52aSchristosfrag= 2066ca2c52aSchristoscase "${host}" in 2076ca2c52aSchristos rs6000-ibm-aix3.1 | rs6000-ibm-aix) 2086ca2c52aSchristos frag=mh-aix ;; 2096ca2c52aSchristos *-*-cxux7*) frag=mh-cxux7 ;; 2106ca2c52aSchristos *-*-freebsd2.1.*) frag=mh-fbsd21 ;; 2116ca2c52aSchristos *-*-freebsd2.2.[[012]]) frag=mh-fbsd21 ;; 2126ca2c52aSchristos i370-*-opened*) frag=mh-openedition ;; 2136ca2c52aSchristos i[[34567]]86-*-windows*) frag=mh-windows ;; 2146ca2c52aSchristosesac 2156ca2c52aSchristos 2166ca2c52aSchristosif [[ -n "${frag}" ]]; then 2176ca2c52aSchristos frag=${libiberty_topdir}/libiberty/config/$frag 2186ca2c52aSchristosfi 2196ca2c52aSchristos 2206ca2c52aSchristosGCC_PICFLAG 2216ca2c52aSchristos 2226ca2c52aSchristos# If they didn't specify --enable-shared, don't generate shared libs. 2236ca2c52aSchristoscase "${enable_shared}" in 2246ca2c52aSchristos yes) shared=yes ;; 2256ca2c52aSchristos no) shared=no ;; 2266ca2c52aSchristos "") shared=no ;; 2276ca2c52aSchristos *) shared=yes ;; 2286ca2c52aSchristosesac 2296ca2c52aSchristos 2306ca2c52aSchristos# ...unless --enable-host-shared was passed from top-level config: 2316ca2c52aSchristosif [[ "${enable_host_shared}" = "yes" ]]; then 2326ca2c52aSchristos shared=yes 2336ca2c52aSchristosfi 2346ca2c52aSchristos 2356ca2c52aSchristosif [[ "${shared}" != "yes" ]]; then 2366ca2c52aSchristos PICFLAG= 2376ca2c52aSchristosfi 2386ca2c52aSchristosAC_SUBST(PICFLAG) 2396ca2c52aSchristos 2406ca2c52aSchristosNOASANFLAG= 2416ca2c52aSchristoscase " ${CFLAGS} " in 2426ca2c52aSchristos *\ -fsanitize=address\ *) NOASANFLAG=-fno-sanitize=address ;; 2436ca2c52aSchristosesac 2446ca2c52aSchristosAC_SUBST(NOASANFLAG) 2456ca2c52aSchristos 246*184b2d41SchristosGCC_CET_HOST_FLAGS(CET_HOST_FLAGS) 247*184b2d41SchristosAC_SUBST(CET_HOST_FLAGS) 248*184b2d41Schristos 2496ca2c52aSchristosecho "# Warning: this fragment is automatically generated" > temp-frag 2506ca2c52aSchristos 2516ca2c52aSchristosif [[ -n "${frag}" ]] && [[ -f "${frag}" ]]; then 2526ca2c52aSchristos echo "Appending ${frag} to xhost-mkfrag" 2536ca2c52aSchristos echo "# Following fragment copied from ${frag}" >> temp-frag 2546ca2c52aSchristos cat ${frag} >> temp-frag 2556ca2c52aSchristosfi 2566ca2c52aSchristos 2576ca2c52aSchristos# record if we want to build shared libs. 2586ca2c52aSchristosif [[ "${shared}" = "yes" ]]; then 2596ca2c52aSchristos echo enable_shared = yes >> temp-frag 2606ca2c52aSchristoselse 2616ca2c52aSchristos echo enable_shared = no >> temp-frag 2626ca2c52aSchristosfi 2636ca2c52aSchristos 2646ca2c52aSchristosfrag=xhost-mkfrag 2656ca2c52aSchristos${CONFIG_SHELL-/bin/sh} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag 2666ca2c52aSchristos 2676ca2c52aSchristoshost_makefile_frag=${frag} 2686ca2c52aSchristosAC_SUBST_FILE(host_makefile_frag) 2696ca2c52aSchristos 2706ca2c52aSchristos# It's OK to check for header files. Although the compiler may not be 2716ca2c52aSchristos# able to link anything, it had better be able to at least compile 2726ca2c52aSchristos# something. 2736ca2c52aSchristosAC_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) 2746ca2c52aSchristosAC_HEADER_SYS_WAIT 2756ca2c52aSchristosAC_HEADER_TIME 2766ca2c52aSchristos 2776ca2c52aSchristoslibiberty_AC_DECLARE_ERRNO 2786ca2c52aSchristos 2796ca2c52aSchristos# Determine sizes of some types. 2806ca2c52aSchristosAC_CHECK_SIZEOF([int]) 2816ca2c52aSchristosAC_CHECK_SIZEOF([long]) 282b2396a7bSchristosAC_CHECK_SIZEOF([size_t]) 2836ca2c52aSchristos 2846ca2c52aSchristos# Check for presense of long long 2856ca2c52aSchristosAC_CHECK_TYPE([long long], 2866ca2c52aSchristos [AC_DEFINE(HAVE_LONG_LONG, 1, [Define if you have the `long long' type.]) AC_CHECK_SIZEOF([long long])], 2876ca2c52aSchristos []) 2886ca2c52aSchristos 2896ca2c52aSchristos# Look for a 64-bit type. 2906ca2c52aSchristosAC_MSG_CHECKING([for a 64-bit type]) 2916ca2c52aSchristosAC_CACHE_VAL(liberty_cv_uint64, 2926ca2c52aSchristos[AC_TRY_COMPILE( 2936ca2c52aSchristos[#ifdef HAVE_STDINT_H 2946ca2c52aSchristos#include <stdint.h> 2956ca2c52aSchristos#endif], 2966ca2c52aSchristos[extern uint64_t foo;], 2976ca2c52aSchristosliberty_cv_uint64=uint64_t, 2986ca2c52aSchristos[AC_TRY_COMPILE( 2996ca2c52aSchristos[#ifdef HAVE_LIMITS_H 3006ca2c52aSchristos#include <limits.h> 3016ca2c52aSchristos#endif 3026ca2c52aSchristos#ifndef CHAR_BIT 3036ca2c52aSchristos#define CHAR_BIT 8 3046ca2c52aSchristos#endif], 3056ca2c52aSchristos[extern char foo[sizeof(long) * CHAR_BIT >= 64 ? 1 : -1];], 3066ca2c52aSchristosliberty_cv_uint64="unsigned long", 3076ca2c52aSchristos[AC_TRY_COMPILE( 3086ca2c52aSchristos[#ifdef HAVE_LIMITS_H 3096ca2c52aSchristos#include <limits.h> 3106ca2c52aSchristos#endif 3116ca2c52aSchristos#ifndef CHAR_BIT 3126ca2c52aSchristos#define CHAR_BIT 8 3136ca2c52aSchristos#endif], 3146ca2c52aSchristos[extern char foo[sizeof(long long) * CHAR_BIT >= 64 ? 1 : -1];], 3156ca2c52aSchristosliberty_cv_uint64="unsigned long long", liberty_cv_uint64=none)])])]) 3166ca2c52aSchristosAC_MSG_RESULT($liberty_cv_uint64) 3176ca2c52aSchristosif test "$liberty_cv_uint64" != none; then 3186ca2c52aSchristos AC_DEFINE_UNQUOTED(UNSIGNED_64BIT_TYPE, $liberty_cv_uint64, 3196ca2c52aSchristos [Define to an unsigned 64-bit type available in the compiler.]) 3206ca2c52aSchristosfi 3216ca2c52aSchristos 3226ca2c52aSchristosAC_TYPE_INTPTR_T 3236ca2c52aSchristosAC_TYPE_UINTPTR_T 3246ca2c52aSchristosAC_TYPE_SSIZE_T 3256ca2c52aSchristos 3266ca2c52aSchristos# Given the above check, we always have uintptr_t or a fallback 3276ca2c52aSchristos# definition. So define HAVE_UINTPTR_T in case any imported code 3286ca2c52aSchristos# relies on it. 3296ca2c52aSchristosAC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.]) 3306ca2c52aSchristos 3316ca2c52aSchristosAC_TYPE_PID_T 3326ca2c52aSchristos 3336ca2c52aSchristos# This is the list of functions which libiberty will provide if they 3346ca2c52aSchristos# are not available on the host. 3356ca2c52aSchristos 3366ca2c52aSchristosfuncs="asprintf" 3376ca2c52aSchristosfuncs="$funcs atexit" 3386ca2c52aSchristosfuncs="$funcs basename" 3396ca2c52aSchristosfuncs="$funcs bcmp" 3406ca2c52aSchristosfuncs="$funcs bcopy" 3416ca2c52aSchristosfuncs="$funcs bsearch" 3426ca2c52aSchristosfuncs="$funcs bzero" 3436ca2c52aSchristosfuncs="$funcs calloc" 3446ca2c52aSchristosfuncs="$funcs clock" 3456ca2c52aSchristosfuncs="$funcs ffs" 3466ca2c52aSchristosfuncs="$funcs getcwd" 3476ca2c52aSchristosfuncs="$funcs getpagesize" 3486ca2c52aSchristosfuncs="$funcs gettimeofday" 3496ca2c52aSchristosfuncs="$funcs index" 3506ca2c52aSchristosfuncs="$funcs insque" 3516ca2c52aSchristosfuncs="$funcs memchr" 3526ca2c52aSchristosfuncs="$funcs memcmp" 3536ca2c52aSchristosfuncs="$funcs memcpy" 3546ca2c52aSchristosfuncs="$funcs memmem" 3556ca2c52aSchristosfuncs="$funcs memmove" 3566ca2c52aSchristosfuncs="$funcs mempcpy" 3576ca2c52aSchristosfuncs="$funcs memset" 3586ca2c52aSchristosfuncs="$funcs mkstemps" 3596ca2c52aSchristosfuncs="$funcs putenv" 3606ca2c52aSchristosfuncs="$funcs random" 3616ca2c52aSchristosfuncs="$funcs rename" 3626ca2c52aSchristosfuncs="$funcs rindex" 3636ca2c52aSchristosfuncs="$funcs setenv" 3646ca2c52aSchristosfuncs="$funcs snprintf" 3656ca2c52aSchristosfuncs="$funcs sigsetmask" 3666ca2c52aSchristosfuncs="$funcs stpcpy" 3676ca2c52aSchristosfuncs="$funcs stpncpy" 3686ca2c52aSchristosfuncs="$funcs strcasecmp" 3696ca2c52aSchristosfuncs="$funcs strchr" 3706ca2c52aSchristosfuncs="$funcs strdup" 3716ca2c52aSchristosfuncs="$funcs strncasecmp" 3726ca2c52aSchristosfuncs="$funcs strndup" 3736ca2c52aSchristosfuncs="$funcs strnlen" 3746ca2c52aSchristosfuncs="$funcs strrchr" 3756ca2c52aSchristosfuncs="$funcs strstr" 3766ca2c52aSchristosfuncs="$funcs strtod" 3776ca2c52aSchristosfuncs="$funcs strtol" 3786ca2c52aSchristosfuncs="$funcs strtoul" 3796ca2c52aSchristosfuncs="$funcs strtoll" 3806ca2c52aSchristosfuncs="$funcs strtoull" 3816ca2c52aSchristosfuncs="$funcs strverscmp" 3826ca2c52aSchristosfuncs="$funcs tmpnam" 3836ca2c52aSchristosfuncs="$funcs vasprintf" 3846ca2c52aSchristosfuncs="$funcs vfprintf" 3856ca2c52aSchristosfuncs="$funcs vprintf" 3866ca2c52aSchristosfuncs="$funcs vsnprintf" 3876ca2c52aSchristosfuncs="$funcs vsprintf" 3886ca2c52aSchristosfuncs="$funcs waitpid" 3896ca2c52aSchristosfuncs="$funcs setproctitle" 3906ca2c52aSchristos 3916ca2c52aSchristos# Also in the old function.def file: alloca, vfork, getopt. 3926ca2c52aSchristos 3936ca2c52aSchristosvars="sys_errlist sys_nerr sys_siglist" 3946ca2c52aSchristos 3956ca2c52aSchristoscheckfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \ 396dc268d07Schristos getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \ 3976ca2c52aSchristos realpath setrlimit sbrk spawnve spawnvpe strerror strsignal sysconf sysctl \ 3986ca2c52aSchristos sysmp table times wait3 wait4" 3996ca2c52aSchristos 4006ca2c52aSchristos# These are neither executed nor required, but they help keep 4016ca2c52aSchristos# autoheader happy without adding a bunch of text to acconfig.h. 4026ca2c52aSchristosif test "x" = "y"; then 4036ca2c52aSchristos AC_CHECK_FUNCS(asprintf atexit \ 4046ca2c52aSchristos basename bcmp bcopy bsearch bzero \ 4056ca2c52aSchristos calloc canonicalize_file_name clock \ 4066ca2c52aSchristos dup3 \ 4076ca2c52aSchristos ffs __fsetlocking \ 4086ca2c52aSchristos getcwd getpagesize getrlimit getrusage getsysinfo gettimeofday \ 4096ca2c52aSchristos index insque \ 4106ca2c52aSchristos memchr memcmp memcpy memmem memmove memset mkstemps \ 4116ca2c52aSchristos on_exit \ 412dc268d07Schristos pipe2 psignal pstat_getdynamic pstat_getstatic putenv \ 4136ca2c52aSchristos random realpath rename rindex \ 4146ca2c52aSchristos sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \ 4156ca2c52aSchristos stpcpy stpncpy strcasecmp strchr strdup \ 4166ca2c52aSchristos strerror strncasecmp strndup strnlen strrchr strsignal strstr strtod \ 4176ca2c52aSchristos strtol strtoul strtoll strtoull strverscmp sysconf sysctl sysmp \ 4186ca2c52aSchristos table times tmpnam \ 4196ca2c52aSchristos vasprintf vfprintf vprintf vsprintf \ 4206ca2c52aSchristos wait3 wait4 waitpid) 42115d8e94aSchristos AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf, strtol, strtoul, strtoll, strtoull, strnlen]) 4226ca2c52aSchristos AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.]) 4236ca2c52aSchristos AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.]) 4246ca2c52aSchristos AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.]) 4256ca2c52aSchristosfi 4266ca2c52aSchristos 4276ca2c52aSchristos# For each of these functions, if the host does not provide the 4286ca2c52aSchristos# function we want to put FN.o in LIBOBJS, and if the host does 4296ca2c52aSchristos# provide the function, we want to define HAVE_FN in config.h. 4306ca2c52aSchristos 4316ca2c52aSchristossetobjs= 4326ca2c52aSchristosCHECK= 4336ca2c52aSchristosif test -n "${with_target_subdir}"; then 4346ca2c52aSchristos 4356ca2c52aSchristos # We are being configured as a target library. AC_REPLACE_FUNCS 4366ca2c52aSchristos # may not work correctly, because the compiler may not be able to 4376ca2c52aSchristos # link executables. Note that we may still be being configured 4386ca2c52aSchristos # native. 4396ca2c52aSchristos 4406ca2c52aSchristos # If we are being configured for newlib, we know which functions 4416ca2c52aSchristos # newlib provide and which ones we will be expected to provide. 4426ca2c52aSchristos 4436ca2c52aSchristos if test "x${with_newlib}" = "xyes"; then 4446ca2c52aSchristos AC_LIBOBJ([asprintf]) 4456ca2c52aSchristos AC_LIBOBJ([basename]) 4466ca2c52aSchristos AC_LIBOBJ([insque]) 4476ca2c52aSchristos AC_LIBOBJ([random]) 4486ca2c52aSchristos AC_LIBOBJ([strdup]) 4496ca2c52aSchristos AC_LIBOBJ([vasprintf]) 4506ca2c52aSchristos 4516ca2c52aSchristos for f in $funcs; do 4526ca2c52aSchristos case "$f" in 4536ca2c52aSchristos asprintf | basename | insque | random | strdup | vasprintf) 4546ca2c52aSchristos ;; 4556ca2c52aSchristos *) 4566ca2c52aSchristos n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` 4576ca2c52aSchristos AC_DEFINE_UNQUOTED($n) 4586ca2c52aSchristos ;; 4596ca2c52aSchristos esac 4606ca2c52aSchristos done 4616ca2c52aSchristos 4626ca2c52aSchristos # newlib doesnt provide any of the variables in $vars, so we 4636ca2c52aSchristos # dont have to check them here. 4646ca2c52aSchristos 4656ca2c52aSchristos # Of the functions in $checkfuncs, newlib only has strerror. 4666ca2c52aSchristos AC_DEFINE(HAVE_STRERROR) 4676ca2c52aSchristos 4686ca2c52aSchristos setobjs=yes 4696ca2c52aSchristos 4706ca2c52aSchristos fi 4716ca2c52aSchristos 4726ca2c52aSchristos # If we are being configured for Mingw, we know which functions 4736ca2c52aSchristos # Mingw provides and which ones we will be expected to provide. 4746ca2c52aSchristos 4756ca2c52aSchristos case "${host}" in 4766ca2c52aSchristos *-*-mingw*) 4776ca2c52aSchristos AC_LIBOBJ([asprintf]) 4786ca2c52aSchristos AC_LIBOBJ([basename]) 4796ca2c52aSchristos AC_LIBOBJ([bcmp]) 4806ca2c52aSchristos AC_LIBOBJ([bcopy]) 4816ca2c52aSchristos AC_LIBOBJ([bzero]) 4826ca2c52aSchristos AC_LIBOBJ([clock]) 4836ca2c52aSchristos AC_LIBOBJ([ffs]) 4846ca2c52aSchristos AC_LIBOBJ([getpagesize]) 4856ca2c52aSchristos AC_LIBOBJ([index]) 4866ca2c52aSchristos AC_LIBOBJ([insque]) 4876ca2c52aSchristos AC_LIBOBJ([mempcpy]) 4886ca2c52aSchristos AC_LIBOBJ([mkstemps]) 4896ca2c52aSchristos AC_LIBOBJ([random]) 4906ca2c52aSchristos AC_LIBOBJ([rindex]) 4916ca2c52aSchristos AC_LIBOBJ([sigsetmask]) 4926ca2c52aSchristos AC_LIBOBJ([stpcpy]) 4936ca2c52aSchristos AC_LIBOBJ([stpncpy]) 4946ca2c52aSchristos AC_LIBOBJ([strndup]) 4956ca2c52aSchristos AC_LIBOBJ([strnlen]) 4966ca2c52aSchristos AC_LIBOBJ([strverscmp]) 4976ca2c52aSchristos AC_LIBOBJ([vasprintf]) 4986ca2c52aSchristos AC_LIBOBJ([waitpid]) 4996ca2c52aSchristos 5006ca2c52aSchristos for f in $funcs; do 5016ca2c52aSchristos case "$f" in 5026ca2c52aSchristos asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid) 5036ca2c52aSchristos ;; 5046ca2c52aSchristos *) 5056ca2c52aSchristos n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` 5066ca2c52aSchristos AC_DEFINE_UNQUOTED($n) 5076ca2c52aSchristos ;; 5086ca2c52aSchristos esac 5096ca2c52aSchristos done 5106ca2c52aSchristos 5116ca2c52aSchristos # Mingw doesnt provide any of the variables in $vars, so we 5126ca2c52aSchristos # dont have to check them here. 5136ca2c52aSchristos 5146ca2c52aSchristos # Of the functions in $checkfuncs, Mingw only has strerror. 5156ca2c52aSchristos AC_DEFINE(HAVE_STRERROR) 5166ca2c52aSchristos 5176ca2c52aSchristos setobjs=yes 5186ca2c52aSchristos ;; 5196ca2c52aSchristos 5206ca2c52aSchristos *-*-msdosdjgpp) 5216ca2c52aSchristos AC_LIBOBJ([vasprintf]) 5226ca2c52aSchristos AC_LIBOBJ([vsnprintf]) 5236ca2c52aSchristos AC_LIBOBJ([snprintf]) 5246ca2c52aSchristos AC_LIBOBJ([asprintf]) 5256ca2c52aSchristos 5266ca2c52aSchristos for f in atexit basename bcmp bcopy bsearch bzero calloc clock ffs \ 5276ca2c52aSchristos getcwd getpagesize getrusage gettimeofday \ 5286ca2c52aSchristos index insque memchr memcmp memcpy memmove memset psignal \ 5296ca2c52aSchristos putenv random rename rindex sbrk setenv stpcpy strcasecmp \ 5306ca2c52aSchristos strchr strdup strerror strncasecmp strrchr strstr strtod \ 5316ca2c52aSchristos strtol strtoul sysconf times tmpnam vfprintf vprintf \ 5326ca2c52aSchristos vsprintf waitpid 5336ca2c52aSchristos do 5346ca2c52aSchristos n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` 5356ca2c52aSchristos AC_DEFINE_UNQUOTED($n) 5366ca2c52aSchristos done 5376ca2c52aSchristos 5386ca2c52aSchristos 5396ca2c52aSchristos setobjs=yes 5406ca2c52aSchristos ;; 5416ca2c52aSchristos 5426ca2c52aSchristos esac 5436ca2c52aSchristos 5446ca2c52aSchristoselse 5456ca2c52aSchristos 5466ca2c52aSchristos # Not a target library, so we set things up to run the test suite. 5476ca2c52aSchristos CHECK=really-check 5486ca2c52aSchristos 5496ca2c52aSchristosfi 5506ca2c52aSchristos 5516ca2c52aSchristosAC_SUBST(CHECK) 5526ca2c52aSchristosAC_SUBST(target_header_dir) 5536ca2c52aSchristos 5546ca2c52aSchristoscase "${host}" in 5556ca2c52aSchristos *-*-cygwin* | *-*-mingw*) 5566ca2c52aSchristos AC_DEFINE(HAVE_SYS_ERRLIST) 5576ca2c52aSchristos AC_DEFINE(HAVE_SYS_NERR) 5586ca2c52aSchristos ;; 5596ca2c52aSchristosesac 5606ca2c52aSchristos 5616ca2c52aSchristosif test -z "${setobjs}"; then 5626ca2c52aSchristos case "${host}" in 5636ca2c52aSchristos 5646ca2c52aSchristos *-*-vxworks*) 5656ca2c52aSchristos # Handle VxWorks configuration specially, since on VxWorks the 5666ca2c52aSchristos # libraries are actually on the target board, not in the file 5676ca2c52aSchristos # system. 5686ca2c52aSchristos AC_LIBOBJ([basename]) 5696ca2c52aSchristos AC_LIBOBJ([getpagesize]) 5706ca2c52aSchristos AC_LIBOBJ([insque]) 5716ca2c52aSchristos AC_LIBOBJ([random]) 5726ca2c52aSchristos AC_LIBOBJ([strcasecmp]) 5736ca2c52aSchristos AC_LIBOBJ([strncasecmp]) 5746ca2c52aSchristos AC_LIBOBJ([strdup]) 5756ca2c52aSchristos AC_LIBOBJ([vfork]) 5766ca2c52aSchristos AC_LIBOBJ([waitpid]) 5776ca2c52aSchristos AC_LIBOBJ([vasprintf]) 5786ca2c52aSchristos for f in $funcs; do 5796ca2c52aSchristos case "$f" in 5806ca2c52aSchristos basename | getpagesize | insque | random | strcasecmp) 5816ca2c52aSchristos ;; 5826ca2c52aSchristos strncasecmp | strdup | vfork | waitpid | vasprintf) 5836ca2c52aSchristos ;; 5846ca2c52aSchristos *) 5856ca2c52aSchristos n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` 5866ca2c52aSchristos AC_DEFINE_UNQUOTED($n) 5876ca2c52aSchristos ;; 5886ca2c52aSchristos esac 5896ca2c52aSchristos done 5906ca2c52aSchristos 5916ca2c52aSchristos # VxWorks doesn't provide any of the variables in $vars, so we 5926ca2c52aSchristos # don't have to check them here. 5936ca2c52aSchristos 5946ca2c52aSchristos # Of the functions in $checkfuncs, VxWorks only has strerror. 5956ca2c52aSchristos AC_DEFINE(HAVE_STRERROR) 5966ca2c52aSchristos 5976ca2c52aSchristos setobjs=yes 5986ca2c52aSchristos ;; 5996ca2c52aSchristos 6006ca2c52aSchristos esac 6016ca2c52aSchristosfi 6026ca2c52aSchristos 6036ca2c52aSchristosif test -z "${setobjs}"; then 6046ca2c52aSchristos 6056ca2c52aSchristos case "${host}" in 6066ca2c52aSchristos 607b2396a7bSchristos *-*-android*) 608b2396a7bSchristos # On android, getpagesize is defined in unistd.h as a static inline 609b2396a7bSchristos # function, which AC_CHECK_FUNCS does not handle properly. 610b2396a7bSchristos ac_cv_func_getpagesize=yes 611b2396a7bSchristos ;; 612b2396a7bSchristos 6136ca2c52aSchristos *-*-mingw32*) 6146ca2c52aSchristos # Under mingw32, sys_nerr and sys_errlist exist, but they are 6156ca2c52aSchristos # macros, so the test below won't find them. 6166ca2c52aSchristos libiberty_cv_var_sys_nerr=yes 6176ca2c52aSchristos libiberty_cv_var_sys_errlist=yes 6186ca2c52aSchristos ;; 6196ca2c52aSchristos 6206ca2c52aSchristos *-*-msdosdjgpp*) 6216ca2c52aSchristos # vfork and fork are stubs. 6226ca2c52aSchristos ac_cv_func_vfork_works=no 6236ca2c52aSchristos ;; 6246ca2c52aSchristos 6256ca2c52aSchristos *-*-uwin*) 6266ca2c52aSchristos # Under some versions of uwin, vfork is notoriously buggy and the test 6276ca2c52aSchristos # can hang configure; on other versions, vfork exists just as a stub. 6286ca2c52aSchristos # FIXME: This should be removed once vfork in uwin's runtime is fixed. 6296ca2c52aSchristos ac_cv_func_vfork_works=no 6306ca2c52aSchristos # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are 6316ca2c52aSchristos # macros (actually, these are imported from a DLL, but the end effect 6326ca2c52aSchristos # is the same), so the test below won't find them. 6336ca2c52aSchristos libiberty_cv_var_sys_nerr=yes 6346ca2c52aSchristos libiberty_cv_var_sys_errlist=yes 6356ca2c52aSchristos ;; 6366ca2c52aSchristos 6376ca2c52aSchristos *-*-*vms*) 6386ca2c52aSchristos # Under VMS, vfork works very different than on Unix. The standard test 6396ca2c52aSchristos # won't work, and it isn't easily adaptable. It makes more sense to 6406ca2c52aSchristos # just force it. 6416ca2c52aSchristos ac_cv_func_vfork_works=yes 6426ca2c52aSchristos ;; 6436ca2c52aSchristos 6446ca2c52aSchristos esac 6456ca2c52aSchristos 6466ca2c52aSchristos # We haven't set the list of objects yet. Use the standard autoconf 6476ca2c52aSchristos # tests. This will only work if the compiler works. 6486ca2c52aSchristos AC_ISC_POSIX 6496ca2c52aSchristos AC_REPLACE_FUNCS($funcs) 6506ca2c52aSchristos libiberty_AC_FUNC_C_ALLOCA 6516ca2c52aSchristos AC_FUNC_FORK 6526ca2c52aSchristos if test $ac_cv_func_vfork_works = no; then 6536ca2c52aSchristos AC_LIBOBJ([vfork]) 6546ca2c52aSchristos fi 6556ca2c52aSchristos # We only need _doprnt if we might use it to implement v*printf. 6566ca2c52aSchristos if test $ac_cv_func_vprintf != yes \ 6576ca2c52aSchristos || test $ac_cv_func_vfprintf != yes \ 6586ca2c52aSchristos || test $ac_cv_func_vsprintf != yes; then 6596ca2c52aSchristos AC_REPLACE_FUNCS(_doprnt) 6606ca2c52aSchristos else 6616ca2c52aSchristos AC_CHECK_FUNCS(_doprnt) 6626ca2c52aSchristos fi 6636ca2c52aSchristos 6646ca2c52aSchristos for v in $vars; do 6656ca2c52aSchristos AC_MSG_CHECKING([for $v]) 6666ca2c52aSchristos AC_CACHE_VAL(libiberty_cv_var_$v, 6676ca2c52aSchristos [AC_LINK_IFELSE([AC_LANG_PROGRAM([[int *p;]],[[extern int $v []; p = $v;]])], 6686ca2c52aSchristos [eval "libiberty_cv_var_$v=yes"], 6696ca2c52aSchristos [eval "libiberty_cv_var_$v=no"])]) 6706ca2c52aSchristos if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then 6716ca2c52aSchristos AC_MSG_RESULT(yes) 6726ca2c52aSchristos n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` 6736ca2c52aSchristos AC_DEFINE_UNQUOTED($n) 6746ca2c52aSchristos else 6756ca2c52aSchristos AC_MSG_RESULT(no) 6766ca2c52aSchristos fi 6776ca2c52aSchristos done 6786ca2c52aSchristos 6796ca2c52aSchristos # special check for _system_configuration because AIX <4.3.2 do not 6806ca2c52aSchristos # contain the `physmem' member. 6816ca2c52aSchristos AC_MSG_CHECKING([for external symbol _system_configuration]) 6826ca2c52aSchristos AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/systemcfg.h>]], 6836ca2c52aSchristos [[double x = _system_configuration.physmem;]])], 6846ca2c52aSchristos [AC_MSG_RESULT([yes]) 6856ca2c52aSchristos AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1, 6866ca2c52aSchristos [Define if you have the _system_configuration variable.])], 6876ca2c52aSchristos [AC_MSG_RESULT([no])]) 6886ca2c52aSchristos 6896ca2c52aSchristos AC_CHECK_FUNCS($checkfuncs) 6906ca2c52aSchristos AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf]) 6916ca2c52aSchristos AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc, sbrk]) 6926ca2c52aSchristos AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoull]) 6936ca2c52aSchristos AC_CHECK_DECLS([strverscmp]) 69415d8e94aSchristos AC_CHECK_DECLS([strnlen]) 6956ca2c52aSchristos libiberty_NEED_DECLARATION(canonicalize_file_name) 6966ca2c52aSchristosfi 6976ca2c52aSchristos 6986ca2c52aSchristos# Figure out which version of pexecute to use. 6996ca2c52aSchristoscase "${host}" in 7006ca2c52aSchristos *-*-mingw* | *-*-winnt*) pexecute=pex-win32 ;; 7016ca2c52aSchristos *-*-msdosdjgpp*) pexecute=pex-djgpp ;; 7026ca2c52aSchristos *-*-msdos*) pexecute=pex-msdos ;; 7036ca2c52aSchristos *) pexecute=pex-unix ;; 7046ca2c52aSchristosesac 7056ca2c52aSchristosAC_SUBST(pexecute) 7066ca2c52aSchristos 7076ca2c52aSchristoslibiberty_AC_FUNC_STRNCMP 7086ca2c52aSchristos 7096ca2c52aSchristos# Install a library built with a cross compiler in $(tooldir) rather 7106ca2c52aSchristos# than $(libdir). 7116ca2c52aSchristosif test -z "${with_cross_host}"; then 7126ca2c52aSchristos INSTALL_DEST=libdir 7136ca2c52aSchristoselse 7146ca2c52aSchristos INSTALL_DEST=tooldir 7156ca2c52aSchristosfi 7166ca2c52aSchristosAC_SUBST(INSTALL_DEST) 7176ca2c52aSchristos 7186ca2c52aSchristosm4_pattern_allow(LIBOBJS) 7196ca2c52aSchristosL="" 7206ca2c52aSchristosfor l in x $LIBOBJS; do 7216ca2c52aSchristos case $l in 7226ca2c52aSchristos x) ;; 7236ca2c52aSchristos *) L="$L ./$l" ;; 7246ca2c52aSchristos esac 7256ca2c52aSchristosdone 7266ca2c52aSchristosLIBOBJS="$L" 7276ca2c52aSchristos 7286ca2c52aSchristosdnl Required by html and install-html 7296ca2c52aSchristosAC_SUBST(datarootdir) 7306ca2c52aSchristosAC_SUBST(docdir) 7316ca2c52aSchristosAC_SUBST(htmldir) 7326ca2c52aSchristos 7336ca2c52aSchristos# We need multilib support, but only if configuring for the target. 7346ca2c52aSchristosAC_CONFIG_FILES([Makefile testsuite/Makefile]) 7356ca2c52aSchristosAC_CONFIG_COMMANDS([default], 7366ca2c52aSchristos [[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h 7376ca2c52aSchristosif test -n "$CONFIG_FILES"; then 7386ca2c52aSchristos if test -n "${with_target_subdir}"; then 7396ca2c52aSchristos # FIXME: We shouldn't need to set ac_file 7406ca2c52aSchristos ac_file=Makefile 7416ca2c52aSchristos LD="${ORIGINAL_LD_FOR_MULTILIBS}" 7426ca2c52aSchristos . ${libiberty_topdir}/config-ml.in 7436ca2c52aSchristos fi 7446ca2c52aSchristosfi]], 7456ca2c52aSchristos[[srcdir=${srcdir} 7466ca2c52aSchristoshost=${host} 7476ca2c52aSchristostarget=${target} 7486ca2c52aSchristoswith_target_subdir=${with_target_subdir} 7496ca2c52aSchristoswith_multisubdir=${with_multisubdir} 7506ca2c52aSchristosac_configure_args="--enable-multilib ${ac_configure_args}" 7516ca2c52aSchristosCONFIG_SHELL=${CONFIG_SHELL-/bin/sh} 7526ca2c52aSchristosORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}" 7536ca2c52aSchristoslibiberty_topdir=${libiberty_topdir} 7546ca2c52aSchristos]]) 7556ca2c52aSchristosAC_OUTPUT 756