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"
72 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
74 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
77 *** Makeinfo is too old. Info documentation will not be built.])
84 AC_CHECK_PROG(PERL, perl, perl, )
85 if test x"$PERL" = x""; then
94 dnl When we start using automake:
95 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
97 dnl These must be called before AM_PROG_LIBTOOL, because it may want
98 dnl to call AC_CHECK_PROG.
100 AC_CHECK_TOOL(RANLIB, ranlib, :)
105 # autoconf is lame and doesn't give us any substitution variable for this.
106 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
107 NO_MINUS_C_MINUS_O=yes
109 OUTPUT_OPTION='-o $@'
111 AC_SUBST(NO_MINUS_C_MINUS_O)
112 AC_SUBST(OUTPUT_OPTION)
118 dnl When we start using libtool:
119 dnl Default to a non shared library. This may be overridden by the
120 dnl configure option --enable-shared.
121 dnl AM_DISABLE_SHARED
123 dnl When we start using libtool:
126 dnl When we start using automake:
127 dnl AM_CONFIG_HEADER(config.h:config.in)
128 AC_CONFIG_HEADER(config.h:config.in)
130 dnl When we start using automake:
131 dnl AM_MAINTAINER_MODE
134 dnl When we start using automake:
138 . ${srcdir}/config.table
139 host_makefile_frag=${frag}
140 AC_SUBST_FILE(host_makefile_frag)
142 # It's OK to check for header files. Although the compiler may not be
143 # able to link anything, it had better be able to at least compile
145 AC_CHECK_HEADERS(sys/file.h sys/param.h limits.h stdlib.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)
149 libiberty_AC_DECLARE_ERRNO
151 AC_CHECK_TYPE(uintptr_t, unsigned long)
153 if test $ac_cv_type_uintptr_t = yes
155 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
160 # This is the list of functions which libiberty will provide if they
161 # are not available on the host.
164 funcs="$funcs atexit"
165 funcs="$funcs basename"
168 funcs="$funcs bsearch"
170 funcs="$funcs calloc"
173 funcs="$funcs getcwd"
174 funcs="$funcs getpagesize"
176 funcs="$funcs insque"
177 funcs="$funcs memchr"
178 funcs="$funcs memcmp"
179 funcs="$funcs memcpy"
180 funcs="$funcs memmove"
181 funcs="$funcs memset"
182 funcs="$funcs mkstemps"
183 funcs="$funcs putenv"
184 funcs="$funcs random"
185 funcs="$funcs rename"
186 funcs="$funcs rindex"
187 funcs="$funcs setenv"
188 funcs="$funcs sigsetmask"
189 funcs="$funcs strcasecmp"
190 funcs="$funcs strchr"
191 funcs="$funcs strdup"
192 funcs="$funcs strncasecmp"
193 funcs="$funcs strrchr"
194 funcs="$funcs strstr"
195 funcs="$funcs strtod"
196 funcs="$funcs strtol"
197 funcs="$funcs strtoul"
198 funcs="$funcs tmpnam"
199 funcs="$funcs vasprintf"
200 funcs="$funcs vfprintf"
201 funcs="$funcs vprintf"
202 funcs="$funcs vsprintf"
203 funcs="$funcs waitpid"
205 # Also in the old function.def file: alloca, vfork, getopt.
207 vars="sys_errlist sys_nerr sys_siglist _system_configuration"
209 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
210 checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic sysmp"
211 checkfuncs="$checkfuncs getsysinfo table sysctl"
213 # These are neither executed nor required, but they help keep
214 # autoheader happy without adding a bunch of text to acconfig.h.
215 if test "x" = "y"; then
216 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock)
217 AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy)
218 AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask)
219 AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
220 AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
221 AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
222 AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
223 AC_CHECK_FUNCS(pstat_getstatic pstat_getdynamic sysmp getsysinfo table sysctl)
224 AC_CHECK_FUNCS(realpath canonicalize_file_name)
225 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
226 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
227 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
228 AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1, [Define if you have the _system_configuration variable.])
231 # For each of these functions, if the host does not provide the
232 # function we want to put FN.o in LIBOBJS, and if the host does
233 # provide the function, we want to define HAVE_FN in config.h.
238 if test -n "${with_target_subdir}"; then
240 # We are being configured as a target library. AC_REPLACE_FUNCS
241 # may not work correctly, because the compiler may not be able to
242 # link executables. Note that we may still be being configured
245 # If we are being configured for newlib, we know which functions
246 # newlib provide and which ones we will be expected to provide.
248 if test "x${with_newlib}" = "xyes"; then
249 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
253 asprintf | basename | insque | random | strdup | vasprintf)
256 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
257 AC_DEFINE_UNQUOTED($n)
262 # newlib doesnt provide any of the variables in $vars, so we
263 # dont have to check them here.
265 # Of the functions in $checkfuncs, newlib only has strerror.
266 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
272 # We may wish to install the target headers somewhere.
273 AC_ARG_ENABLE(install-libiberty,
274 [ --enable-install-libiberty Install headers for end users],
275 enable_install_libiberty=$enableval,
276 enable_install_libiberty=no)dnl
278 # Option parsed, now set things appropriately.
279 case x"$enable_install_libiberty" in
281 target_header_dir=libiberty
287 # This could be sanity-checked in various ways...
288 target_header_dir="${enable_install_libiberty}"
295 # Not a target library, so we set things up to run the test suite.
296 CHECK=check-cplus-dem
301 AC_SUBST(target_header_dir)
304 *-*-cygwin* | *-*-mingw*)
305 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
306 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
310 if test -z "${setobjs}"; then
314 # Handle VxWorks configuration specially, since on VxWorks the
315 # libraries are actually on the target board, not in the file
317 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
318 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
321 basename | getpagesize | insque | random | strcasecmp)
323 strncasecmp | strdup | vfork | waitpid | vasprintf)
326 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
327 AC_DEFINE_UNQUOTED($n)
332 # VxWorks doesn't provide any of the variables in $vars, so we
333 # don't have to check them here.
335 # Of the functions in $checkfuncs, VxWorks only has strerror.
336 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
344 if test -z "${setobjs}"; then
349 # The Cygwin library actually uses a couple of files from
350 # libiberty when it is built. If we are building a native
351 # Cygwin, and we run the tests, we will appear to have these
352 # files. However, when we go on to build winsup, we will wind up
353 # with a library which does not have the files, since they should
354 # have come from libiberty.
356 # We handle this by removing the functions the winsup library
357 # provides from our shell variables, so that they appear to be
360 # DJ - only if we're *building* cygwin, not just building *with* cygwin
362 if test -n "${with_target_subdir}"
364 funcs="`echo $funcs | sed -e 's/random//'`"
365 LIBOBJS="$LIBOBJS random.o"
366 vars="`echo $vars | sed -e 's/sys_siglist//'`"
367 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
372 # Under mingw32, sys_nerr and sys_errlist exist, but they are
373 # macros, so the test below won't find them.
374 libiberty_cv_var_sys_nerr=yes
375 libiberty_cv_var_sys_errlist=yes
379 # Under some versions of uwin, vfork is notoriously buggy and the test
380 # can hang configure; on other versions, vfork exists just as a stub.
381 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
382 ac_cv_func_vfork_works=no
383 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
384 # macros (actually, these are imported from a DLL, but the end effect
385 # is the same), so the test below won't find them.
386 libiberty_cv_var_sys_nerr=yes
387 libiberty_cv_var_sys_errlist=yes
391 # Under VMS, vfork works very different than on Unix. The standard test
392 # won't work, and it isn't easily adaptable. It makes more sense to
394 ac_cv_func_vfork_works=yes
399 # We haven't set the list of objects yet. Use the standard autoconf
400 # tests. This will only work if the compiler works.
402 AC_REPLACE_FUNCS($funcs)
403 libiberty_AC_FUNC_C_ALLOCA
405 if test $ac_cv_func_vfork_works = no; then
406 LIBOBJS="$LIBOBJS vfork.o"
408 # We only need _doprnt if we might use it to implement v*printf.
409 if test $ac_cv_func_vprintf != yes \
410 || test $ac_cv_func_vfprintf != yes \
411 || test $ac_cv_func_vsprintf != yes; then
412 AC_REPLACE_FUNCS(_doprnt)
414 AC_CHECK_FUNCS(_doprnt)
418 AC_MSG_CHECKING([for $v])
419 AC_CACHE_VAL(libiberty_cv_var_$v,
420 [AC_TRY_LINK([int *p;], [extern int $v []; p = $v;],
421 [eval "libiberty_cv_var_$v=yes"],
422 [eval "libiberty_cv_var_$v=no"])])
423 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
425 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
426 AC_DEFINE_UNQUOTED($n)
431 AC_CHECK_FUNCS($checkfuncs)
432 libiberty_NEED_DECLARATION(canonicalize_file_name)
435 # Figure out which version of pexecute to use.
437 *-*-mingw* | *-*-winnt*) pexecute=pex-win32.o ;;
438 *-*-msdosdjgpp*) pexecute=pex-djgpp.o ;;
439 *-*-msdos*) pexecute=pex-msdos.o ;;
440 *-*-os2-emx*) pexecute=pex-os2.o ;;
441 *) pexecute=pex-unix.o ;;
445 libiberty_AC_FUNC_STRNCMP
447 # Install a library built with a cross compiler in $(tooldir) rather
449 if test -z "${with_cross_host}"; then
454 AC_SUBST(INSTALL_DEST)
456 # We need multilib support, but only if configuring for the target.
457 AC_OUTPUT(Makefile testsuite/Makefile,
458 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
459 if test -n "$CONFIG_FILES"; then
460 if test -n "${with_build_subdir}" || test -n "${with_target_subdir}"; then
461 # FIXME: We shouldn't need to set ac_file
463 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
464 . ${libiberty_topdir}/config-ml.in
470 with_target_subdir=${with_target_subdir}
471 with_build_subdir=${with_build_subdir}
472 with_multisubdir=${with_multisubdir}
473 ac_configure_args="--enable-multilib ${ac_configure_args}"
474 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
475 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
476 libiberty_topdir=${libiberty_topdir}