1 dnl Process this file with autoconf to produce a configure script
6 dnl We use these options to decide which functions to include.
7 AC_ARG_WITH(target-subdir,
8 [ --with-target-subdir=SUBDIR Configuring in a subdirectory for target])
9 AC_ARG_WITH(build-subdir,
10 [ --with-build-subdir=SUBDIR Configuring in a subdirectory for build])
11 AC_ARG_WITH(cross-host,
12 [ --with-cross-host=HOST Configuring with a cross compiler])
14 [ --with-newlib Configuring with newlib])
16 if test "${srcdir}" = "."; then
17 if test -n "${with_build_subdir}"; then
18 libiberty_topdir="${srcdir}/../.."
20 elif test -z "${with_target_subdir}"; then
21 libiberty_topdir="${srcdir}/.."
23 if test "${with_target_subdir}" != "."; then
24 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
26 libiberty_topdir="${srcdir}/${with_multisrctop}.."
30 libiberty_topdir="${srcdir}/.."
32 AC_CONFIG_AUX_DIR($libiberty_topdir)
34 dnl Very limited version of automake's enable-maintainer-mode
36 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
37 dnl maintainer-mode is disabled by default
38 AC_ARG_ENABLE(maintainer-mode,
39 [ --enable-maintainer-mode
40 enable make rules and dependencies not useful
41 (and sometimes confusing) to the casual installer],
42 maintainer_mode=$enableval,
45 AC_MSG_RESULT($maintainer_mode)
47 if test "$maintainer_mode" = "yes"; then
57 # Do we have a single-tree copy of texinfo? Even if we do, we can't
58 # rely on it - libiberty is built before texinfo.
59 AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
60 if test "x$MAKEINFO" = "x"; then
61 MAKEINFO="@echo makeinfo missing; true"
65 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
67 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required; true"
70 *** Makeinfo is too old. Info documentation will not be built.])
77 AC_CHECK_PROG(PERL, perl, perl, )
78 if test x"$PERL" = x""; then
87 dnl When we start using automake:
88 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
90 dnl These must be called before AM_PROG_LIBTOOL, because it may want
91 dnl to call AC_CHECK_PROG.
93 AC_CHECK_TOOL(RANLIB, ranlib, :)
101 dnl When we start using libtool:
102 dnl Default to a non shared library. This may be overridden by the
103 dnl configure option --enable-shared.
104 dnl AM_DISABLE_SHARED
106 dnl When we start using libtool:
109 dnl When we start using automake:
110 dnl AM_CONFIG_HEADER(config.h:config.in)
111 AC_CONFIG_HEADER(config.h:config.in)
113 dnl When we start using automake:
114 dnl AM_MAINTAINER_MODE
117 dnl When we start using automake:
121 . ${srcdir}/config.table
122 host_makefile_frag=${frag}
123 AC_SUBST_FILE(host_makefile_frag)
125 # It's OK to check for header files. Although the compiler may not be
126 # able to link anything, it had better be able to at least compile
128 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)
132 libiberty_AC_DECLARE_ERRNO
134 AC_CHECK_TYPE(uintptr_t, unsigned long)
136 if test $ac_cv_type_uintptr_t = yes
138 AC_DEFINE(HAVE_UINTPTR_T, 1, [Define if you have the \`uintptr_t' type.])
143 # This is the list of functions which libiberty will provide if they
144 # are not available on the host.
147 funcs="$funcs atexit"
148 funcs="$funcs basename"
151 funcs="$funcs bsearch"
153 funcs="$funcs calloc"
156 funcs="$funcs getcwd"
157 funcs="$funcs getpagesize"
159 funcs="$funcs insque"
160 funcs="$funcs memchr"
161 funcs="$funcs memcmp"
162 funcs="$funcs memcpy"
163 funcs="$funcs memmove"
164 funcs="$funcs memset"
165 funcs="$funcs mkstemps"
166 funcs="$funcs putenv"
167 funcs="$funcs random"
168 funcs="$funcs rename"
169 funcs="$funcs rindex"
170 funcs="$funcs setenv"
171 funcs="$funcs sigsetmask"
172 funcs="$funcs strcasecmp"
173 funcs="$funcs strchr"
174 funcs="$funcs strdup"
175 funcs="$funcs strncasecmp"
176 funcs="$funcs strrchr"
177 funcs="$funcs strstr"
178 funcs="$funcs strtod"
179 funcs="$funcs strtol"
180 funcs="$funcs strtoul"
181 funcs="$funcs tmpnam"
182 funcs="$funcs vasprintf"
183 funcs="$funcs vfprintf"
184 funcs="$funcs vprintf"
185 funcs="$funcs vsprintf"
186 funcs="$funcs waitpid"
188 # Also in the old function.def file: alloca, vfork, getopt.
190 vars="sys_errlist sys_nerr sys_siglist"
192 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
194 # These are neither executed nor required, but they help keep
195 # autoheader happy without adding a bunch of text to acconfig.h.
196 if test "x" = "y"; then
197 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock)
198 AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy)
199 AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask)
200 AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
201 AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
202 AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
203 AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
204 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
205 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
206 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
209 # For each of these functions, if the host does not provide the
210 # function we want to put FN.o in LIBOBJS, and if the host does
211 # provide the function, we want to define HAVE_FN in config.h.
216 if test -n "${with_target_subdir}"; then
218 # We are being configured as a target library. AC_REPLACE_FUNCS
219 # may not work correctly, because the compiler may not be able to
220 # link executables. Note that we may still be being configured
223 # If we are being configured for newlib, we know which functions
224 # newlib provide and which ones we will be expected to provide.
226 if test "x${with_newlib}" = "xyes"; then
227 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
231 asprintf | basename | insque | random | strdup | vasprintf)
234 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
235 AC_DEFINE_UNQUOTED($n)
240 # newlib doesnt provide any of the variables in $vars, so we
241 # dont have to check them here.
243 # Of the functions in $checkfuncs, newlib only has strerror.
244 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
250 # We may wish to install the target headers somewhere.
251 AC_ARG_ENABLE(install-libiberty,
252 [ --enable-install-libiberty Install headers for end users],
253 enable_install_libiberty=$enableval,
254 enable_install_libiberty=no)dnl
256 # Option parsed, now set things appropriately.
257 case x"$enable_install_libiberty" in
259 target_header_dir=libiberty
265 # This could be sanity-checked in various ways...
266 target_header_dir="${enable_install_libiberty}"
273 # Not a target library, so we set things up to run the test suite.
274 CHECK=check-cplus-dem
279 AC_SUBST(target_header_dir)
282 *-*-cygwin* | *-*-mingw*)
283 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
284 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
288 if test -z "${setobjs}"; then
292 # Handle VxWorks configuration specially, since on VxWorks the
293 # libraries are actually on the target board, not in the file
295 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
296 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
299 basename | getpagesize | insque | random | strcasecmp)
301 strncasecmp | strdup | vfork | waitpid | vasprintf)
304 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
305 AC_DEFINE_UNQUOTED($n)
310 # VxWorks doesn't provide any of the variables in $vars, so we
311 # don't have to check them here.
313 # Of the functions in $checkfuncs, VxWorks only has strerror.
314 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
322 if test -z "${setobjs}"; then
327 # The Cygwin library actually uses a couple of files from
328 # libiberty when it is built. If we are building a native
329 # Cygwin, and we run the tests, we will appear to have these
330 # files. However, when we go on to build winsup, we will wind up
331 # with a library which does not have the files, since they should
332 # have come from libiberty.
334 # We handle this by removing the functions the winsup library
335 # provides from our shell variables, so that they appear to be
338 # DJ - only if we're *building* cygwin, not just building *with* cygwin
340 if test -n "${with_target_subdir}"
342 funcs="`echo $funcs | sed -e 's/random//'`"
343 LIBOBJS="$LIBOBJS random.o"
344 vars="`echo $vars | sed -e 's/sys_siglist//'`"
345 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
350 # Under mingw32, sys_nerr and sys_errlist exist, but they are
351 # macros, so the test below won't find them.
352 libiberty_cv_var_sys_nerr=yes
353 libiberty_cv_var_sys_errlist=yes
357 # Under some versions of uwin, vfork is notoriously buggy and the test
358 # can hang configure; on other versions, vfork exists just as a stub.
359 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
360 ac_cv_func_vfork_works=no
361 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
362 # macros (actually, these are imported from a DLL, but the end effect
363 # is the same), so the test below won't find them.
364 libiberty_cv_var_sys_nerr=yes
365 libiberty_cv_var_sys_errlist=yes
369 # Under VMS, vfork works very different than on Unix. The standard test
370 # won't work, and it isn't easily adaptable. It makes more sense to
372 ac_cv_func_vfork_works=yes
377 # We haven't set the list of objects yet. Use the standard autoconf
378 # tests. This will only work if the compiler works.
380 AC_REPLACE_FUNCS($funcs)
381 libiberty_AC_FUNC_C_ALLOCA
383 if test $ac_cv_func_vfork_works = no; then
384 LIBOBJS="$LIBOBJS vfork.o"
386 # We only need _doprnt if we might use it to implement v*printf.
387 if test $ac_cv_func_vprintf != yes \
388 || test $ac_cv_func_vfprintf != yes \
389 || test $ac_cv_func_vsprintf != yes; then
390 AC_REPLACE_FUNCS(_doprnt)
392 AC_CHECK_FUNCS(_doprnt)
396 AC_MSG_CHECKING([for $v])
397 AC_CACHE_VAL(libiberty_cv_var_$v,
398 [AC_TRY_LINK([int *p;], [extern int $v []; p = &$v;],
399 [eval "libiberty_cv_var_$v=yes"],
400 [eval "libiberty_cv_var_$v=no"])])
401 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
403 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
404 AC_DEFINE_UNQUOTED($n)
409 AC_CHECK_FUNCS($checkfuncs)
412 libiberty_AC_FUNC_STRNCMP
414 # Install a library built with a cross compiler in $(tooldir) rather
416 if test -z "${with_cross_host}"; then
421 AC_SUBST(INSTALL_DEST)
423 # We need multilib support, but only if configuring for the target.
424 AC_OUTPUT(Makefile testsuite/Makefile,
425 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
426 if test -n "$CONFIG_FILES"; then
427 if test -n "${with_build_subdir}" || test -n "${with_target_subdir}"; then
428 # FIXME: We shouldn't need to set ac_file
430 . ${libiberty_topdir}/config-ml.in
436 with_target_subdir=${with_target_subdir}
437 with_build_subdir=${with_build_subdir}
438 with_multisubdir=${with_multisubdir}
439 ac_configure_args="--enable-multilib ${ac_configure_args}"
440 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
441 libiberty_topdir=${libiberty_topdir}