]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - libiberty/configure.ac
f59f35e1f208cb493a0696faac9c0ea836f09263
[thirdparty/binutils-gdb.git] / libiberty / configure.ac
1 dnl Process this file with autoconf to produce a configure script
2
3 AC_INIT
4 AC_CONFIG_SRCDIR([xmalloc.c])
5
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
11
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])
19 AC_ARG_WITH(newlib,
20 [ --with-newlib Configuring with newlib])
21
22 if test "${srcdir}" = "."; then
23 if test -n "${with_build_subdir}"; then
24 libiberty_topdir="${srcdir}/../.."
25 with_target_subdir=
26 elif test -z "${with_target_subdir}"; then
27 libiberty_topdir="${srcdir}/.."
28 else
29 if test "${with_target_subdir}" != "."; then
30 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
31 else
32 libiberty_topdir="${srcdir}/${with_multisrctop}.."
33 fi
34 fi
35 else
36 libiberty_topdir="${srcdir}/.."
37 fi
38 AC_SUBST(libiberty_topdir)
39 AC_CONFIG_AUX_DIR($libiberty_topdir)
40
41 dnl Very limited version of automake's enable-maintainer-mode
42
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,
50 maintainer_mode=no)
51
52 AC_MSG_RESULT($maintainer_mode)
53
54 if test "$maintainer_mode" = "yes"; then
55 MAINT=''
56 NOTMAINT='#'
57 else
58 MAINT='#'
59 NOTMAINT=''
60 fi
61 AC_SUBST(MAINT)dnl
62 AC_SUBST(NOTMAINT)dnl
63
64 if test -z "$ETAGS"; then
65 ETAGS=etags
66 fi
67 AC_SUBST([ETAGS])
68
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"
74 BUILD_INFO=
75 else
76 BUILD_INFO=info
77 case "$MAKEINFO" in
78 */missing\ makeinfo*)
79 BUILD_INFO=
80 AC_MSG_WARN([
81 *** Makeinfo is missing. Info documentation will not be built.])
82 ;;
83 *)
84 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
85 x*\ [[1-3]].* )
86 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
87 BUILD_INFO=
88 AC_MSG_WARN([
89 *** Makeinfo is too old. Info documentation will not be built.])
90 ;;
91 esac
92 ;;
93 esac
94 fi
95 AC_SUBST(MAKEINFO)
96 AC_SUBST(BUILD_INFO)
97
98 AC_CHECK_PROG(PERL, perl, perl, )
99 if test x"$PERL" = x""; then
100 HAVE_PERL='#'
101 else
102 HAVE_PERL=''
103 fi
104 AC_SUBST(HAVE_PERL)
105
106 AC_CANONICAL_HOST
107
108 dnl When we start using automake:
109 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
110
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, :)
115
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)
121 fi
122 if $RANLIB --help 2>&1 | grep -q "\--plugin"; then
123 RANLIB_PLUGIN_OPTION="$PLUGIN_OPTION"
124 AC_SUBST(RANLIB_PLUGIN_OPTION)
125 fi
126 fi
127
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
134 yes) multilib=yes ;;
135 no) multilib=no ;;
136 *) AC_MSG_ERROR([bad value $enableval for multilib option]) ;;
137 esac],
138 [multilib=yes])
139
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
145 fi
146
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
150
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
155
156 # Option parsed, now set things appropriately.
157 case x"$enable_install_libiberty" in
158 xyes|x)
159 target_header_dir=libiberty
160 ;;
161 xno)
162 target_header_dir=
163 ;;
164 *)
165 # This could be sanity-checked in various ways...
166 target_header_dir="${enable_install_libiberty}"
167 ;;
168 esac
169 AC_MSG_RESULT($enable_install_libiberty)
170 AC_MSG_NOTICE([target_header_dir = $target_header_dir])
171
172 GCC_NO_EXECUTABLES
173 AC_PROG_CC
174 AC_GNU_SOURCE
175 AC_SYS_LARGEFILE
176 AC_PROG_CPP_WERROR
177
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])
182
183 AC_PROG_CC_C_O
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
187 else
188 OUTPUT_OPTION='-o $@'
189 fi
190 AC_SUBST(NO_MINUS_C_MINUS_O)
191 AC_SUBST(OUTPUT_OPTION)
192
193 AC_C_CONST
194 AC_C_INLINE
195 AC_C_BIGENDIAN
196
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
201
202 dnl When we start using libtool:
203 dnl AM_PROG_LIBTOOL
204
205 dnl When we start using automake:
206 dnl AM_CONFIG_HEADER(config.h:config.in)
207 AC_CONFIG_HEADER(config.h:config.in)
208
209 dnl When we start using automake:
210 dnl AM_MAINTAINER_MODE
211 dnl AC_EXEEXT
212
213 dnl When we start using automake:
214 dnl AM_PROG_INSTALL
215 AC_PROG_INSTALL
216
217 # Don't build the shared library for build.
218 if [[ -n "${with_build_subdir}" ]]; then
219 enable_shared=no
220 fi
221
222 frag=
223 case "${host}" in
224 rs6000-ibm-aix3.1 | rs6000-ibm-aix)
225 frag=mh-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 ;;
231 esac
232
233 if [[ -n "${frag}" ]]; then
234 frag=${libiberty_topdir}/libiberty/config/$frag
235 fi
236
237 GCC_PICFLAG
238
239 # If they didn't specify --enable-shared, don't generate shared libs.
240 case "${enable_shared}" in
241 yes) shared=yes ;;
242 no) shared=no ;;
243 "") shared=no ;;
244 *) shared=yes ;;
245 esac
246
247 # ...unless --enable-host-shared was passed from top-level config:
248 if [[ "${enable_host_shared}" = "yes" ]]; then
249 shared=yes
250 fi
251
252 if [[ "${shared}" != "yes" ]]; then
253 PICFLAG=
254 fi
255 AC_SUBST(PICFLAG)
256
257 NOASANFLAG=
258 case " ${CFLAGS} " in
259 *\ -fsanitize=address\ *) NOASANFLAG=-fno-sanitize=address ;;
260 *\ -fsanitize=hwaddress\ *) NOASANFLAG=-fno-sanitize=hwaddress ;;
261 esac
262 AC_SUBST(NOASANFLAG)
263
264 GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
265 AC_SUBST(CET_HOST_FLAGS)
266
267 echo "# Warning: this fragment is automatically generated" > temp-frag
268
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
273 fi
274
275 # record if we want to build shared libs.
276 if [[ "${shared}" = "yes" ]]; then
277 echo enable_shared = yes >> temp-frag
278 else
279 echo enable_shared = no >> temp-frag
280 fi
281
282 frag=xhost-mkfrag
283 ${CONFIG_SHELL-/bin/sh} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag
284
285 host_makefile_frag=${frag}
286 AC_SUBST_FILE(host_makefile_frag)
287
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
290 # something.
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)
292 AC_HEADER_SYS_WAIT
293 AC_HEADER_TIME
294
295 libiberty_AC_DECLARE_ERRNO
296
297 # Determine sizes of some types.
298 AC_CHECK_SIZEOF([int])
299 AC_CHECK_SIZEOF([long])
300 AC_CHECK_SIZEOF([size_t])
301
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])],
305 [])
306
307 # Look for a 64-bit type.
308 AC_MSG_CHECKING([for a 64-bit type])
309 AC_CACHE_VAL(liberty_cv_uint64,
310 [AC_TRY_COMPILE(
311 [#ifdef HAVE_STDINT_H
312 #include <stdint.h>
313 #endif],
314 [extern uint64_t foo;],
315 liberty_cv_uint64=uint64_t,
316 [AC_TRY_COMPILE(
317 [#ifdef HAVE_LIMITS_H
318 #include <limits.h>
319 #endif
320 #ifndef CHAR_BIT
321 #define CHAR_BIT 8
322 #endif],
323 [extern char foo[sizeof(long) * CHAR_BIT >= 64 ? 1 : -1];],
324 liberty_cv_uint64="unsigned long",
325 [AC_TRY_COMPILE(
326 [#ifdef HAVE_LIMITS_H
327 #include <limits.h>
328 #endif
329 #ifndef CHAR_BIT
330 #define CHAR_BIT 8
331 #endif],
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.])
338 fi
339
340 AC_TYPE_INTPTR_T
341 AC_TYPE_UINTPTR_T
342 AC_TYPE_SSIZE_T
343
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
346 # relies on it.
347 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
348
349 AC_TYPE_PID_T
350
351 # This is the list of functions which libiberty will provide if they
352 # are not available on the host.
353
354 funcs="asprintf"
355 funcs="$funcs atexit"
356 funcs="$funcs basename"
357 funcs="$funcs bcmp"
358 funcs="$funcs bcopy"
359 funcs="$funcs bsearch"
360 funcs="$funcs bzero"
361 funcs="$funcs calloc"
362 funcs="$funcs clock"
363 funcs="$funcs ffs"
364 funcs="$funcs getcwd"
365 funcs="$funcs getpagesize"
366 funcs="$funcs gettimeofday"
367 funcs="$funcs index"
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"
408
409 # Also in the old function.def file: alloca, vfork, getopt.
410
411 vars="sys_errlist sys_nerr sys_siglist"
412
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"
417
418 # Darwin has sbrk, but it is deprecated and that produces build-time warnings
419 # so do not check for it.
420 case "${host}" in
421 *-*-darwin*) ;;
422 *) checkfuncs="$checkfuncs sbrk"
423 esac
424
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 \
431 dup3 \
432 ffs __fsetlocking \
433 getcwd getpagesize getrlimit getrusage getsysinfo gettimeofday \
434 index insque \
435 memchr memcmp memcpy memmem memmove memset mkstemps \
436 on_exit \
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 \
443 table times tmpnam \
444 vasprintf vfprintf vprintf vsprintf \
445 wait3 wait4 waitpid)
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.])
450 fi
451
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.
455
456 setobjs=
457 CHECK=
458 if test -n "${with_target_subdir}"; then
459
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
463 # native.
464
465 # If we are being configured for newlib, we know which functions
466 # newlib provide and which ones we will be expected to provide.
467
468 if test "x${with_newlib}" = "xyes"; then
469 AC_LIBOBJ([asprintf])
470 AC_LIBOBJ([basename])
471 AC_LIBOBJ([insque])
472 AC_LIBOBJ([random])
473 AC_LIBOBJ([strdup])
474 AC_LIBOBJ([vasprintf])
475
476 for f in $funcs; do
477 case "$f" in
478 asprintf | basename | insque | random | strdup | vasprintf)
479 ;;
480 *)
481 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
482 AC_DEFINE_UNQUOTED($n)
483 ;;
484 esac
485 done
486
487 # newlib doesnt provide any of the variables in $vars, so we
488 # dont have to check them here.
489
490 # Of the functions in $checkfuncs, newlib only has strerror.
491 AC_DEFINE(HAVE_STRERROR)
492
493 setobjs=yes
494
495 fi
496
497 # If we are being configured for Mingw, we know which functions
498 # Mingw provides and which ones we will be expected to provide.
499
500 case "${host}" in
501 *-*-mingw*)
502 AC_LIBOBJ([asprintf])
503 AC_LIBOBJ([basename])
504 AC_LIBOBJ([bcmp])
505 AC_LIBOBJ([bcopy])
506 AC_LIBOBJ([bzero])
507 AC_LIBOBJ([clock])
508 AC_LIBOBJ([ffs])
509 AC_LIBOBJ([getpagesize])
510 AC_LIBOBJ([index])
511 AC_LIBOBJ([insque])
512 AC_LIBOBJ([mempcpy])
513 AC_LIBOBJ([mkstemps])
514 AC_LIBOBJ([random])
515 AC_LIBOBJ([rindex])
516 AC_LIBOBJ([sigsetmask])
517 AC_LIBOBJ([stpcpy])
518 AC_LIBOBJ([stpncpy])
519 AC_LIBOBJ([strndup])
520 AC_LIBOBJ([strnlen])
521 AC_LIBOBJ([strverscmp])
522 AC_LIBOBJ([vasprintf])
523 AC_LIBOBJ([waitpid])
524
525 for f in $funcs; do
526 case "$f" in
527 asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid)
528 ;;
529 *)
530 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
531 AC_DEFINE_UNQUOTED($n)
532 ;;
533 esac
534 done
535
536 # Mingw doesnt provide any of the variables in $vars, so we
537 # dont have to check them here.
538
539 # Of the functions in $checkfuncs, Mingw only has strerror.
540 AC_DEFINE(HAVE_STRERROR)
541
542 setobjs=yes
543 ;;
544
545 *-*-msdosdjgpp)
546 AC_LIBOBJ([vasprintf])
547 AC_LIBOBJ([vsnprintf])
548 AC_LIBOBJ([snprintf])
549 AC_LIBOBJ([asprintf])
550
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 \
557 vsprintf waitpid
558 do
559 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
560 AC_DEFINE_UNQUOTED($n)
561 done
562
563
564 setobjs=yes
565 ;;
566
567 esac
568
569 else
570
571 # Not a target library, so we set things up to run the test suite.
572 CHECK=really-check
573
574 fi
575
576 AC_SUBST(CHECK)
577 AC_SUBST(target_header_dir)
578
579 case "${host}" in
580 *-*-cygwin* | *-*-mingw*)
581 AC_DEFINE(HAVE_SYS_ERRLIST)
582 AC_DEFINE(HAVE_SYS_NERR)
583 ;;
584 esac
585
586 if test -z "${setobjs}"; then
587 case "${host}" in
588
589 *-*-vxworks*)
590 # Handle VxWorks configuration specially, since on VxWorks the
591 # libraries are actually on the target board, not in the file
592 # system.
593 AC_LIBOBJ([basename])
594 AC_LIBOBJ([getpagesize])
595 AC_LIBOBJ([insque])
596 AC_LIBOBJ([random])
597 AC_LIBOBJ([strcasecmp])
598 AC_LIBOBJ([strncasecmp])
599 AC_LIBOBJ([strdup])
600 AC_LIBOBJ([vfork])
601 AC_LIBOBJ([waitpid])
602 AC_LIBOBJ([vasprintf])
603 for f in $funcs; do
604 case "$f" in
605 basename | getpagesize | insque | random | strcasecmp)
606 ;;
607 strncasecmp | strdup | vfork | waitpid | vasprintf)
608 ;;
609 *)
610 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
611 AC_DEFINE_UNQUOTED($n)
612 ;;
613 esac
614 done
615
616 # VxWorks doesn't provide any of the variables in $vars, so we
617 # don't have to check them here.
618
619 # Of the functions in $checkfuncs, VxWorks only has strerror.
620 AC_DEFINE(HAVE_STRERROR)
621
622 setobjs=yes
623 ;;
624
625 esac
626 fi
627
628 if test -z "${setobjs}"; then
629
630 case "${host}" in
631
632 *-*-android*)
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
636 ;;
637
638 hppa*-*-hpux*)
639 # Replace system snprintf and vsnprintf with libiberty implementations.
640 AC_LIBOBJ([snprintf])
641 AC_LIBOBJ([vsnprintf])
642 ;;
643
644 *-*-mingw32*)
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
649 ;;
650
651 *-*-msdosdjgpp*)
652 # vfork and fork are stubs.
653 ac_cv_func_vfork_works=no
654 ;;
655
656 *-*-uwin*)
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
666 ;;
667
668 *-*-*vms*)
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
671 # just force it.
672 ac_cv_func_vfork_works=yes
673 ;;
674
675 esac
676
677 # We haven't set the list of objects yet. Use the standard autoconf
678 # tests. This will only work if the compiler works.
679 AC_ISC_POSIX
680 AC_REPLACE_FUNCS($funcs)
681 libiberty_AC_FUNC_C_ALLOCA
682 AC_FUNC_FORK
683 if test $ac_cv_func_vfork_works = no; then
684 AC_LIBOBJ([vfork])
685 fi
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)
691 else
692 AC_CHECK_FUNCS(_doprnt)
693 fi
694
695 for v in $vars; do
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
702 AC_MSG_RESULT(yes)
703 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
704 AC_DEFINE_UNQUOTED($n)
705 else
706 AC_MSG_RESULT(no)
707 fi
708 done
709
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])])
719
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])
723 case "${host}" in
724 *-*-darwin*) ;; # Darwin's sbrk implementation is deprecated.
725 *) AC_CHECK_DECLS([sbrk]);;
726 esac
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)
731 fi
732
733 # Figure out which version of pexecute to use.
734 case "${host}" in
735 *-*-mingw* | *-*-winnt*) pexecute=pex-win32 ;;
736 *-*-msdosdjgpp*) pexecute=pex-djgpp ;;
737 *-*-msdos*) pexecute=pex-msdos ;;
738 *) pexecute=pex-unix ;;
739 esac
740 AC_SUBST(pexecute)
741
742 libiberty_AC_FUNC_STRNCMP
743
744 # Install a library built with a cross compiler in $(tooldir) rather
745 # than $(libdir).
746 if test -z "${with_cross_host}"; then
747 INSTALL_DEST=libdir
748 else
749 INSTALL_DEST=tooldir
750 fi
751 AC_SUBST(INSTALL_DEST)
752
753 m4_pattern_allow(LIBOBJS)
754 L=""
755 for l in x $LIBOBJS; do
756 case $l in
757 x) ;;
758 *) L="$L ./$l" ;;
759 esac
760 done
761 LIBOBJS="$L"
762
763 dnl Required by html and install-html
764 AC_SUBST(datarootdir)
765 AC_SUBST(docdir)
766 AC_SUBST(htmldir)
767
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
775 ac_file=Makefile
776 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
777 . ${libiberty_topdir}/config-ml.in
778 fi
779 fi]],
780 [[srcdir=${srcdir}
781 host=${host}
782 target=${target}
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}
789 ]])
790 AC_OUTPUT