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_CONFIG_AUX_DIR($libiberty_topdir)
40 dnl Very limited version of automake's enable-maintainer-mode
42 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
43 dnl maintainer-mode is disabled by default
44 AC_ARG_ENABLE(maintainer-mode,
45 [ --enable-maintainer-mode
46 enable make rules and dependencies not useful
47 (and sometimes confusing) to the casual installer],
48 maintainer_mode=$enableval,
51 AC_MSG_RESULT($maintainer_mode)
53 if test "$maintainer_mode" = "yes"; then
63 # Do we have a single-tree copy of texinfo? Even if we do, we can't
64 # rely on it - libiberty is built before texinfo.
65 AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
66 if test "x$MAKEINFO" = "x"; then
67 MAKEINFO="@echo makeinfo missing; true"
71 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
73 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
76 *** Makeinfo is too old. Info documentation will not be built.])
83 AC_CHECK_PROG(PERL, perl, perl, )
84 if test x"$PERL" = x""; then
93 dnl When we start using automake:
94 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
96 dnl These must be called before AM_PROG_LIBTOOL, because it may want
97 dnl to call AC_CHECK_PROG.
99 AC_CHECK_TOOL(RANLIB, ranlib, :)
104 # autoconf is lame and doesn't give us any substitution variable for this.
105 if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
106 NO_MINUS_C_MINUS_O=yes
108 OUTPUT_OPTION='-o $@'
110 AC_SUBST(NO_MINUS_C_MINUS_O)
111 AC_SUBST(OUTPUT_OPTION)
117 dnl When we start using libtool:
118 dnl Default to a non shared library. This may be overridden by the
119 dnl configure option --enable-shared.
120 dnl AM_DISABLE_SHARED
122 dnl When we start using libtool:
125 dnl When we start using automake:
126 dnl AM_CONFIG_HEADER(config.h:config.in)
127 AC_CONFIG_HEADER(config.h:config.in)
129 dnl When we start using automake:
130 dnl AM_MAINTAINER_MODE
133 dnl When we start using automake:
137 . ${srcdir}/config.table
138 host_makefile_frag=${frag}
139 AC_SUBST_FILE(host_makefile_frag)
141 # It's OK to check for header files. Although the compiler may not be
142 # able to link anything, it had better be able to at least compile
144 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)
148 libiberty_AC_DECLARE_ERRNO
150 AC_CHECK_TYPE(uintptr_t, unsigned long)
152 if test $ac_cv_type_uintptr_t = yes
154 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
159 # This is the list of functions which libiberty will provide if they
160 # are not available on the host.
163 funcs="$funcs atexit"
164 funcs="$funcs basename"
167 funcs="$funcs bsearch"
169 funcs="$funcs calloc"
172 funcs="$funcs getcwd"
173 funcs="$funcs getpagesize"
175 funcs="$funcs insque"
176 funcs="$funcs memchr"
177 funcs="$funcs memcmp"
178 funcs="$funcs memcpy"
179 funcs="$funcs memmove"
180 funcs="$funcs memset"
181 funcs="$funcs mkstemps"
182 funcs="$funcs putenv"
183 funcs="$funcs random"
184 funcs="$funcs rename"
185 funcs="$funcs rindex"
186 funcs="$funcs setenv"
187 funcs="$funcs sigsetmask"
188 funcs="$funcs strcasecmp"
189 funcs="$funcs strchr"
190 funcs="$funcs strdup"
191 funcs="$funcs strncasecmp"
192 funcs="$funcs strrchr"
193 funcs="$funcs strstr"
194 funcs="$funcs strtod"
195 funcs="$funcs strtol"
196 funcs="$funcs strtoul"
197 funcs="$funcs tmpnam"
198 funcs="$funcs vasprintf"
199 funcs="$funcs vfprintf"
200 funcs="$funcs vprintf"
201 funcs="$funcs vsprintf"
202 funcs="$funcs waitpid"
204 # Also in the old function.def file: alloca, vfork, getopt.
206 vars="sys_errlist sys_nerr sys_siglist"
208 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
210 # These are neither executed nor required, but they help keep
211 # autoheader happy without adding a bunch of text to acconfig.h.
212 if test "x" = "y"; then
213 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock)
214 AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy)
215 AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask)
216 AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
217 AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
218 AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
219 AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
220 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
221 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
222 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
225 # For each of these functions, if the host does not provide the
226 # function we want to put FN.o in LIBOBJS, and if the host does
227 # provide the function, we want to define HAVE_FN in config.h.
232 if test -n "${with_target_subdir}"; then
234 # We are being configured as a target library. AC_REPLACE_FUNCS
235 # may not work correctly, because the compiler may not be able to
236 # link executables. Note that we may still be being configured
239 # If we are being configured for newlib, we know which functions
240 # newlib provide and which ones we will be expected to provide.
242 if test "x${with_newlib}" = "xyes"; then
243 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
247 asprintf | basename | insque | random | strdup | vasprintf)
250 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
251 AC_DEFINE_UNQUOTED($n)
256 # newlib doesnt provide any of the variables in $vars, so we
257 # dont have to check them here.
259 # Of the functions in $checkfuncs, newlib only has strerror.
260 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
266 # We may wish to install the target headers somewhere.
267 AC_ARG_ENABLE(install-libiberty,
268 [ --enable-install-libiberty Install headers for end users],
269 enable_install_libiberty=$enableval,
270 enable_install_libiberty=no)dnl
272 # Option parsed, now set things appropriately.
273 case x"$enable_install_libiberty" in
275 target_header_dir=libiberty
281 # This could be sanity-checked in various ways...
282 target_header_dir="${enable_install_libiberty}"
289 # Not a target library, so we set things up to run the test suite.
290 CHECK=check-cplus-dem
295 AC_SUBST(target_header_dir)
298 *-*-cygwin* | *-*-mingw*)
299 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
300 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
304 if test -z "${setobjs}"; then
308 # Handle VxWorks configuration specially, since on VxWorks the
309 # libraries are actually on the target board, not in the file
311 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
312 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
315 basename | getpagesize | insque | random | strcasecmp)
317 strncasecmp | strdup | vfork | waitpid | vasprintf)
320 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
321 AC_DEFINE_UNQUOTED($n)
326 # VxWorks doesn't provide any of the variables in $vars, so we
327 # don't have to check them here.
329 # Of the functions in $checkfuncs, VxWorks only has strerror.
330 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
338 if test -z "${setobjs}"; then
343 # The Cygwin library actually uses a couple of files from
344 # libiberty when it is built. If we are building a native
345 # Cygwin, and we run the tests, we will appear to have these
346 # files. However, when we go on to build winsup, we will wind up
347 # with a library which does not have the files, since they should
348 # have come from libiberty.
350 # We handle this by removing the functions the winsup library
351 # provides from our shell variables, so that they appear to be
354 # DJ - only if we're *building* cygwin, not just building *with* cygwin
356 if test -n "${with_target_subdir}"
358 funcs="`echo $funcs | sed -e 's/random//'`"
359 LIBOBJS="$LIBOBJS random.o"
360 vars="`echo $vars | sed -e 's/sys_siglist//'`"
361 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
366 # Under mingw32, sys_nerr and sys_errlist exist, but they are
367 # macros, so the test below won't find them.
368 libiberty_cv_var_sys_nerr=yes
369 libiberty_cv_var_sys_errlist=yes
373 # Under some versions of uwin, vfork is notoriously buggy and the test
374 # can hang configure; on other versions, vfork exists just as a stub.
375 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
376 ac_cv_func_vfork_works=no
377 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
378 # macros (actually, these are imported from a DLL, but the end effect
379 # is the same), so the test below won't find them.
380 libiberty_cv_var_sys_nerr=yes
381 libiberty_cv_var_sys_errlist=yes
385 # Under VMS, vfork works very different than on Unix. The standard test
386 # won't work, and it isn't easily adaptable. It makes more sense to
388 ac_cv_func_vfork_works=yes
393 # We haven't set the list of objects yet. Use the standard autoconf
394 # tests. This will only work if the compiler works.
396 AC_REPLACE_FUNCS($funcs)
397 libiberty_AC_FUNC_C_ALLOCA
399 if test $ac_cv_func_vfork_works = no; then
400 LIBOBJS="$LIBOBJS vfork.o"
402 # We only need _doprnt if we might use it to implement v*printf.
403 if test $ac_cv_func_vprintf != yes \
404 || test $ac_cv_func_vfprintf != yes \
405 || test $ac_cv_func_vsprintf != yes; then
406 AC_REPLACE_FUNCS(_doprnt)
408 AC_CHECK_FUNCS(_doprnt)
412 AC_MSG_CHECKING([for $v])
413 AC_CACHE_VAL(libiberty_cv_var_$v,
414 [AC_TRY_LINK([int *p;], [extern int $v []; p = $v;],
415 [eval "libiberty_cv_var_$v=yes"],
416 [eval "libiberty_cv_var_$v=no"])])
417 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
419 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
420 AC_DEFINE_UNQUOTED($n)
425 AC_CHECK_FUNCS($checkfuncs)
428 libiberty_AC_FUNC_STRNCMP
430 # Install a library built with a cross compiler in $(tooldir) rather
432 if test -z "${with_cross_host}"; then
437 AC_SUBST(INSTALL_DEST)
439 # We need multilib support, but only if configuring for the target.
440 AC_OUTPUT(Makefile testsuite/Makefile,
441 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
442 if test -n "$CONFIG_FILES"; then
443 if test -n "${with_build_subdir}" || test -n "${with_target_subdir}"; then
444 # FIXME: We shouldn't need to set ac_file
446 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
447 . ${libiberty_topdir}/config-ml.in
453 with_target_subdir=${with_target_subdir}
454 with_build_subdir=${with_build_subdir}
455 with_multisubdir=${with_multisubdir}
456 ac_configure_args="--enable-multilib ${ac_configure_args}"
457 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
458 libiberty_topdir=${libiberty_topdir}