Fix capitialisation of setnaces in comment.
[deliverable/binutils-gdb.git] / libiberty / configure.in
CommitLineData
252b5132
RH
1dnl Process this file with autoconf to produce a configure script
2
0c0a36a4 3AC_PREREQ(2.13)
252b5132
RH
4AC_INIT(pexecute.c)
5
6dnl We use these options to decide which functions to include.
7AC_ARG_WITH(target-subdir,
8[ --with-target-subdir=SUBDIR Configuring in a subdirectory])
9AC_ARG_WITH(cross-host,
10[ --with-cross-host=HOST Configuring with a cross compiler])
11AC_ARG_WITH(newlib,
12[ --with-newlib Configuring with newlib])
13
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
0c0a36a4 58 ac_libiberty_warn_cflags='-W -Wall -Wtraditional'
252b5132
RH
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=
0c0a36a4 75 ac_libiberty_warn_cflags=
252b5132
RH
76 test "${CFLAGS+set}" = set || CFLAGS="-g"
77fi
78])
0c0a36a4 79AC_SUBST(ac_libiberty_warn_cflags)
252b5132
RH
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
99dnl AC_EXEEXT
100
101dnl When we start using automake:
102dnl AM_PROG_INSTALL
103AC_PROG_INSTALL
104
105. ${srcdir}/config.table
106host_makefile_frag=${frag}
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.
0c0a36a4 112AC_CHECK_HEADERS(sys/file.h sys/param.h stdlib.h string.h unistd.h strings.h sys/time.h sys/resource.h sys/stat.h)
252b5132
RH
113AC_HEADER_SYS_WAIT
114
115# This is the list of functions which libiberty will provide if they
116# are not available on the host.
117
118funcs="asprintf"
119funcs="$funcs atexit"
120funcs="$funcs basename"
121funcs="$funcs bcmp"
122funcs="$funcs bcopy"
123funcs="$funcs bzero"
124funcs="$funcs calloc"
125funcs="$funcs clock"
126funcs="$funcs getcwd"
127funcs="$funcs getpagesize"
128funcs="$funcs index"
129funcs="$funcs insque"
130funcs="$funcs memchr"
131funcs="$funcs memcmp"
132funcs="$funcs memcpy"
133funcs="$funcs memmove"
134funcs="$funcs memset"
135funcs="$funcs mkstemps"
0c0a36a4 136funcs="$funcs putenv"
252b5132
RH
137funcs="$funcs random"
138funcs="$funcs rename"
139funcs="$funcs rindex"
0c0a36a4 140funcs="$funcs setenv"
252b5132
RH
141funcs="$funcs sigsetmask"
142funcs="$funcs strcasecmp"
143funcs="$funcs strchr"
144funcs="$funcs strdup"
145funcs="$funcs strncasecmp"
146funcs="$funcs strrchr"
147funcs="$funcs strstr"
148funcs="$funcs strtod"
149funcs="$funcs strtol"
150funcs="$funcs strtoul"
151funcs="$funcs tmpnam"
152funcs="$funcs vasprintf"
153funcs="$funcs vfprintf"
154funcs="$funcs vprintf"
155funcs="$funcs vsprintf"
156funcs="$funcs waitpid"
157
158# Also in the old function.def file: alloca, vfork, getopt.
159
160vars="sys_errlist sys_nerr sys_siglist"
161
0c0a36a4 162checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
252b5132
RH
163
164# These are neither executed nor required, but they help keep
165# autoheader happy without adding a bunch of text to acconfig.h.
166if test "x" = "y"; then
167 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bzero calloc clock getcwd)
168 AC_CHECK_FUNCS(getpagesize index insque mkstemps memchr memcmp memcpy memmove)
0c0a36a4
ILT
169 AC_CHECK_FUNCS(memset putenv random rename rindex sigsetmask strcasecmp)
170 AC_CHECK_FUNCS(setenv strchr strdup strncasecmp strrchr strstr strtod strtol)
252b5132
RH
171 AC_CHECK_FUNCS(strtoul tmpnam vasprintf vfprintf vprintf vsprintf waitpid)
172 AC_DEFINE(HAVE_SYS_ERRLIST)
173 AC_DEFINE(HAVE_SYS_NERR)
174 AC_DEFINE(HAVE_SYS_SIGLIST)
175 AC_CHECK_FUNCS(getrusage on_exit psignal strerror strsignal sysconf times)
0c0a36a4 176 AC_CHECK_FUNCS(sbrk gettimeofday)
252b5132
RH
177fi
178
179# For each of these functions, if the host does not provide the
180# function we want to put FN.o in LIBOBJS, and if the host does
181# provide the function, we want to define HAVE_FN in config.h. Also,
182# if the host does not provide alloca, we set ALLOCA to alloca.o
183
184setobjs=
0c0a36a4 185CHECK=
252b5132
RH
186if test -n "${with_target_subdir}"; then
187
188 # We are being configured as a target library. AC_REPLACE_FUNCS
189 # may not work correctly, because the compiler may not be able to
190 # link executables. Note that we may still be being configured
191 # native.
192
193 # If we are being configured for newlib, we know which functions
194 # newlib provide and which ones we will be expected to provide.
195
196 if test "x${with_newlib}" = "xyes"; then
197 ALLOCA="alloca.o"
198 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
199
200 for f in $funcs; do
201 case "$f" in
202 asprintf | basename | insque | random | strdup | vasprintf)
203 ;;
204 *)
205 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
206 AC_DEFINE_UNQUOTED($n)
207 ;;
208 esac
209 done
210
211 # newlib doesnt provide any of the variables in $vars, so we
212 # dont have to check them here.
213
214 # Of the functions in $checkfuncs, newlib only has strerror.
215 AC_DEFINE(HAVE_STRERROR)
216
217 setobjs=yes
218
219 fi
0c0a36a4
ILT
220
221else
222
223 # Not a target library, so we set things up to run the test suite.
224 CHECK=check-cplus-dem
225
252b5132
RH
226fi
227
0c0a36a4
ILT
228AC_SUBST(CHECK)
229
252b5132
RH
230if test -z "${setobjs}"; then
231 case "${host}" in
232
233 *-*-vxworks*)
234 # Handle VxWorks configuration specially, since on VxWorks the
235 # libraries are actually on the target board, not in the file
236 # system.
237 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
238 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
239 for f in $funcs; do
240 case "$f" in
241 basename | getpagesize | insque | random | strcasecmp)
242 ;;
243 strncasecmp | strdup | vfork | waitpid | vasprintf)
244 ;;
245 *)
246 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
247 AC_DEFINE_UNQUOTED($n)
248 ;;
249 esac
250 done
251
252 # VxWorks doesn't provide any of the variables in $vars, so we
253 # don't have to check them here.
254
255 # Of the functions in $checkfuncs, VxWorks only has strerror.
256 AC_DEFINE(HAVE_STRERROR)
257
258 setobjs=yes
259 ;;
260
261 esac
262fi
263
264if test -z "${setobjs}"; then
265
266 case "${host}" in
267
268 *-*-cygwin*)
269 # The Cygwin library actually uses a couple of files from
270 # libiberty when it is built. If we are building a native
271 # Cygwin, and we run the tests, we will appear to have these
272 # files. However, when we go on to build winsup, we will wind up
273 # with a library which does not have the files, since they should
274 # have come from libiberty.
275
276 # We handle this by removing the functions the winsup library
277 # provides from our shell variables, so that they appear to be
278 # missing.
279
280 funcs="`echo $funcs | sed -e 's/random//'`"
281 LIBOBJS="$LIBOBJS random.o"
282 vars="`echo $vars | sed -e 's/sys_siglist//'`"
283 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
284 ;;
285
286 *-*-mingw32*)
287 # Under mingw32, sys_nerr and sys_errlist exist, but they are
288 # macros, so the test below won't find them.
289 vars="`echo $vars | sed -e 's/sys_nerr//' -e 's/sys_errlist//'`"
290 AC_DEFINE(HAVE_SYS_NERR)
291 AC_DEFINE(HAVE_SYS_ERRLIST)
292 ;;
293
294 *-*-uwin*)
295 # Under some versions of uwin, vfork is notoriously buggy and the test
296 # can hang configure; on other versions, vfork exists just as a stub.
297 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
298 ac_cv_func_vfork_works=no
0c0a36a4
ILT
299 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
300 # macros (actually, these are imported from a DLL, but the end effect
301 # is the same), so the test below won't find them.
302 AC_DEFINE(HAVE_SYS_NERR)
303 AC_DEFINE(HAVE_SYS_ERRLIST)
252b5132
RH
304 ;;
305
306 esac
307
308 # We haven't set the list of objects yet. Use the standard autoconf
309 # tests. This will only work if the compiler works.
310 AC_PROG_CC_WORKS
311 AC_REPLACE_FUNCS($funcs)
0c0a36a4
ILT
312
313 case "${host}" in
314 *-*-interix)
315 # On Interix, it wrongly concludes that the MSVC compiler supports alloca.
316 # (MSVC does on Win32, not on Interix.)
317 # This should be temporary.
318
319 ac_cv_header_alloca_h=no
320 ac_cv_func_alloca_works=no
321 ALLOCA=alloca.o
322 cat >> confdefs.h <<\EOF
323#define C_ALLOCA 1
324EOF
325 cat >> confdefs.h <<EOF
326#define STACK_DIRECTION -1
327EOF
328 ;;
329 *)
330 AC_FUNC_ALLOCA
331 ;;
332 esac
333
252b5132
RH
334 AC_FUNC_VFORK
335 if test $ac_cv_func_vfork_works = no; then
336 LIBOBJS="$LIBOBJS vfork.o"
337 fi
338 for v in $vars; do
339 AC_MSG_CHECKING([for $v])
340 AC_CACHE_VAL(libiberty_cv_var_$v,
341 [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
342 [eval "libiberty_cv_var_$v=yes"],
343 [eval "libiberty_cv_var_$v=no"])])
344 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
345 AC_MSG_RESULT(yes)
346 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
347 AC_DEFINE_UNQUOTED($n)
348 else
349 AC_MSG_RESULT(no)
350 fi
351 done
352 AC_CHECK_FUNCS($checkfuncs)
353fi
354
355# Install a library built with a cross compiler in $(tooldir) rather
356# than $(libdir).
357if test -z "${with_cross_host}"; then
358 INSTALL_DEST=libdir
359else
360 INSTALL_DEST=tooldir
361fi
362AC_SUBST(INSTALL_DEST)
363
364# We need multilib support, but only if configuring for the target.
0c0a36a4 365AC_OUTPUT(Makefile testsuite/Makefile,
252b5132
RH
366[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
367if test -n "$CONFIG_FILES"; then
368 if test -n "${with_target_subdir}"; then
369 # FIXME: We shouldn't need to set ac_file
370 ac_file=Makefile
371 . ${libiberty_topdir}/config-ml.in
372 fi
373fi],
374srcdir=${srcdir}
375host=${host}
376target=${target}
377with_target_subdir=${with_target_subdir}
378with_multisubdir=${with_multisubdir}
379ac_configure_args="--enable-multilib ${ac_configure_args}"
380CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
381libiberty_topdir=${libiberty_topdir}
382)
This page took 0.05639 seconds and 4 git commands to generate.