Undo some formatting fixes
[deliverable/binutils-gdb.git] / libiberty / configure.in
1 dnl Process this file with autoconf to produce a configure script
2
3 AC_PREREQ(2.13)
4 AC_INIT(pexecute.c)
5
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])
11 AC_ARG_WITH(newlib,
12 [ --with-newlib Configuring with newlib])
13
14 if 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
24 else
25 libiberty_topdir="${srcdir}/.."
26 fi
27 AC_CONFIG_AUX_DIR($libiberty_topdir)
28
29 AC_CANONICAL_HOST
30
31 dnl When we start using automake:
32 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
33
34 dnl These must be called before AM_PROG_LIBTOOL, because it may want
35 dnl to call AC_CHECK_PROG.
36 AC_CHECK_TOOL(AR, ar)
37 AC_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
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])
52 fi
53
54 AC_PROG_CC_GNU
55
56 if test $ac_cv_prog_gcc = yes; then
57 GCC=yes
58 ac_libiberty_warn_cflags='-W -Wall -Wtraditional -pedantic'
59 dnl Check whether -g works, even if CFLAGS is set, in case the package
60 dnl plays around with CFLAGS (such as to build both debugging and
61 dnl 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
73 else
74 GCC=
75 ac_libiberty_warn_cflags=
76 test "${CFLAGS+set}" = set || CFLAGS="-g"
77 fi
78 ])
79 AC_SUBST(ac_libiberty_warn_cflags)
80
81 LIB_AC_PROG_CC
82
83 AC_ISC_POSIX
84
85 dnl When we start using libtool:
86 dnl Default to a non shared library. This may be overridden by the
87 dnl configure option --enable-shared.
88 dnl AM_DISABLE_SHARED
89
90 dnl When we start using libtool:
91 dnl AM_PROG_LIBTOOL
92
93 dnl When we start using automake:
94 dnl AM_CONFIG_HEADER(config.h:config.in)
95 AC_CONFIG_HEADER(config.h:config.in)
96
97 dnl When we start using automake:
98 dnl AM_MAINTAINER_MODE
99 dnl AC_EXEEXT
100
101 dnl When we start using automake:
102 dnl AM_PROG_INSTALL
103 AC_PROG_INSTALL
104
105 . ${srcdir}/config.table
106 host_makefile_frag=${frag}
107 AC_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.
112 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)
113 AC_HEADER_SYS_WAIT
114 AC_HEADER_TIME
115
116 libiberty_AC_DECLARE_ERRNO
117
118 # This is the list of functions which libiberty will provide if they
119 # are not available on the host.
120
121 funcs="asprintf"
122 funcs="$funcs atexit"
123 funcs="$funcs basename"
124 funcs="$funcs bcmp"
125 funcs="$funcs bcopy"
126 funcs="$funcs bzero"
127 funcs="$funcs calloc"
128 funcs="$funcs clock"
129 funcs="$funcs getcwd"
130 funcs="$funcs getpagesize"
131 funcs="$funcs index"
132 funcs="$funcs insque"
133 funcs="$funcs memchr"
134 funcs="$funcs memcmp"
135 funcs="$funcs memcpy"
136 funcs="$funcs memmove"
137 funcs="$funcs memset"
138 funcs="$funcs mkstemps"
139 funcs="$funcs putenv"
140 funcs="$funcs random"
141 funcs="$funcs rename"
142 funcs="$funcs rindex"
143 funcs="$funcs setenv"
144 funcs="$funcs sigsetmask"
145 funcs="$funcs strcasecmp"
146 funcs="$funcs strchr"
147 funcs="$funcs strdup"
148 funcs="$funcs strncasecmp"
149 funcs="$funcs strrchr"
150 funcs="$funcs strstr"
151 funcs="$funcs strtod"
152 funcs="$funcs strtol"
153 funcs="$funcs strtoul"
154 funcs="$funcs tmpnam"
155 funcs="$funcs vasprintf"
156 funcs="$funcs vfprintf"
157 funcs="$funcs vprintf"
158 funcs="$funcs vsprintf"
159 funcs="$funcs waitpid"
160
161 # Also in the old function.def file: alloca, vfork, getopt.
162
163 vars="sys_errlist sys_nerr sys_siglist"
164
165 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
166
167 # These are neither executed nor required, but they help keep
168 # autoheader happy without adding a bunch of text to acconfig.h.
169 if test "x" = "y"; then
170 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bzero calloc clock getcwd)
171 AC_CHECK_FUNCS(getpagesize index insque mkstemps memchr memcmp memcpy memmove)
172 AC_CHECK_FUNCS(memset putenv random rename rindex sigsetmask strcasecmp)
173 AC_CHECK_FUNCS(setenv strchr strdup strncasecmp strrchr strstr strtod strtol)
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)
179 AC_CHECK_FUNCS(sbrk gettimeofday)
180 fi
181
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
187 setobjs=
188 CHECK=
189 if test -n "${with_target_subdir}"; then
190
191 # We are being configured as a target library. AC_REPLACE_FUNCS
192 # may not work correctly, because the compiler may not be able to
193 # link executables. Note that we may still be being configured
194 # native.
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"
201 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
202
203 for f in $funcs; do
204 case "$f" in
205 asprintf | basename | insque | random | strdup | vasprintf)
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
217 # Of the functions in $checkfuncs, newlib only has strerror.
218 AC_DEFINE(HAVE_STRERROR)
219
220 setobjs=yes
221
222 fi
223
224 else
225
226 # Not a target library, so we set things up to run the test suite.
227 CHECK=check-cplus-dem
228
229 fi
230
231 AC_SUBST(CHECK)
232
233 if 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
265 fi
266
267 if test -z "${setobjs}"; then
268
269 case "${host}" in
270
271 *-*-cygwin*)
272 # The Cygwin library actually uses a couple of files from
273 # libiberty when it is built. If we are building a native
274 # Cygwin, and we run the tests, we will appear to have these
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
283 funcs="`echo $funcs | sed -e 's/random//'`"
284 LIBOBJS="$LIBOBJS random.o"
285 vars="`echo $vars | sed -e 's/sys_siglist//'`"
286 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
287 ;;
288
289 *-*-mingw32*)
290 # Under mingw32, sys_nerr and sys_errlist exist, but they are
291 # macros, so the test below won't find them.
292 vars="`echo $vars | sed -e 's/sys_nerr//' -e 's/sys_errlist//'`"
293 AC_DEFINE(HAVE_SYS_NERR)
294 AC_DEFINE(HAVE_SYS_ERRLIST)
295 ;;
296
297 *-*-uwin*)
298 # Under some versions of uwin, vfork is notoriously buggy and the test
299 # can hang configure; on other versions, vfork exists just as a stub.
300 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
301 ac_cv_func_vfork_works=no
302 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
303 # macros (actually, these are imported from a DLL, but the end effect
304 # is the same), so the test below won't find them.
305 AC_DEFINE(HAVE_SYS_NERR)
306 AC_DEFINE(HAVE_SYS_ERRLIST)
307 ;;
308
309 esac
310
311 # We haven't set the list of objects yet. Use the standard autoconf
312 # tests. This will only work if the compiler works.
313 AC_PROG_CC_WORKS
314 AC_REPLACE_FUNCS($funcs)
315
316 case "${host}" in
317 *-*-interix)
318 # On Interix, it wrongly concludes that the MSVC compiler supports alloca.
319 # (MSVC does on Win32, not on Interix.)
320 # This should be temporary.
321
322 ac_cv_header_alloca_h=no
323 ac_cv_func_alloca_works=no
324 ALLOCA=alloca.o
325 cat >> confdefs.h <<\EOF
326 #define C_ALLOCA 1
327 EOF
328 cat >> confdefs.h <<EOF
329 #define STACK_DIRECTION -1
330 EOF
331 ;;
332 *)
333 AC_FUNC_ALLOCA
334 ;;
335 esac
336
337 AC_FUNC_VFORK
338 if test $ac_cv_func_vfork_works = no; then
339 LIBOBJS="$LIBOBJS vfork.o"
340 fi
341 for v in $vars; do
342 AC_MSG_CHECKING([for $v])
343 AC_CACHE_VAL(libiberty_cv_var_$v,
344 [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
345 [eval "libiberty_cv_var_$v=yes"],
346 [eval "libiberty_cv_var_$v=no"])])
347 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
348 AC_MSG_RESULT(yes)
349 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
350 AC_DEFINE_UNQUOTED($n)
351 else
352 AC_MSG_RESULT(no)
353 fi
354 done
355 AC_CHECK_FUNCS($checkfuncs)
356 fi
357
358 libiberty_AC_FUNC_STRNCMP
359
360 # Install a library built with a cross compiler in $(tooldir) rather
361 # than $(libdir).
362 if test -z "${with_cross_host}"; then
363 INSTALL_DEST=libdir
364 else
365 INSTALL_DEST=tooldir
366 fi
367 AC_SUBST(INSTALL_DEST)
368
369 # We need multilib support, but only if configuring for the target.
370 AC_OUTPUT(Makefile testsuite/Makefile,
371 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
372 if test -n "$CONFIG_FILES"; then
373 if test -n "${with_target_subdir}"; then
374 # FIXME: We shouldn't need to set ac_file
375 ac_file=Makefile
376 . ${libiberty_topdir}/config-ml.in
377 fi
378 fi],
379 srcdir=${srcdir}
380 host=${host}
381 target=${target}
382 with_target_subdir=${with_target_subdir}
383 with_multisubdir=${with_multisubdir}
384 ac_configure_args="--enable-multilib ${ac_configure_args}"
385 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
386 libiberty_topdir=${libiberty_topdir}
387 )
This page took 0.039477 seconds and 4 git commands to generate.