*** empty log message ***
[deliverable/binutils-gdb.git] / libiberty / configure.in
CommitLineData
252b5132
RH
1dnl Process this file with autoconf to produce a configure script
2
0c0a36a4 3AC_PREREQ(2.13)
5a17353c 4AC_INIT(xmalloc.c)
252b5132 5
52d98c2d
DD
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...
10ORIGINAL_LD_FOR_MULTILIBS=$LD
11
252b5132
RH
12dnl We use these options to decide which functions to include.
13AC_ARG_WITH(target-subdir,
cfed0715
DD
14[ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
15AC_ARG_WITH(build-subdir,
16[ --with-build-subdir=SUBDIR Configuring in a subdirectory for build])
252b5132
RH
17AC_ARG_WITH(cross-host,
18[ --with-cross-host=HOST Configuring with a cross compiler])
19AC_ARG_WITH(newlib,
20[ --with-newlib Configuring with newlib])
21
22if test "${srcdir}" = "."; then
cfed0715
DD
23 if test -n "${with_build_subdir}"; then
24 libiberty_topdir="${srcdir}/../.."
25 with_target_subdir=
26 elif test -z "${with_target_subdir}"; then
252b5132
RH
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
35else
36 libiberty_topdir="${srcdir}/.."
37fi
85b9a938 38AC_SUBST(libiberty_topdir)
252b5132
RH
39AC_CONFIG_AUX_DIR($libiberty_topdir)
40
39423523
DD
41dnl Very limited version of automake's enable-maintainer-mode
42
43AC_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
52AC_MSG_RESULT($maintainer_mode)
53
54if test "$maintainer_mode" = "yes"; then
55 MAINT=''
56 NOTMAINT='#'
57else
58 MAINT='#'
59 NOTMAINT=''
60fi
61AC_SUBST(MAINT)dnl
62AC_SUBST(NOTMAINT)dnl
63
fa9f0e33
DD
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.
66AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
1a78a35a
DD
67if test "x$MAKEINFO" = "x"; then
68 MAKEINFO="@echo makeinfo missing; true"
fa9f0e33 69 BUILD_INFO=
1a78a35a
DD
70else
71 BUILD_INFO=info
72 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
73 x*\ [[1-3]].* )
74 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
75 BUILD_INFO=
76 AC_MSG_WARN([
fa9f0e33 77*** Makeinfo is too old. Info documentation will not be built.])
1a78a35a
DD
78 ;;
79 esac
80fi
fa9f0e33 81AC_SUBST(MAKEINFO)
39423523
DD
82AC_SUBST(BUILD_INFO)
83
84AC_CHECK_PROG(PERL, perl, perl, )
85if test x"$PERL" = x""; then
86 HAVE_PERL='#'
87else
88 HAVE_PERL=''
89fi
90AC_SUBST(HAVE_PERL)
91
252b5132
RH
92AC_CANONICAL_HOST
93
94dnl When we start using automake:
95dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
96
97dnl These must be called before AM_PROG_LIBTOOL, because it may want
98dnl to call AC_CHECK_PROG.
99AC_CHECK_TOOL(AR, ar)
100AC_CHECK_TOOL(RANLIB, ranlib, :)
101
252b5132
RH
102LIB_AC_PROG_CC
103
b39b76b8
DD
104AC_PROG_CC_C_O
105# autoconf is lame and doesn't give us any substitution variable for this.
106if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
107 NO_MINUS_C_MINUS_O=yes
108else
109 OUTPUT_OPTION='-o $@'
110fi
111AC_SUBST(NO_MINUS_C_MINUS_O)
112AC_SUBST(OUTPUT_OPTION)
113
252b5132 114AC_ISC_POSIX
2ea7befd
DD
115AC_C_CONST
116AC_C_INLINE
7108c5dc 117AC_C_BIGENDIAN_CROSS
252b5132
RH
118
119dnl When we start using libtool:
120dnl Default to a non shared library. This may be overridden by the
121dnl configure option --enable-shared.
122dnl AM_DISABLE_SHARED
123
124dnl When we start using libtool:
125dnl AM_PROG_LIBTOOL
126
127dnl When we start using automake:
128dnl AM_CONFIG_HEADER(config.h:config.in)
129AC_CONFIG_HEADER(config.h:config.in)
130
131dnl When we start using automake:
132dnl AM_MAINTAINER_MODE
133dnl AC_EXEEXT
134
135dnl When we start using automake:
136dnl AM_PROG_INSTALL
137AC_PROG_INSTALL
138
139. ${srcdir}/config.table
140host_makefile_frag=${frag}
141AC_SUBST_FILE(host_makefile_frag)
142
143# It's OK to check for header files. Although the compiler may not be
144# able to link anything, it had better be able to at least compile
145# something.
cc529274 146AC_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)
252b5132 147AC_HEADER_SYS_WAIT
62df2065 148AC_HEADER_TIME
252b5132 149
7d3ffcaf
JL
150libiberty_AC_DECLARE_ERRNO
151
15ae9e71 152AC_CHECK_TYPE(uintptr_t, unsigned long)
daf7c4ad
DD
153# Given the above check, we always have uintptr_t or a fallback
154# definition. So define HAVE_UINTPTR_T in case any imported code
155# relies on it.
156AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
dc579051 157
cafa3917
DD
158AC_TYPE_PID_T
159
252b5132
RH
160# This is the list of functions which libiberty will provide if they
161# are not available on the host.
162
163funcs="asprintf"
164funcs="$funcs atexit"
165funcs="$funcs basename"
166funcs="$funcs bcmp"
167funcs="$funcs bcopy"
c6da642e 168funcs="$funcs bsearch"
252b5132
RH
169funcs="$funcs bzero"
170funcs="$funcs calloc"
171funcs="$funcs clock"
7b78baae 172funcs="$funcs ffs"
252b5132
RH
173funcs="$funcs getcwd"
174funcs="$funcs getpagesize"
175funcs="$funcs index"
176funcs="$funcs insque"
177funcs="$funcs memchr"
178funcs="$funcs memcmp"
179funcs="$funcs memcpy"
180funcs="$funcs memmove"
10b57b38 181funcs="$funcs mempcpy"
252b5132
RH
182funcs="$funcs memset"
183funcs="$funcs mkstemps"
0c0a36a4 184funcs="$funcs putenv"
252b5132
RH
185funcs="$funcs random"
186funcs="$funcs rename"
187funcs="$funcs rindex"
0c0a36a4 188funcs="$funcs setenv"
2ed1e5cc 189funcs="$funcs snprintf"
252b5132 190funcs="$funcs sigsetmask"
10b57b38
DD
191funcs="$funcs stpcpy"
192funcs="$funcs stpncpy"
252b5132
RH
193funcs="$funcs strcasecmp"
194funcs="$funcs strchr"
195funcs="$funcs strdup"
196funcs="$funcs strncasecmp"
197funcs="$funcs strrchr"
198funcs="$funcs strstr"
199funcs="$funcs strtod"
200funcs="$funcs strtol"
201funcs="$funcs strtoul"
202funcs="$funcs tmpnam"
203funcs="$funcs vasprintf"
204funcs="$funcs vfprintf"
205funcs="$funcs vprintf"
2ed1e5cc 206funcs="$funcs vsnprintf"
252b5132
RH
207funcs="$funcs vsprintf"
208funcs="$funcs waitpid"
209
210# Also in the old function.def file: alloca, vfork, getopt.
211
cc529274 212vars="sys_errlist sys_nerr sys_siglist _system_configuration"
252b5132 213
0c0a36a4 214checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
192cbe66 215checkfuncs="$checkfuncs realpath canonicalize_file_name pstat_getstatic pstat_getdynamic sysmp"
cc529274 216checkfuncs="$checkfuncs getsysinfo table sysctl"
252b5132
RH
217
218# These are neither executed nor required, but they help keep
219# autoheader happy without adding a bunch of text to acconfig.h.
220if test "x" = "y"; then
0b555173
DD
221 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock \
222 getcwd getpagesize index insque mkstemps memchr memcmp memcpy \
223 memmove mempcpy memset putenv random rename rindex sigsetmask \
224 strcasecmp setenv stpcpy stpncpy strchr strdup strncasecmp strrchr strstr \
225 strtod strtol strtoul tmpnam vasprintf vfprintf vprintf \
226 vsprintf waitpid getrusage on_exit psignal strerror strsignal \
227 sysconf times sbrk gettimeofday ffs snprintf vsnprintf \
228 pstat_getstatic pstat_getdynamic sysmp getsysinfo table sysctl \
229 realpath canonicalize_file_name)
2ea7befd
DD
230 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
231 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
232 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
cc529274 233 AC_DEFINE(HAVE__SYSTEM_CONFIGURATION, 1, [Define if you have the _system_configuration variable.])
252b5132
RH
234fi
235
236# For each of these functions, if the host does not provide the
237# function we want to put FN.o in LIBOBJS, and if the host does
30673bf5 238# provide the function, we want to define HAVE_FN in config.h.
252b5132
RH
239
240setobjs=
0c0a36a4 241CHECK=
50d4562d 242target_header_dir=
252b5132
RH
243if test -n "${with_target_subdir}"; then
244
245 # We are being configured as a target library. AC_REPLACE_FUNCS
246 # may not work correctly, because the compiler may not be able to
247 # link executables. Note that we may still be being configured
248 # native.
249
250 # If we are being configured for newlib, we know which functions
251 # newlib provide and which ones we will be expected to provide.
252
253 if test "x${with_newlib}" = "xyes"; then
252b5132
RH
254 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
255
256 for f in $funcs; do
257 case "$f" in
258 asprintf | basename | insque | random | strdup | vasprintf)
259 ;;
260 *)
261 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
262 AC_DEFINE_UNQUOTED($n)
263 ;;
264 esac
265 done
266
267 # newlib doesnt provide any of the variables in $vars, so we
268 # dont have to check them here.
269
270 # Of the functions in $checkfuncs, newlib only has strerror.
2ea7befd 271 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
252b5132
RH
272
273 setobjs=yes
274
275 fi
0c0a36a4 276
50d4562d
DD
277 # We may wish to install the target headers somewhere.
278 AC_ARG_ENABLE(install-libiberty,
279 [ --enable-install-libiberty Install headers for end users],
280 enable_install_libiberty=$enableval,
281 enable_install_libiberty=no)dnl
282
283 # Option parsed, now set things appropriately.
284 case x"$enable_install_libiberty" in
285 xyes|x)
286 target_header_dir=libiberty
287 ;;
288 xno)
289 target_header_dir=
290 ;;
291 *)
292 # This could be sanity-checked in various ways...
293 target_header_dir="${enable_install_libiberty}"
294 ;;
295 esac
296
297
0c0a36a4
ILT
298else
299
300 # Not a target library, so we set things up to run the test suite.
301 CHECK=check-cplus-dem
302
252b5132
RH
303fi
304
0c0a36a4 305AC_SUBST(CHECK)
50d4562d 306AC_SUBST(target_header_dir)
0c0a36a4 307
f01b59ed 308case "${host}" in
bef8b55d 309 *-*-cygwin* | *-*-mingw*)
24acd898
DD
310 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
311 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
f01b59ed
DD
312 ;;
313esac
314
252b5132
RH
315if test -z "${setobjs}"; then
316 case "${host}" in
317
318 *-*-vxworks*)
319 # Handle VxWorks configuration specially, since on VxWorks the
320 # libraries are actually on the target board, not in the file
321 # system.
322 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
323 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
324 for f in $funcs; do
325 case "$f" in
326 basename | getpagesize | insque | random | strcasecmp)
327 ;;
328 strncasecmp | strdup | vfork | waitpid | vasprintf)
329 ;;
330 *)
331 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
332 AC_DEFINE_UNQUOTED($n)
333 ;;
334 esac
335 done
336
337 # VxWorks doesn't provide any of the variables in $vars, so we
338 # don't have to check them here.
339
340 # Of the functions in $checkfuncs, VxWorks only has strerror.
2ea7befd 341 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
252b5132
RH
342
343 setobjs=yes
344 ;;
345
346 esac
347fi
348
349if test -z "${setobjs}"; then
350
351 case "${host}" in
352
353 *-*-cygwin*)
354 # The Cygwin library actually uses a couple of files from
355 # libiberty when it is built. If we are building a native
356 # Cygwin, and we run the tests, we will appear to have these
357 # files. However, when we go on to build winsup, we will wind up
358 # with a library which does not have the files, since they should
359 # have come from libiberty.
360
361 # We handle this by removing the functions the winsup library
362 # provides from our shell variables, so that they appear to be
363 # missing.
364
64e3a659
DD
365 # DJ - only if we're *building* cygwin, not just building *with* cygwin
366
367 if test -n "${with_target_subdir}"
368 then
369 funcs="`echo $funcs | sed -e 's/random//'`"
370 LIBOBJS="$LIBOBJS random.o"
371 vars="`echo $vars | sed -e 's/sys_siglist//'`"
372 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
373 fi
252b5132
RH
374 ;;
375
376 *-*-mingw32*)
377 # Under mingw32, sys_nerr and sys_errlist exist, but they are
378 # macros, so the test below won't find them.
2ea7befd
DD
379 libiberty_cv_var_sys_nerr=yes
380 libiberty_cv_var_sys_errlist=yes
252b5132
RH
381 ;;
382
383 *-*-uwin*)
384 # Under some versions of uwin, vfork is notoriously buggy and the test
385 # can hang configure; on other versions, vfork exists just as a stub.
386 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
387 ac_cv_func_vfork_works=no
0c0a36a4
ILT
388 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
389 # macros (actually, these are imported from a DLL, but the end effect
390 # is the same), so the test below won't find them.
2ea7befd
DD
391 libiberty_cv_var_sys_nerr=yes
392 libiberty_cv_var_sys_errlist=yes
252b5132
RH
393 ;;
394
c0eb281b
DD
395 *-*-*vms*)
396 # Under VMS, vfork works very different than on Unix. The standard test
397 # won't work, and it isn't easily adaptable. It makes more sense to
398 # just force it.
399 ac_cv_func_vfork_works=yes
400 ;;
401
252b5132
RH
402 esac
403
404 # We haven't set the list of objects yet. Use the standard autoconf
405 # tests. This will only work if the compiler works.
406 AC_PROG_CC_WORKS
407 AC_REPLACE_FUNCS($funcs)
30673bf5 408 libiberty_AC_FUNC_C_ALLOCA
252b5132
RH
409 AC_FUNC_VFORK
410 if test $ac_cv_func_vfork_works = no; then
411 LIBOBJS="$LIBOBJS vfork.o"
412 fi
24acd898
DD
413 # We only need _doprnt if we might use it to implement v*printf.
414 if test $ac_cv_func_vprintf != yes \
415 || test $ac_cv_func_vfprintf != yes \
416 || test $ac_cv_func_vsprintf != yes; then
417 AC_REPLACE_FUNCS(_doprnt)
cc096b71
DD
418 else
419 AC_CHECK_FUNCS(_doprnt)
24acd898
DD
420 fi
421
252b5132
RH
422 for v in $vars; do
423 AC_MSG_CHECKING([for $v])
424 AC_CACHE_VAL(libiberty_cv_var_$v,
18893690 425 [AC_TRY_LINK([int *p;], [extern int $v []; p = $v;],
252b5132
RH
426 [eval "libiberty_cv_var_$v=yes"],
427 [eval "libiberty_cv_var_$v=no"])])
428 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
429 AC_MSG_RESULT(yes)
430 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
431 AC_DEFINE_UNQUOTED($n)
432 else
433 AC_MSG_RESULT(no)
434 fi
435 done
436 AC_CHECK_FUNCS($checkfuncs)
ba61a412 437 libiberty_NEED_DECLARATION(canonicalize_file_name)
252b5132
RH
438fi
439
5a17353c
DD
440# Figure out which version of pexecute to use.
441case "${host}" in
5a17353c
DD
442 *-*-mingw* | *-*-winnt*) pexecute=pex-win32.o ;;
443 *-*-msdosdjgpp*) pexecute=pex-djgpp.o ;;
444 *-*-msdos*) pexecute=pex-msdos.o ;;
445 *-*-os2-emx*) pexecute=pex-os2.o ;;
446 *) pexecute=pex-unix.o ;;
447esac
448AC_SUBST(pexecute)
449
eb383413
L
450libiberty_AC_FUNC_STRNCMP
451
252b5132
RH
452# Install a library built with a cross compiler in $(tooldir) rather
453# than $(libdir).
454if test -z "${with_cross_host}"; then
455 INSTALL_DEST=libdir
456else
457 INSTALL_DEST=tooldir
458fi
459AC_SUBST(INSTALL_DEST)
460
461# We need multilib support, but only if configuring for the target.
0c0a36a4 462AC_OUTPUT(Makefile testsuite/Makefile,
252b5132
RH
463[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
464if test -n "$CONFIG_FILES"; then
cfed0715 465 if test -n "${with_build_subdir}" || test -n "${with_target_subdir}"; then
252b5132
RH
466 # FIXME: We shouldn't need to set ac_file
467 ac_file=Makefile
52d98c2d 468 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
252b5132
RH
469 . ${libiberty_topdir}/config-ml.in
470 fi
471fi],
472srcdir=${srcdir}
473host=${host}
474target=${target}
475with_target_subdir=${with_target_subdir}
cfed0715 476with_build_subdir=${with_build_subdir}
252b5132
RH
477with_multisubdir=${with_multisubdir}
478ac_configure_args="--enable-multilib ${ac_configure_args}"
479CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
8b90eef4 480ORIGINAL_LD_FOR_MULTILIBS="${ORIGINAL_LD_FOR_MULTILIBS}"
252b5132
RH
481libiberty_topdir=${libiberty_topdir}
482)
This page took 0.197061 seconds and 4 git commands to generate.