1 dnl Process this file with autoconf to produce a configure script
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 # Do we have a single-tree copy of texinfo? Even if we do, we can't
65 # rely on it - libiberty is built before texinfo.
66 AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
67 if test "x$MAKEINFO" = "x"; then
68 MAKEINFO="@echo makeinfo missing; true"
76 *** Makeinfo is missing. Info documentation will not be built.])
79 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
81 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
84 *** Makeinfo is too old. Info documentation will not be built.])
93 AC_CHECK_PROG(PERL, perl, perl, )
94 if test x"$PERL" = x""; then
103 dnl When we start using automake:
104 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
106 dnl These must be called before AM_PROG_LIBTOOL, because it may want
107 dnl to call AC_CHECK_PROG.
108 AC_CHECK_TOOL(AR, ar)
109 AC_CHECK_TOOL(RANLIB, ranlib, :)
115 if test x$GCC = xyes; then
116 ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic'
118 AC_SUBST(ac_libiberty_warn_cflags)
121 # autoconf is lame and doesn't give us any substitution variable for this.
122 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
123 NO_MINUS_C_MINUS_O=yes
125 OUTPUT_OPTION='-o $@'
127 AC_SUBST(NO_MINUS_C_MINUS_O)
128 AC_SUBST(OUTPUT_OPTION)
134 dnl When we start using libtool:
135 dnl Default to a non shared library. This may be overridden by the
136 dnl configure option --enable-shared.
137 dnl AM_DISABLE_SHARED
139 dnl When we start using libtool:
142 dnl When we start using automake:
143 dnl AM_CONFIG_HEADER(config.h:config.in)
144 AC_CONFIG_HEADER(config.h:config.in)
146 dnl When we start using automake:
147 dnl AM_MAINTAINER_MODE
150 dnl When we start using automake:
154 . ${srcdir}/config.table
155 host_makefile_frag=${frag}
156 AC_SUBST_FILE(host_makefile_frag)
158 # It's OK to check for header files. Although the compiler may not be
159 # able to link anything, it had better be able to at least compile
161 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)
165 libiberty_AC_DECLARE_ERRNO
167 AC_CHECK_TYPE(uintptr_t, unsigned long)
168 # Given the above check, we always have uintptr_t or a fallback
169 # definition. So define HAVE_UINTPTR_T in case any imported code
171 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
175 # This is the list of functions which libiberty will provide if they
176 # are not available on the host.
179 funcs="$funcs atexit"
180 funcs="$funcs basename"
183 funcs="$funcs bsearch"
185 funcs="$funcs calloc"
188 funcs="$funcs getcwd"
189 funcs="$funcs getpagesize"
191 funcs="$funcs insque"
192 funcs="$funcs memchr"
193 funcs="$funcs memcmp"
194 funcs="$funcs memcpy"
195 funcs="$funcs memmove"
196 funcs="$funcs mempcpy"
197 funcs="$funcs memset"
198 funcs="$funcs mkstemps"
199 funcs="$funcs putenv"
200 funcs="$funcs random"
201 funcs="$funcs rename"
202 funcs="$funcs rindex"
203 funcs="$funcs setenv"
204 funcs="$funcs snprintf"
205 funcs="$funcs sigsetmask"
206 funcs="$funcs stpcpy"
207 funcs="$funcs stpncpy"
208 funcs="$funcs strcasecmp"
209 funcs="$funcs strchr"
210 funcs="$funcs strdup"
211 funcs="$funcs strncasecmp"
212 funcs="$funcs strrchr"
213 funcs="$funcs strstr"
214 funcs="$funcs strtod"
215 funcs="$funcs strtol"
216 funcs="$funcs strtoul"
217 funcs="$funcs tmpnam"
218 funcs="$funcs vasprintf"
219 funcs="$funcs vfprintf"
220 funcs="$funcs vprintf"
221 funcs="$funcs vsnprintf"
222 funcs="$funcs vsprintf"
223 funcs="$funcs waitpid"
225 # Also in the old function.def file: alloca, vfork, getopt.
227 vars="sys_errlist sys_nerr sys_siglist"
229 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
230 checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic sysmp"
231 checkfuncs="$checkfuncs getsysinfo table sysctl"
233 # These are neither executed nor required, but they help keep
234 # autoheader happy without adding a bunch of text to acconfig.h.
235 if test "x" = "y"; then
236 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock \
237 getcwd getpagesize index insque mkstemps memchr memcmp memcpy \
238 memmove mempcpy memset putenv random rename rindex sigsetmask \
239 strcasecmp setenv stpcpy stpncpy strchr strdup strncasecmp strrchr strstr \
240 strtod strtol strtoul tmpnam vasprintf vfprintf vprintf \
241 vsprintf waitpid getrusage on_exit psignal strerror strsignal \
242 sysconf times sbrk gettimeofday ffs snprintf vsnprintf \
243 pstat_getstatic pstat_getdynamic sysmp getsysinfo table sysctl \
244 realpath canonicalize_file_name)
245 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
246 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
247 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
250 # For each of these functions, if the host does not provide the
251 # function we want to put FN.o in LIBOBJS, and if the host does
252 # provide the function, we want to define HAVE_FN in config.h.
257 if test -n "${with_target_subdir}"; then
259 # We are being configured as a target library. AC_REPLACE_FUNCS
260 # may not work correctly, because the compiler may not be able to
261 # link executables. Note that we may still be being configured
264 # If we are being configured for newlib, we know which functions
265 # newlib provide and which ones we will be expected to provide.
267 if test "x${with_newlib}" = "xyes"; then
268 AC_LIBOBJ([asprintf])
269 AC_LIBOBJ([basename])
273 AC_LIBOBJ([vasprintf])
277 asprintf | basename | insque | random | strdup | vasprintf)
280 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
281 AC_DEFINE_UNQUOTED($n)
286 # newlib doesnt provide any of the variables in $vars, so we
287 # dont have to check them here.
289 # Of the functions in $checkfuncs, newlib only has strerror.
290 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
296 # We may wish to install the target headers somewhere.
297 AC_ARG_ENABLE(install-libiberty,
298 [ --enable-install-libiberty Install headers for end users],
299 enable_install_libiberty=$enableval,
300 enable_install_libiberty=no)dnl
302 # Option parsed, now set things appropriately.
303 case x"$enable_install_libiberty" in
305 target_header_dir=libiberty
311 # This could be sanity-checked in various ways...
312 target_header_dir="${enable_install_libiberty}"
319 # Not a target library, so we set things up to run the test suite.
320 CHECK=check-cplus-dem
325 AC_SUBST(target_header_dir)
328 *-*-cygwin* | *-*-mingw*)
329 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
330 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
334 if test -z "${setobjs}"; then
338 # Handle VxWorks configuration specially, since on VxWorks the
339 # libraries are actually on the target board, not in the file
341 AC_LIBOBJ([basename])
342 AC_LIBOBJ([getpagesize])
345 AC_LIBOBJ([strcasecmp])
346 AC_LIBOBJ([strncasecmp])
350 AC_LIBOBJ([vasprintf])
353 basename | getpagesize | insque | random | strcasecmp)
355 strncasecmp | strdup | vfork | waitpid | vasprintf)
358 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
359 AC_DEFINE_UNQUOTED($n)
364 # VxWorks doesn't provide any of the variables in $vars, so we
365 # don't have to check them here.
367 # Of the functions in $checkfuncs, VxWorks only has strerror.
368 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
376 if test -z "${setobjs}"; then
381 # The Cygwin library actually uses a couple of files from
382 # libiberty when it is built. If we are building a native
383 # Cygwin, and we run the tests, we will appear to have these
384 # files. However, when we go on to build winsup, we will wind up
385 # with a library which does not have the files, since they should
386 # have come from libiberty.
388 # We handle this by removing the functions the winsup library
389 # provides from our shell variables, so that they appear to be
392 # DJ - only if we're *building* cygwin, not just building *with* cygwin
394 if test -n "${with_target_subdir}"
396 funcs="`echo $funcs | sed -e 's/random//'`"
398 vars="`echo $vars | sed -e 's/sys_siglist//'`"
399 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
404 # Under mingw32, sys_nerr and sys_errlist exist, but they are
405 # macros, so the test below won't find them.
406 libiberty_cv_var_sys_nerr=yes
407 libiberty_cv_var_sys_errlist=yes
411 # Under some versions of uwin, vfork is notoriously buggy and the test
412 # can hang configure; on other versions, vfork exists just as a stub.
413 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
414 ac_cv_func_vfork_works=no
415 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
416 # macros (actually, these are imported from a DLL, but the end effect
417 # is the same), so the test below won't find them.
418 libiberty_cv_var_sys_nerr=yes
419 libiberty_cv_var_sys_errlist=yes
423 # Under VMS, vfork works very different than on Unix. The standard test
424 # won't work, and it isn't easily adaptable. It makes more sense to
426 ac_cv_func_vfork_works=yes
431 # We haven't set the list of objects yet. Use the standard autoconf
432 # tests. This will only work if the compiler works.
434 AC_REPLACE_FUNCS($funcs)
435 libiberty_AC_FUNC_C_ALLOCA
437 if test $ac_cv_func_vfork_works = no; then
440 # We only need _doprnt if we might use it to implement v*printf.
441 if test $ac_cv_func_vprintf != yes \
442 || test $ac_cv_func_vfprintf != yes \
443 || test $ac_cv_func_vsprintf != yes; then
444 AC_REPLACE_FUNCS(_doprnt)
446 AC_CHECK_FUNCS(_doprnt)
450 AC_MSG_CHECKING([for $v])
451 AC_CACHE_VAL(libiberty_cv_var_$v,
452 [AC_TRY_LINK([int *p;], [extern int $v []; p = $v;],
453 [eval "libiberty_cv_var_$v=yes"],
454 [eval "libiberty_cv_var_$v=no"])])
455 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
457 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
458 AC_DEFINE_UNQUOTED($n)
464 # special check for _system_configuration because AIX <4.3.2 do not
465 # contain the `physmem' member.
466 AC_MSG_CHECKING([for external symbol _system_configuration])
467 AC_TRY_COMPILE([#include <sys/systemcfg.h>],
468 [double x = _system_configuration.physmem;],
469 [AC_MSG_RESULT([yes])
470 AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1,
471 [Define if you have the _system_configuration variable.])],
472 [AC_MSG_RESULT([no])])
474 AC_CHECK_FUNCS($checkfuncs)
475 libiberty_NEED_DECLARATION(canonicalize_file_name)
478 # Figure out which version of pexecute to use.
480 *-*-mingw* | *-*-winnt*) pexecute=pex-win32.o ;;
481 *-*-msdosdjgpp*) pexecute=pex-djgpp.o ;;
482 *-*-msdos*) pexecute=pex-msdos.o ;;
483 *-*-os2-emx*) pexecute=pex-os2.o ;;
484 *) pexecute=pex-unix.o ;;
488 libiberty_AC_FUNC_STRNCMP
490 # Install a library built with a cross compiler in $(tooldir) rather
492 if test -z "${with_cross_host}"; then
497 AC_SUBST(INSTALL_DEST)
499 # We need multilib support, but only if configuring for the target.
500 AC_OUTPUT(Makefile testsuite/Makefile,
501 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
502 if test -n "$CONFIG_FILES"; then
503 if test -n "${with_build_subdir}" || test -n "${with_target_subdir}"; then
504 # FIXME: We shouldn't need to set ac_file
506 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
507 . ${libiberty_topdir}/config-ml.in
513 with_target_subdir=${with_target_subdir}
514 with_build_subdir=${with_build_subdir}
515 with_multisubdir=${with_multisubdir}
516 ac_configure_args="--enable-multilib ${ac_configure_args}"
517 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
518 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
519 libiberty_topdir=${libiberty_topdir}