1 dnl Process this file with autoconf to produce a configure script
5 AC_CONFIG_SRCDIR([xmalloc.c])
7 # FIXME: libiberty doesn't support --disable-static
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...
14 ORIGINAL_LD_FOR_MULTILIBS=$LD
16 dnl We use these options to decide which functions to include.
17 AC_ARG_WITH(target-subdir,
18 [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
19 AC_ARG_WITH(build-subdir,
20 [ --with-build-subdir=SUBDIR Configuring in a subdirectory for build])
21 AC_ARG_WITH(cross-host,
22 [ --with-cross-host=HOST Configuring with a cross compiler])
24 [ --with-newlib Configuring with newlib])
26 if test "${srcdir}" = "."; then
27 if test -n "${with_build_subdir}"; then
28 libiberty_topdir="${srcdir}/../.."
30 elif test -z "${with_target_subdir}"; then
31 libiberty_topdir="${srcdir}/.."
33 if test "${with_target_subdir}" != "."; then
34 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
36 libiberty_topdir="${srcdir}/${with_multisrctop}.."
40 libiberty_topdir="${srcdir}/.."
42 AC_SUBST(libiberty_topdir)
43 AC_CONFIG_AUX_DIR($libiberty_topdir)
45 dnl Very limited version of automake's enable-maintainer-mode
47 AC_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,
56 AC_MSG_RESULT($maintainer_mode)
58 if test "$maintainer_mode" = "yes"; then
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.
70 AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
71 if test "x$MAKEINFO" = "x"; then
72 MAKEINFO="@echo makeinfo missing; true"
80 *** Makeinfo is missing. Info documentation will not be built.])
83 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
85 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
88 *** Makeinfo is too old. Info documentation will not be built.])
97 AC_CHECK_PROG(PERL, perl, perl, )
98 if test x"$PERL" = x""; then
107 dnl When we start using automake:
108 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
110 dnl These must be called before AM_PROG_LIBTOOL, because it may want
111 dnl to call AC_CHECK_PROG.
112 AC_CHECK_TOOL(AR, ar)
113 AC_CHECK_TOOL(RANLIB, ranlib, :)
119 if test x$GCC = xyes; then
120 ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic'
122 AC_SUBST(ac_libiberty_warn_cflags)
128 dnl Default to a non shared library. This may be overridden by the
129 dnl configure option --enable-shared.
134 dnl When we start using automake:
135 dnl AM_CONFIG_HEADER(config.h:config.in)
136 AC_CONFIG_HEADER(config.h:config.in)
138 dnl When we start using automake:
139 dnl AM_MAINTAINER_MODE
142 dnl When we start using automake:
146 . ${srcdir}/config.table
147 host_makefile_frag=${frag}
148 AC_SUBST_FILE(host_makefile_frag)
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
153 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)
157 libiberty_AC_DECLARE_ERRNO
159 # Determine the size of an int for struct fibnode.
160 AC_CHECK_SIZEOF([int])
162 AC_CHECK_TYPE(uintptr_t, unsigned long)
164 # Look for a 64-bit type.
165 AC_MSG_CHECKING([for a 64-bit type])
166 AC_CACHE_VAL(liberty_cv_uint64,
168 [#ifdef HAVE_STDINT_H
171 [extern uint64_t foo;],
172 liberty_cv_uint64=uint64_t,
174 [#ifdef HAVE_LIMITS_H
180 [extern char foo[sizeof(long) * CHAR_BIT >= 64 ? 1 : -1];],
181 liberty_cv_uint64="unsigned long",
183 [#ifdef HAVE_LIMITS_H
189 [extern char foo[sizeof(long long) * CHAR_BIT >= 64 ? 1 : -1];],
190 liberty_cv_uint64="unsigned long long", liberty_cv_uint64=none)])])])
191 AC_MSG_RESULT($liberty_cv_uint64)
192 if test "$liberty_cv_uint64" != none; then
193 AC_DEFINE_UNQUOTED(UNSIGNED_64BIT_TYPE, $liberty_cv_uint64,
194 [Define to an unsigned 64-bit type available in the compiler.])
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
200 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
204 # This is the list of functions which libiberty will provide if they
205 # are not available on the host.
208 funcs="$funcs atexit"
209 funcs="$funcs basename"
212 funcs="$funcs bsearch"
214 funcs="$funcs calloc"
217 funcs="$funcs getcwd"
218 funcs="$funcs getpagesize"
220 funcs="$funcs insque"
221 funcs="$funcs memchr"
222 funcs="$funcs memcmp"
223 funcs="$funcs memcpy"
224 funcs="$funcs memmove"
225 funcs="$funcs mempcpy"
226 funcs="$funcs memset"
227 funcs="$funcs mkstemps"
228 funcs="$funcs putenv"
229 funcs="$funcs random"
230 funcs="$funcs rename"
231 funcs="$funcs rindex"
232 funcs="$funcs setenv"
233 funcs="$funcs snprintf"
234 funcs="$funcs sigsetmask"
235 funcs="$funcs stpcpy"
236 funcs="$funcs stpncpy"
237 funcs="$funcs strcasecmp"
238 funcs="$funcs strchr"
239 funcs="$funcs strdup"
240 funcs="$funcs strncasecmp"
241 funcs="$funcs strrchr"
242 funcs="$funcs strstr"
243 funcs="$funcs strtod"
244 funcs="$funcs strtol"
245 funcs="$funcs strtoul"
246 funcs="$funcs tmpnam"
247 funcs="$funcs vasprintf"
248 funcs="$funcs vfprintf"
249 funcs="$funcs vprintf"
250 funcs="$funcs vsnprintf"
251 funcs="$funcs vsprintf"
252 funcs="$funcs waitpid"
254 # Also in the old function.def file: alloca, vfork, getopt.
256 vars="sys_errlist sys_nerr sys_siglist"
258 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
259 checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic sysmp"
260 checkfuncs="$checkfuncs getsysinfo table sysctl"
262 # These are neither executed nor required, but they help keep
263 # autoheader happy without adding a bunch of text to acconfig.h.
264 if 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.])
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.
286 if test -n "${with_target_subdir}"; then
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
293 # If we are being configured for newlib, we know which functions
294 # newlib provide and which ones we will be expected to provide.
296 if test "x${with_newlib}" = "xyes"; then
297 AC_LIBOBJ([asprintf])
298 AC_LIBOBJ([basename])
302 AC_LIBOBJ([vasprintf])
306 asprintf | basename | insque | random | strdup | vasprintf)
309 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
310 AC_DEFINE_UNQUOTED($n)
315 # newlib doesnt provide any of the variables in $vars, so we
316 # dont have to check them here.
318 # Of the functions in $checkfuncs, newlib only has strerror.
319 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
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
331 # Option parsed, now set things appropriately.
332 case x"$enable_install_libiberty" in
334 target_header_dir=libiberty
340 # This could be sanity-checked in various ways...
341 target_header_dir="${enable_install_libiberty}"
348 # Not a target library, so we set things up to run the test suite.
349 CHECK=check-cplus-dem
354 AC_SUBST(target_header_dir)
357 *-*-cygwin* | *-*-mingw*)
358 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
359 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
363 if test -z "${setobjs}"; then
367 # Handle VxWorks configuration specially, since on VxWorks the
368 # libraries are actually on the target board, not in the file
370 AC_LIBOBJ([basename])
371 AC_LIBOBJ([getpagesize])
374 AC_LIBOBJ([strcasecmp])
375 AC_LIBOBJ([strncasecmp])
379 AC_LIBOBJ([vasprintf])
382 basename | getpagesize | insque | random | strcasecmp)
384 strncasecmp | strdup | vfork | waitpid | vasprintf)
387 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
388 AC_DEFINE_UNQUOTED($n)
393 # VxWorks doesn't provide any of the variables in $vars, so we
394 # don't have to check them here.
396 # Of the functions in $checkfuncs, VxWorks only has strerror.
397 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
405 if test -z "${setobjs}"; then
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.
417 # We handle this by removing the functions the winsup library
418 # provides from our shell variables, so that they appear to be
421 # DJ - only if we're *building* cygwin, not just building *with* cygwin
423 if test -n "${with_target_subdir}"
425 funcs="`echo $funcs | sed -e 's/random//'`"
427 vars="`echo $vars | sed -e 's/sys_siglist//'`"
428 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
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
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
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
455 ac_cv_func_vfork_works=yes
460 # We haven't set the list of objects yet. Use the standard autoconf
461 # tests. This will only work if the compiler works.
463 AC_REPLACE_FUNCS($funcs)
464 libiberty_AC_FUNC_C_ALLOCA
466 if test $ac_cv_func_vfork_works = no; then
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)
475 AC_CHECK_FUNCS(_doprnt)
479 AC_MSG_CHECKING([for $v])
480 AC_CACHE_VAL(libiberty_cv_var_$v,
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"])])
484 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
486 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
487 AC_DEFINE_UNQUOTED($n)
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])
496 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/systemcfg.h>]],
497 [[double x = _system_configuration.physmem;]])],
498 [AC_MSG_RESULT([yes])
499 AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1,
500 [Define if you have the _system_configuration variable.])],
501 [AC_MSG_RESULT([no])])
503 AC_CHECK_FUNCS($checkfuncs)
504 libiberty_NEED_DECLARATION(canonicalize_file_name)
507 # Figure out which version of pexecute to use.
509 *-*-mingw* | *-*-winnt*) pex=./pex-win32 ;;
510 *-*-msdosdjgpp*) pex=./pex-djgpp ;;
511 *-*-msdos*) pex=./pex-msdos ;;
512 *-*-os2-emx*) pex=./pex-os2 ;;
520 libiberty_AC_FUNC_STRNCMP
522 # Install a library built with a cross compiler in $(tooldir) rather
524 if test -z "${with_cross_host}"; then
529 AC_SUBST(INSTALL_DEST)
531 # Add `./' to avoid VPATH.
532 m4_pattern_allow(LIBOBJS)
534 for l in x $LIBOBJS; do
542 m4_pattern_allow(LTLIBOBJS)
544 for l in x $LTLIBOBJS; do
552 dnl Delete it when we start creating shared library with libtool.
553 AC_SUBST(enable_shared)
555 # We need multilib support, but only if configuring for the target.
556 AC_CONFIG_FILES([Makefile testsuite/Makefile])
557 AC_CONFIG_COMMANDS([default],
558 [[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
559 if test -n "$CONFIG_FILES"; then
560 if test -n "${with_target_subdir}"; then
561 # FIXME: We shouldn't need to set ac_file
563 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
564 . ${libiberty_topdir}/config-ml.in
570 with_target_subdir=${with_target_subdir}
571 with_multisubdir=${with_multisubdir}
572 ac_configure_args="--enable-multilib ${ac_configure_args}"
573 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
574 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
575 libiberty_topdir=${libiberty_topdir}