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, :)
107 dnl When we start using libtool:
108 dnl Default to a non shared library. This may be overridden by the
109 dnl configure option --enable-shared.
110 dnl AM_DISABLE_SHARED
112 dnl When we start using libtool:
115 dnl When we start using automake:
116 dnl AM_CONFIG_HEADER(config.h:config.in)
117 AC_CONFIG_HEADER(config.h:config.in)
119 dnl When we start using automake:
120 dnl AM_MAINTAINER_MODE
123 dnl When we start using automake:
127 . ${srcdir}/config.table
128 host_makefile_frag=${frag}
129 AC_SUBST_FILE(host_makefile_frag)
131 # It's OK to check for header files. Although the compiler may not be
132 # able to link anything, it had better be able to at least compile
134 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)
138 libiberty_AC_DECLARE_ERRNO
140 AC_CHECK_TYPE(uintptr_t, unsigned long)
142 if test $ac_cv_type_uintptr_t = yes
144 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
149 # This is the list of functions which libiberty will provide if they
150 # are not available on the host.
153 funcs="$funcs atexit"
154 funcs="$funcs basename"
157 funcs="$funcs bsearch"
159 funcs="$funcs calloc"
162 funcs="$funcs getcwd"
163 funcs="$funcs getpagesize"
165 funcs="$funcs insque"
166 funcs="$funcs memchr"
167 funcs="$funcs memcmp"
168 funcs="$funcs memcpy"
169 funcs="$funcs memmove"
170 funcs="$funcs memset"
171 funcs="$funcs mkstemps"
172 funcs="$funcs putenv"
173 funcs="$funcs random"
174 funcs="$funcs rename"
175 funcs="$funcs rindex"
176 funcs="$funcs setenv"
177 funcs="$funcs sigsetmask"
178 funcs="$funcs strcasecmp"
179 funcs="$funcs strchr"
180 funcs="$funcs strdup"
181 funcs="$funcs strncasecmp"
182 funcs="$funcs strrchr"
183 funcs="$funcs strstr"
184 funcs="$funcs strtod"
185 funcs="$funcs strtol"
186 funcs="$funcs strtoul"
187 funcs="$funcs tmpnam"
188 funcs="$funcs vasprintf"
189 funcs="$funcs vfprintf"
190 funcs="$funcs vprintf"
191 funcs="$funcs vsprintf"
192 funcs="$funcs waitpid"
194 # Also in the old function.def file: alloca, vfork, getopt.
196 vars="sys_errlist sys_nerr sys_siglist"
198 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
200 # These are neither executed nor required, but they help keep
201 # autoheader happy without adding a bunch of text to acconfig.h.
202 if test "x" = "y"; then
203 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock)
204 AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy)
205 AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask)
206 AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
207 AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
208 AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
209 AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
210 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
211 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
212 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
215 # For each of these functions, if the host does not provide the
216 # function we want to put FN.o in LIBOBJS, and if the host does
217 # provide the function, we want to define HAVE_FN in config.h.
222 if test -n "${with_target_subdir}"; then
224 # We are being configured as a target library. AC_REPLACE_FUNCS
225 # may not work correctly, because the compiler may not be able to
226 # link executables. Note that we may still be being configured
229 # If we are being configured for newlib, we know which functions
230 # newlib provide and which ones we will be expected to provide.
232 if test "x${with_newlib}" = "xyes"; then
233 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
237 asprintf | basename | insque | random | strdup | vasprintf)
240 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
241 AC_DEFINE_UNQUOTED($n)
246 # newlib doesnt provide any of the variables in $vars, so we
247 # dont have to check them here.
249 # Of the functions in $checkfuncs, newlib only has strerror.
250 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
256 # We may wish to install the target headers somewhere.
257 AC_ARG_ENABLE(install-libiberty,
258 [ --enable-install-libiberty Install headers for end users],
259 enable_install_libiberty=$enableval,
260 enable_install_libiberty=no)dnl
262 # Option parsed, now set things appropriately.
263 case x"$enable_install_libiberty" in
265 target_header_dir=libiberty
271 # This could be sanity-checked in various ways...
272 target_header_dir="${enable_install_libiberty}"
279 # Not a target library, so we set things up to run the test suite.
280 CHECK=check-cplus-dem
285 AC_SUBST(target_header_dir)
288 *-*-cygwin* | *-*-mingw*)
289 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
290 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
294 if test -z "${setobjs}"; then
298 # Handle VxWorks configuration specially, since on VxWorks the
299 # libraries are actually on the target board, not in the file
301 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
302 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
305 basename | getpagesize | insque | random | strcasecmp)
307 strncasecmp | strdup | vfork | waitpid | vasprintf)
310 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
311 AC_DEFINE_UNQUOTED($n)
316 # VxWorks doesn't provide any of the variables in $vars, so we
317 # don't have to check them here.
319 # Of the functions in $checkfuncs, VxWorks only has strerror.
320 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
328 if test -z "${setobjs}"; then
333 # The Cygwin library actually uses a couple of files from
334 # libiberty when it is built. If we are building a native
335 # Cygwin, and we run the tests, we will appear to have these
336 # files. However, when we go on to build winsup, we will wind up
337 # with a library which does not have the files, since they should
338 # have come from libiberty.
340 # We handle this by removing the functions the winsup library
341 # provides from our shell variables, so that they appear to be
344 # DJ - only if we're *building* cygwin, not just building *with* cygwin
346 if test -n "${with_target_subdir}"
348 funcs="`echo $funcs | sed -e 's/random//'`"
349 LIBOBJS="$LIBOBJS random.o"
350 vars="`echo $vars | sed -e 's/sys_siglist//'`"
351 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
356 # Under mingw32, sys_nerr and sys_errlist exist, but they are
357 # macros, so the test below won't find them.
358 libiberty_cv_var_sys_nerr=yes
359 libiberty_cv_var_sys_errlist=yes
363 # Under some versions of uwin, vfork is notoriously buggy and the test
364 # can hang configure; on other versions, vfork exists just as a stub.
365 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
366 ac_cv_func_vfork_works=no
367 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
368 # macros (actually, these are imported from a DLL, but the end effect
369 # is the same), so the test below won't find them.
370 libiberty_cv_var_sys_nerr=yes
371 libiberty_cv_var_sys_errlist=yes
375 # Under VMS, vfork works very different than on Unix. The standard test
376 # won't work, and it isn't easily adaptable. It makes more sense to
378 ac_cv_func_vfork_works=yes
383 # We haven't set the list of objects yet. Use the standard autoconf
384 # tests. This will only work if the compiler works.
386 AC_REPLACE_FUNCS($funcs)
387 libiberty_AC_FUNC_C_ALLOCA
389 if test $ac_cv_func_vfork_works = no; then
390 LIBOBJS="$LIBOBJS vfork.o"
392 # We only need _doprnt if we might use it to implement v*printf.
393 if test $ac_cv_func_vprintf != yes \
394 || test $ac_cv_func_vfprintf != yes \
395 || test $ac_cv_func_vsprintf != yes; then
396 AC_REPLACE_FUNCS(_doprnt)
398 AC_CHECK_FUNCS(_doprnt)
402 AC_MSG_CHECKING([for $v])
403 AC_CACHE_VAL(libiberty_cv_var_$v,
404 [AC_TRY_LINK([int *p;], [extern int $v []; p = $v;],
405 [eval "libiberty_cv_var_$v=yes"],
406 [eval "libiberty_cv_var_$v=no"])])
407 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
409 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
410 AC_DEFINE_UNQUOTED($n)
415 AC_CHECK_FUNCS($checkfuncs)
418 libiberty_AC_FUNC_STRNCMP
420 # Install a library built with a cross compiler in $(tooldir) rather
422 if test -z "${with_cross_host}"; then
427 AC_SUBST(INSTALL_DEST)
429 # We need multilib support, but only if configuring for the target.
430 AC_OUTPUT(Makefile testsuite/Makefile,
431 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
432 if test -n "$CONFIG_FILES"; then
433 if test -n "${with_build_subdir}" || test -n "${with_target_subdir}"; then
434 # FIXME: We shouldn't need to set ac_file
436 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
437 . ${libiberty_topdir}/config-ml.in
443 with_target_subdir=${with_target_subdir}
444 with_build_subdir=${with_build_subdir}
445 with_multisubdir=${with_multisubdir}
446 ac_configure_args="--enable-multilib ${ac_configure_args}"
447 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
448 libiberty_topdir=${libiberty_topdir}