1dnl This is the newlib configure.in file.
2dnl Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.13)
5AC_INIT(libc)
6AM_CONFIG_HEADER(newlib.h:newlib.hin)
7
8dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake.
9AC_CONFIG_AUX_DIR(..)
10
11dnl Support --enable-newlib-io-pos-args
12dnl This option is actually read in libc/configure.in.  It is repeated
13dnl here so that it shows up in the help text.
14AC_ARG_ENABLE(newlib-io-pos-args,
15[  --enable-newlib-io-pos-args enable printf-family positional arg support],
16[case "${enableval}" in
17  yes) newlib_io_pos_args=yes ;;
18  no)  newlib_io_pos_args=no ;;
19  *)   AC_MSG_ERROR(bad value ${enableval} for newlib-io-pos-args option) ;;
20 esac], [newlib_io_pos_args=no])dnl
21
22
23NEWLIB_CONFIGURE(.)
24
25dnl We have to enable libtool after NEWLIB_CONFIGURE because if we try and
26dnl add it into NEWLIB_CONFIGURE, executable tests are made before the first
27dnl line of the macro which fail because appropriate LDFLAGS are not set.
28if test "${use_libtool}" = "yes"; then
29AC_LIBTOOL_WIN32_DLL
30AM_PROG_LIBTOOL
31AC_PROG_AWK
32fi
33
34configdirs="libc libm"
35
36AC_ARG_ENABLE(newlib_hw_fp,
37[  --enable-newlib-hw-fp    Turn on hardware floating point math],
38[case "${enableval}" in
39   yes) newlib_hw_fp=true ;;
40   no)  newlib_hw_fp=false ;;
41   *) AC_MSG_ERROR(bad value ${enableval} for --enable-newlib-hw-fp) ;;
42 esac],[newlib_hw_fp=false])
43AM_CONDITIONAL(NEWLIB_HW_FP, test x$newlib_hw_fp = xtrue)
44
45if test -z "${with_multisubdir}"; then
46  configdirs="${configdirs} doc"
47  have_doc=yes
48else
49  have_doc=
50fi
51AM_CONDITIONAL(HAVE_DOC, test x$have_doc = xyes)
52
53EXTRA_DIRS=
54case $host in
55  i[[34567]]86-pc-linux-*)
56	configdirs="${configdirs} iconvdata"
57	EXTRA_DIRS=iconvdata
58	;;
59esac
60AC_SUBST(EXTRA_DIRS)
61
62# These get added in the top-level configure.in, except in the case where
63# newlib is being built natively.
64LIBC_INCLUDE_GREP=`echo ${CC} | grep \/libc\/include`
65abs_newlib_basedir=`cd ${newlib_basedir} && pwd`
66if test -z "${LIBC_INCLUDE_GREP}"; then
67  CC_FOR_NEWLIB="${CC} -I$PWD/targ-include -I${abs_newlib_basedir}/libc/include"
68else
69  CC_FOR_NEWLIB="${CC}"
70fi
71AC_SUBST(CC_FOR_NEWLIB)
72
73AC_CONFIG_SUBDIRS(${configdirs})
74
75CRT0=
76CRT0_DIR=
77if test -n "${sys_dir}"; then
78  CRT0=crt0.o
79  CRT0_DIR=libc/
80fi
81AC_SUBST(CRT0)
82AC_SUBST(CRT0_DIR)
83
84CRT1=${crt1}
85CRT1_DIR=
86if test -n "${crt1_dir}"; then
87  CRT1_DIR=${crt1_dir}/
88fi
89AC_SUBST(CRT1)
90AC_SUBST(CRT1_DIR)
91
92if test -n "${libm_machine_dir}"; then
93  LIBM_MACHINE_OBJECTLIST=libm/machine/${libm_machine_dir}/objectlist.awk.in
94fi
95AC_SUBST(LIBM_MACHINE_OBJECTLIST)
96
97if test -n "${machine_dir}"; then
98  MACHINE_OBJECTLIST=libc/machine/${machine_dir}/objectlist.awk.in
99fi
100AC_SUBST(MACHINE_OBJECTLIST)
101
102if test -n "${sys_dir}"; then
103  SYS_OBJECTLIST=libc/sys/${sys_dir}/objectlist.awk.in
104fi
105AC_SUBST(SYS_OBJECTLIST)
106
107if test "${have_sys_mach_dir}" = "yes"; then
108  SYS_MACH_OBJECTLIST=libc/sys/${sys_dir}/machine/${machine_dir}/objectlist.awk.in
109fi
110AC_SUBST(SYS_MACH_OBJECTLIST)
111
112if test -n "${posix_dir}"; then
113  POSIX_OBJECTLIST=libc/${posix_dir}/objectlist.awk.in
114fi
115AC_SUBST(POSIX_OBJECTLIST)
116
117if test -n "${signal_dir}"; then
118  SIGNAL_OBJECTLIST=libc/${signal_dir}/objectlist.awk.in
119fi
120AC_SUBST(SIGNAL_OBJECTLIST)
121
122if test -n "${syscall_dir}"; then
123  SYSCALL_OBJECTLIST=libc/${syscall_dir}/objectlist.awk.in
124fi
125AC_SUBST(SYSCALL_OBJECTLIST)
126
127if test -n "${unix_dir}"; then
128  UNIX_OBJECTLIST=libc/${unix_dir}/objectlist.awk.in
129fi
130AC_SUBST(UNIX_OBJECTLIST)
131
132if test -n "${stdio64_dir}"; then
133  STDIO64_OBJECTLIST=libc/${stdio64_dir}/objectlist.awk.in
134fi
135AC_SUBST(STDIO64_OBJECTLIST)
136
137# Put a plausible default for CC_FOR_BUILD in Makefile.
138if test -z "$CC_FOR_BUILD"; then
139  CC_FOR_BUILD=gcc
140fi
141AC_SUBST(CC_FOR_BUILD)
142
143if test "${newlib_elix_level}" -gt "0"; then
144AC_DEFINE_UNQUOTED(_ELIX_LEVEL,${newlib_elix_level})
145fi
146
147if test "${newlib_mb}" = "yes"; then
148AC_DEFINE_UNQUOTED(_MB_LEN_MAX,8)
149else
150AC_DEFINE_UNQUOTED(_MB_LEN_MAX,1)
151fi
152
153AC_DEFINE_UNQUOTED(_NEWLIB_VERSION,"$VERSION")
154
155if test "${multilib}" = "yes"; then
156  multilib_arg="--enable-multilib"
157else
158  multilib_arg=
159fi
160
161if test "${newlib_iconv}" = "yes"; then
162AC_DEFINE_UNQUOTED(_ICONV_ENABLED,1)
163fi
164
165dnl Parse --enable-newlib-builtin-converters option argument
166if test "x${builtin_converters}" != "x"; then
167
168  dnl Check that --enable-newlib-iconv was enabled
169  if test x${newlib_iconv} = x; then
170      AC_MSG_ERROR(--enable-newlib-builtin-converters option can't be used if iconv library is disabled - use --enable-newlib-iconv to enable it)
171  fi
172
173  dnl Normalize converter names and delete commas
174  builtin_converters=`echo "${builtin_converters}" | sed -e 's/,/ /g' -e 's/-/_/g' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
175
176  dnl Get the list of available converters excluding comments
177  dnl Join line with previous if the first character is whitespace
178  available_converters=`cat "${srcdir}/libc/iconv/charset.aliases" | sed -e '/#/d' | sed -e 'N; s/\n //;'`
179
180  dnl Check if required converters are supported
181  dnl Convert aliases to "official" names
182  builtin_converters1="${builtin_converters}"
183  builtin_converters=""
184  for converter in ${builtin_converters1}; do
185      result=`echo "${available_converters}" | grep -e "\(^\| \)${converter}\( \|\$\)"`
186      if test $? != "0"; then
187          AC_MSG_ERROR(${converter} is not supported - see ${srcdir}/libc/iconv/charset.aliases file for the list of available converters)
188      fi
189      converter1=`echo "${result}" | sed -e 's/\(^[[^ ]]*\).*$/\1/'`
190      builtin_converters="${builtin_converters} ${converter1}"
191  done
192
193  dnl Enable appropriate option in newlib.h
194  for converter in ${builtin_converters}; do
195      opt=_ICONV_CONVERTER_`echo "${converter}" | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
196      AC_DEFINE_UNQUOTED($opt,1)
197  done
198fi;
199
200AC_OUTPUT(Makefile,
201[if test -n "$CONFIG_FILES"; then
202  unset ac_file
203  . ${newlib_basedir}/../config-ml.in
204fi],
205srcdir=${srcdir}
206host=${host}
207target=${target}
208with_multisubdir=${with_multisubdir}
209ac_configure_args="${multilib_arg} ${ac_configure_args}"
210CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
211newlib_basedir=${newlib_basedir}
212CC="${CC}"
213LDFLAGS="${LDFLAGS}"
214)
215