1dnl $MirOS: src/gnu/usr.bin/binutils/binutils/configure.in,v 1.5 2005/07/07 16:22:44 tg Exp $
2
3dnl Process this file with autoconf to produce a configure script.
4dnl
5AC_PREREQ(2.57)
6AC_INIT(ar.c)
7
8AC_CANONICAL_SYSTEM
9AC_ISC_POSIX
10
11changequote(,)dnl
12BFD_VERSION=`sed -n -e 's/^.._INIT_AUTOMAKE.*,[ 	]*\([^ 	]*\)[ 	]*).*/\1/p' < ${srcdir}/../bfd/configure.in`
13changequote([,])dnl
14AM_INIT_AUTOMAKE(binutils, 050707)
15
16AM_PROG_LIBTOOL
17
18AC_ARG_ENABLE(targets,
19[  --enable-targets        alternative target configurations],
20[case "${enableval}" in
21  yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
22            ;;
23  no)       enable_targets= ;;
24  *)        enable_targets=$enableval ;;
25esac])dnl
26AC_ARG_ENABLE(commonbfdlib,
27[  --enable-commonbfdlib   build shared BFD/opcodes/libiberty library],
28[case "${enableval}" in
29  yes) commonbfdlib=true ;;
30  no)  commonbfdlib=false ;;
31  *)   AC_MSG_ERROR([bad value ${enableval} for BFD commonbfdlib option]) ;;
32esac])dnl
33
34AM_BINUTILS_WARNINGS
35
36AM_CONFIG_HEADER(config.h:config.in)
37
38if test -z "$target" ; then
39    AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
40fi
41if test -z "$host" ; then
42    AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
43fi
44
45AC_PROG_CC
46
47AC_PROG_YACC
48AM_PROG_LEX
49
50AM_MAINTAINER_MODE
51AC_EXEEXT
52if test -n "$EXEEXT"; then
53  AC_DEFINE(HAVE_EXECUTABLE_SUFFIX, 1,
54	    [Does the platform use an executable suffix?])
55fi
56AC_DEFINE_UNQUOTED(EXECUTABLE_SUFFIX, "${EXEEXT}",
57		   [Suffix used for executables, if any.])
58
59# host-specific stuff:
60
61HDEFINES=
62
63. ${srcdir}/../bfd/configure.host
64
65AC_SUBST(HDEFINES)
66AR=${AR-ar}
67AC_SUBST(AR)
68AC_PROG_RANLIB
69AC_PROG_INSTALL
70
71BFD_CC_FOR_BUILD
72
73DEMANGLER_NAME=c++filt
74case "${host}" in
75  *-*-go32* | *-*-msdos*)
76    DEMANGLER_NAME=cxxfilt
77esac
78AC_SUBST(DEMANGLER_NAME)
79
80AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h)
81AC_HEADER_SYS_WAIT
82AC_FUNC_ALLOCA
83AC_CHECK_FUNCS(sbrk utimes setmode getc_unlocked strcoll mkdtemp mkstemp)
84
85# Check whether fopen64 is available and whether _LARGEFILE64_SOURCE
86# needs to be defined for it
87AC_MSG_CHECKING([for fopen64])
88AC_CACHE_VAL(bu_cv_have_fopen64,
89[AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");],
90bu_cv_have_fopen64=yes,
91[saved_CPPFLAGS=$CPPFLAGS
92 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
93 AC_TRY_LINK([#include <stdio.h>], [FILE *f = fopen64 ("/tmp/foo","r");],
94bu_cv_have_fopen64="need -D_LARGEFILE64_SOURCE",
95bu_cv_have_fopen64=no)
96 CPPFLAGS=$saved_CPPFLAGS])])
97AC_MSG_RESULT($bu_cv_have_fopen64)
98if test "$bu_cv_have_fopen64" != no; then
99  AC_DEFINE([HAVE_FOPEN64], 1,
100	    [Is fopen64 available?])
101fi
102AC_MSG_CHECKING([for stat64])
103AC_CACHE_VAL(bu_cv_have_stat64,
104[AC_TRY_LINK([#include <sys/stat.h>], [struct stat64 st; stat64 ("/tmp/foo", &st);],
105bu_cv_have_stat64=yes,
106[saved_CPPFLAGS=$CPPFLAGS
107 CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
108 AC_TRY_LINK([#include <sys/stat.h>], [struct stat64 st; stat64 ("/tmp/foo", &st);],
109bu_cv_have_stat64="need -D_LARGEFILE64_SOURCE",
110bu_cv_have_stat64=no)
111 CPPFLAGS=$saved_CPPFLAGS])])
112AC_MSG_RESULT($bu_cv_have_stat64)
113if test "$bu_cv_have_stat64" != no; then
114  AC_DEFINE([HAVE_STAT64], 1,
115	    [Is stat64 available?])
116fi
117if test "$bu_cv_have_fopen64" = "need -D_LARGEFILE64_SOURCE" \
118   || test "$bu_cv_have_stat64" = "need -D_LARGEFILE64_SOURCE"; then
119  AC_DEFINE([_LARGEFILE64_SOURCE], 1,
120	    [Enable LFS])
121  CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
122fi
123
124# Some systems have frexp only in -lm, not in -lc.
125AC_SEARCH_LIBS(frexp, m)
126
127AC_MSG_CHECKING(for time_t in time.h)
128AC_CACHE_VAL(bu_cv_decl_time_t_time_h,
129[AC_TRY_COMPILE([#include <time.h>], [time_t i;],
130bu_cv_decl_time_t_time_h=yes, bu_cv_decl_time_t_time_h=no)])
131AC_MSG_RESULT($bu_cv_decl_time_t_time_h)
132if test $bu_cv_decl_time_t_time_h = yes; then
133  AC_DEFINE([HAVE_TIME_T_IN_TIME_H], 1,
134	    [Is the type time_t defined in <time.h>?])
135fi
136
137AC_MSG_CHECKING(for time_t in sys/types.h)
138AC_CACHE_VAL(bu_cv_decl_time_t_types_h,
139[AC_TRY_COMPILE([#include <sys/types.h>], [time_t i;],
140bu_cv_decl_time_t_types_h=yes, bu_cv_decl_time_t_types_h=no)])
141AC_MSG_RESULT($bu_cv_decl_time_t_types_h)
142if test $bu_cv_decl_time_t_types_h = yes; then
143  AC_DEFINE([HAVE_TIME_T_IN_TYPES_H], 1,
144	    [Is the type time_t defined in <sys/types.h>?])
145fi
146
147AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
148AC_CACHE_VAL(bu_cv_decl_getopt_unistd_h,
149[AC_TRY_COMPILE([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);],
150bu_cv_decl_getopt_unistd_h=yes, bu_cv_decl_getopt_unistd_h=no)])
151AC_MSG_RESULT($bu_cv_decl_getopt_unistd_h)
152if test $bu_cv_decl_getopt_unistd_h = yes; then
153  AC_DEFINE([HAVE_DECL_GETOPT], 1,
154	    [Is the prototype for getopt in <unistd.h> in the expected format?])
155fi
156
157# Under Next 3.2 <utime.h> apparently does not define struct utimbuf
158# by default.
159AC_MSG_CHECKING([for utime.h])
160AC_CACHE_VAL(bu_cv_header_utime_h,
161[AC_TRY_COMPILE([#include <sys/types.h>
162#ifdef HAVE_TIME_H
163#include <time.h>
164#endif
165#include <utime.h>],
166[struct utimbuf s;],
167bu_cv_header_utime_h=yes, bu_cv_header_utime_h=no)])
168AC_MSG_RESULT($bu_cv_header_utime_h)
169if test $bu_cv_header_utime_h = yes; then
170  AC_DEFINE(HAVE_GOOD_UTIME_H, 1, [Does <utime.h> define struct utimbuf?])
171fi
172
173AC_CHECK_DECLS([fprintf, strstr, sbrk, getenv, environ, getc_unlocked])
174
175BFD_BINARY_FOPEN
176
177# target-specific stuff:
178
179# Canonicalize the secondary target names.
180if test -n "$enable_targets"; then
181    for targ in `echo $enable_targets | sed 's/,/ /g'`
182    do
183	result=`$ac_config_sub $targ 2>/dev/null`
184	if test -n "$result"; then
185	    canon_targets="$canon_targets $result"
186	else
187	    # Allow targets that config.sub doesn't recognize, like "all".
188	    canon_targets="$canon_targets $targ"
189	fi
190    done
191fi
192
193all_targets=false
194BUILD_NLMCONV=
195NLMCONV_DEFS=
196BUILD_SRCONV=
197BUILD_DLLTOOL=
198DLLTOOL_DEFS=
199BUILD_WINDRES=
200BUILD_DLLWRAP=
201BUILD_MISC=
202OBJDUMP_DEFS=
203
204for targ in $target $canon_targets
205do
206    if test "x$targ" = "xall"; then
207        all_targets=true
208	BUILD_NLMCONV='$(NLMCONV_PROG)$(EXEEXT)'
209	BUILD_SRCONV='$(SRCONV_PROG)'
210	NLMCONV_DEFS="-DNLMCONV_I386 -DNLMCONV_ALPHA -DNLMCONV_POWERPC -DNLMCONV_SPARC"
211    else
212	case $targ in
213changequote(,)dnl
214	i[3-7]86*-*-netware*)
215changequote([,])dnl
216	  BUILD_NLMCONV='$(NLMCONV_PROG)$(EXEEXT)'
217	  NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_I386"
218	  ;;
219	alpha*-*-netware*)
220	  BUILD_NLMCONV='$(NLMCONV_PROG)$(EXEEXT)'
221	  NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_ALPHA"
222	  ;;
223	powerpc*-*-netware*)
224	  BUILD_NLMCONV='$(NLMCONV_PROG)$(EXEEXT)'
225	  NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_POWERPC"
226	  ;;
227	sparc*-*-netware*)
228	  BUILD_NLMCONV='$(NLMCONV_PROG)$(EXEEXT)'
229	  NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_SPARC"
230	  ;;
231	esac
232	case $targ in
233	*-*-hms*) BUILD_SRCONV='$(SRCONV_PROG)' ;;
234	esac
235	case $targ in
236	arm-epoc-pe*)
237  	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
238	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM_EPOC -DDLLTOOL_ARM"
239	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
240	  ;;
241	arm-*-pe* | arm-*-wince)
242  	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
243	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM"
244	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
245	  ;;
246	thumb-*-pe*)
247  	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
248	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM"
249	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
250	  ;;
251  	arm*-* | xscale-* | strongarm-* | d10v-*)
252	  OBJDUMP_DEFS="-DDISASSEMBLER_NEEDS_RELOCS"
253	  ;;
254changequote(,)dnl
255	i[3-7]86-*-pe* | i[3-7]86-*-cygwin* | i[3-7]86-*-mingw32** | i[3-7]86-*-netbsdpe*)
256changequote([,])dnl
257  	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
258	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386"
259	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
260	  BUILD_DLLWRAP='$(DLLWRAP_PROG)$(EXEEXT)'
261	  ;;
262changequote(,)dnl
263	i[3-7]86-*-interix)
264changequote([,])dnl
265	  BUILD_DLLTOOL='$(DLLTOOL_PROG)'
266	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386"
267	  ;;
268changequote(,)dnl
269	powerpc*-aix5.[01])
270changequote([,])dnl
271	  ;;
272	powerpc*-aix5.*)
273	  OBJDUMP_DEFS="-DAIX_WEAK_SUPPORT"
274	  ;;
275	powerpc*-*-pe* | powerpc*-*-cygwin*)
276  	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
277	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_PPC"
278	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
279	  ;;
280	sh*-*-pe)
281  	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
282	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_SH"
283	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
284	  ;;
285	mips*-*-pe)
286  	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
287	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MIPS"
288	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
289	  ;;
290	mcore-*-pe)
291  	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
292	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MCORE"
293	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
294	  ;;
295	mcore-*-elf)
296  	  BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
297	  DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MCORE_ELF"
298	  ;;
299	esac
300    fi
301done
302
303if test "${with_windres+set}" = set; then
304	  BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
305fi
306
307AC_SUBST(NLMCONV_DEFS)
308AC_SUBST(BUILD_NLMCONV)
309AC_SUBST(BUILD_SRCONV)
310AC_SUBST(BUILD_DLLTOOL)
311AC_SUBST(DLLTOOL_DEFS)
312AC_SUBST(BUILD_WINDRES)
313AC_SUBST(BUILD_DLLWRAP)
314AC_SUBST(BUILD_MISC)
315AC_SUBST(OBJDUMP_DEFS)
316
317AC_DEFINE_UNQUOTED(TARGET, "${target}", [Configured target name.])
318
319targ=$target
320. $srcdir/../bfd/config.bfd
321if test "x$targ_underscore" = "xyes"; then
322    UNDERSCORE=1
323else
324    UNDERSCORE=0
325fi
326AC_DEFINE_UNQUOTED(TARGET_PREPENDS_UNDERSCORE, $UNDERSCORE,
327 [Define to 1 if user symbol names have a leading underscore, 0 if not.])
328
329# Emulation
330for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
331do
332  # Canonicalize the secondary target names.
333 result=`$ac_config_sub $targ_alias 2>/dev/null`
334 if test -n "$result"; then
335   targ=$result
336 else
337   targ=$targ_alias
338 fi
339
340 . ${srcdir}/configure.tgt
341
342  EMULATION=$targ_emul
343  EMULATION_VECTOR=$targ_emul_vector
344done
345
346AC_SUBST(EMULATION)
347AC_SUBST(EMULATION_VECTOR)
348
349AC_OUTPUT(Makefile doc/Makefile)
350