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])
9 AC_ARG_WITH(cross-host,
10 [ --with-cross-host=HOST Configuring with a cross compiler])
12 [ --with-newlib Configuring with newlib])
14 if test "${srcdir}" = "."; then
15 if test -z "${with_target_subdir}"; then
16 libiberty_topdir="${srcdir}/.."
18 if test "${with_target_subdir}" != "."; then
19 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
21 libiberty_topdir="${srcdir}/${with_multisrctop}.."
25 libiberty_topdir="${srcdir}/.."
27 AC_CONFIG_AUX_DIR($libiberty_topdir)
31 dnl When we start using automake:
32 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
34 dnl These must be called before AM_PROG_LIBTOOL, because it may want
35 dnl to call AC_CHECK_PROG.
37 AC_CHECK_TOOL(RANLIB, ranlib, :)
39 # FIXME: We temporarily define our own version of AC_PROG_CC. This is
40 # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
41 # are probably using a cross compiler, which will not be able to fully
42 # link an executable. This should really be fixed in autoconf
45 AC_DEFUN(LIB_AC_PROG_CC,
46 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
47 AC_PROVIDE([AC_PROG_CC])
48 AC_CHECK_PROG(CC, gcc, gcc)
49 if test -z "$CC"; then
50 AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
51 test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
56 if test $ac_cv_prog_gcc = yes; then
58 dnl Check whether -g works, even if CFLAGS is set, in case the package
59 dnl plays around with CFLAGS (such as to build both debugging and
60 dnl normal versions of a library), tasteless as that idea is.
61 ac_test_CFLAGS="${CFLAGS+set}"
62 ac_save_CFLAGS="$CFLAGS"
65 if test "$ac_test_CFLAGS" = set; then
66 CFLAGS="$ac_save_CFLAGS"
67 elif test $ac_cv_prog_cc_g = yes; then
74 test "${CFLAGS+set}" = set || CFLAGS="-g"
82 dnl When we start using libtool:
83 dnl Default to a non shared library. This may be overridden by the
84 dnl configure option --enable-shared.
87 dnl When we start using libtool:
90 dnl When we start using automake:
91 dnl AM_CONFIG_HEADER(config.h:config.in)
92 AC_CONFIG_HEADER(config.h:config.in)
94 dnl When we start using automake:
95 dnl AM_MAINTAINER_MODE
98 dnl When we start using automake:
102 . ${srcdir}/config.table
103 host_makefile_frag=${frag}
104 AC_SUBST_FILE(host_makefile_frag)
106 # It's OK to check for header files. Although the compiler may not be
107 # able to link anything, it had better be able to at least compile
109 AC_CHECK_HEADERS(sys/file.h sys/param.h stdlib.h string.h unistd.h strings.h sys/time.h sys/resource.h)
112 # This is the list of functions which libiberty will provide if they
113 # are not available on the host.
116 funcs="$funcs atexit"
117 funcs="$funcs basename"
121 funcs="$funcs calloc"
123 funcs="$funcs getcwd"
124 funcs="$funcs getpagesize"
126 funcs="$funcs insque"
127 funcs="$funcs memchr"
128 funcs="$funcs memcmp"
129 funcs="$funcs memcpy"
130 funcs="$funcs memmove"
131 funcs="$funcs memset"
132 funcs="$funcs mkstemps"
133 funcs="$funcs random"
134 funcs="$funcs rename"
135 funcs="$funcs rindex"
136 funcs="$funcs sigsetmask"
137 funcs="$funcs strcasecmp"
138 funcs="$funcs strchr"
139 funcs="$funcs strdup"
140 funcs="$funcs strncasecmp"
141 funcs="$funcs strrchr"
142 funcs="$funcs strstr"
143 funcs="$funcs strtod"
144 funcs="$funcs strtol"
145 funcs="$funcs strtoul"
146 funcs="$funcs tmpnam"
147 funcs="$funcs vasprintf"
148 funcs="$funcs vfprintf"
149 funcs="$funcs vprintf"
150 funcs="$funcs vsprintf"
151 funcs="$funcs waitpid"
153 # Also in the old function.def file: alloca, vfork, getopt.
155 vars="sys_errlist sys_nerr sys_siglist"
157 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times"
159 # These are neither executed nor required, but they help keep
160 # autoheader happy without adding a bunch of text to acconfig.h.
161 if test "x" = "y"; then
162 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bzero calloc clock getcwd)
163 AC_CHECK_FUNCS(getpagesize index insque mkstemps memchr memcmp memcpy memmove)
164 AC_CHECK_FUNCS(memset random rename rindex sigsetmask strcasecmp)
165 AC_CHECK_FUNCS(strchr strdup strncasecmp strrchr strstr strtod strtol)
166 AC_CHECK_FUNCS(strtoul tmpnam vasprintf vfprintf vprintf vsprintf waitpid)
167 AC_DEFINE(HAVE_SYS_ERRLIST)
168 AC_DEFINE(HAVE_SYS_NERR)
169 AC_DEFINE(HAVE_SYS_SIGLIST)
170 AC_CHECK_FUNCS(getrusage on_exit psignal strerror strsignal sysconf times)
173 # For each of these functions, if the host does not provide the
174 # function we want to put FN.o in LIBOBJS, and if the host does
175 # provide the function, we want to define HAVE_FN in config.h. Also,
176 # if the host does not provide alloca, we set ALLOCA to alloca.o
179 if test -n "${with_target_subdir}"; then
181 # We are being configured as a target library. AC_REPLACE_FUNCS
182 # may not work correctly, because the compiler may not be able to
183 # link executables. Note that we may still be being configured
186 # If we are being configured for newlib, we know which functions
187 # newlib provide and which ones we will be expected to provide.
189 if test "x${with_newlib}" = "xyes"; then
191 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
195 asprintf | basename | insque | random | strdup | vasprintf)
198 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
199 AC_DEFINE_UNQUOTED($n)
204 # newlib doesnt provide any of the variables in $vars, so we
205 # dont have to check them here.
207 # Of the functions in $checkfuncs, newlib only has strerror.
208 AC_DEFINE(HAVE_STRERROR)
215 if test -z "${setobjs}"; then
219 # Handle VxWorks configuration specially, since on VxWorks the
220 # libraries are actually on the target board, not in the file
222 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
223 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
226 basename | getpagesize | insque | random | strcasecmp)
228 strncasecmp | strdup | vfork | waitpid | vasprintf)
231 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
232 AC_DEFINE_UNQUOTED($n)
237 # VxWorks doesn't provide any of the variables in $vars, so we
238 # don't have to check them here.
240 # Of the functions in $checkfuncs, VxWorks only has strerror.
241 AC_DEFINE(HAVE_STRERROR)
249 if test -z "${setobjs}"; then
254 # The Cygwin library actually uses a couple of files from
255 # libiberty when it is built. If we are building a native
256 # Cygwin, and we run the tests, we will appear to have these
257 # files. However, when we go on to build winsup, we will wind up
258 # with a library which does not have the files, since they should
259 # have come from libiberty.
261 # We handle this by removing the functions the winsup library
262 # provides from our shell variables, so that they appear to be
265 funcs="`echo $funcs | sed -e 's/random//'`"
266 LIBOBJS="$LIBOBJS random.o"
267 vars="`echo $vars | sed -e 's/sys_siglist//'`"
268 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
272 # Under mingw32, sys_nerr and sys_errlist exist, but they are
273 # macros, so the test below won't find them.
274 vars="`echo $vars | sed -e 's/sys_nerr//' -e 's/sys_errlist//'`"
275 AC_DEFINE(HAVE_SYS_NERR)
276 AC_DEFINE(HAVE_SYS_ERRLIST)
280 # Under some versions of uwin, vfork is notoriously buggy and the test
281 # can hang configure; on other versions, vfork exists just as a stub.
282 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
283 ac_cv_func_vfork_works=no
288 # We haven't set the list of objects yet. Use the standard autoconf
289 # tests. This will only work if the compiler works.
291 AC_REPLACE_FUNCS($funcs)
294 if test $ac_cv_func_vfork_works = no; then
295 LIBOBJS="$LIBOBJS vfork.o"
298 AC_MSG_CHECKING([for $v])
299 AC_CACHE_VAL(libiberty_cv_var_$v,
300 [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
301 [eval "libiberty_cv_var_$v=yes"],
302 [eval "libiberty_cv_var_$v=no"])])
303 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
305 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
306 AC_DEFINE_UNQUOTED($n)
311 AC_CHECK_FUNCS($checkfuncs)
314 # Install a library built with a cross compiler in $(tooldir) rather
316 if test -z "${with_cross_host}"; then
321 AC_SUBST(INSTALL_DEST)
323 # We need multilib support, but only if configuring for the target.
325 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
326 if test -n "$CONFIG_FILES"; then
327 if test -n "${with_target_subdir}"; then
328 # FIXME: We shouldn't need to set ac_file
330 . ${libiberty_topdir}/config-ml.in
336 with_target_subdir=${with_target_subdir}
337 with_multisubdir=${with_multisubdir}
338 ac_configure_args="--enable-multilib ${ac_configure_args}"
339 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
340 libiberty_topdir=${libiberty_topdir}