OSDN Git Service

* configure.in: detect cygwin* instead of cygwin32*
[pf3gnuchains/gcc-fork.git] / libiberty / configure.in
1 dnl Process this file with autoconf to produce a configure script
2
3 AC_PREREQ(2.5)
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 dnl Check whether -g works, even if CFLAGS is set, in case the package
59 dnl plays around with CFLAGS (such as to build both debugging and
60 dnl normal versions of a library), tasteless as that idea is.
61   ac_test_CFLAGS="${CFLAGS+set}"
62   ac_save_CFLAGS="$CFLAGS"
63   CFLAGS=
64   AC_PROG_CC_G
65   if test "$ac_test_CFLAGS" = set; then
66     CFLAGS="$ac_save_CFLAGS"
67   elif test $ac_cv_prog_cc_g = yes; then
68     CFLAGS="-g -O2"
69   else
70     CFLAGS="-O2"
71   fi
72 else
73   GCC=
74   test "${CFLAGS+set}" = set || CFLAGS="-g"
75 fi
76 ])
77
78 LIB_AC_PROG_CC
79
80 AC_ISC_POSIX
81
82 dnl When we start using libtool:
83 dnl Default to a non shared library.  This may be overridden by the
84 dnl configure option --enable-shared.
85 dnl AM_DISABLE_SHARED
86
87 dnl When we start using libtool:
88 dnl AM_PROG_LIBTOOL
89
90 dnl When we start using automake:
91 dnl AM_CONFIG_HEADER(config.h:config.in)
92 AC_CONFIG_HEADER(config.h:config.in)
93
94 dnl When we start using automake:
95 dnl AM_MAINTAINER_MODE
96 dnl AC_EXEEXT
97
98 dnl When we start using automake:
99 dnl AM_PROG_INSTALL
100 AC_PROG_INSTALL
101
102 . ${srcdir}/config.table
103 host_makefile_frag=${frag}
104 AC_SUBST_FILE(host_makefile_frag)
105
106 # It's OK to check for header files.  Although the compiler may not be
107 # able to link anything, it had better be able to at least compile
108 # something.
109 AC_CHECK_HEADERS(sys/file.h sys/param.h stdlib.h string.h unistd.h strings.h sys/time.h)
110 AC_HEADER_SYS_WAIT
111
112 # This is the list of functions which libiberty will provide if they
113 # are not available on the host.
114
115 funcs="asprintf"
116 funcs="$funcs atexit"
117 funcs="$funcs basename"
118 funcs="$funcs bcmp"
119 funcs="$funcs bcopy"
120 funcs="$funcs bzero"
121 funcs="$funcs calloc"
122 funcs="$funcs clock"
123 funcs="$funcs getcwd"
124 funcs="$funcs getpagesize"
125 funcs="$funcs index"
126 funcs="$funcs insque"
127 funcs="$funcs memchr"
128 funcs="$funcs memcmp"
129 funcs="$funcs memcpy"
130 funcs="$funcs memmove"
131 funcs="$funcs memset"
132 funcs="$funcs random"
133 funcs="$funcs rename"
134 funcs="$funcs rindex"
135 funcs="$funcs sigsetmask"
136 funcs="$funcs strcasecmp"
137 funcs="$funcs strchr"
138 funcs="$funcs strdup"
139 funcs="$funcs strncasecmp"
140 funcs="$funcs strrchr"
141 funcs="$funcs strstr"
142 funcs="$funcs strtod"
143 funcs="$funcs strtol"
144 funcs="$funcs strtoul"
145 funcs="$funcs tmpnam"
146 funcs="$funcs vasprintf"
147 funcs="$funcs vfprintf"
148 funcs="$funcs vprintf"
149 funcs="$funcs vsprintf"
150 funcs="$funcs waitpid"
151
152 # Also in the old function.def file: alloca, vfork, getopt.
153
154 vars="sys_errlist sys_nerr sys_siglist"
155
156 checkfuncs="getrusage on_exit psignal strerror strsignal sysconf times"
157
158 # These are neither executed nor required, but they help keep
159 # autoheader happy without adding a bunch of text to acconfig.h.
160 if test "x" = "y"; then
161   AC_CHECK_FUNCS(asprintf atexit basename bcmp bcopy bzero calloc clock getcwd)
162   AC_CHECK_FUNCS(getpagesize index insque memchr memcmp memcpy memmove)
163   AC_CHECK_FUNCS(memset random rename rindex sigsetmask strcasecmp)
164   AC_CHECK_FUNCS(strchr strdup strncasecmp strrchr strstr strtod strtol)
165   AC_CHECK_FUNCS(strtoul tmpnam vasprintf vfprintf vprintf vsprintf waitpid)
166   AC_DEFINE(HAVE_SYS_ERRLIST)
167   AC_DEFINE(HAVE_SYS_NERR)
168   AC_DEFINE(HAVE_SYS_SIGLIST)
169   AC_CHECK_FUNCS(getrusage on_exit psignal strerror strsignal sysconf times)
170 fi
171
172 # For each of these functions, if the host does not provide the
173 # function we want to put FN.o in LIBOBJS, and if the host does
174 # provide the function, we want to define HAVE_FN in config.h.  Also,
175 # if the host does not provide alloca, we set ALLOCA to alloca.o
176
177 setobjs=
178 if test -n "${with_target_subdir}"; then
179
180   # We are being configured as a target library.  AC_REPLACE_FUNCS
181   # may not work correctly, because the compiler may not be able to
182   # link executables.  Note that we may still be being configured
183   # native.
184
185   # If we are being configured for newlib, we know which functions
186   # newlib provide and which ones we will be expected to provide.
187
188   if test "x${with_newlib}" = "xyes"; then
189     ALLOCA="alloca.o"
190     LIBOBJS="asprintf.o basename.o insque.o random.o strdup.o vasprintf.o"
191
192     for f in $funcs; do
193       case "$f" in
194         asprintf | basename | insque | random | strdup | vasprintf)
195           ;;
196         *)
197           n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
198           AC_DEFINE_UNQUOTED($n)
199           ;;
200       esac
201     done
202
203     # newlib doesnt provide any of the variables in $vars, so we
204     # dont have to check them here.
205
206     # Of the functions in $checkfuncs, newlib only has strerror.
207     AC_DEFINE(HAVE_STRERROR)
208
209     setobjs=yes
210
211   fi
212 fi
213
214 if test -z "${setobjs}"; then
215   case "${host}" in
216
217   *-*-vxworks*)
218     # Handle VxWorks configuration specially, since on VxWorks the
219     # libraries are actually on the target board, not in the file
220     # system.
221     LIBOBJS="basename.o getpagesize.o insque.o random.o strcasecmp.o"
222     LIBOBJS="$LIBOBJS strncasecmp.o strdup.o vfork.o waitpid.o vasprintf.o"
223     for f in $funcs; do
224       case "$f" in
225         basename | getpagesize | insque | random | strcasecmp)
226           ;;
227         strncasecmp | strdup | vfork | waitpid | vasprintf)
228           ;;
229         *)
230           n=HAVE_`echo $f | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
231           AC_DEFINE_UNQUOTED($n)
232           ;;
233       esac
234     done
235
236     # VxWorks doesn't provide any of the variables in $vars, so we
237     # don't have to check them here.
238
239     # Of the functions in $checkfuncs, VxWorks only has strerror.
240     AC_DEFINE(HAVE_STRERROR)
241
242     setobjs=yes
243     ;;
244
245   esac
246 fi
247
248 if test -z "${setobjs}"; then
249
250   case "${host}" in
251
252   *-*-cygwin*)
253     # The Cygwin library actually uses a couple of files from
254     # libiberty when it is built.  If we are building a native
255     # Cygwin, and we run the tests, we will appear to have these
256     # files.  However, when we go on to build winsup, we will wind up
257     # with a library which does not have the files, since they should
258     # have come from libiberty.
259
260     # We handle this by removing the functions the winsup library
261     # provides from our shell variables, so that they appear to be
262     # missing.
263
264     funcs="`echo $funcs | sed -e 's/random//'`"
265     LIBOBJS="$LIBOBJS random.o"
266     vars="`echo $vars | sed -e 's/sys_siglist//'`"
267     checkfuncs="`echo $checkfuncs | sed -e 's/strsignal//' -e 's/psignal//'`"
268     ;;
269
270   *-*-mingw32*)
271     # Under mingw32, sys_nerr and sys_errlist exist, but they are
272     # macros, so the test below won't find them.
273     vars="`echo $vars | sed -e 's/sys_nerr//' -e 's/sys_errlist//'`"
274     AC_DEFINE(HAVE_SYS_NERR)
275     AC_DEFINE(HAVE_SYS_ERRLIST)
276     ;;
277
278   esac
279
280   # We haven't set the list of objects yet.  Use the standard autoconf
281   # tests.  This will only work if the compiler works.
282   AC_PROG_CC_WORKS
283   AC_REPLACE_FUNCS($funcs)
284   AC_FUNC_ALLOCA
285   AC_FUNC_VFORK
286   if test $ac_cv_func_vfork_works = no; then
287     LIBOBJS="$LIBOBJS vfork.o"
288   fi
289   for v in $vars; do
290     AC_MSG_CHECKING([for $v])
291     AC_CACHE_VAL(libiberty_cv_var_$v,
292       [AC_TRY_LINK([int *p;], [extern int $v; p = &$v;],
293                    [eval "libiberty_cv_var_$v=yes"],
294                    [eval "libiberty_cv_var_$v=no"])])
295     if eval "test \"`echo '$libiberty_cv_var_'$v`\" = yes"; then
296       AC_MSG_RESULT(yes)
297       n=HAVE_`echo $v | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
298       AC_DEFINE_UNQUOTED($n)
299     else
300       AC_MSG_RESULT(no)
301     fi
302   done
303   AC_CHECK_FUNCS($checkfuncs)
304 fi
305
306 # Install a library built with a cross compiler in $(tooldir) rather
307 # than $(libdir).
308 if test -z "${with_cross_host}"; then
309   INSTALL_DEST=libdir
310 else
311   INSTALL_DEST=tooldir
312 fi
313 AC_SUBST(INSTALL_DEST)
314
315 # We need multilib support, but only if configuring for the target.
316 AC_OUTPUT(Makefile,
317 [test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h
318 if test -n "$CONFIG_FILES"; then
319   if test -n "${with_target_subdir}"; then
320     # FIXME: We shouldn't need to set ac_file
321     ac_file=Makefile
322     . ${libiberty_topdir}/config-ml.in
323   fi
324 fi],
325 srcdir=${srcdir}
326 host=${host}
327 target=${target}
328 with_target_subdir=${with_target_subdir}
329 with_multisubdir=${with_multisubdir}
330 ac_configure_args="--enable-multilib ${ac_configure_args}"
331 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
332 libiberty_topdir=${libiberty_topdir}
333 )