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])
15 AC_ARG_WITH(cross-host,
16 [ --with-cross-host=HOST Configuring with a cross compiler])
18 [ --with-newlib Configuring with newlib])
20 if test "${srcdir}" = "."; then
21 if test -z "${with_target_subdir}"; then
22 libiberty_topdir="${srcdir}/.."
24 if test "${with_target_subdir}" != "."; then
25 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
27 libiberty_topdir="${srcdir}/${with_multisrctop}.."
31 libiberty_topdir="${srcdir}/.."
33 AC_CONFIG_AUX_DIR($libiberty_topdir)
35 dnl Very limited version of automake's enable-maintainer-mode
37 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
38 dnl maintainer-mode is disabled by default
39 AC_ARG_ENABLE(maintainer-mode,
40 [ --enable-maintainer-mode
41 enable make rules and dependencies not useful
42 (and sometimes confusing) to the casual installer],
43 maintainer_mode=$enableval,
46 AC_MSG_RESULT($maintainer_mode)
48 if test "$maintainer_mode" = "yes"; then
58 # Do we have a single-tree copy of texinfo? Even if we do, we can't
59 # rely on it - libiberty is built before texinfo.
60 AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
61 if test "x$MAKEINFO" = "x"; then
62 MAKEINFO="@echo makeinfo missing; true"
66 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
68 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
71 *** Makeinfo is too old. Info documentation will not be built.])
78 AC_CHECK_PROG(PERL, perl, perl, )
79 if test x"$PERL" = x""; then
88 dnl When we start using automake:
89 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
91 dnl These must be called before AM_PROG_LIBTOOL, because it may want
92 dnl to call AC_CHECK_PROG.
94 AC_CHECK_TOOL(RANLIB, ranlib, :)
102 dnl When we start using libtool:
103 dnl Default to a non shared library. This may be overridden by the
104 dnl configure option --enable-shared.
105 dnl AM_DISABLE_SHARED
107 dnl When we start using libtool:
110 dnl When we start using automake:
111 dnl AM_CONFIG_HEADER(config.h:config.in)
112 AC_CONFIG_HEADER(config.h:config.in)
114 dnl When we start using automake:
115 dnl AM_MAINTAINER_MODE
118 dnl When we start using automake:
122 . ${srcdir}/config.table
123 host_makefile_frag=${frag}
124 AC_SUBST_FILE(host_makefile_frag)
126 # It's OK to check for header files. Although the compiler may not be
127 # able to link anything, it had better be able to at least compile
129 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)
133 libiberty_AC_DECLARE_ERRNO
135 AC_CHECK_TYPE(uintptr_t, unsigned long)
137 if test $ac_cv_type_uintptr_t = yes
139 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
142 # This is the list of functions which libiberty will provide if they
143 # are not available on the host.
146 funcs="$funcs atexit"
147 funcs="$funcs basename"
150 funcs="$funcs bsearch"
152 funcs="$funcs calloc"
155 funcs="$funcs getcwd"
156 funcs="$funcs getpagesize"
158 funcs="$funcs insque"
159 funcs="$funcs memchr"
160 funcs="$funcs memcmp"
161 funcs="$funcs memcpy"
162 funcs="$funcs memmove"
163 funcs="$funcs memset"
164 funcs="$funcs mkstemps"
165 funcs="$funcs putenv"
166 funcs="$funcs random"
167 funcs="$funcs rename"
168 funcs="$funcs rindex"
169 funcs="$funcs setenv"
170 funcs="$funcs sigsetmask"
171 funcs="$funcs strcasecmp"
172 funcs="$funcs strchr"
173 funcs="$funcs strdup"
174 funcs="$funcs strncasecmp"
175 funcs="$funcs strrchr"
176 funcs="$funcs strstr"
177 funcs="$funcs strtod"
178 funcs="$funcs strtol"
179 funcs="$funcs strtoul"
180 funcs="$funcs tmpnam"
181 funcs="$funcs vasprintf"
182 funcs="$funcs vfprintf"
183 funcs="$funcs vprintf"
184 funcs="$funcs vsprintf"
185 funcs="$funcs waitpid"
187 # Also in the old function.def file: alloca, vfork, getopt.
189 vars="sys_errlist sys_nerr sys_siglist"
191 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
193 # These are neither executed nor required, but they help keep
194 # autoheader happy without adding a bunch of text to acconfig.h.
195 if test "x" = "y"; then
196 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock)
197 AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy)
198 AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask)
199 AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
200 AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
201 AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
202 AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
203 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
204 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
205 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
208 # For each of these functions, if the host does not provide the
209 # function we want to put FN.o in LIBOBJS, and if the host does
210 # provide the function, we want to define HAVE_FN in config.h.
214 if test -n "${with_target_subdir}"; then
216 # We are being configured as a target library. AC_REPLACE_FUNCS
217 # may not work correctly, because the compiler may not be able to
218 # link executables. Note that we may still be being configured
221 # If we are being configured for newlib, we know which functions
222 # newlib provide and which ones we will be expected to provide.
224 if test "x${with_newlib}" = "xyes"; then
225 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
229 asprintf | basename | insque | random | strdup | vasprintf)
232 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
233 AC_DEFINE_UNQUOTED($n)
238 # newlib doesnt provide any of the variables in $vars, so we
239 # dont have to check them here.
241 # Of the functions in $checkfuncs, newlib only has strerror.
242 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
250 # Not a target library, so we set things up to run the test suite.
251 CHECK=check-cplus-dem
258 *-*-cygwin* | *-*-mingw*)
259 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
260 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
264 if test -z "${setobjs}"; then
268 # Handle VxWorks configuration specially, since on VxWorks the
269 # libraries are actually on the target board, not in the file
271 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
272 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
275 basename | getpagesize | insque | random | strcasecmp)
277 strncasecmp | strdup | vfork | waitpid | vasprintf)
280 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
281 AC_DEFINE_UNQUOTED($n)
286 # VxWorks doesn't provide any of the variables in $vars, so we
287 # don't have to check them here.
289 # Of the functions in $checkfuncs, VxWorks only has strerror.
290 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
298 if test -z "${setobjs}"; then
303 # The Cygwin library actually uses a couple of files from
304 # libiberty when it is built. If we are building a native
305 # Cygwin, and we run the tests, we will appear to have these
306 # files. However, when we go on to build winsup, we will wind up
307 # with a library which does not have the files, since they should
308 # have come from libiberty.
310 # We handle this by removing the functions the winsup library
311 # provides from our shell variables, so that they appear to be
314 # DJ - only if we're *building* cygwin, not just building *with* cygwin
316 if test -n "${with_target_subdir}"
318 funcs="`echo $funcs | sed -e 's/random//'`"
319 LIBOBJS="$LIBOBJS random.o"
320 vars="`echo $vars | sed -e 's/sys_siglist//'`"
321 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
326 # Under mingw32, sys_nerr and sys_errlist exist, but they are
327 # macros, so the test below won't find them.
328 libiberty_cv_var_sys_nerr=yes
329 libiberty_cv_var_sys_errlist=yes
333 # Under some versions of uwin, vfork is notoriously buggy and the test
334 # can hang configure; on other versions, vfork exists just as a stub.
335 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
336 ac_cv_func_vfork_works=no
337 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
338 # macros (actually, these are imported from a DLL, but the end effect
339 # is the same), so the test below won't find them.
340 libiberty_cv_var_sys_nerr=yes
341 libiberty_cv_var_sys_errlist=yes
345 # Under VMS, vfork works very different than on Unix. The standard test
346 # won't work, and it isn't easily adaptable. It makes more sense to
348 ac_cv_func_vfork_works=yes
353 # We haven't set the list of objects yet. Use the standard autoconf
354 # tests. This will only work if the compiler works.
356 AC_REPLACE_FUNCS($funcs)
357 libiberty_AC_FUNC_C_ALLOCA
359 if test $ac_cv_func_vfork_works = no; then
360 LIBOBJS="$LIBOBJS vfork.o"
362 # We only need _doprnt if we might use it to implement v*printf.
363 if test $ac_cv_func_vprintf != yes \
364 || test $ac_cv_func_vfprintf != yes \
365 || test $ac_cv_func_vsprintf != yes; then
366 AC_REPLACE_FUNCS(_doprnt)
368 AC_CHECK_FUNCS(_doprnt)
372 AC_MSG_CHECKING([for $v])
373 AC_CACHE_VAL(libiberty_cv_var_$v,
374 [AC_TRY_LINK([int *p;], [extern int $v []; p = $v;],
375 [eval "libiberty_cv_var_$v=yes"],
376 [eval "libiberty_cv_var_$v=no"])])
377 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
379 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
380 AC_DEFINE_UNQUOTED($n)
385 AC_CHECK_FUNCS($checkfuncs)
388 libiberty_AC_FUNC_STRNCMP
390 # Install a library built with a cross compiler in $(tooldir) rather
392 if test -z "${with_cross_host}"; then
397 AC_SUBST(INSTALL_DEST)
399 # We need multilib support, but only if configuring for the target.
400 AC_OUTPUT(Makefile testsuite/Makefile,
401 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
402 if test -n "$CONFIG_FILES"; then
403 if test -n "${with_target_subdir}"; then
404 # FIXME: We shouldn't need to set ac_file
406 LD="${ORIGINAL_LD_FOR_MULTILIBS}"
407 . ${libiberty_topdir}/config-ml.in
413 with_target_subdir=${with_target_subdir}
414 with_multisubdir=${with_multisubdir}
415 ac_configure_args="--enable-multilib ${ac_configure_args}"
416 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
417 libiberty_topdir=${libiberty_topdir}