OSDN Git Service

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