1 dnl Process this file with autoconf to produce a configure script
4 AC_CONFIG_SRCDIR([xmalloc.c])
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...
10 ORIGINAL_LD_FOR_MULTILIBS=$LD
12 dnl We use these options to decide which functions to include.
13 AC_ARG_WITH(target-subdir,
14 [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
15 AC_ARG_WITH(build-subdir,
16 [ --with-build-subdir=SUBDIR Configuring in a subdirectory for build])
17 AC_ARG_WITH(cross-host,
18 [ --with-cross-host=HOST Configuring with a cross compiler])
20 [ --with-newlib Configuring with newlib])
22 if test "${srcdir}" = "."; then
23 if test -n "${with_build_subdir}"; then
24 libiberty_topdir="${srcdir}/../.."
26 elif test -z "${with_target_subdir}"; then
27 libiberty_topdir="${srcdir}/.."
29 if test "${with_target_subdir}" != "."; then
30 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
32 libiberty_topdir="${srcdir}/${with_multisrctop}.."
36 libiberty_topdir="${srcdir}/.."
38 AC_SUBST(libiberty_topdir)
39 AC_CONFIG_AUX_DIR($libiberty_topdir)
41 dnl Very limited version of automake's enable-maintainer-mode
43 AC_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,
52 AC_MSG_RESULT($maintainer_mode)
54 if test "$maintainer_mode" = "yes"; then
64 if test -z "$ETAGS"; then
69 # Do we have a single-tree copy of texinfo? Even if we do, we can't
70 # rely on it - libiberty is built before texinfo.
71 AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
72 if test "x$MAKEINFO" = "x"; then
73 MAKEINFO="@echo makeinfo missing; true"
81 *** Makeinfo is missing. Info documentation will not be built.])
84 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
86 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
89 *** Makeinfo is too old. Info documentation will not be built.])
98 AC_CHECK_PROG(PERL, perl, perl, )
99 if test x"$PERL" = x""; then
108 dnl When we start using automake:
109 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
111 dnl These must be called before AM_PROG_LIBTOOL, because it may want
112 dnl to call AC_CHECK_PROG.
113 AC_CHECK_TOOL(AR, ar)
114 AC_CHECK_TOOL(RANLIB, ranlib, :)
116 GCC_PLUGIN_OPTION(PLUGIN_OPTION)
117 if test -n "$PLUGIN_OPTION"; then
118 if $AR --help 2>&1 | grep -q "\--plugin"; then
119 AR_PLUGIN_OPTION="$PLUGIN_OPTION"
120 AC_SUBST(AR_PLUGIN_OPTION)
122 if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
123 RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
124 AC_SUBST(RANLIB_PLUGIN_OPTION)
128 dnl When switching to automake, replace the following with AM_ENABLE_MULTILIB.
129 # Add --enable-multilib to configure.
130 # Default to --enable-multilib
131 AC_ARG_ENABLE(multilib,
132 [ --enable-multilib build many library versions (default)],
133 [case "$enableval" in
136 *) AC_MSG_ERROR([bad value $enableval for multilib option]) ;;
140 # Even if the default multilib is not a cross compilation,
141 # it may be that some of the other multilibs are.
142 if test $cross_compiling = no && test $multilib = yes \
143 && test "x${with_multisubdir}" != x ; then
144 cross_compiling=maybe
147 # We may wish to install the target headers somewhere.
148 AC_MSG_CHECKING([whether to install libiberty headers and static library])
149 dnl install-libiberty is disabled by default
151 AC_ARG_ENABLE(install-libiberty,
152 [ --enable-install-libiberty Install headers and library for end users],
153 enable_install_libiberty=$enableval,
154 enable_install_libiberty=no)dnl
156 # Option parsed, now set things appropriately.
157 case x"$enable_install_libiberty" in
159 target_header_dir=libiberty
165 # This could be sanity-checked in various ways...
166 target_header_dir="${enable_install_libiberty}"
169 AC_MSG_RESULT($enable_install_libiberty)
170 AC_MSG_NOTICE([target_header_dir = $target_header_dir])
178 ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wc++-compat \
179 -Wstrict-prototypes \
180 -Wshadow=local], [ac_libiberty_warn_cflags])
181 ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([], [ac_libiberty_warn_cflags])
184 # autoconf is lame and doesn't give us any substitution variable for this.
185 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
186 NO_MINUS_C_MINUS_O=yes
188 OUTPUT_OPTION='-o $@'
190 AC_SUBST(NO_MINUS_C_MINUS_O)
191 AC_SUBST(OUTPUT_OPTION)
197 dnl When we start using libtool:
198 dnl Default to a non shared library. This may be overridden by the
199 dnl configure option --enable-shared.
200 dnl AM_DISABLE_SHARED
202 dnl When we start using libtool:
205 dnl When we start using automake:
206 dnl AM_CONFIG_HEADER(config.h:config.in)
207 AC_CONFIG_HEADER(config.h:config.in)
209 dnl When we start using automake:
210 dnl AM_MAINTAINER_MODE
213 dnl When we start using automake:
217 # Don't build the shared library for build.
218 if [[ -n "${with_build_subdir}" ]]; then
224 rs6000-ibm-aix3.1 | rs6000-ibm-aix)
226 *-*-cxux7*) frag=mh-cxux7 ;;
227 *-*-freebsd2.1.*) frag=mh-fbsd21 ;;
228 *-*-freebsd2.2.[[012]]) frag=mh-fbsd21 ;;
229 i370-*-opened*) frag=mh-openedition ;;
230 i[[34567]]86-*-windows*) frag=mh-windows ;;
233 if [[ -n "${frag}" ]]; then
234 frag=${libiberty_topdir}/libiberty/config/$frag
239 # If they didn't specify --enable-shared, don't generate shared libs.
240 case "${enable_shared}" in
247 # ...unless --enable-host-shared was passed from top-level config:
248 if [[ "${enable_host_shared}" = "yes" ]]; then
252 if [[ "${shared}" != "yes" ]]; then
258 case " ${CFLAGS} " in
259 *\ -fsanitize=address\ *) NOASANFLAG=-fno-sanitize=address ;;
260 *\ -fsanitize=hwaddress\ *) NOASANFLAG=-fno-sanitize=hwaddress ;;
264 GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
265 AC_SUBST(CET_HOST_FLAGS)
267 echo "# Warning: this fragment is automatically generated" > temp-frag
269 if [[ -n "${frag}" ]] && [[ -f "${frag}" ]]; then
270 echo "Appending ${frag} to xhost-mkfrag"
271 echo "# Following fragment copied from ${frag}" >> temp-frag
272 cat ${frag} >> temp-frag
275 # record if we want to build shared libs.
276 if [[ "${shared}" = "yes" ]]; then
277 echo enable_shared = yes >> temp-frag
279 echo enable_shared = no >> temp-frag
283 ${CONFIG_SHELL-/bin/sh} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag
285 host_makefile_frag=${frag}
286 AC_SUBST_FILE(host_makefile_frag)
288 # It's OK to check for header files. Although the compiler may not be
289 # able to link anything, it had better be able to at least compile
291 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)
295 libiberty_AC_DECLARE_ERRNO
297 # Determine sizes of some types.
298 AC_CHECK_SIZEOF([int])
299 AC_CHECK_SIZEOF([long])
300 AC_CHECK_SIZEOF([size_t])
302 # Check for presense of long long
303 AC_CHECK_TYPE([long long],
304 [AC_DEFINE(HAVE_LONG_LONG, 1, [Define if you have the `long long' type.]) AC_CHECK_SIZEOF([long long])],
307 # Look for a 64-bit type.
308 AC_MSG_CHECKING([for a 64-bit type])
309 AC_CACHE_VAL(liberty_cv_uint64,
311 [#ifdef HAVE_STDINT_H
314 [extern uint64_t foo;],
315 liberty_cv_uint64=uint64_t,
317 [#ifdef HAVE_LIMITS_H
323 [extern char foo[sizeof(long) * CHAR_BIT >= 64 ? 1 : -1];],
324 liberty_cv_uint64="unsigned long",
326 [#ifdef HAVE_LIMITS_H
332 [extern char foo[sizeof(long long) * CHAR_BIT >= 64 ? 1 : -1];],
333 liberty_cv_uint64="unsigned long long", liberty_cv_uint64=none)])])])
334 AC_MSG_RESULT($liberty_cv_uint64)
335 if test "$liberty_cv_uint64" != none; then
336 AC_DEFINE_UNQUOTED(UNSIGNED_64BIT_TYPE, $liberty_cv_uint64,
337 [Define to an unsigned 64-bit type available in the compiler.])
344 # Given the above check, we always have uintptr_t or a fallback
345 # definition. So define HAVE_UINTPTR_T in case any imported code
347 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
351 # This is the list of functions which libiberty will provide if they
352 # are not available on the host.
355 funcs="$funcs atexit"
356 funcs="$funcs basename"
359 funcs="$funcs bsearch"
361 funcs="$funcs calloc"
364 funcs="$funcs getcwd"
365 funcs="$funcs getpagesize"
366 funcs="$funcs gettimeofday"
368 funcs="$funcs insque"
369 funcs="$funcs memchr"
370 funcs="$funcs memcmp"
371 funcs="$funcs memcpy"
372 funcs="$funcs memmem"
373 funcs="$funcs memmove"
374 funcs="$funcs mempcpy"
375 funcs="$funcs memset"
376 funcs="$funcs mkstemps"
377 funcs="$funcs putenv"
378 funcs="$funcs random"
379 funcs="$funcs rename"
380 funcs="$funcs rindex"
381 funcs="$funcs setenv"
382 funcs="$funcs snprintf"
383 funcs="$funcs sigsetmask"
384 funcs="$funcs stpcpy"
385 funcs="$funcs stpncpy"
386 funcs="$funcs strcasecmp"
387 funcs="$funcs strchr"
388 funcs="$funcs strdup"
389 funcs="$funcs strncasecmp"
390 funcs="$funcs strndup"
391 funcs="$funcs strnlen"
392 funcs="$funcs strrchr"
393 funcs="$funcs strstr"
394 funcs="$funcs strtod"
395 funcs="$funcs strtol"
396 funcs="$funcs strtoul"
397 funcs="$funcs strtoll"
398 funcs="$funcs strtoull"
399 funcs="$funcs strverscmp"
400 funcs="$funcs tmpnam"
401 funcs="$funcs vasprintf"
402 funcs="$funcs vfprintf"
403 funcs="$funcs vprintf"
404 funcs="$funcs vsnprintf"
405 funcs="$funcs vsprintf"
406 funcs="$funcs waitpid"
407 funcs="$funcs setproctitle"
409 # Also in the old function.def file: alloca, vfork, getopt.
411 vars="sys_errlist sys_nerr sys_siglist"
413 checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \
414 getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \
415 realpath setrlimit spawnve spawnvpe strerror strsignal sysconf sysctl \
416 sysmp table times wait3 wait4"
418 #Â Darwin has sbrk, but it is deprecated and that produces build-time warnings
419 #Â so do not check for it.
422 *) checkfuncs="$checkfuncs sbrk"
425 # These are neither executed nor required, but they help keep
426 # autoheader happy without adding a bunch of text to acconfig.h.
427 if test "x" = "y"; then
428 AC_CHECK_FUNCS(asprintf atexit \
429 basename bcmp bcopy bsearch bzero \
430 calloc canonicalize_file_name clock \
433 getcwd getpagesize getrlimit getrusage getsysinfo gettimeofday \
435 memchr memcmp memcpy memmem memmove memset mkstemps \
437 pipe2 psignal pstat_getdynamic pstat_getstatic putenv \
438 random realpath rename rindex \
439 sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \
440 stpcpy stpncpy strcasecmp strchr strdup \
441 strerror strncasecmp strndup strnlen strrchr strsignal strstr strtod \
442 strtol strtoul strtoll strtoull strverscmp sysconf sysctl sysmp \
444 vasprintf vfprintf vprintf vsprintf \
446 AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf, strtol, strtoul, strtoll, strtoull, strnlen])
447 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
448 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
449 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
452 # For each of these functions, if the host does not provide the
453 # function we want to put FN.o in LIBOBJS, and if the host does
454 # provide the function, we want to define HAVE_FN in config.h.
458 if test -n "${with_target_subdir}"; then
460 # We are being configured as a target library. AC_REPLACE_FUNCS
461 # may not work correctly, because the compiler may not be able to
462 # link executables. Note that we may still be being configured
465 # If we are being configured for newlib, we know which functions
466 # newlib provide and which ones we will be expected to provide.
468 if test "x${with_newlib}" = "xyes"; then
469 AC_LIBOBJ([asprintf])
470 AC_LIBOBJ([basename])
474 AC_LIBOBJ([vasprintf])
478 asprintf | basename | insque | random | strdup | vasprintf)
481 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
482 AC_DEFINE_UNQUOTED($n)
487 # newlib doesnt provide any of the variables in $vars, so we
488 # dont have to check them here.
490 # Of the functions in $checkfuncs, newlib only has strerror.
491 AC_DEFINE(HAVE_STRERROR)
497 # If we are being configured for Mingw, we know which functions
498 # Mingw provides and which ones we will be expected to provide.
502 AC_LIBOBJ([asprintf])
503 AC_LIBOBJ([basename])
509 AC_LIBOBJ([getpagesize])
513 AC_LIBOBJ([mkstemps])
516 AC_LIBOBJ([sigsetmask])
521 AC_LIBOBJ([strverscmp])
522 AC_LIBOBJ([vasprintf])
527 asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid)
530 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
531 AC_DEFINE_UNQUOTED($n)
536 # Mingw doesnt provide any of the variables in $vars, so we
537 # dont have to check them here.
539 # Of the functions in $checkfuncs, Mingw only has strerror.
540 AC_DEFINE(HAVE_STRERROR)
546 AC_LIBOBJ([vasprintf])
547 AC_LIBOBJ([vsnprintf])
548 AC_LIBOBJ([snprintf])
549 AC_LIBOBJ([asprintf])
551 for f in atexit basename bcmp bcopy bsearch bzero calloc clock ffs \
552 getcwd getpagesize getrusage gettimeofday \
553 index insque memchr memcmp memcpy memmove memset psignal \
554 putenv random rename rindex sbrk setenv stpcpy strcasecmp \
555 strchr strdup strerror strncasecmp strrchr strstr strtod \
556 strtol strtoul sysconf times tmpnam vfprintf vprintf \
559 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
560 AC_DEFINE_UNQUOTED($n)
571 # Not a target library, so we set things up to run the test suite.
577 AC_SUBST(target_header_dir)
580 *-*-cygwin* | *-*-mingw*)
581 AC_DEFINE(HAVE_SYS_ERRLIST)
582 AC_DEFINE(HAVE_SYS_NERR)
586 if test -z "${setobjs}"; then
590 # Handle VxWorks configuration specially, since on VxWorks the
591 # libraries are actually on the target board, not in the file
593 AC_LIBOBJ([basename])
594 AC_LIBOBJ([getpagesize])
597 AC_LIBOBJ([strcasecmp])
598 AC_LIBOBJ([strncasecmp])
602 AC_LIBOBJ([vasprintf])
605 basename | getpagesize | insque | random | strcasecmp)
607 strncasecmp | strdup | vfork | waitpid | vasprintf)
610 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
611 AC_DEFINE_UNQUOTED($n)
616 # VxWorks doesn't provide any of the variables in $vars, so we
617 # don't have to check them here.
619 # Of the functions in $checkfuncs, VxWorks only has strerror.
620 AC_DEFINE(HAVE_STRERROR)
628 if test -z "${setobjs}"; then
633 # On android, getpagesize is defined in unistd.h as a static inline
634 # function, which AC_CHECK_FUNCS does not handle properly.
635 ac_cv_func_getpagesize=yes
639 # Replace system snprintf and vsnprintf with libiberty implementations.
640 AC_LIBOBJ([snprintf])
641 AC_LIBOBJ([vsnprintf])
645 # Under mingw32, sys_nerr and sys_errlist exist, but they are
646 # macros, so the test below won't find them.
647 libiberty_cv_var_sys_nerr=yes
648 libiberty_cv_var_sys_errlist=yes
652 # vfork and fork are stubs.
653 ac_cv_func_vfork_works=no
657 # Under some versions of uwin, vfork is notoriously buggy and the test
658 # can hang configure; on other versions, vfork exists just as a stub.
659 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
660 ac_cv_func_vfork_works=no
661 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
662 # macros (actually, these are imported from a DLL, but the end effect
663 # is the same), so the test below won't find them.
664 libiberty_cv_var_sys_nerr=yes
665 libiberty_cv_var_sys_errlist=yes
669 # Under VMS, vfork works very different than on Unix. The standard test
670 # won't work, and it isn't easily adaptable. It makes more sense to
672 ac_cv_func_vfork_works=yes
677 # We haven't set the list of objects yet. Use the standard autoconf
678 # tests. This will only work if the compiler works.
680 AC_REPLACE_FUNCS($funcs)
681 libiberty_AC_FUNC_C_ALLOCA
683 if test $ac_cv_func_vfork_works = no; then
686 # We only need _doprnt if we might use it to implement v*printf.
687 if test $ac_cv_func_vprintf != yes \
688 || test $ac_cv_func_vfprintf != yes \
689 || test $ac_cv_func_vsprintf != yes; then
690 AC_REPLACE_FUNCS(_doprnt)
692 AC_CHECK_FUNCS(_doprnt)
696 AC_MSG_CHECKING([for $v])
697 AC_CACHE_VAL(libiberty_cv_var_$v,
698 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int $v [];]],[[if ($v [0]) return 1;]])],
699 [eval "libiberty_cv_var_$v=yes"],
700 [eval "libiberty_cv_var_$v=no"])])
701 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
703 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
704 AC_DEFINE_UNQUOTED($n)
710 # special check for _system_configuration because AIX <4.3.2 do not
711 # contain the `physmem' member.
712 AC_MSG_CHECKING([for external symbol _system_configuration])
713 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/systemcfg.h>]],
714 [[double x = _system_configuration.physmem;]])],
715 [AC_MSG_RESULT([yes])
716 AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1,
717 [Define if you have the _system_configuration variable.])],
718 [AC_MSG_RESULT([no])])
720 AC_CHECK_FUNCS($checkfuncs)
721 AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf])
722 AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc])
724 *-*-darwin*) ;; # Darwin's sbrk implementation is deprecated.
725 *) AC_CHECK_DECLS([sbrk]);;
727 AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoull])
728 AC_CHECK_DECLS([strverscmp])
729 AC_CHECK_DECLS([strnlen])
730 libiberty_NEED_DECLARATION(canonicalize_file_name)
733 # Figure out which version of pexecute to use.
735 *-*-mingw* | *-*-winnt*) pexecute=pex-win32 ;;
736 *-*-msdosdjgpp*) pexecute=pex-djgpp ;;
737 *-*-msdos*) pexecute=pex-msdos ;;
738 *) pexecute=pex-unix ;;
742 libiberty_AC_FUNC_STRNCMP
744 # Install a library built with a cross compiler in $(tooldir) rather
746 if test -z "${with_cross_host}"; then
751 AC_SUBST(INSTALL_DEST)
753 m4_pattern_allow(LIBOBJS)
755 for l in x $LIBOBJS; do
763 dnl Required by html and install-html
764 AC_SUBST(datarootdir)
768 # We need multilib support, but only if configuring for the target.
769 AC_CONFIG_FILES([Makefile testsuite/Makefile])
770 AC_CONFIG_COMMANDS([default],
771 [[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
772 if test -n "$CONFIG_FILES"; then
773 if test -n "${with_target_subdir}"; then
774 # FIXME: We shouldn't need to set ac_file
776 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
777 . ${libiberty_topdir}/config-ml.in
783 with_target_subdir=${with_target_subdir}
784 with_multisubdir=${with_multisubdir}
785 ac_configure_args="--enable-multilib ${ac_configure_args}"
786 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
787 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
788 libiberty_topdir=${libiberty_topdir}