2004-12-27 H.J. Lu <hongjiu.lu@intel.com>
[deliverable/binutils-gdb.git] / libiberty / configure.ac
1 dnl Process this file with autoconf to produce a configure script
2
3 AC_PREREQ(2.59)
4 AC_INIT
5 AC_CONFIG_SRCDIR([xmalloc.c])
6
7 # FIXME: libiberty doesn't support --disable-static
8 enable_static=yes
9
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
15
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])
23 AC_ARG_WITH(newlib,
24 [ --with-newlib Configuring with newlib])
25
26 if test "${srcdir}" = "."; then
27 if test -n "${with_build_subdir}"; then
28 libiberty_topdir="${srcdir}/../.."
29 with_target_subdir=
30 elif test -z "${with_target_subdir}"; then
31 libiberty_topdir="${srcdir}/.."
32 else
33 if test "${with_target_subdir}" != "."; then
34 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
35 else
36 libiberty_topdir="${srcdir}/${with_multisrctop}.."
37 fi
38 fi
39 else
40 libiberty_topdir="${srcdir}/.."
41 fi
42 AC_SUBST(libiberty_topdir)
43 AC_CONFIG_AUX_DIR($libiberty_topdir)
44
45 dnl Very limited version of automake's enable-maintainer-mode
46
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,
54 maintainer_mode=no)
55
56 AC_MSG_RESULT($maintainer_mode)
57
58 if test "$maintainer_mode" = "yes"; then
59 MAINT=''
60 NOTMAINT='#'
61 else
62 MAINT='#'
63 NOTMAINT=''
64 fi
65 AC_SUBST(MAINT)dnl
66 AC_SUBST(NOTMAINT)dnl
67
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"
73 BUILD_INFO=
74 else
75 BUILD_INFO=info
76 case "$MAKEINFO" in
77 */missing\ makeinfo*)
78 BUILD_INFO=
79 AC_MSG_WARN([
80 *** Makeinfo is missing. Info documentation will not be built.])
81 ;;
82 *)
83 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
84 x*\ [[1-3]].* )
85 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
86 BUILD_INFO=
87 AC_MSG_WARN([
88 *** Makeinfo is too old. Info documentation will not be built.])
89 ;;
90 esac
91 ;;
92 esac
93 fi
94 AC_SUBST(MAKEINFO)
95 AC_SUBST(BUILD_INFO)
96
97 AC_CHECK_PROG(PERL, perl, perl, )
98 if test x"$PERL" = x""; then
99 HAVE_PERL='#'
100 else
101 HAVE_PERL=''
102 fi
103 AC_SUBST(HAVE_PERL)
104
105 AC_CANONICAL_HOST
106
107 dnl When we start using automake:
108 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
109
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, :)
114
115 GCC_NO_EXECUTABLES
116 AC_PROG_CC
117 AC_PROG_CPP_WERROR
118
119 if test x$GCC = xyes; then
120 ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic'
121 fi
122 AC_SUBST(ac_libiberty_warn_cflags)
123
124 AC_C_CONST
125 AC_C_INLINE
126 AC_C_BIGENDIAN_CROSS
127
128 dnl Default to a non shared library. This may be overridden by the
129 dnl configure option --enable-shared.
130 AM_DISABLE_SHARED
131
132 AM_PROG_LIBTOOL
133
134 dnl When we start using automake:
135 dnl AM_CONFIG_HEADER(config.h:config.in)
136 AC_CONFIG_HEADER(config.h:config.in)
137
138 dnl When we start using automake:
139 dnl AM_MAINTAINER_MODE
140 dnl AC_EXEEXT
141
142 dnl When we start using automake:
143 dnl AM_PROG_INSTALL
144 AC_PROG_INSTALL
145
146 . ${srcdir}/config.table
147 host_makefile_frag=${frag}
148 AC_SUBST_FILE(host_makefile_frag)
149
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
152 # something.
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)
154 AC_HEADER_SYS_WAIT
155 AC_HEADER_TIME
156
157 libiberty_AC_DECLARE_ERRNO
158
159 # Determine the size of an int for struct fibnode.
160 AC_CHECK_SIZEOF([int])
161
162 AC_CHECK_TYPE(uintptr_t, unsigned long)
163
164 # Look for a 64-bit type.
165 AC_MSG_CHECKING([for a 64-bit type])
166 AC_CACHE_VAL(liberty_cv_uint64,
167 [AC_TRY_COMPILE(
168 [#ifdef HAVE_STDINT_H
169 #include <stdint.h>
170 #endif],
171 [extern uint64_t foo;],
172 liberty_cv_uint64=uint64_t,
173 [AC_TRY_COMPILE(
174 [#ifdef HAVE_LIMITS_H
175 #include <limits.h>
176 #endif
177 #ifndef CHAR_BIT
178 #define CHAR_BIT 8
179 #endif],
180 [extern char foo[sizeof(long) * CHAR_BIT >= 64 ? 1 : -1];],
181 liberty_cv_uint64="unsigned long",
182 [AC_TRY_COMPILE(
183 [#ifdef HAVE_LIMITS_H
184 #include <limits.h>
185 #endif
186 #ifndef CHAR_BIT
187 #define CHAR_BIT 8
188 #endif],
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.])
195 fi
196
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
199 # relies on it.
200 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
201
202 AC_TYPE_PID_T
203
204 # This is the list of functions which libiberty will provide if they
205 # are not available on the host.
206
207 funcs="asprintf"
208 funcs="$funcs atexit"
209 funcs="$funcs basename"
210 funcs="$funcs bcmp"
211 funcs="$funcs bcopy"
212 funcs="$funcs bsearch"
213 funcs="$funcs bzero"
214 funcs="$funcs calloc"
215 funcs="$funcs clock"
216 funcs="$funcs ffs"
217 funcs="$funcs getcwd"
218 funcs="$funcs getpagesize"
219 funcs="$funcs index"
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"
253
254 # Also in the old function.def file: alloca, vfork, getopt.
255
256 vars="sys_errlist sys_nerr sys_siglist"
257
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"
261
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.])
277 fi
278
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.
282
283 setobjs=
284 CHECK=
285 target_header_dir=
286 if test -n "${with_target_subdir}"; then
287
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
291 # native.
292
293 # If we are being configured for newlib, we know which functions
294 # newlib provide and which ones we will be expected to provide.
295
296 if test "x${with_newlib}" = "xyes"; then
297 AC_LIBOBJ([asprintf])
298 AC_LIBOBJ([basename])
299 AC_LIBOBJ([insque])
300 AC_LIBOBJ([random])
301 AC_LIBOBJ([strdup])
302 AC_LIBOBJ([vasprintf])
303
304 for f in $funcs; do
305 case "$f" in
306 asprintf | basename | insque | random | strdup | vasprintf)
307 ;;
308 *)
309 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
310 AC_DEFINE_UNQUOTED($n)
311 ;;
312 esac
313 done
314
315 # newlib doesnt provide any of the variables in $vars, so we
316 # dont have to check them here.
317
318 # Of the functions in $checkfuncs, newlib only has strerror.
319 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
320
321 setobjs=yes
322
323 fi
324
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
330
331 # Option parsed, now set things appropriately.
332 case x"$enable_install_libiberty" in
333 xyes|x)
334 target_header_dir=libiberty
335 ;;
336 xno)
337 target_header_dir=
338 ;;
339 *)
340 # This could be sanity-checked in various ways...
341 target_header_dir="${enable_install_libiberty}"
342 ;;
343 esac
344
345
346 else
347
348 # Not a target library, so we set things up to run the test suite.
349 CHECK=check-cplus-dem
350
351 fi
352
353 AC_SUBST(CHECK)
354 AC_SUBST(target_header_dir)
355
356 case "${host}" in
357 *-*-cygwin* | *-*-mingw*)
358 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
359 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
360 ;;
361 esac
362
363 if test -z "${setobjs}"; then
364 case "${host}" in
365
366 *-*-vxworks*)
367 # Handle VxWorks configuration specially, since on VxWorks the
368 # libraries are actually on the target board, not in the file
369 # system.
370 AC_LIBOBJ([basename])
371 AC_LIBOBJ([getpagesize])
372 AC_LIBOBJ([insque])
373 AC_LIBOBJ([random])
374 AC_LIBOBJ([strcasecmp])
375 AC_LIBOBJ([strncasecmp])
376 AC_LIBOBJ([strdup])
377 AC_LIBOBJ([vfork])
378 AC_LIBOBJ([waitpid])
379 AC_LIBOBJ([vasprintf])
380 for f in $funcs; do
381 case "$f" in
382 basename | getpagesize | insque | random | strcasecmp)
383 ;;
384 strncasecmp | strdup | vfork | waitpid | vasprintf)
385 ;;
386 *)
387 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
388 AC_DEFINE_UNQUOTED($n)
389 ;;
390 esac
391 done
392
393 # VxWorks doesn't provide any of the variables in $vars, so we
394 # don't have to check them here.
395
396 # Of the functions in $checkfuncs, VxWorks only has strerror.
397 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
398
399 setobjs=yes
400 ;;
401
402 esac
403 fi
404
405 if test -z "${setobjs}"; then
406
407 case "${host}" in
408
409 *-*-cygwin*)
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.
416
417 # We handle this by removing the functions the winsup library
418 # provides from our shell variables, so that they appear to be
419 # missing.
420
421 # DJ - only if we're *building* cygwin, not just building *with* cygwin
422
423 if test -n "${with_target_subdir}"
424 then
425 funcs="`echo $funcs | sed -e 's/random//'`"
426 AC_LIBOBJ([random])
427 vars="`echo $vars | sed -e 's/sys_siglist//'`"
428 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
429 fi
430 ;;
431
432 *-*-mingw32*)
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
437 ;;
438
439 *-*-uwin*)
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
449 ;;
450
451 *-*-*vms*)
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
454 # just force it.
455 ac_cv_func_vfork_works=yes
456 ;;
457
458 esac
459
460 # We haven't set the list of objects yet. Use the standard autoconf
461 # tests. This will only work if the compiler works.
462 AC_ISC_POSIX
463 AC_REPLACE_FUNCS($funcs)
464 libiberty_AC_FUNC_C_ALLOCA
465 AC_FUNC_FORK
466 if test $ac_cv_func_vfork_works = no; then
467 AC_LIBOBJ([vfork])
468 fi
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)
474 else
475 AC_CHECK_FUNCS(_doprnt)
476 fi
477
478 for v in $vars; do
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
485 AC_MSG_RESULT(yes)
486 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
487 AC_DEFINE_UNQUOTED($n)
488 else
489 AC_MSG_RESULT(no)
490 fi
491 done
492
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])])
502
503 AC_CHECK_FUNCS($checkfuncs)
504 libiberty_NEED_DECLARATION(canonicalize_file_name)
505 fi
506
507 # Figure out which version of pexecute to use.
508 case "${host}" in
509 *-*-mingw* | *-*-winnt*) pex=./pex-win32 ;;
510 *-*-msdosdjgpp*) pex=./pex-djgpp ;;
511 *-*-msdos*) pex=./pex-msdos ;;
512 *-*-os2-emx*) pex=./pex-os2 ;;
513 *) pex=./pex-unix ;;
514 esac
515 pexecute=${pex}.o
516 ltpexecute=${pex}.lo
517 AC_SUBST(pexecute)
518 AC_SUBST(ltpexecute)
519
520 libiberty_AC_FUNC_STRNCMP
521
522 # Install a library built with a cross compiler in $(tooldir) rather
523 # than $(libdir).
524 if test -z "${with_cross_host}"; then
525 INSTALL_DEST=libdir
526 else
527 INSTALL_DEST=tooldir
528 fi
529 AC_SUBST(INSTALL_DEST)
530
531 # Add `./' to avoid VPATH.
532 m4_pattern_allow(LIBOBJS)
533 L=""
534 for l in x $LIBOBJS; do
535 case $l in
536 x) ;;
537 *) L="$L ./$l" ;;
538 esac
539 done
540 LIBOBJS="$L"
541
542 m4_pattern_allow(LTLIBOBJS)
543 L=""
544 for l in x $LTLIBOBJS; do
545 case $l in
546 x) ;;
547 *) L="$L ./$l" ;;
548 esac
549 done
550 LTLIBOBJS="$L"
551
552 dnl Delete it when we start creating shared library with libtool.
553 AC_SUBST(enable_shared)
554
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
562 ac_file=Makefile
563 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
564 . ${libiberty_topdir}/config-ml.in
565 fi
566 fi]],
567 [[srcdir=${srcdir}
568 host=${host}
569 target=${target}
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}
576 ]])
577 AC_OUTPUT
This page took 0.042258 seconds and 5 git commands to generate.