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.])
141 # This is the list of functions which libiberty will provide if they
142 # are not available on the host.
145 funcs="$funcs atexit"
146 funcs="$funcs basename"
149 funcs="$funcs bsearch"
151 funcs="$funcs calloc"
154 funcs="$funcs getcwd"
155 funcs="$funcs getpagesize"
157 funcs="$funcs insque"
158 funcs="$funcs memchr"
159 funcs="$funcs memcmp"
160 funcs="$funcs memcpy"
161 funcs="$funcs memmove"
162 funcs="$funcs memset"
163 funcs="$funcs mkstemps"
164 funcs="$funcs putenv"
165 funcs="$funcs random"
166 funcs="$funcs rename"
167 funcs="$funcs rindex"
168 funcs="$funcs setenv"
169 funcs="$funcs sigsetmask"
170 funcs="$funcs strcasecmp"
171 funcs="$funcs strchr"
172 funcs="$funcs strdup"
173 funcs="$funcs strncasecmp"
174 funcs="$funcs strrchr"
175 funcs="$funcs strstr"
176 funcs="$funcs strtod"
177 funcs="$funcs strtol"
178 funcs="$funcs strtoul"
179 funcs="$funcs tmpnam"
180 funcs="$funcs vasprintf"
181 funcs="$funcs vfprintf"
182 funcs="$funcs vprintf"
183 funcs="$funcs vsprintf"
184 funcs="$funcs waitpid"
186 # Also in the old function.def file: alloca, vfork, getopt.
188 vars="sys_errlist sys_nerr sys_siglist"
190 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
192 # These are neither executed nor required, but they help keep
193 # autoheader happy without adding a bunch of text to acconfig.h.
194 if test "x" = "y"; then
195 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock)
196 AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy)
197 AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask)
198 AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
199 AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
200 AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
201 AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
202 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
203 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
204 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
207 # For each of these functions, if the host does not provide the
208 # function we want to put FN.o in LIBOBJS, and if the host does
209 # 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)
248 # We may wish to install the target headers somewhere.
249 AC_ARG_ENABLE(install-libiberty,
250 [ --enable-install-libiberty Install headers for end users],
251 enable_install_libiberty=$enableval,
252 enable_install_libiberty=no)dnl
254 # Option parsed, now set things appropriately.
255 case x"$enable_install_libiberty" in
257 target_header_dir=libiberty
263 # This could be sanity-checked in various ways...
264 target_header_dir="${enable_install_libiberty}"
271 # Not a target library, so we set things up to run the test suite.
272 CHECK=check-cplus-dem
277 AC_SUBST(target_header_dir)
280 *-*-cygwin* | *-*-mingw*)
281 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_ERRLIST)
282 AC_DEFINE_NOAUTOHEADER(HAVE_SYS_NERR)
286 if test -z "${setobjs}"; then
290 # Handle VxWorks configuration specially, since on VxWorks the
291 # libraries are actually on the target board, not in the file
293 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
294 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
297 basename | getpagesize | insque | random | strcasecmp)
299 strncasecmp | strdup | vfork | waitpid | vasprintf)
302 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
303 AC_DEFINE_UNQUOTED($n)
308 # VxWorks doesn't provide any of the variables in $vars, so we
309 # don't have to check them here.
311 # Of the functions in $checkfuncs, VxWorks only has strerror.
312 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
320 if test -z "${setobjs}"; then
325 # The Cygwin library actually uses a couple of files from
326 # libiberty when it is built. If we are building a native
327 # Cygwin, and we run the tests, we will appear to have these
328 # files. However, when we go on to build winsup, we will wind up
329 # with a library which does not have the files, since they should
330 # have come from libiberty.
332 # We handle this by removing the functions the winsup library
333 # provides from our shell variables, so that they appear to be
336 # DJ - only if we're *building* cygwin, not just building *with* cygwin
338 if test -n "${with_target_subdir}"
340 funcs="`echo $funcs | sed -e 's/random//'`"
341 LIBOBJS="$LIBOBJS random.o"
342 vars="`echo $vars | sed -e 's/sys_siglist//'`"
343 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
348 # Under mingw32, sys_nerr and sys_errlist exist, but they are
349 # macros, so the test below won't find them.
350 libiberty_cv_var_sys_nerr=yes
351 libiberty_cv_var_sys_errlist=yes
355 # Under some versions of uwin, vfork is notoriously buggy and the test
356 # can hang configure; on other versions, vfork exists just as a stub.
357 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
358 ac_cv_func_vfork_works=no
359 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
360 # macros (actually, these are imported from a DLL, but the end effect
361 # is the same), so the test below won't find them.
362 libiberty_cv_var_sys_nerr=yes
363 libiberty_cv_var_sys_errlist=yes
367 # Under VMS, vfork works very different than on Unix. The standard test
368 # won't work, and it isn't easily adaptable. It makes more sense to
370 ac_cv_func_vfork_works=yes
375 # We haven't set the list of objects yet. Use the standard autoconf
376 # tests. This will only work if the compiler works.
378 AC_REPLACE_FUNCS($funcs)
379 libiberty_AC_FUNC_C_ALLOCA
381 if test $ac_cv_func_vfork_works = no; then
382 LIBOBJS="$LIBOBJS vfork.o"
384 # We only need _doprnt if we might use it to implement v*printf.
385 if test $ac_cv_func_vprintf != yes \
386 || test $ac_cv_func_vfprintf != yes \
387 || test $ac_cv_func_vsprintf != yes; then
388 AC_REPLACE_FUNCS(_doprnt)
390 AC_CHECK_FUNCS(_doprnt)
394 AC_MSG_CHECKING([for $v])
395 AC_CACHE_VAL(libiberty_cv_var_$v,
396 [AC_TRY_LINK([int *p;], [extern int $v []; p = &$v;],
397 [eval "libiberty_cv_var_$v=yes"],
398 [eval "libiberty_cv_var_$v=no"])])
399 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
401 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
402 AC_DEFINE_UNQUOTED($n)
407 AC_CHECK_FUNCS($checkfuncs)
410 libiberty_AC_FUNC_STRNCMP
412 # Install a library built with a cross compiler in $(tooldir) rather
414 if test -z "${with_cross_host}"; then
419 AC_SUBST(INSTALL_DEST)
421 # We need multilib support, but only if configuring for the target.
422 AC_OUTPUT(Makefile testsuite/Makefile,
423 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
424 if test -n "$CONFIG_FILES"; then
425 if test -n "${with_build_subdir}" || test -n "${with_target_subdir}"; then
426 # FIXME: We shouldn't need to set ac_file
428 . ${libiberty_topdir}/config-ml.in
434 with_target_subdir=${with_target_subdir}
435 with_build_subdir=${with_build_subdir}
436 with_multisubdir=${with_multisubdir}
437 ac_configure_args="--enable-multilib ${ac_configure_args}"
438 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
439 libiberty_topdir=${libiberty_topdir}