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