OSDN Git Service

gdb/
[pf3gnuchains/pf3gnuchains3x.git] / newlib / configure.in
1 dnl This is the newlib configure.in file.
2 dnl Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.59)
5 AC_INIT([newlib],[NEWLIB_VERSION])
6 AC_CONFIG_SRCDIR([libc])
7 AC_CONFIG_HEADER(newlib.h:newlib.hin)
8
9 dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake. 
10 AC_CONFIG_AUX_DIR(..)
11
12 dnl Support --enable-newlib-io-pos-args
13 dnl This option is actually read in libc/configure.in.  It is repeated
14 dnl here so that it shows up in the help text.
15 AC_ARG_ENABLE(newlib-io-pos-args,
16 [  --enable-newlib-io-pos-args enable printf-family positional arg support],
17 [case "${enableval}" in
18   yes) newlib_io_pos_args=yes ;;
19   no)  newlib_io_pos_args=no ;;
20   *)   AC_MSG_ERROR(bad value ${enableval} for newlib-io-pos-args option) ;;
21  esac], [newlib_io_pos_args=])dnl
22
23 dnl Support --enable-newlib-io-c99-formats
24 AC_ARG_ENABLE(newlib-io-c99-formats,
25 [  --enable-newlib-io-c99-formats   enable C99 support in IO functions like printf/scanf],
26 [case "${enableval}" in
27   yes) newlib_io_c99_formats=yes;;
28   no)  newlib_io_c99_formats=no ;;
29   *)   AC_MSG_ERROR(bad value ${enableval} for newlib-io-c99-formats option) ;;
30  esac], [newlib_io_c99_formats=])dnl
31
32 dnl Support --enable-newlib-io-long-long
33 AC_ARG_ENABLE(newlib-io-long-long,
34 [  --enable-newlib-io-long-long   enable long long type support in IO functions like printf/scanf],
35 [case "${enableval}" in
36   yes) newlib_io_long_long=yes;;
37   no)  newlib_io_long_long=no ;;
38   *)   AC_MSG_ERROR(bad value ${enableval} for newlib-io-long-long option) ;;
39  esac], [newlib_io_long_long=])dnl
40
41 dnl Support --enable-newlib-io-long-double
42 AC_ARG_ENABLE(newlib-io-long-double,
43 [  --enable-newlib-io-long-double   enable long double type support in IO functions printf/scanf],
44 [case "${enableval}" in
45   yes) newlib_io_long_double=yes;;
46   no)  newlib_io_long_double=no ;;
47   *)   AC_MSG_ERROR(bad value ${enableval} for newlib-io-long-double option) ;;
48  esac], [newlib_io_long_double=])dnl
49
50 dnl If multibyte support is enabled, iconv should be enabled too
51 dnl Support --enable-newlib-mb
52 AC_ARG_ENABLE(newlib-mb,
53 [  --enable-newlib-mb        enable multibyte support],
54 [case "${enableval}" in
55   yes) newlib_mb=yes;;
56   no)  newlib_mb=no ;;
57   *)   AC_MSG_ERROR(bad value ${enableval} for newlib-mb option) ;;
58  esac], [newlib_mb=])dnl
59
60 dnl Support --enable-newlib-iconv-encodings
61 AC_ARG_ENABLE(newlib-iconv-encodings,
62 [  --enable-newlib-iconv-encodings   enable specific comma-separated list of bidirectional iconv encodings to be built-in],
63 [if test x${enableval} = x; then
64    AC_MSG_ERROR(bad value ${enableval} for newlib-iconv-encodings option - use comma-separated encodings list)
65  fi
66  iconv_encodings=${enableval}
67  ], [iconv_encodings=])dnl
68
69 dnl Support --enable-newlib-iconv-from-encodings
70 AC_ARG_ENABLE(newlib-iconv-from-encodings,
71 [  --enable-newlib-iconv-from-encodings   enable specific comma-separated list of \"from\" iconv encodings to be built-in],
72 [if test x${enableval} = x; then
73    AC_MSG_ERROR(bad value ${enableval} for newlib-iconv-from-encodings option - use comma-separated encodings list)
74  fi
75  iconv_from_encodings=${enableval}
76  ], [iconv_from_encodings=])dnl
77
78 dnl Support --enable-newlib-iconv-to-encodings
79 AC_ARG_ENABLE(newlib-iconv-to-encodings,
80 [  --enable-newlib-iconv-to-encodings   enable specific comma-separated list of \"to\" iconv encodings to be built-in],
81 [if test x${enableval} = x; then
82    AC_MSG_ERROR(bad value ${enableval} for newlib-iconv-to-encodings option - use comma-separated encodings list)
83  fi
84  iconv_to_encodings=${enableval}
85  ], [iconv_to_encodings=])dnl
86
87 dnl Support --enable-newlib-iconv-external-ccs
88 AC_ARG_ENABLE(newlib-iconv-external-ccs,
89 [  --enable-newlib-iconv-external-ccs     enable capabilities to load external CCS files for iconv],
90 [if test "${newlib_iconv_external_ccs+set}" != set; then
91    case "${enableval}" in
92      yes) newlib_iconv_external_ccs=yes ;;
93      no)  newlib_iconv_external_ccs=no ;;
94      *)   AC_MSG_ERROR(bad value ${enableval} for newlib-iconv-external-ccs option) ;;
95    esac
96  fi], [newlib_iconv_external_ccs=${newlib_iconv_external_ccs}])dnl
97
98 dnl Support --disable-newlib-atexit-dynamic-alloc
99 AC_ARG_ENABLE(newlib-atexit-dynamic-alloc,
100 [  --disable-newlib-atexit-alloc    disable dynamic allocation of atexit entries],
101 [if test "${newlib_atexit_dynamic_alloc+set}" != set; then
102   case "${enableval}" in
103     yes) newlib_atexit_dynamic_alloc=yes ;;
104     no)  newlib_atexit_dynamic_alloc=no  ;;
105     *)   AC_MSG_ERROR(bad value ${enableval} for newlib-atexit-dynamic-alloc option) ;;
106   esac
107  fi], [newlib_atexit_dynamic_alloc=${newlib_atexit_dynamic_alloc}])dnl
108
109 dnl Support --enable-newlib-reent-small
110 AC_ARG_ENABLE(newlib-reent-small,
111 [  --enable-newlib-reent-small   enable small reentrant struct support],
112 [case "${enableval}" in
113   yes) newlib_reent_small=yes;;
114   no)  newlib_reent_small=no ;;
115   *)   AC_MSG_ERROR(bad value ${enableval} for newlib-reent-small option) ;;
116  esac], [newlib_reent_small=])dnl
117
118 NEWLIB_CONFIGURE(.)
119
120 dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and
121 dnl add it into NEWLIB_CONFIGURE, executable tests are made before the first
122 dnl line of the macro which fail because appropriate LDFLAGS are not set.
123 _LT_DECL_SED
124 AC_PROG_AWK
125 if test "${use_libtool}" = "yes"; then
126 AC_LIBTOOL_WIN32_DLL
127 AM_PROG_LIBTOOL
128 fi
129
130 AC_ARG_ENABLE(newlib_hw_fp,
131 [  --enable-newlib-hw-fp    Turn on hardware floating point math],
132 [case "${enableval}" in
133    yes) newlib_hw_fp=true ;;
134    no)  newlib_hw_fp=false ;;
135    *) AC_MSG_ERROR(bad value ${enableval} for --enable-newlib-hw-fp) ;;
136  esac],[newlib_hw_fp=false])
137 AM_CONDITIONAL(NEWLIB_HW_FP, test x$newlib_hw_fp = xtrue)
138
139 # These get added in the top-level configure.in, except in the case where
140 # newlib is being built natively.
141 LIBC_INCLUDE_GREP=`echo ${CC} | grep \/libc\/include`
142 abs_newlib_basedir=`cd ${newlib_basedir} && pwd`
143 if test -z "${LIBC_INCLUDE_GREP}"; then
144   CC_FOR_NEWLIB="${CC} -I$PWD/targ-include -I${abs_newlib_basedir}/libc/include"
145 else
146   CC_FOR_NEWLIB="${CC}"
147 fi
148 AC_SUBST(CC_FOR_NEWLIB)
149
150 AC_CONFIG_SUBDIRS(libc)
151 AC_CONFIG_SUBDIRS(libm)
152
153 if test -z "${with_multisubdir}"; then
154   AC_CONFIG_SUBDIRS(doc)
155   have_doc=yes
156 else
157   have_doc=
158 fi
159 AM_CONDITIONAL(HAVE_DOC, test x$have_doc = xyes)
160
161 EXTRA_DIRS=
162 case $host in
163   i[[34567]]86-pc-linux-*)
164         AC_CONFIG_SUBDIRS(iconvdata)
165         EXTRA_DIRS=iconvdata
166         ;;
167 esac
168 AC_SUBST(EXTRA_DIRS)
169
170 CRT0=
171 CRT0_DIR=
172 if test "x${have_crt0}" = "xyes"; then
173   CRT0=crt0.o
174   CRT0_DIR=libc/
175 fi
176 AC_SUBST(CRT0)
177 AC_SUBST(CRT0_DIR)
178
179 CRT1=${crt1}
180 CRT1_DIR=
181 if test -n "${crt1_dir}"; then
182   CRT1_DIR=${crt1_dir}/
183 fi
184 AC_SUBST(CRT1)
185 AC_SUBST(CRT1_DIR)
186
187 if test -n "${libm_machine_dir}"; then
188   LIBM_MACHINE_OBJECTLIST=libm/machine/${libm_machine_dir}/objectlist.awk.in
189 fi
190 AC_SUBST(LIBM_MACHINE_OBJECTLIST)
191
192 if test -n "${machine_dir}"; then
193   MACHINE_OBJECTLIST=libc/machine/${machine_dir}/objectlist.awk.in
194 fi
195 AC_SUBST(MACHINE_OBJECTLIST)
196
197 if test -n "${sys_dir}"; then
198   SYS_OBJECTLIST=libc/sys/${sys_dir}/objectlist.awk.in
199 fi
200 AC_SUBST(SYS_OBJECTLIST)
201
202 if test "${have_sys_mach_dir}" = "yes"; then
203   SYS_MACH_OBJECTLIST=libc/sys/${sys_dir}/machine/${machine_dir}/objectlist.awk.in
204 fi
205 AC_SUBST(SYS_MACH_OBJECTLIST)
206
207 if test -n "${posix_dir}"; then
208   POSIX_OBJECTLIST=libc/${posix_dir}/objectlist.awk.in
209 fi
210 AC_SUBST(POSIX_OBJECTLIST)
211
212 if test -n "${signal_dir}"; then
213   SIGNAL_OBJECTLIST=libc/${signal_dir}/objectlist.awk.in
214 fi
215 AC_SUBST(SIGNAL_OBJECTLIST)
216
217 if test -n "${syscall_dir}"; then
218   SYSCALL_OBJECTLIST=libc/${syscall_dir}/objectlist.awk.in
219 fi
220 AC_SUBST(SYSCALL_OBJECTLIST)
221
222 if test -n "${unix_dir}"; then
223   UNIX_OBJECTLIST=libc/${unix_dir}/objectlist.awk.in
224 fi
225 AC_SUBST(UNIX_OBJECTLIST)
226
227 if test -n "${stdio64_dir}"; then
228   STDIO64_OBJECTLIST=libc/${stdio64_dir}/objectlist.awk.in
229 fi
230 AC_SUBST(STDIO64_OBJECTLIST)
231
232 # Put a plausible default for CC_FOR_BUILD in Makefile.
233 if test -z "$CC_FOR_BUILD"; then
234   CC_FOR_BUILD=gcc
235 fi
236 AC_SUBST(CC_FOR_BUILD)
237
238 if test "${newlib_elix_level}" -gt "0"; then
239 AC_DEFINE_UNQUOTED(_ELIX_LEVEL,${newlib_elix_level})
240 fi
241
242 if test "${newlib_io_c99_formats}" = "yes"; then
243 AC_DEFINE_UNQUOTED(_WANT_IO_C99_FORMATS)
244 fi
245
246 if test "${newlib_io_long_long}" = "yes"; then
247 AC_DEFINE_UNQUOTED(_WANT_IO_LONG_LONG)
248 fi
249
250 if test "${newlib_io_long_double}" = "yes"; then
251 AC_DEFINE_UNQUOTED(_WANT_IO_LONG_DOUBLE)
252 fi
253
254 if test "${newlib_io_pos_args}" = "yes"; then
255 AC_DEFINE_UNQUOTED(_WANT_IO_POS_ARGS)
256 fi
257
258 if test "${newlib_reent_small}" = "yes"; then
259 AC_DEFINE_UNQUOTED(_WANT_REENT_SMALL)
260 fi
261
262 if test "${newlib_mb}" = "yes"; then
263 AC_DEFINE_UNQUOTED(_MB_CAPABLE)
264 AC_DEFINE_UNQUOTED(_MB_LEN_MAX,8)
265 else
266 AC_DEFINE_UNQUOTED(_MB_LEN_MAX,1)
267 fi
268
269 if test "${newlib_iconv_external_ccs}" = "yes"; then
270 AC_DEFINE_UNQUOTED(_ICONV_ENABLE_EXTERNAL_CCS)
271 fi
272
273 AC_DEFINE_UNQUOTED(_NEWLIB_VERSION,"NEWLIB_VERSION")
274
275 if test "${multilib}" = "yes"; then
276   multilib_arg="--enable-multilib"
277 else
278   multilib_arg=
279 fi
280
281 if test "${newlib_iconv}" = "yes"; then
282 AC_DEFINE_UNQUOTED(_ICONV_ENABLED,1)
283 fi
284
285 if test "x${newlib_iconv_external_ccs}" = "xyes"; then
286   if test "x${newlib_iconv}" = "x"; then
287       AC_MSG_ERROR(--enable-newlib-iconv-external-ccs option can't be used if iconv library is disabled, use --enable-newlib-iconv to enable it.)
288   fi
289   AC_DEFINE_UNQUOTED(_ICONV_ENABLE_EXTERNAL_CCS,1)
290 fi
291
292 if test "${newlib_atexit_dynamic_alloc}" = "yes"; then
293 AC_DEFINE_UNQUOTED(_ATEXIT_DYNAMIC_ALLOC)
294 fi
295
296 dnl
297 dnl Parse --enable-newlib-iconv-encodings option argument
298 dnl
299
300 if test "x${iconv_encodings}" != "x" \
301    || test "x${iconv_to_encodings}" != "x" \
302    || test "x${iconv_from_encodings}" != "x"; then
303   if test "x${newlib_iconv}" = "x"; then
304       AC_MSG_ERROR([--enable-newlib-iconv-encodings, --enable-newlib-iconv-from-encodings and --enable-newlib-iconv-to-encodings option can't be used if iconv library is disabled, use --enable-newlib-iconv to enable it.])
305   fi
306   
307   dnl Normalize encodings names and delete commas
308   iconv_encodings=`echo "${iconv_encodings}" | sed -e 's/,/ /g' -e 's/-/_/g' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
309   iconv_to_encodings=`echo "${iconv_to_encodings}" | sed -e 's/,/ /g' -e 's/-/_/g' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
310   iconv_from_encodings=`echo "${iconv_from_encodings}" | sed -e 's/,/ /g' -e 's/-/_/g' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
311  
312   dnl Get the list of available encodings excluding comments
313   dnl Join line with previous if the first character is whitespace
314   available_encodings=`cat "${srcdir}/libc/iconv/encoding.aliases" | sed -e '/^#.*/d'`
315   
316   dnl Check if required encodings are supported
317   dnl Convert aliases to names
318   
319   dnl iconv_encodings
320   iconv_encodings1="${iconv_encodings}"
321   iconv_encodings=""
322   for encoding in ${iconv_encodings1}; do
323       result=`echo "${available_encodings}" | grep -e "\(^\| \)${encoding}\( \|\$\)"`
324       if test $? != "0"; then
325           AC_MSG_ERROR(${encoding} is not supported - see ${srcdir}/libc/iconv/encoding.aliases file for the list of available encodings)
326       fi
327       encoding1=`echo "${result}" | sed -e 's/\(^[[^ ]]*\).*$/\1/'`
328       iconv_encodings="${iconv_encodings} ${encoding1}"
329   done
330   dnl Enable appropriate option in newlib.h
331   for encoding in ${iconv_encodings}; do
332       opt=_ICONV_TO_ENCODING_`echo "${encoding}" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
333       AC_DEFINE_UNQUOTED($opt,1)
334       opt=_ICONV_FROM_ENCODING_`echo "${encoding}" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
335       AC_DEFINE_UNQUOTED($opt,1)
336   done
337
338   dnl iconv_to_encodings
339   iconv_encodings1="${iconv_to_encodings}"
340   iconv_to_encodings=""
341   for encoding in ${iconv_encodings1}; do
342       result=`echo "${available_encodings}" | grep -e "\(^\| \)${encoding}\( \|\$\)"`
343       if test $? != "0"; then
344           AC_MSG_ERROR(${encoding} is not supported - see ${srcdir}/libc/iconv/encoding.aliases file for the list of available encodings)
345       fi
346       encoding1=`echo "${result}" | sed -e 's/\(^[[^ ]]*\).*$/\1/'`
347       iconv_to_encodings="${iconv_to_encodings} ${encoding1}"
348   done
349   dnl Enable appropriate option in newlib.h
350   for encoding in ${iconv_to_encodings}; do
351       opt=_ICONV_TO_ENCODING_`echo "${encoding}" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
352       AC_DEFINE_UNQUOTED($opt,1)
353   done
354
355   dnl iconv_from_encodings
356   iconv_encodings1="${iconv_from_encodings}"
357   iconv_from_encodings=""
358   for encoding in ${iconv_encodings1}; do
359       result=`echo "${available_encodings}" | grep -e "\(^\| \)${encoding}\( \|\$\)"`
360       if test $? != "0"; then
361           AC_MSG_ERROR(${encoding} is not supported - see ${srcdir}/libc/iconv/encoding.aliases file for the list of available encodings)
362       fi
363       encoding1=`echo "${result}" | sed -e 's/\(^[[^ ]]*\).*$/\1/'`
364       iconv_from_encodings="${iconv_from_encodings} ${encoding1}"
365   done
366   dnl Enable appropriate option in newlib.h
367   for encoding in ${iconv_from_encodings}; do
368       opt=_ICONV_FROM_ENCODING_`echo "${encoding}" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
369       AC_DEFINE_UNQUOTED($opt,1)
370   done
371 fi;
372
373 AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
374                libc_cv_initfinit_array, [dnl
375 cat > conftest.c <<EOF
376 int _start (void) { return 0; }
377 int __start (void) { return 0; }
378 int foo (void) { return 1; }
379 int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;
380 EOF
381 if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -c -o conftest conftest.c
382                                                         1>&AS_MESSAGE_LOG_FD])
383 then
384   if ${READELF} -S conftest | grep -e INIT_ARRAY > /dev/null; then
385     libc_cv_initfinit_array=yes
386   else
387     libc_cv_initfinit_array=no
388   fi
389 else
390   libc_cv_initfinit_array=no
391 fi
392 rm -f conftest*])
393 AC_SUBST(libc_cv_initfinit_array)
394 if test $libc_cv_initfinit_array = yes; then
395   AC_DEFINE_UNQUOTED(HAVE_INITFINI_ARRAY)
396 fi
397
398 dnl Autoconf 2.59 doesn't support the AC_TYPE_LONG_DOUBLE macro. Instead of:
399 dnl   AC_TYPE_LONG_DOUBLE
400 dnl   AM_CONDITIONAL(HAVE_LONG_DOUBLE, test x"$ac_cv_type_long_double" = x"yes")
401 dnl we specify our own long double test.
402 dnl Additionally, ac_cv_objext is broken so that AC_COMPILE_IFELSE cannot be
403 dnl used, so use AC_TRY_COMMAND instead.
404 AC_CACHE_CHECK(whether long double type exists,
405                acnewlib_cv_type_long_double, [dnl
406 cat > conftest.c <<EOF
407 /* Check two ways:  float.h defines and direct type declaration.  */
408 #include <float.h>
409 #if defined(LDBL_MANT_DIG)
410   #define _HAVE_LONG_DOUBLE
411  #else
412   #error "LDBL != DBL"
413 #endif
414 long double test() {
415 long double ld = 0.0L;
416 return ld;
417 }
418 EOF
419 if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -c -o conftest.o conftest.c
420                                                         1>&AS_MESSAGE_LOG_FD])
421 then
422   acnewlib_cv_type_long_double=yes;
423 else
424   acnewlib_cv_type_long_double=no;
425 fi
426 rm -f conftest*])
427 if test $acnewlib_cv_type_long_double = yes; then
428   AC_DEFINE_UNQUOTED(_HAVE_LONG_DOUBLE)
429 fi
430 AM_CONDITIONAL(HAVE_LONG_DOUBLE, test x"$acnewlib_cv_type_long_double" = x"yes")
431
432 AC_CACHE_CHECK(whether long double equals double,
433                newlib_cv_ldbl_eq_dbl, [dnl
434 cat > conftest.c <<EOF
435 #include <float.h>
436 #if DBL_MANT_DIG == LDBL_MANT_DIG  &&  LDBL_MIN_EXP == DBL_MIN_EXP  && \
437     LDBL_MAX_EXP == DBL_MAX_EXP
438   #define _LDBL_EQ_DBL
439  #else
440   #error "LDBL != DBL"
441 #endif
442 EOF
443 if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -c -o conftest.o conftest.c
444                                                         1>&AS_MESSAGE_LOG_FD])
445 then
446   newlib_cv_ldbl_eq_dbl=yes;
447 else
448   newlib_cv_ldbl_eq_dbl=no;
449 fi
450 rm -f conftest*])
451 if test $newlib_cv_ldbl_eq_dbl = yes; then
452   AC_DEFINE_UNQUOTED(_LDBL_EQ_DBL)
453 fi
454
455 AC_SUBST(CFLAGS)
456
457 AC_CONFIG_FILES([Makefile],
458 [if test -n "$CONFIG_FILES"; then
459   unset ac_file
460   . ${newlib_basedir}/../config-ml.in
461 fi],
462 srcdir=${srcdir}
463 host=${host}
464 with_multisubdir=${with_multisubdir}
465 ac_configure_args="${multilib_arg} ${ac_configure_args}"
466 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
467 newlib_basedir=${newlib_basedir}
468 CC="${CC}"
469 LDFLAGS="${LDFLAGS}"
470 )
471 AC_OUTPUT