1 dnl This is the newlib configure.in file.
2 dnl Process this file with autoconf to produce a configure script.
5 AC_INIT([newlib],[NEWLIB_VERSION])
6 AC_CONFIG_SRCDIR([libc])
7 AC_CONFIG_HEADER(newlib.h:newlib.hin)
9 dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake.
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
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
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
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
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
57 *) AC_MSG_ERROR(bad value ${enableval} for newlib-mb option) ;;
58 esac], [newlib_mb=])dnl
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)
66 iconv_encodings=${enableval}
67 ], [iconv_encodings=])dnl
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)
75 iconv_from_encodings=${enableval}
76 ], [iconv_from_encodings=])dnl
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)
84 iconv_to_encodings=${enableval}
85 ], [iconv_to_encodings=])dnl
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) ;;
96 fi], [newlib_iconv_external_ccs=${newlib_iconv_external_ccs}])dnl
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) ;;
107 fi], [newlib_atexit_dynamic_alloc=${newlib_atexit_dynamic_alloc}])dnl
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
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.
125 if test "${use_libtool}" = "yes"; then
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)
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"
146 CC_FOR_NEWLIB="${CC}"
148 AC_SUBST(CC_FOR_NEWLIB)
150 AC_CONFIG_SUBDIRS(libc)
151 AC_CONFIG_SUBDIRS(libm)
153 if test -z "${with_multisubdir}"; then
154 AC_CONFIG_SUBDIRS(doc)
159 AM_CONDITIONAL(HAVE_DOC, test x$have_doc = xyes)
163 i[[34567]]86-pc-linux-*)
164 AC_CONFIG_SUBDIRS(iconvdata)
172 if test "x${have_crt0}" = "xyes"; then
181 if test -n "${crt1_dir}"; then
182 CRT1_DIR=${crt1_dir}/
187 if test -n "${libm_machine_dir}"; then
188 LIBM_MACHINE_OBJECTLIST=libm/machine/${libm_machine_dir}/objectlist.awk.in
190 AC_SUBST(LIBM_MACHINE_OBJECTLIST)
192 if test -n "${machine_dir}"; then
193 MACHINE_OBJECTLIST=libc/machine/${machine_dir}/objectlist.awk.in
195 AC_SUBST(MACHINE_OBJECTLIST)
197 if test -n "${sys_dir}"; then
198 SYS_OBJECTLIST=libc/sys/${sys_dir}/objectlist.awk.in
200 AC_SUBST(SYS_OBJECTLIST)
202 if test "${have_sys_mach_dir}" = "yes"; then
203 SYS_MACH_OBJECTLIST=libc/sys/${sys_dir}/machine/${machine_dir}/objectlist.awk.in
205 AC_SUBST(SYS_MACH_OBJECTLIST)
207 if test -n "${posix_dir}"; then
208 POSIX_OBJECTLIST=libc/${posix_dir}/objectlist.awk.in
210 AC_SUBST(POSIX_OBJECTLIST)
212 if test -n "${signal_dir}"; then
213 SIGNAL_OBJECTLIST=libc/${signal_dir}/objectlist.awk.in
215 AC_SUBST(SIGNAL_OBJECTLIST)
217 if test -n "${syscall_dir}"; then
218 SYSCALL_OBJECTLIST=libc/${syscall_dir}/objectlist.awk.in
220 AC_SUBST(SYSCALL_OBJECTLIST)
222 if test -n "${unix_dir}"; then
223 UNIX_OBJECTLIST=libc/${unix_dir}/objectlist.awk.in
225 AC_SUBST(UNIX_OBJECTLIST)
227 if test -n "${stdio64_dir}"; then
228 STDIO64_OBJECTLIST=libc/${stdio64_dir}/objectlist.awk.in
230 AC_SUBST(STDIO64_OBJECTLIST)
232 # Put a plausible default for CC_FOR_BUILD in Makefile.
233 if test -z "$CC_FOR_BUILD"; then
236 AC_SUBST(CC_FOR_BUILD)
238 if test "${newlib_elix_level}" -gt "0"; then
239 AC_DEFINE_UNQUOTED(_ELIX_LEVEL,${newlib_elix_level})
242 if test "${newlib_io_c99_formats}" = "yes"; then
243 AC_DEFINE_UNQUOTED(_WANT_IO_C99_FORMATS)
246 if test "${newlib_io_long_long}" = "yes"; then
247 AC_DEFINE_UNQUOTED(_WANT_IO_LONG_LONG)
250 if test "${newlib_io_long_double}" = "yes"; then
251 AC_DEFINE_UNQUOTED(_WANT_IO_LONG_DOUBLE)
254 if test "${newlib_io_pos_args}" = "yes"; then
255 AC_DEFINE_UNQUOTED(_WANT_IO_POS_ARGS)
258 if test "${newlib_reent_small}" = "yes"; then
259 AC_DEFINE_UNQUOTED(_WANT_REENT_SMALL)
262 if test "${newlib_mb}" = "yes"; then
263 AC_DEFINE_UNQUOTED(_MB_CAPABLE)
264 AC_DEFINE_UNQUOTED(_MB_LEN_MAX,8)
266 AC_DEFINE_UNQUOTED(_MB_LEN_MAX,1)
269 if test "${newlib_iconv_external_ccs}" = "yes"; then
270 AC_DEFINE_UNQUOTED(_ICONV_ENABLE_EXTERNAL_CCS)
273 AC_DEFINE_UNQUOTED(_NEWLIB_VERSION,"NEWLIB_VERSION")
275 if test "${multilib}" = "yes"; then
276 multilib_arg="--enable-multilib"
281 if test "${newlib_iconv}" = "yes"; then
282 AC_DEFINE_UNQUOTED(_ICONV_ENABLED,1)
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.)
289 AC_DEFINE_UNQUOTED(_ICONV_ENABLE_EXTERNAL_CCS,1)
292 if test "${newlib_atexit_dynamic_alloc}" = "yes"; then
293 AC_DEFINE_UNQUOTED(_ATEXIT_DYNAMIC_ALLOC)
297 dnl Parse --enable-newlib-iconv-encodings option argument
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.])
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/'`
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'`
316 dnl Check if required encodings are supported
317 dnl Convert aliases to names
320 iconv_encodings1="${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)
327 encoding1=`echo "${result}" | sed -e 's/\(^[[^ ]]*\).*$/\1/'`
328 iconv_encodings="${iconv_encodings} ${encoding1}"
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)
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)
346 encoding1=`echo "${result}" | sed -e 's/\(^[[^ ]]*\).*$/\1/'`
347 iconv_to_encodings="${iconv_to_encodings} ${encoding1}"
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)
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)
363 encoding1=`echo "${result}" | sed -e 's/\(^[[^ ]]*\).*$/\1/'`
364 iconv_from_encodings="${iconv_from_encodings} ${encoding1}"
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)
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;
381 if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -c -o conftest conftest.c
382 1>&AS_MESSAGE_LOG_FD])
384 if ${READELF} -S conftest | grep -e INIT_ARRAY > /dev/null; then
385 libc_cv_initfinit_array=yes
387 libc_cv_initfinit_array=no
390 libc_cv_initfinit_array=no
393 AC_SUBST(libc_cv_initfinit_array)
394 if test $libc_cv_initfinit_array = yes; then
395 AC_DEFINE_UNQUOTED(HAVE_INITFINI_ARRAY)
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. */
409 #if defined(LDBL_MANT_DIG)
410 #define _HAVE_LONG_DOUBLE
415 long double ld = 0.0L;
419 if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -c -o conftest.o conftest.c
420 1>&AS_MESSAGE_LOG_FD])
422 acnewlib_cv_type_long_double=yes;
424 acnewlib_cv_type_long_double=no;
427 if test $acnewlib_cv_type_long_double = yes; then
428 AC_DEFINE_UNQUOTED(_HAVE_LONG_DOUBLE)
430 AM_CONDITIONAL(HAVE_LONG_DOUBLE, test x"$acnewlib_cv_type_long_double" = x"yes")
432 AC_CACHE_CHECK(whether long double equals double,
433 newlib_cv_ldbl_eq_dbl, [dnl
434 cat > conftest.c <<EOF
436 #if DBL_MANT_DIG == LDBL_MANT_DIG && LDBL_MIN_EXP == DBL_MIN_EXP && \
437 LDBL_MAX_EXP == DBL_MAX_EXP
443 if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -c -o conftest.o conftest.c
444 1>&AS_MESSAGE_LOG_FD])
446 newlib_cv_ldbl_eq_dbl=yes;
448 newlib_cv_ldbl_eq_dbl=no;
451 if test $newlib_cv_ldbl_eq_dbl = yes; then
452 AC_DEFINE_UNQUOTED(_LDBL_EQ_DBL)
457 AC_CONFIG_FILES([Makefile],
458 [if test -n "$CONFIG_FILES"; then
460 . ${newlib_basedir}/../config-ml.in
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}