OSDN Git Service

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