]> git.ipfire.org Git - thirdparty/gcc.git/blob - libiberty/configure.ac
Revert "configure: always set SPHINX_BUILD"
[thirdparty/gcc.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 AC_CONFIG_MACRO_DIRS([../config])
6
7 # This works around the fact that libtool configuration may change LD
8 # for this particular configuration, but some shells, instead of
9 # keeping the changes in LD private, export them just because LD is
10 # exported. We don't use libtool yet, but some day we might, so...
11 ORIGINAL_LD_FOR_MULTILIBS=$LD
12
13 dnl We use these options to decide which functions to include.
14 AC_ARG_WITH(target-subdir,
15 [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
16 AC_ARG_WITH(build-subdir,
17 [ --with-build-subdir=SUBDIR Configuring in a subdirectory for build])
18 AC_ARG_WITH(cross-host,
19 [ --with-cross-host=HOST Configuring with a cross compiler])
20 AC_ARG_WITH(newlib,
21 [ --with-newlib Configuring with newlib])
22
23 AC_ARG_WITH(sphinx-build,
24 [AS_HELP_STRING([--with-sphinx-build=],
25 [Use sphinx-build from a given path])],
26 [CONFIGURE_SPHINX_BUILD=$withval],
27 [CONFIGURE_SPHINX_BUILD=]
28 )
29 AC_SUBST(CONFIGURE_SPHINX_BUILD)
30
31 # See if sphinx-build has been installed and is modern enough
32 # that we can use it.
33 AC_MSG_CHECKING([for sphinx-build])
34 sphinx=sphinx-build
35 if test x${CONFIGURE_SPHINX_BUILD} != x ; then
36 sphinx=${CONFIGURE_SPHINX_BUILD}
37 fi
38
39 tempdir=build.$$
40 source=source.$$
41 mkdir $source
42 grep 'needs_sphinx =' ${srcdir}/../doc/baseconf.py > $source/conf.py
43 touch $source/index.rst
44 if ${sphinx} $source $tempdir >/dev/null 2>&1; then
45 SPHINX_BUILD=${sphinx}
46 HAS_SPHINX_BUILD=has-sphinx-build
47 AC_MSG_RESULT(yes)
48 else
49 AC_MSG_WARN([
50 *** sphinx-build is missing or too old.
51 *** Info and man pages documentation will not be built.])
52 AC_MSG_RESULT(no)
53 SPHINX_BUILD=
54 HAS_SPHINX_BUILD=
55 fi
56 rm -rf $tempdir
57 rm -rf $source
58 AC_SUBST(SPHINX_BUILD)
59 AC_SUBST(HAS_SPHINX_BUILD)
60
61 if test "${srcdir}" = "."; then
62 if test -n "${with_build_subdir}"; then
63 libiberty_topdir="${srcdir}/../.."
64 with_target_subdir=
65 elif test -z "${with_target_subdir}"; then
66 libiberty_topdir="${srcdir}/.."
67 else
68 if test "${with_target_subdir}" != "."; then
69 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
70 else
71 libiberty_topdir="${srcdir}/${with_multisrctop}.."
72 fi
73 fi
74 else
75 libiberty_topdir="${srcdir}/.."
76 fi
77 AC_SUBST(libiberty_topdir)
78 AC_CONFIG_AUX_DIR($libiberty_topdir)
79
80 dnl Very limited version of automake's enable-maintainer-mode
81
82 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
83 dnl maintainer-mode is disabled by default
84 AC_ARG_ENABLE(maintainer-mode,
85 [ --enable-maintainer-mode
86 enable make rules and dependencies not useful
87 (and sometimes confusing) to the casual installer],
88 maintainer_mode=$enableval,
89 maintainer_mode=no)
90
91 AC_MSG_RESULT($maintainer_mode)
92
93 if test "$maintainer_mode" = "yes"; then
94 MAINT=''
95 NOTMAINT='#'
96 else
97 MAINT='#'
98 NOTMAINT=''
99 fi
100 AC_SUBST(MAINT)dnl
101 AC_SUBST(NOTMAINT)dnl
102
103 if test -z "$ETAGS"; then
104 ETAGS=etags
105 fi
106 AC_SUBST([ETAGS])
107
108 # Do we have a single-tree copy of texinfo? Even if we do, we can't
109 # rely on it - libiberty is built before texinfo.
110 AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
111 if test "x$MAKEINFO" = "x"; then
112 MAKEINFO="@echo makeinfo missing; true"
113 BUILD_INFO=
114 else
115 BUILD_INFO=info
116 case "$MAKEINFO" in
117 */missing\ makeinfo*)
118 BUILD_INFO=
119 AC_MSG_WARN([
120 *** Makeinfo is missing. Info documentation will not be built.])
121 ;;
122 *)
123 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
124 x*\ [[1-3]].* )
125 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
126 BUILD_INFO=
127 AC_MSG_WARN([
128 *** Makeinfo is too old. Info documentation will not be built.])
129 ;;
130 esac
131 ;;
132 esac
133 fi
134 AC_SUBST(MAKEINFO)
135 AC_SUBST(BUILD_INFO)
136
137 AC_CHECK_PROG(PERL, perl, perl, )
138 if test x"$PERL" = x""; then
139 HAVE_PERL='#'
140 else
141 HAVE_PERL=''
142 fi
143 AC_SUBST(HAVE_PERL)
144
145 AC_CANONICAL_HOST
146
147 dnl When we start using automake:
148 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
149
150 dnl These must be called before AM_PROG_LIBTOOL, because it may want
151 dnl to call AC_CHECK_PROG.
152 AC_CHECK_TOOL(AR, ar)
153 AC_CHECK_TOOL(RANLIB, ranlib, :)
154
155 dnl When switching to automake, replace the following with AM_ENABLE_MULTILIB.
156 # Add --enable-multilib to configure.
157 # Default to --enable-multilib
158 AC_ARG_ENABLE(multilib,
159 [ --enable-multilib build many library versions (default)],
160 [case "$enableval" in
161 yes) multilib=yes ;;
162 no) multilib=no ;;
163 *) AC_MSG_ERROR([bad value $enableval for multilib option]) ;;
164 esac],
165 [multilib=yes])
166
167 # Even if the default multilib is not a cross compilation,
168 # it may be that some of the other multilibs are.
169 if test $cross_compiling = no && test $multilib = yes \
170 && test "x${with_multisubdir}" != x ; then
171 cross_compiling=maybe
172 fi
173
174 # We may wish to install the target headers somewhere.
175 AC_MSG_CHECKING([whether to install libiberty headers and static library])
176 dnl install-libiberty is disabled by default
177
178 AC_ARG_ENABLE(install-libiberty,
179 [ --enable-install-libiberty Install headers and library for end users],
180 enable_install_libiberty=$enableval,
181 enable_install_libiberty=no)dnl
182
183 # Option parsed, now set things appropriately.
184 case x"$enable_install_libiberty" in
185 xyes|x)
186 target_header_dir=libiberty
187 ;;
188 xno)
189 target_header_dir=
190 ;;
191 *)
192 # This could be sanity-checked in various ways...
193 target_header_dir="${enable_install_libiberty}"
194 ;;
195 esac
196 AC_MSG_RESULT($enable_install_libiberty)
197 AC_MSG_NOTICE([target_header_dir = $target_header_dir])
198
199 GCC_NO_EXECUTABLES
200 AC_PROG_CC
201 AC_GNU_SOURCE
202 AC_SYS_LARGEFILE
203 AC_PROG_CPP_WERROR
204
205 ACX_PROG_CC_WARNING_OPTS([-W -Wall -Wwrite-strings -Wc++-compat \
206 -Wstrict-prototypes \
207 -Wshadow=local], [ac_libiberty_warn_cflags])
208 ACX_PROG_CC_WARNING_ALMOST_PEDANTIC([], [ac_libiberty_warn_cflags])
209
210 AC_PROG_CC_C_O
211 # autoconf is lame and doesn't give us any substitution variable for this.
212 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
213 NO_MINUS_C_MINUS_O=yes
214 else
215 OUTPUT_OPTION='-o $@'
216 fi
217 AC_SUBST(NO_MINUS_C_MINUS_O)
218 AC_SUBST(OUTPUT_OPTION)
219
220 AC_C_CONST
221 AC_C_INLINE
222 AC_C_BIGENDIAN
223
224 dnl When we start using libtool:
225 dnl Default to a non shared library. This may be overridden by the
226 dnl configure option --enable-shared.
227 dnl AM_DISABLE_SHARED
228
229 dnl When we start using libtool:
230 dnl AM_PROG_LIBTOOL
231
232 dnl When we start using automake:
233 dnl AM_CONFIG_HEADER(config.h:config.in)
234 AC_CONFIG_HEADER(config.h:config.in)
235
236 dnl When we start using automake:
237 dnl AM_MAINTAINER_MODE
238 dnl AC_EXEEXT
239
240 dnl When we start using automake:
241 dnl AM_PROG_INSTALL
242 AC_PROG_INSTALL
243
244 # Don't build the shared library for build.
245 if [[ -n "${with_build_subdir}" ]]; then
246 enable_shared=no
247 fi
248
249 frag=
250 case "${host}" in
251 rs6000-ibm-aix3.1 | rs6000-ibm-aix)
252 frag=mh-aix ;;
253 *-*-cxux7*) frag=mh-cxux7 ;;
254 *-*-freebsd2.1.*) frag=mh-fbsd21 ;;
255 *-*-freebsd2.2.[[012]]) frag=mh-fbsd21 ;;
256 i370-*-opened*) frag=mh-openedition ;;
257 i[[34567]]86-*-windows*) frag=mh-windows ;;
258 esac
259
260 if [[ -n "${frag}" ]]; then
261 frag=${libiberty_topdir}/libiberty/config/$frag
262 fi
263
264 GCC_PICFLAG
265
266 # If they didn't specify --enable-shared, don't generate shared libs.
267 case "${enable_shared}" in
268 yes) shared=yes ;;
269 no) shared=no ;;
270 "") shared=no ;;
271 *) shared=yes ;;
272 esac
273
274 # ...unless --enable-host-shared was passed from top-level config:
275 if [[ "${enable_host_shared}" = "yes" ]]; then
276 shared=yes
277 fi
278
279 if [[ "${shared}" != "yes" ]]; then
280 PICFLAG=
281 fi
282 AC_SUBST(PICFLAG)
283
284 NOASANFLAG=
285 case " ${CFLAGS} " in
286 *\ -fsanitize=address\ *) NOASANFLAG=-fno-sanitize=address ;;
287 *\ -fsanitize=hwaddress\ *) NOASANFLAG=-fno-sanitize=hwaddress ;;
288 esac
289 AC_SUBST(NOASANFLAG)
290
291 GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
292 AC_SUBST(CET_HOST_FLAGS)
293
294 echo "# Warning: this fragment is automatically generated" > temp-frag
295
296 if [[ -n "${frag}" ]] && [[ -f "${frag}" ]]; then
297 echo "Appending ${frag} to xhost-mkfrag"
298 echo "# Following fragment copied from ${frag}" >> temp-frag
299 cat ${frag} >> temp-frag
300 fi
301
302 # record if we want to build shared libs.
303 if [[ "${shared}" = "yes" ]]; then
304 echo enable_shared = yes >> temp-frag
305 else
306 echo enable_shared = no >> temp-frag
307 fi
308
309 frag=xhost-mkfrag
310 ${CONFIG_SHELL-/bin/sh} ${libiberty_topdir}/move-if-change temp-frag xhost-mkfrag
311
312 host_makefile_frag=${frag}
313 AC_SUBST_FILE(host_makefile_frag)
314
315 # It's OK to check for header files. Although the compiler may not be
316 # able to link anything, it had better be able to at least compile
317 # something.
318 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)
319 AC_HEADER_SYS_WAIT
320 AC_HEADER_TIME
321
322 libiberty_AC_DECLARE_ERRNO
323
324 # Determine sizes of some types.
325 AC_CHECK_SIZEOF([int])
326 AC_CHECK_SIZEOF([long])
327 AC_CHECK_SIZEOF([size_t])
328
329 # Check for presense of long long
330 AC_CHECK_TYPE([long long],
331 [AC_DEFINE(HAVE_LONG_LONG, 1, [Define if you have the `long long' type.]) AC_CHECK_SIZEOF([long long])],
332 [])
333
334 # Look for a 64-bit type.
335 AC_MSG_CHECKING([for a 64-bit type])
336 AC_CACHE_VAL(liberty_cv_uint64,
337 [AC_TRY_COMPILE(
338 [#ifdef HAVE_STDINT_H
339 #include <stdint.h>
340 #endif],
341 [extern uint64_t foo;],
342 liberty_cv_uint64=uint64_t,
343 [AC_TRY_COMPILE(
344 [#ifdef HAVE_LIMITS_H
345 #include <limits.h>
346 #endif
347 #ifndef CHAR_BIT
348 #define CHAR_BIT 8
349 #endif],
350 [extern char foo[sizeof(long) * CHAR_BIT >= 64 ? 1 : -1];],
351 liberty_cv_uint64="unsigned long",
352 [AC_TRY_COMPILE(
353 [#ifdef HAVE_LIMITS_H
354 #include <limits.h>
355 #endif
356 #ifndef CHAR_BIT
357 #define CHAR_BIT 8
358 #endif],
359 [extern char foo[sizeof(long long) * CHAR_BIT >= 64 ? 1 : -1];],
360 liberty_cv_uint64="unsigned long long", liberty_cv_uint64=none)])])])
361 AC_MSG_RESULT($liberty_cv_uint64)
362 if test "$liberty_cv_uint64" != none; then
363 AC_DEFINE_UNQUOTED(UNSIGNED_64BIT_TYPE, $liberty_cv_uint64,
364 [Define to an unsigned 64-bit type available in the compiler.])
365 fi
366
367 AC_TYPE_INTPTR_T
368 AC_TYPE_UINTPTR_T
369 AC_TYPE_SSIZE_T
370
371 # Given the above check, we always have uintptr_t or a fallback
372 # definition. So define HAVE_UINTPTR_T in case any imported code
373 # relies on it.
374 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
375
376 AC_TYPE_PID_T
377
378 # This is the list of functions which libiberty will provide if they
379 # are not available on the host.
380
381 funcs="asprintf"
382 funcs="$funcs atexit"
383 funcs="$funcs basename"
384 funcs="$funcs bcmp"
385 funcs="$funcs bcopy"
386 funcs="$funcs bsearch"
387 funcs="$funcs bzero"
388 funcs="$funcs calloc"
389 funcs="$funcs clock"
390 funcs="$funcs ffs"
391 funcs="$funcs getcwd"
392 funcs="$funcs getpagesize"
393 funcs="$funcs gettimeofday"
394 funcs="$funcs index"
395 funcs="$funcs insque"
396 funcs="$funcs memchr"
397 funcs="$funcs memcmp"
398 funcs="$funcs memcpy"
399 funcs="$funcs memmem"
400 funcs="$funcs memmove"
401 funcs="$funcs mempcpy"
402 funcs="$funcs memset"
403 funcs="$funcs mkstemps"
404 funcs="$funcs putenv"
405 funcs="$funcs random"
406 funcs="$funcs rename"
407 funcs="$funcs rindex"
408 funcs="$funcs setenv"
409 funcs="$funcs snprintf"
410 funcs="$funcs sigsetmask"
411 funcs="$funcs stpcpy"
412 funcs="$funcs stpncpy"
413 funcs="$funcs strcasecmp"
414 funcs="$funcs strchr"
415 funcs="$funcs strdup"
416 funcs="$funcs strncasecmp"
417 funcs="$funcs strndup"
418 funcs="$funcs strnlen"
419 funcs="$funcs strrchr"
420 funcs="$funcs strstr"
421 funcs="$funcs strtod"
422 funcs="$funcs strtol"
423 funcs="$funcs strtoul"
424 funcs="$funcs strtoll"
425 funcs="$funcs strtoull"
426 funcs="$funcs strverscmp"
427 funcs="$funcs tmpnam"
428 funcs="$funcs vasprintf"
429 funcs="$funcs vfprintf"
430 funcs="$funcs vprintf"
431 funcs="$funcs vsnprintf"
432 funcs="$funcs vsprintf"
433 funcs="$funcs waitpid"
434 funcs="$funcs setproctitle"
435
436 # Also in the old function.def file: alloca, vfork, getopt.
437
438 vars="sys_errlist sys_nerr sys_siglist"
439
440 checkfuncs="__fsetlocking canonicalize_file_name dup3 getrlimit getrusage \
441 getsysinfo gettimeofday on_exit pipe2 psignal pstat_getdynamic pstat_getstatic \
442 realpath setrlimit spawnve spawnvpe strerror strsignal sysconf sysctl \
443 sysmp table times wait3 wait4"
444
445 # Darwin has sbrk, but it is deprecated and that produces build-time warnings
446 # so do not check for it.
447 case "${host}" in
448 *-*-darwin*) ;;
449 *) checkfuncs="$checkfuncs sbrk"
450 esac
451
452 # These are neither executed nor required, but they help keep
453 # autoheader happy without adding a bunch of text to acconfig.h.
454 if test "x" = "y"; then
455 AC_CHECK_FUNCS(asprintf atexit \
456 basename bcmp bcopy bsearch bzero \
457 calloc canonicalize_file_name clock \
458 dup3 \
459 ffs __fsetlocking \
460 getcwd getpagesize getrlimit getrusage getsysinfo gettimeofday \
461 index insque \
462 memchr memcmp memcpy memmem memmove memset mkstemps \
463 on_exit \
464 pipe2 psignal pstat_getdynamic pstat_getstatic putenv \
465 random realpath rename rindex \
466 sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \
467 stpcpy stpncpy strcasecmp strchr strdup \
468 strerror strncasecmp strndup strnlen strrchr strsignal strstr strtod \
469 strtol strtoul strtoll strtoull strverscmp sysconf sysctl sysmp \
470 table times tmpnam \
471 vasprintf vfprintf vprintf vsprintf \
472 wait3 wait4 waitpid)
473 AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf, strtol, strtoul, strtoll, strtoull, strnlen])
474 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
475 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
476 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
477 fi
478
479 # For each of these functions, if the host does not provide the
480 # function we want to put FN.o in LIBOBJS, and if the host does
481 # provide the function, we want to define HAVE_FN in config.h.
482
483 setobjs=
484 CHECK=
485 if test -n "${with_target_subdir}"; then
486
487 # We are being configured as a target library. AC_REPLACE_FUNCS
488 # may not work correctly, because the compiler may not be able to
489 # link executables. Note that we may still be being configured
490 # native.
491
492 # If we are being configured for newlib, we know which functions
493 # newlib provide and which ones we will be expected to provide.
494
495 if test "x${with_newlib}" = "xyes"; then
496 AC_LIBOBJ([asprintf])
497 AC_LIBOBJ([basename])
498 AC_LIBOBJ([insque])
499 AC_LIBOBJ([random])
500 AC_LIBOBJ([strdup])
501 AC_LIBOBJ([vasprintf])
502
503 for f in $funcs; do
504 case "$f" in
505 asprintf | basename | insque | random | strdup | vasprintf)
506 ;;
507 *)
508 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
509 AC_DEFINE_UNQUOTED($n)
510 ;;
511 esac
512 done
513
514 # newlib doesnt provide any of the variables in $vars, so we
515 # dont have to check them here.
516
517 # Of the functions in $checkfuncs, newlib only has strerror.
518 AC_DEFINE(HAVE_STRERROR)
519
520 setobjs=yes
521
522 fi
523
524 # If we are being configured for Mingw, we know which functions
525 # Mingw provides and which ones we will be expected to provide.
526
527 case "${host}" in
528 *-*-mingw*)
529 AC_LIBOBJ([asprintf])
530 AC_LIBOBJ([basename])
531 AC_LIBOBJ([bcmp])
532 AC_LIBOBJ([bcopy])
533 AC_LIBOBJ([bzero])
534 AC_LIBOBJ([clock])
535 AC_LIBOBJ([ffs])
536 AC_LIBOBJ([getpagesize])
537 AC_LIBOBJ([index])
538 AC_LIBOBJ([insque])
539 AC_LIBOBJ([mempcpy])
540 AC_LIBOBJ([mkstemps])
541 AC_LIBOBJ([random])
542 AC_LIBOBJ([rindex])
543 AC_LIBOBJ([sigsetmask])
544 AC_LIBOBJ([stpcpy])
545 AC_LIBOBJ([stpncpy])
546 AC_LIBOBJ([strndup])
547 AC_LIBOBJ([strnlen])
548 AC_LIBOBJ([strverscmp])
549 AC_LIBOBJ([vasprintf])
550 AC_LIBOBJ([waitpid])
551
552 for f in $funcs; do
553 case "$f" in
554 asprintf | basename | bcmp | bcopy | bzero | clock | ffs | getpagesize | index | insque | mempcpy | mkstemps | random | rindex | sigsetmask | stpcpy | stpncpy | strdup | strndup | strnlen | strverscmp | vasprintf | waitpid)
555 ;;
556 *)
557 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
558 AC_DEFINE_UNQUOTED($n)
559 ;;
560 esac
561 done
562
563 # Mingw doesnt provide any of the variables in $vars, so we
564 # dont have to check them here.
565
566 # Of the functions in $checkfuncs, Mingw only has strerror.
567 AC_DEFINE(HAVE_STRERROR)
568
569 setobjs=yes
570 ;;
571
572 *-*-msdosdjgpp)
573 AC_LIBOBJ([vasprintf])
574 AC_LIBOBJ([vsnprintf])
575 AC_LIBOBJ([snprintf])
576 AC_LIBOBJ([asprintf])
577
578 for f in atexit basename bcmp bcopy bsearch bzero calloc clock ffs \
579 getcwd getpagesize getrusage gettimeofday \
580 index insque memchr memcmp memcpy memmove memset psignal \
581 putenv random rename rindex sbrk setenv stpcpy strcasecmp \
582 strchr strdup strerror strncasecmp strrchr strstr strtod \
583 strtol strtoul sysconf times tmpnam vfprintf vprintf \
584 vsprintf waitpid
585 do
586 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
587 AC_DEFINE_UNQUOTED($n)
588 done
589
590
591 setobjs=yes
592 ;;
593
594 esac
595
596 else
597
598 # Not a target library, so we set things up to run the test suite.
599 CHECK=really-check
600
601 fi
602
603 AC_SUBST(CHECK)
604 AC_SUBST(target_header_dir)
605
606 case "${host}" in
607 *-*-cygwin* | *-*-mingw*)
608 AC_DEFINE(HAVE_SYS_ERRLIST)
609 AC_DEFINE(HAVE_SYS_NERR)
610 ;;
611 esac
612
613 if test -z "${setobjs}"; then
614 case "${host}" in
615
616 *-*-vxworks*)
617 # Handle VxWorks configuration specially, since on VxWorks the
618 # libraries are actually on the target board, not in the file
619 # system.
620 AC_LIBOBJ([basename])
621 AC_LIBOBJ([getpagesize])
622 AC_LIBOBJ([insque])
623 AC_LIBOBJ([random])
624 AC_LIBOBJ([strcasecmp])
625 AC_LIBOBJ([strncasecmp])
626 AC_LIBOBJ([strdup])
627 AC_LIBOBJ([vfork])
628 AC_LIBOBJ([waitpid])
629 AC_LIBOBJ([vasprintf])
630 for f in $funcs; do
631 case "$f" in
632 basename | getpagesize | insque | random | strcasecmp)
633 ;;
634 strncasecmp | strdup | vfork | waitpid | vasprintf)
635 ;;
636 *)
637 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
638 AC_DEFINE_UNQUOTED($n)
639 ;;
640 esac
641 done
642
643 # VxWorks doesn't provide any of the variables in $vars, so we
644 # don't have to check them here.
645
646 # Of the functions in $checkfuncs, VxWorks only has strerror.
647 AC_DEFINE(HAVE_STRERROR)
648
649 setobjs=yes
650 ;;
651
652 esac
653 fi
654
655 if test -z "${setobjs}"; then
656
657 case "${host}" in
658
659 *-*-android*)
660 # On android, getpagesize is defined in unistd.h as a static inline
661 # function, which AC_CHECK_FUNCS does not handle properly.
662 ac_cv_func_getpagesize=yes
663 ;;
664
665 hppa*-*-hpux*)
666 # Replace system snprintf and vsnprintf with libiberty implementations.
667 AC_LIBOBJ([snprintf])
668 AC_LIBOBJ([vsnprintf])
669 ;;
670
671 *-*-mingw32*)
672 # Under mingw32, sys_nerr and sys_errlist exist, but they are
673 # macros, so the test below won't find them.
674 libiberty_cv_var_sys_nerr=yes
675 libiberty_cv_var_sys_errlist=yes
676 ;;
677
678 *-*-msdosdjgpp*)
679 # vfork and fork are stubs.
680 ac_cv_func_vfork_works=no
681 ;;
682
683 *-*-uwin*)
684 # Under some versions of uwin, vfork is notoriously buggy and the test
685 # can hang configure; on other versions, vfork exists just as a stub.
686 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
687 ac_cv_func_vfork_works=no
688 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
689 # macros (actually, these are imported from a DLL, but the end effect
690 # is the same), so the test below won't find them.
691 libiberty_cv_var_sys_nerr=yes
692 libiberty_cv_var_sys_errlist=yes
693 ;;
694
695 *-*-*vms*)
696 # Under VMS, vfork works very different than on Unix. The standard test
697 # won't work, and it isn't easily adaptable. It makes more sense to
698 # just force it.
699 ac_cv_func_vfork_works=yes
700 ;;
701
702 esac
703
704 # We haven't set the list of objects yet. Use the standard autoconf
705 # tests. This will only work if the compiler works.
706 AC_ISC_POSIX
707 AC_REPLACE_FUNCS($funcs)
708 libiberty_AC_FUNC_C_ALLOCA
709 AC_FUNC_FORK
710 if test $ac_cv_func_vfork_works = no; then
711 AC_LIBOBJ([vfork])
712 fi
713 # We only need _doprnt if we might use it to implement v*printf.
714 if test $ac_cv_func_vprintf != yes \
715 || test $ac_cv_func_vfprintf != yes \
716 || test $ac_cv_func_vsprintf != yes; then
717 AC_REPLACE_FUNCS(_doprnt)
718 else
719 AC_CHECK_FUNCS(_doprnt)
720 fi
721
722 for v in $vars; do
723 AC_MSG_CHECKING([for $v])
724 AC_CACHE_VAL(libiberty_cv_var_$v,
725 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern int $v [];]],[[if ($v [0]) return 1;]])],
726 [eval "libiberty_cv_var_$v=yes"],
727 [eval "libiberty_cv_var_$v=no"])])
728 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
729 AC_MSG_RESULT(yes)
730 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
731 AC_DEFINE_UNQUOTED($n)
732 else
733 AC_MSG_RESULT(no)
734 fi
735 done
736
737 # special check for _system_configuration because AIX <4.3.2 do not
738 # contain the `physmem' member.
739 AC_MSG_CHECKING([for external symbol _system_configuration])
740 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/systemcfg.h>]],
741 [[double x = _system_configuration.physmem;]])],
742 [AC_MSG_RESULT([yes])
743 AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1,
744 [Define if you have the _system_configuration variable.])],
745 [AC_MSG_RESULT([no])])
746
747 AC_CHECK_FUNCS($checkfuncs)
748 AC_CHECK_DECLS([basename(char *), ffs, asprintf, vasprintf, snprintf, vsnprintf])
749 AC_CHECK_DECLS([calloc, getenv, getopt, malloc, realloc])
750 case "${host}" in
751 *-*-darwin*) ;; # Darwin's sbrk implementation is deprecated.
752 *) AC_CHECK_DECLS([sbrk]);;
753 esac
754 AC_CHECK_DECLS([strtol, strtoul, strtoll, strtoull])
755 AC_CHECK_DECLS([strverscmp])
756 AC_CHECK_DECLS([strnlen])
757 libiberty_NEED_DECLARATION(canonicalize_file_name)
758 fi
759
760 # Figure out which version of pexecute to use.
761 case "${host}" in
762 *-*-mingw* | *-*-winnt*) pexecute=pex-win32 ;;
763 *-*-msdosdjgpp*) pexecute=pex-djgpp ;;
764 *-*-msdos*) pexecute=pex-msdos ;;
765 *) pexecute=pex-unix ;;
766 esac
767 AC_SUBST(pexecute)
768
769 libiberty_AC_FUNC_STRNCMP
770
771 # Install a library built with a cross compiler in $(tooldir) rather
772 # than $(libdir).
773 if test -z "${with_cross_host}"; then
774 INSTALL_DEST=libdir
775 else
776 INSTALL_DEST=tooldir
777 fi
778 AC_SUBST(INSTALL_DEST)
779
780 m4_pattern_allow(LIBOBJS)
781 L=""
782 for l in x $LIBOBJS; do
783 case $l in
784 x) ;;
785 *) L="$L ./$l" ;;
786 esac
787 done
788 LIBOBJS="$L"
789
790 dnl Required by html and install-html
791 AC_SUBST(datarootdir)
792 AC_SUBST(docdir)
793 AC_SUBST(htmldir)
794
795 # We need multilib support, but only if configuring for the target.
796 AC_CONFIG_FILES([Makefile testsuite/Makefile])
797 AC_CONFIG_COMMANDS([default],
798 [[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
799 if test -n "$CONFIG_FILES"; then
800 if test -n "${with_target_subdir}"; then
801 # FIXME: We shouldn't need to set ac_file
802 ac_file=Makefile
803 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
804 . ${libiberty_topdir}/config-ml.in
805 fi
806 fi]],
807 [[srcdir=${srcdir}
808 host=${host}
809 target=${target}
810 with_target_subdir=${with_target_subdir}
811 with_multisubdir=${with_multisubdir}
812 ac_configure_args="--enable-multilib ${ac_configure_args}"
813 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
814 ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
815 libiberty_topdir=${libiberty_topdir}
816 ]])
817 AC_OUTPUT