OSDN Git Service

2004-12-17 Jeff Johnston <jjohnstn@redhat.com>
[pf3gnuchains/pf3gnuchains3x.git] / newlib / acinclude.m4
1 dnl This provides configure definitions used by all the newlib
2 dnl configure.in files.
3
4 dnl Basic newlib configury.  This calls basic introductory stuff,
5 dnl including AM_INIT_AUTOMAKE and AC_CANONICAL_HOST.  It also runs
6 dnl configure.host.  The only argument is the relative path to the top
7 dnl newlib directory.
8
9 AC_DEFUN(NEWLIB_CONFIGURE,
10 [
11 dnl Default to --enable-multilib
12 AC_ARG_ENABLE(multilib,
13 [  --enable-multilib         build many library versions (default)],
14 [case "${enableval}" in
15   yes) multilib=yes ;;
16   no)  multilib=no ;;
17   *)   AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
18  esac], [multilib=yes])dnl
19
20 dnl Support --enable-target-optspace
21 AC_ARG_ENABLE(target-optspace,
22 [  --enable-target-optspace  optimize for space],
23 [case "${enableval}" in
24   yes) target_optspace=yes ;;
25   no)  target_optspace=no ;;
26   *)   AC_MSG_ERROR(bad value ${enableval} for target-optspace option) ;;
27  esac], [target_optspace=])dnl
28
29 dnl Support --enable-malloc-debugging - currently only supported for Cygwin
30 AC_ARG_ENABLE(malloc-debugging,
31 [  --enable-malloc-debugging indicate malloc debugging requested],
32 [case "${enableval}" in
33   yes) malloc_debugging=yes ;;
34   no)  malloc_debugging=no ;;
35   *)   AC_MSG_ERROR(bad value ${enableval} for malloc-debugging option) ;;
36  esac], [malloc_debugging=])dnl
37
38 dnl Support --enable-newlib-multithread
39 AC_ARG_ENABLE(newlib-multithread,
40 [  --enable-newlib-multithread        enable support for multiple threads],
41 [case "${enableval}" in
42   yes) newlib_multithread=yes ;;
43   no)  newlib_multithread=no ;;
44   *)   AC_MSG_ERROR(bad value ${enableval} for newlib-multithread option) ;;
45  esac], [newlib_multithread=yes])dnl
46
47 dnl Support --enable-newlib-iconv
48 AC_ARG_ENABLE(newlib-iconv,
49 [  --enable-newlib-iconv     enable iconv library support],
50 [if test "${newlib_iconv+set}" != set; then
51    case "${enableval}" in
52      yes) newlib_iconv=yes ;;
53      no)  newlib_iconv=no ;;
54      *)   AC_MSG_ERROR(bad value ${enableval} for newlib-iconv option) ;;
55    esac
56  fi], [newlib_iconv=${newlib_iconv}])dnl
57
58 dnl Support --enable-newlib-elix-level
59 AC_ARG_ENABLE(newlib-elix-level,
60 [  --enable-newlib-elix-level         supply desired elix library level (1-4)],
61 [case "${enableval}" in
62   0)   newlib_elix_level=0 ;;
63   1)   newlib_elix_level=1 ;;
64   2)   newlib_elix_level=2 ;;
65   3)   newlib_elix_level=3 ;;
66   4)   newlib_elix_level=4 ;;
67   *)   AC_MSG_ERROR(bad value ${enableval} for newlib-elix-level option) ;;
68  esac], [newlib_elix_level=0])dnl
69
70 dnl Support --disable-newlib-io-float
71 AC_ARG_ENABLE(newlib-io-float,
72 [  --disable-newlib-io-float disable printf/scanf family float support],
73 [case "${enableval}" in
74   yes) newlib_io_float=yes ;;
75   no)  newlib_io_float=no ;;
76   *)   AC_MSG_ERROR(bad value ${enableval} for newlib-io-float option) ;;
77  esac], [newlib_io_float=yes])dnl
78
79 dnl Support --disable-newlib-supplied-syscalls
80 AC_ARG_ENABLE(newlib-supplied-syscalls,
81 [  --disable-newlib-supplied-syscalls disable newlib from supplying syscalls],
82 [case "${enableval}" in
83   yes) newlib_may_supply_syscalls=yes ;;
84   no)  newlib_may_supply_syscalls=no ;;
85   *)   AC_MSG_ERROR(bad value ${enableval} for newlib-supplied-syscalls option) ;;
86  esac], [newlib_may_supply_syscalls=yes])dnl
87
88 AM_CONDITIONAL(MAY_SUPPLY_SYSCALLS, test x[$]{newlib_may_supply_syscalls} = xyes)
89
90 dnl We may get other options which we don't document:
91 dnl --with-target-subdir, --with-multisrctop, --with-multisubdir
92
93 test -z "[$]{with_target_subdir}" && with_target_subdir=.
94
95 if test "[$]{srcdir}" = "."; then
96   if test "[$]{with_target_subdir}" != "."; then
97     newlib_basedir="[$]{srcdir}/[$]{with_multisrctop}../$1"
98   else
99     newlib_basedir="[$]{srcdir}/[$]{with_multisrctop}$1"
100   fi
101 else
102   newlib_basedir="[$]{srcdir}/$1"
103 fi
104 AC_SUBST(newlib_basedir)
105
106 AC_CANONICAL_SYSTEM
107
108 AM_INIT_AUTOMAKE(newlib, 1.13.0)
109
110 # FIXME: We temporarily define our own version of AC_PROG_CC.  This is
111 # copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS.  We
112 # are probably using a cross compiler, which will not be able to fully
113 # link an executable.  This should really be fixed in autoconf
114 # itself.
115
116 AC_DEFUN(LIB_AC_PROG_CC,
117 [AC_BEFORE([$0], [AC_PROG_CPP])dnl
118 AC_CHECK_PROG(CC, gcc, gcc)
119 if test -z "$CC"; then
120   AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
121   test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
122 fi
123
124 AC_PROG_CC_GNU
125
126 if test $ac_cv_prog_gcc = yes; then
127   GCC=yes
128 dnl Check whether -g works, even if CFLAGS is set, in case the package
129 dnl plays around with CFLAGS (such as to build both debugging and
130 dnl normal versions of a library), tasteless as that idea is.
131   ac_test_CFLAGS="${CFLAGS+set}"
132   ac_save_CFLAGS="$CFLAGS"
133   CFLAGS=
134   AC_PROG_CC_G
135   if test "$ac_test_CFLAGS" = set; then
136     CFLAGS="$ac_save_CFLAGS"
137   elif test $ac_cv_prog_cc_g = yes; then
138     CFLAGS="-g -O2"
139   else
140     CFLAGS="-O2"
141   fi
142 else
143   GCC=
144   test "${CFLAGS+set}" = set || CFLAGS="-g"
145 fi
146 ])
147
148 LIB_AC_PROG_CC
149
150 AC_CHECK_TOOL(AS, as)
151 AC_CHECK_TOOL(AR, ar)
152 AC_CHECK_TOOL(RANLIB, ranlib, :)
153
154 AC_PROG_INSTALL
155
156 AM_MAINTAINER_MODE
157
158 # We need AC_EXEEXT to keep automake happy in cygnus mode.  However,
159 # at least currently, we never actually build a program, so we never
160 # need to use $(EXEEXT).  Moreover, the test for EXEEXT normally
161 # fails, because we are probably configuring with a cross compiler
162 # which can't create executables.  So we include AC_EXEEXT to keep
163 # automake happy, but we don't execute it, since we don't care about
164 # the result.
165 if false; then
166   AC_EXEEXT
167 fi
168
169 . [$]{newlib_basedir}/configure.host
170
171 newlib_cflags="[$]{newlib_cflags} -fno-builtin"
172
173 NEWLIB_CFLAGS=${newlib_cflags}
174 AC_SUBST(NEWLIB_CFLAGS)
175
176 LDFLAGS=${ldflags}
177 AC_SUBST(LDFLAGS)
178
179 AM_CONDITIONAL(ELIX_LEVEL_0, test x[$]{newlib_elix_level} = x0)
180 AM_CONDITIONAL(ELIX_LEVEL_1, test x[$]{newlib_elix_level} = x1)
181 AM_CONDITIONAL(ELIX_LEVEL_2, test x[$]{newlib_elix_level} = x2)
182 AM_CONDITIONAL(ELIX_LEVEL_3, test x[$]{newlib_elix_level} = x3)
183 AM_CONDITIONAL(ELIX_LEVEL_4, test x[$]{newlib_elix_level} = x4)
184
185 AM_CONDITIONAL(USE_LIBTOOL, test x[$]{use_libtool} = xyes)
186
187 # Hard-code OBJEXT.  Normally it is set by AC_OBJEXT, but we
188 # use oext, which is set in configure.host based on the target platform.
189 OBJEXT=${oext}
190
191 AC_SUBST(OBJEXT)
192 AC_SUBST(oext)
193 AC_SUBST(aext)
194
195 AC_SUBST(libm_machine_dir)
196 AC_SUBST(machine_dir)
197 AC_SUBST(sys_dir)
198 ])