merge from gcc
[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 dnl Very limited version of automake's enable-maintainer-mode
30
31 AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
32 dnl maintainer-mode is disabled by default
33 AC_ARG_ENABLE(maintainer-mode,
34 [ --enable-maintainer-mode
35 enable make rules and dependencies not useful
36 (and sometimes confusing) to the casual installer],
37 maintainer_mode=$enableval,
38 maintainer_mode=no)
39
40 AC_MSG_RESULT($maintainer_mode)
41
42 if test "$maintainer_mode" = "yes"; then
43 MAINT=''
44 NOTMAINT='#'
45 else
46 MAINT='#'
47 NOTMAINT=''
48 fi
49 AC_SUBST(MAINT)dnl
50 AC_SUBST(NOTMAINT)dnl
51
52 # Do we have a single-tree copy of texinfo? Even if we do, we can't
53 # rely on it - libiberty is built before texinfo.
54 AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, )
55 BUILD_INFO=info
56 case x"`$MAKEINFO --version | grep 'GNU texinfo'`" in
57 x*\ [[1-3]].* )
58 MAKEINFO="@echo $MAKEINFO is too old, 4.0 or newer required ;true"
59 BUILD_INFO=
60 AC_MSG_WARN([
61 *** Makeinfo is too old. Info documentation will not be built.])
62 ;;
63 esac
64 AC_SUBST(MAKEINFO)
65 AC_SUBST(BUILD_INFO)
66
67 AC_CHECK_PROG(PERL, perl, perl, )
68 if test x"$PERL" = x""; then
69 HAVE_PERL='#'
70 else
71 HAVE_PERL=''
72 fi
73 AC_SUBST(HAVE_PERL)
74
75 AC_CANONICAL_HOST
76
77 dnl When we start using automake:
78 dnl AM_INIT_AUTOMAKE(libiberty, 1.0)
79
80 dnl These must be called before AM_PROG_LIBTOOL, because it may want
81 dnl to call AC_CHECK_PROG.
82 AC_CHECK_TOOL(AR, ar)
83 AC_CHECK_TOOL(RANLIB, ranlib, :)
84
85 LIB_AC_PROG_CC
86
87 AC_ISC_POSIX
88 AC_C_CONST
89 AC_C_INLINE
90
91 dnl When we start using libtool:
92 dnl Default to a non shared library. This may be overridden by the
93 dnl configure option --enable-shared.
94 dnl AM_DISABLE_SHARED
95
96 dnl When we start using libtool:
97 dnl AM_PROG_LIBTOOL
98
99 dnl When we start using automake:
100 dnl AM_CONFIG_HEADER(config.h:config.in)
101 AC_CONFIG_HEADER(config.h:config.in)
102
103 dnl When we start using automake:
104 dnl AM_MAINTAINER_MODE
105 dnl AC_EXEEXT
106
107 dnl When we start using automake:
108 dnl AM_PROG_INSTALL
109 AC_PROG_INSTALL
110
111 . ${srcdir}/config.table
112 host_makefile_frag=${frag}
113 AC_SUBST_FILE(host_makefile_frag)
114
115 # It's OK to check for header files. Although the compiler may not be
116 # able to link anything, it had better be able to at least compile
117 # something.
118 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)
119 AC_HEADER_SYS_WAIT
120 AC_HEADER_TIME
121
122 libiberty_AC_DECLARE_ERRNO
123
124 # This is the list of functions which libiberty will provide if they
125 # are not available on the host.
126
127 funcs="asprintf"
128 funcs="$funcs atexit"
129 funcs="$funcs basename"
130 funcs="$funcs bcmp"
131 funcs="$funcs bcopy"
132 funcs="$funcs bsearch"
133 funcs="$funcs bzero"
134 funcs="$funcs calloc"
135 funcs="$funcs clock"
136 funcs="$funcs ffs"
137 funcs="$funcs getcwd"
138 funcs="$funcs getpagesize"
139 funcs="$funcs index"
140 funcs="$funcs insque"
141 funcs="$funcs memchr"
142 funcs="$funcs memcmp"
143 funcs="$funcs memcpy"
144 funcs="$funcs memmove"
145 funcs="$funcs memset"
146 funcs="$funcs mkstemps"
147 funcs="$funcs putenv"
148 funcs="$funcs random"
149 funcs="$funcs rename"
150 funcs="$funcs rindex"
151 funcs="$funcs setenv"
152 funcs="$funcs sigsetmask"
153 funcs="$funcs strcasecmp"
154 funcs="$funcs strchr"
155 funcs="$funcs strdup"
156 funcs="$funcs strncasecmp"
157 funcs="$funcs strrchr"
158 funcs="$funcs strstr"
159 funcs="$funcs strtod"
160 funcs="$funcs strtol"
161 funcs="$funcs strtoul"
162 funcs="$funcs tmpnam"
163 funcs="$funcs vasprintf"
164 funcs="$funcs vfprintf"
165 funcs="$funcs vprintf"
166 funcs="$funcs vsprintf"
167 funcs="$funcs waitpid"
168
169 # Also in the old function.def file: alloca, vfork, getopt.
170
171 vars="sys_errlist sys_nerr sys_siglist"
172
173 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times sbrk gettimeofday"
174
175 # These are neither executed nor required, but they help keep
176 # autoheader happy without adding a bunch of text to acconfig.h.
177 if test "x" = "y"; then
178 AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bsearch bzero calloc clock)
179 AC_CHECK_FUNCS(getcwd getpagesize index insque mkstemps memchr memcmp memcpy)
180 AC_CHECK_FUNCS(memmove memset putenv random rename rindex sigsetmask)
181 AC_CHECK_FUNCS(strcasecmp setenv strchr strdup strncasecmp strrchr strstr)
182 AC_CHECK_FUNCS(strtod strtol strtoul tmpnam vasprintf vfprintf vprintf)
183 AC_CHECK_FUNCS(vsprintf waitpid getrusage on_exit psignal strerror strsignal)
184 AC_CHECK_FUNCS(sysconf times sbrk gettimeofday ffs)
185 AC_DEFINE(HAVE_SYS_ERRLIST, 1, [Define if you have the sys_errlist variable.])
186 AC_DEFINE(HAVE_SYS_NERR, 1, [Define if you have the sys_nerr variable.])
187 AC_DEFINE(HAVE_SYS_SIGLIST, 1, [Define if you have the sys_siglist variable.])
188 fi
189
190 # For each of these functions, if the host does not provide the
191 # function we want to put FN.o in LIBOBJS, and if the host does
192 # provide the function, we want to define HAVE_FN in config.h.
193
194 setobjs=
195 CHECK=
196 if test -n "${with_target_subdir}"; then
197
198 # We are being configured as a target library. AC_REPLACE_FUNCS
199 # may not work correctly, because the compiler may not be able to
200 # link executables. Note that we may still be being configured
201 # native.
202
203 # If we are being configured for newlib, we know which functions
204 # newlib provide and which ones we will be expected to provide.
205
206 if test "x${with_newlib}" = "xyes"; then
207 LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
208
209 for f in $funcs; do
210 case "$f" in
211 asprintf | basename | insque | random | strdup | vasprintf)
212 ;;
213 *)
214 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
215 AC_DEFINE_UNQUOTED($n)
216 ;;
217 esac
218 done
219
220 # newlib doesnt provide any of the variables in $vars, so we
221 # dont have to check them here.
222
223 # Of the functions in $checkfuncs, newlib only has strerror.
224 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
225
226 setobjs=yes
227
228 fi
229
230 else
231
232 # Not a target library, so we set things up to run the test suite.
233 CHECK=check-cplus-dem
234
235 fi
236
237 AC_SUBST(CHECK)
238
239 case "${host}" in
240 *-*-cygwin*)
241 AC_DEFINE(HAVE_SYS_ERRLIST)
242 AC_DEFINE(HAVE_SYS_NERR)
243 ;;
244 esac
245
246 if test -z "${setobjs}"; then
247 case "${host}" in
248
249 *-*-vxworks*)
250 # Handle VxWorks configuration specially, since on VxWorks the
251 # libraries are actually on the target board, not in the file
252 # system.
253 LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
254 LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
255 for f in $funcs; do
256 case "$f" in
257 basename | getpagesize | insque | random | strcasecmp)
258 ;;
259 strncasecmp | strdup | vfork | waitpid | vasprintf)
260 ;;
261 *)
262 n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
263 AC_DEFINE_UNQUOTED($n)
264 ;;
265 esac
266 done
267
268 # VxWorks doesn't provide any of the variables in $vars, so we
269 # don't have to check them here.
270
271 # Of the functions in $checkfuncs, VxWorks only has strerror.
272 AC_DEFINE_NOAUTOHEADER(HAVE_STRERROR)
273
274 setobjs=yes
275 ;;
276
277 esac
278 fi
279
280 if test -z "${setobjs}"; then
281
282 case "${host}" in
283
284 *-*-cygwin*)
285 # The Cygwin library actually uses a couple of files from
286 # libiberty when it is built. If we are building a native
287 # Cygwin, and we run the tests, we will appear to have these
288 # files. However, when we go on to build winsup, we will wind up
289 # with a library which does not have the files, since they should
290 # have come from libiberty.
291
292 # We handle this by removing the functions the winsup library
293 # provides from our shell variables, so that they appear to be
294 # missing.
295
296 # DJ - only if we're *building* cygwin, not just building *with* cygwin
297
298 if test -n "${with_target_subdir}"
299 then
300 funcs="`echo $funcs | sed -e 's/random//'`"
301 LIBOBJS="$LIBOBJS random.o"
302 vars="`echo $vars | sed -e 's/sys_siglist//'`"
303 checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
304 fi
305 ;;
306
307 *-*-mingw32*)
308 # Under mingw32, sys_nerr and sys_errlist exist, but they are
309 # macros, so the test below won't find them.
310 libiberty_cv_var_sys_nerr=yes
311 libiberty_cv_var_sys_errlist=yes
312 ;;
313
314 *-*-uwin*)
315 # Under some versions of uwin, vfork is notoriously buggy and the test
316 # can hang configure; on other versions, vfork exists just as a stub.
317 # FIXME: This should be removed once vfork in uwin's runtime is fixed.
318 ac_cv_func_vfork_works=no
319 # Under uwin 2.0+, sys_nerr and sys_errlist exist, but they are
320 # macros (actually, these are imported from a DLL, but the end effect
321 # is the same), so the test below won't find them.
322 libiberty_cv_var_sys_nerr=yes
323 libiberty_cv_var_sys_errlist=yes
324 ;;
325
326 esac
327
328 # We haven't set the list of objects yet. Use the standard autoconf
329 # tests. This will only work if the compiler works.
330 AC_PROG_CC_WORKS
331 AC_REPLACE_FUNCS($funcs)
332 libiberty_AC_FUNC_C_ALLOCA
333 AC_FUNC_VFORK
334 if test $ac_cv_func_vfork_works = no; then
335 LIBOBJS="$LIBOBJS vfork.o"
336 fi
337 for v in $vars; do
338 AC_MSG_CHECKING([for $v])
339 AC_CACHE_VAL(libiberty_cv_var_$v,
340 [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
341 [eval "libiberty_cv_var_$v=yes"],
342 [eval "libiberty_cv_var_$v=no"])])
343 if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
344 AC_MSG_RESULT(yes)
345 n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
346 AC_DEFINE_UNQUOTED($n)
347 else
348 AC_MSG_RESULT(no)
349 fi
350 done
351 AC_CHECK_FUNCS($checkfuncs)
352 fi
353
354 libiberty_AC_FUNC_STRNCMP
355
356 # Install a library built with a cross compiler in $(tooldir) rather
357 # than $(libdir).
358 if test -z "${with_cross_host}"; then
359 INSTALL_DEST=libdir
360 else
361 INSTALL_DEST=tooldir
362 fi
363 AC_SUBST(INSTALL_DEST)
364
365 # We need multilib support, but only if configuring for the target.
366 AC_OUTPUT(Makefile testsuite/Makefile,
367 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
368 if test -n "$CONFIG_FILES"; then
369 if test -n "${with_target_subdir}"; then
370 # FIXME: We shouldn't need to set ac_file
371 ac_file=Makefile
372 . ${libiberty_topdir}/config-ml.in
373 fi
374 fi],
375 srcdir=${srcdir}
376 host=${host}
377 target=${target}
378 with_target_subdir=${with_target_subdir}
379 with_multisubdir=${with_multisubdir}
380 ac_configure_args="--enable-multilib ${ac_configure_args}"
381 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
382 libiberty_topdir=${libiberty_topdir}
383 )