]> git.ipfire.org Git - thirdparty/gcc.git/blame - libiberty/configure.in
Makefile.in (LIBS): Fix definition so we link with $(CLIB).
[thirdparty/gcc.git] / libiberty / configure.in
CommitLineData
3affd5f0 1dnl Process this file with autoconf to produce a configure script
6599da04 2
35a6cd99 3AC_PREREQ(2.12.1)
3affd5f0 4AC_INIT(pexecute.c)
6599da04 5
3affd5f0
JL
6dnl We use these options to decide which functions to include.
7AC_ARG_WITH(target-subdir,
ca6b370d
JL
8[ --with-target-subdir=SUBDIR Configuring in a subdirectory])
9AC_ARG_WITH(cross-host,
10[ --with-cross-host=HOST Configuring with a cross compiler])
3affd5f0
JL
11AC_ARG_WITH(newlib,
12[ --with-newlib Configuring with newlib])
6599da04 13
3affd5f0
JL
14if test "${srcdir}" = "."; then
15 if test -z "${with_target_subdir}"; then
16 libiberty_topdir="${srcdir}/.."
17 else
18 if test "${with_target_subdir}" != "."; then
19 libiberty_topdir="${srcdir}/${with_multisrctop}../.."
20 else
21 libiberty_topdir="${srcdir}/${with_multisrctop}.."
22 fi
23 fi
24else
25 libiberty_topdir="${srcdir}/.."
26fi
27AC_CONFIG_AUX_DIR($libiberty_topdir)
28
29AC_CANONICAL_HOST
30
31dnl When we start using automake:
32dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
33
34dnl These must be called before AM_PROG_LIBTOOL, because it may want
35dnl to call AC_CHECK_PROG.
36AC_CHECK_TOOL(AR, ar)
37AC_CHECK_TOOL(RANLIB, ranlib, :)
38
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
43# itself.
44
45AC_DEFUN(LIB_AC_PROG_CC,
46[AC_BEFORE([$0], [AC_PROG_CPP])dnl
47AC_PROVIDE([AC_PROG_CC])
48AC_CHECK_PROG(CC, gcc, gcc)
49if 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])
52fi
53
54AC_PROG_CC_GNU
55
56if test $ac_cv_prog_gcc = yes; then
57 GCC=yes
58dnl Check whether -g works, even if CFLAGS is set, in case the package
59dnl plays around with CFLAGS (such as to build both debugging and
60dnl normal versions of a library), tasteless as that idea is.
61 ac_test_CFLAGS="${CFLAGS+set}"
62 ac_save_CFLAGS="$CFLAGS"
63 CFLAGS=
64 AC_PROG_CC_G
65 if test "$ac_test_CFLAGS" = set; then
66 CFLAGS="$ac_save_CFLAGS"
67 elif test $ac_cv_prog_cc_g = yes; then
68 CFLAGS="-g -O2"
69 else
70 CFLAGS="-O2"
71 fi
72else
73 GCC=
74 test "${CFLAGS+set}" = set || CFLAGS="-g"
75fi
76])
77
78LIB_AC_PROG_CC
79
80AC_ISC_POSIX
81
82dnl When we start using libtool:
83dnl Default to a non shared library. This may be overridden by the
84dnl configure option --enable-shared.
85dnl AM_DISABLE_SHARED
86
87dnl When we start using libtool:
88dnl AM_PROG_LIBTOOL
89
90dnl When we start using automake:
91dnl AM_CONFIG_HEADER(config.h:config.in)
92AC_CONFIG_HEADER(config.h:config.in)
93
94dnl When we start using automake:
95dnl AM_MAINTAINER_MODE
dd8f3ed5 96dnl AC_EXEEXT
3affd5f0
JL
97
98dnl When we start using automake:
99dnl AM_PROG_INSTALL
100AC_PROG_INSTALL
6599da04
JM
101
102. ${srcdir}/config.table
103host_makefile_frag=${frag}
3affd5f0
JL
104AC_SUBST_FILE(host_makefile_frag)
105
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
108# something.
6a071f4a 109AC_CHECK_HEADERS(sys/file.h sys/param.h stdlib.h string.h unistd.h strings.h sys/time.h sys/resource.h)
a6458d1d 110AC_HEADER_SYS_WAIT
6599da04 111
3affd5f0
JL
112# This is the list of functions which libiberty will provide if they
113# are not available on the host.
114
115funcs="asprintf"
116funcs="$funcs atexit"
117funcs="$funcs basename"
118funcs="$funcs bcmp"
119funcs="$funcs bcopy"
120funcs="$funcs bzero"
a9acf741 121funcs="$funcs calloc"
3affd5f0
JL
122funcs="$funcs clock"
123funcs="$funcs getcwd"
124funcs="$funcs getpagesize"
125funcs="$funcs index"
126funcs="$funcs insque"
127funcs="$funcs memchr"
128funcs="$funcs memcmp"
129funcs="$funcs memcpy"
130funcs="$funcs memmove"
131funcs="$funcs memset"
687361c8 132funcs="$funcs mkstemps"
9eb4080f 133funcs="$funcs putenv"
3affd5f0
JL
134funcs="$funcs random"
135funcs="$funcs rename"
136funcs="$funcs rindex"
9eb4080f 137funcs="$funcs setenv"
3affd5f0
JL
138funcs="$funcs sigsetmask"
139funcs="$funcs strcasecmp"
140funcs="$funcs strchr"
141funcs="$funcs strdup"
142funcs="$funcs strncasecmp"
143funcs="$funcs strrchr"
144funcs="$funcs strstr"
145funcs="$funcs strtod"
146funcs="$funcs strtol"
147funcs="$funcs strtoul"
148funcs="$funcs tmpnam"
149funcs="$funcs vasprintf"
150funcs="$funcs vfprintf"
151funcs="$funcs vprintf"
152funcs="$funcs vsprintf"
153funcs="$funcs waitpid"
154
155# Also in the old function.def file: alloca, vfork, getopt.
156
157vars="sys_errlist sys_nerr sys_siglist"
158
90e72e20 159checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
3affd5f0
JL
160
161# These are neither executed nor required, but they help keep
162# autoheader happy without adding a bunch of text to acconfig.h.
163if test "x" = "y"; then
a9acf741 164 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bzero calloc clock getcwd)
687361c8 165 AC_CHECK_FUNCS(getpagesize index insque mkstemps memchr memcmp memcpy memmove)
9eb4080f
JL
166 AC_CHECK_FUNCS(memset putenv random rename rindex sigsetmask strcasecmp)
167 AC_CHECK_FUNCS(setenv strchr strdup strncasecmp strrchr strstr strtod strtol)
3affd5f0
JL
168 AC_CHECK_FUNCS(strtoul tmpnam vasprintf vfprintf vprintf vsprintf waitpid)
169 AC_DEFINE(HAVE_SYS_ERRLIST)
170 AC_DEFINE(HAVE_SYS_NERR)
171 AC_DEFINE(HAVE_SYS_SIGLIST)
172 AC_CHECK_FUNCS(getrusage on_exit psignal strerror strsignal sysconf times)
90e72e20 173 AC_CHECK_FUNCS(sbrk gettimeofday)
6599da04
JM
174fi
175
3affd5f0
JL
176# For each of these functions, if the host does not provide the
177# function we want to put FN.o in LIBOBJS, and if the host does
178# provide the function, we want to define HAVE_FN in config.h. Also,
179# if the host does not provide alloca, we set ALLOCA to alloca.o
180
181setobjs=
7c72138a 182CHECK=
3affd5f0
JL
183if test -n "${with_target_subdir}"; then
184
ca6b370d 185 # We are being configured as a target library. AC_REPLACE_FUNCS
3affd5f0 186 # may not work correctly, because the compiler may not be able to
ca6b370d
JL
187 # link executables. Note that we may still be being configured
188 # native.
3affd5f0
JL
189
190 # If we are being configured for newlib, we know which functions
191 # newlib provide and which ones we will be expected to provide.
192
193 if test "x${with_newlib}" = "xyes"; then
194 ALLOCA="alloca.o"
ca6b370d 195 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
3affd5f0
JL
196
197 for f in $funcs; do
198 case "$f" in
ca6b370d 199 asprintf | basename | insque | random | strdup | vasprintf)
3affd5f0
JL
200 ;;
201 *)
202 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
203 AC_DEFINE_UNQUOTED($n)
204 ;;
205 esac
206 done
207
208 # newlib doesnt provide any of the variables in $vars, so we
209 # dont have to check them here.
210
ca6b370d 211 # Of the functions in $checkfuncs, newlib only has strerror.
3affd5f0
JL
212 AC_DEFINE(HAVE_STRERROR)
213
214 setobjs=yes
215
216 fi
7c72138a
TT
217
218else
219
220 # Not a target library, so we set things up to run the test suite.
221 CHECK=check-cplus-dem
222
3affd5f0
JL
223fi
224
7c72138a
TT
225AC_SUBST(CHECK)
226
3affd5f0
JL
227if test -z "${setobjs}"; then
228 case "${host}" in
229
230 *-*-vxworks*)
231 # Handle VxWorks configuration specially, since on VxWorks the
232 # libraries are actually on the target board, not in the file
233 # system.
234 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
235 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
236 for f in $funcs; do
237 case "$f" in
238 basename | getpagesize | insque | random | strcasecmp)
239 ;;
240 strncasecmp | strdup | vfork | waitpid | vasprintf)
241 ;;
242 *)
243 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
244 AC_DEFINE_UNQUOTED($n)
245 ;;
246 esac
247 done
248
249 # VxWorks doesn't provide any of the variables in $vars, so we
250 # don't have to check them here.
251
252 # Of the functions in $checkfuncs, VxWorks only has strerror.
253 AC_DEFINE(HAVE_STRERROR)
254
255 setobjs=yes
256 ;;
257
258 esac
259fi
260
261if test -z "${setobjs}"; then
262
263 case "${host}" in
264
dd8f3ed5
GN
265 *-*-cygwin*)
266 # The Cygwin library actually uses a couple of files from
3affd5f0 267 # libiberty when it is built. If we are building a native
dd8f3ed5 268 # Cygwin, and we run the tests, we will appear to have these
3affd5f0
JL
269 # files. However, when we go on to build winsup, we will wind up
270 # with a library which does not have the files, since they should
271 # have come from libiberty.
272
273 # We handle this by removing the functions the winsup library
274 # provides from our shell variables, so that they appear to be
275 # missing.
276
277 funcs="`echo $funcs | sed -e 's/random//'`"
278 LIBOBJS="$LIBOBJS random.o"
279 vars="`echo $vars | sed -e 's/sys_siglist//'`"
6391b50a 280 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
3affd5f0
JL
281 ;;
282
283 *-*-mingw32*)
284 # Under mingw32, sys_nerr and sys_errlist exist, but they are
285 # macros, so the test below won't find them.
286 vars="`echo $vars | sed -e 's/sys_nerr//' -e 's/sys_errlist//'`"
287 AC_DEFINE(HAVE_SYS_NERR)
288 AC_DEFINE(HAVE_SYS_ERRLIST)
289 ;;
290
89f602a7
MK
291 *-*-uwin*)
292 # Under some versions of uwin, vfork is notoriously buggy and the test
293 # can hang configure; on other versions, vfork exists just as a stub.
294 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
295 ac_cv_func_vfork_works=no
62133b5e
MK
296 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
297 # macros (actually, these are imported from a DLL, but the end effect
298 # is the same), so the test below won't find them.
299 AC_DEFINE(HAVE_SYS_NERR)
300 AC_DEFINE(HAVE_SYS_ERRLIST)
89f602a7
MK
301 ;;
302
3affd5f0
JL
303 esac
304
305 # We haven't set the list of objects yet. Use the standard autoconf
306 # tests. This will only work if the compiler works.
307 AC_PROG_CC_WORKS
308 AC_REPLACE_FUNCS($funcs)
7dd88617
DT
309
310 case "${host}" in
311 *-*-interix)
312 # On Interix, it wrongly concludes that the MSVC compiler supports alloca.
313 # (MSVC does on Win32, not on Interix.)
314 # This should be temporary.
315
316 ac_cv_header_alloca_h=no
317 ac_cv_func_alloca_works=no
318 ALLOCA=alloca.o
319 cat >> confdefs.h <<\EOF
320#define C_ALLOCA 1
321EOF
322 cat >> confdefs.h <<EOF
323#define STACK_DIRECTION -1
324EOF
325 ;;
326 *)
327 AC_FUNC_ALLOCA
328 ;;
329 esac
330
3affd5f0
JL
331 AC_FUNC_VFORK
332 if test $ac_cv_func_vfork_works = no; then
333 LIBOBJS="$LIBOBJS vfork.o"
334 fi
335 for v in $vars; do
336 AC_MSG_CHECKING([for $v])
337 AC_CACHE_VAL(libiberty_cv_var_$v,
338 [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
339 [eval "libiberty_cv_var_$v=yes"],
340 [eval "libiberty_cv_var_$v=no"])])
341 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
342 AC_MSG_RESULT(yes)
343 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
344 AC_DEFINE_UNQUOTED($n)
6599da04 345 else
3affd5f0 346 AC_MSG_RESULT(no)
6599da04 347 fi
3affd5f0
JL
348 done
349 AC_CHECK_FUNCS($checkfuncs)
350fi
351
352# Install a library built with a cross compiler in $(tooldir) rather
353# than $(libdir).
ca6b370d 354if test -z "${with_cross_host}"; then
3affd5f0
JL
355 INSTALL_DEST=libdir
356else
357 INSTALL_DEST=tooldir
6599da04 358fi
3affd5f0
JL
359AC_SUBST(INSTALL_DEST)
360
361# We need multilib support, but only if configuring for the target.
7c72138a 362AC_OUTPUT(Makefile testsuite/Makefile,
3affd5f0
JL
363[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
364if test -n "$CONFIG_FILES"; then
365 if test -n "${with_target_subdir}"; then
366 # FIXME: We shouldn't need to set ac_file
367 ac_file=Makefile
368 . ${libiberty_topdir}/config-ml.in
369 fi
370fi],
371srcdir=${srcdir}
372host=${host}
373target=${target}
374with_target_subdir=${with_target_subdir}
375with_multisubdir=${with_multisubdir}
376ac_configure_args="--enable-multilib ${ac_configure_args}"
377CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
378libiberty_topdir=${libiberty_topdir}
379)