* configure.in: Rewrite to use autoconf.
[platform/upstream/binutils.git] / binutils / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 AC_PREREQ(2.0)
4 AC_INIT(ar.c)
5
6 AC_ARG_ENABLE(targets,
7 [  --enable-targets        alternative target configurations],
8 [case "${enableval}" in
9   yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
10             ;;
11   no)       enable_targets= ;;
12   *)        enable_targets=$enableval ;;
13 esac])dnl
14
15 AC_CONFIG_HEADER(config.h)
16
17 AC_CONFIG_AUX_DIR(`cd $srcdir/..; pwd`)
18 AC_CANONICAL_SYSTEM
19 if test -z "$target" ; then
20     AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
21 fi
22 if test -z "$host" ; then
23     AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
24 fi
25 AC_ARG_PROGRAM
26
27 # host-specific stuff:
28
29 HDEFINES=
30 LDFLAGS=
31
32 . ${srcdir}/../bfd/configure.host
33
34 AC_PROG_CC
35 AC_SUBST(CFLAGS)
36 AC_SUBST(HDEFINES)
37 AC_SUBST(LDFLAGS)
38 AR=${AR-ar}
39 AC_SUBST(AR)
40 AC_PROG_RANLIB
41 AC_PROG_INSTALL
42
43 AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h)
44 AC_CHECK_FUNCS(sbrk utimes)
45
46 AC_MSG_CHECKING(for time_t in time.h)
47 AC_CACHE_VAL(bu_cv_decl_time_t_time_h,
48 [AC_TRY_COMPILE([#include <time.h>], [time_t i;],
49 bu_cv_decl_time_t_time_h=yes, bu_cv_decl_time_t_time_h=no)])
50 AC_MSG_RESULT($bu_cv_decl_time_t_time_h)
51 if test $bu_cv_decl_time_t_time_h = yes; then
52   AC_DEFINE([HAVE_TIME_T_IN_TIME_H])
53 fi
54
55 AC_MSG_CHECKING(for time_t in sys/types.h)
56 AC_CACHE_VAL(bu_cv_decl_time_t_types_h,
57 [AC_TRY_COMPILE([#include <sys/types.h>], [time_t i;],
58 bu_cv_decl_time_t_types_h=yes, bu_cv_decl_time_t_types_h=no)])
59 AC_MSG_RESULT($bu_cv_decl_time_t_types_h)
60 if test $bu_cv_decl_time_t_types_h = yes; then
61   AC_DEFINE([HAVE_TIME_T_IN_TYPES_H])
62 fi
63
64 # Under Next 3.2 <utime.h> apparently does not define struct utimbuf
65 # by default.
66 AC_MSG_CHECKING([for utime.h])
67 AC_CACHE_VAL(bu_cv_header_utime_h,
68 [AC_TRY_COMPILE([#include <sys/types.h>
69 #ifdef HAVE_TIME_H
70 #include <time.h>
71 #endif
72 #include <utime.h>],
73 [struct utimbuf s;],
74 bu_cv_header_utime_h=yes, bu_cv_header_utime_h=no)])
75 AC_MSG_RESULT($bu_cv_header_utime_h)
76 if test $bu_cv_header_utime_h = yes; then
77   AC_DEFINE(HAVE_GOOD_UTIME_H)
78 fi
79
80 AC_MSG_CHECKING([whether fprintf must be declared])
81 AC_CACHE_VAL(bu_cv_decl_needed_fprintf,
82 [AC_TRY_COMPILE([#include <stdio.h>],
83 [int (*pfn) = (int (*)) fprintf],
84 bu_cv_decl_needed_fprintf=no, bu_cv_decl_needed_fprintf=yes)])
85 AC_MSG_RESULT($bu_cv_decl_needed_fprintf)
86 if test $bu_cv_decl_needed_fprintf = yes; then
87   AC_DEFINE(NEED_DECLARATION_FPRINTF)
88 fi
89
90 dnl FIXME: We should check this in some central place somehow
91 case "${host}" in
92 i[345]86-*-msdos* | i[345]86-*-go32* | i[345]86-*-win32)
93   AC_DEFINE(USE_BINARY_FOPEN) ;;
94 esac
95
96 # target-specific stuff:
97
98 # Canonicalize the secondary target names.
99 target_makefile_fragment=/dev/null
100 if test -n "$enable_targets"; then
101     for targ in `echo $enable_targets | sed 's/,/ /g'`
102     do
103         result=`$ac_config_sub $targ 2>/dev/null`
104         if test -n "$result"; then
105             canon_targets="$canon_targets $result"
106         else
107             # Allow targets that config.sub doesn't recognize, like "all".
108             canon_targets="$canon_targets $targ"
109         fi
110     done
111 else
112     # If our target is rs6000 _and nothing else_ then we build only nm!
113     case $target in
114     rs6000-*-lynx*) target_makefile_fragment=${srcdir}/config/rslynx ;;
115     esac
116 fi
117 AC_SUBST_FILE(target_makefile_fragment)
118
119 all_targets=false
120 BUILD_NLMCONV=
121 NLMCONV_DEFS=
122 BUILD_SRCONV=
123 BUILD_DLLTOOL=
124 DLLTOOL_DEFS=
125
126 for targ in $target $canon_targets
127 do
128     if test "x$targ" = "xall"; then
129         all_targets=true
130         BUILD_NLMCONV='$(NLMCONV_PROG)'
131         BUILD_SRCONV='$(SRCONV_PROG)'
132         NLMCONV_DEFS="-DNLMCONV_I386 -DNLMCONV_ALPHA -DNLMCONV_POWERPC -DNLMCONV_SPARC"
133     else
134         case $targ in
135 changequote(,)dnl
136         i[345]86*-*-netware*) 
137 changequote([,])dnl
138           BUILD_NLMCONV='$(NLMCONV_PROG)'
139           NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_I386"
140           ;;
141         alpha*-*-netware*)
142           BUILD_NLMCONV='$(NLMCONV_PROG)'
143           NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_ALPHA"
144           ;;
145         powerpc*-*-netware*)
146           BUILD_NLMCONV='$(NLMCONV_PROG)'
147           NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_POWERPC"
148           ;;
149         sparc*-*-netware*)
150           BUILD_NLMCONV='$(NLMCONV_PROG)'
151           NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_SPARC"
152           ;;
153         esac
154         case $targ in
155         *-*-hms*) BUILD_SRCONV='$(SRCONV_PROG)' ;;
156         esac
157         case $targ in
158         arm-*pe*)
159           BUILD_DLLTOOL='$(DLLTOOL_PROG)'
160           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM"
161          ;;
162 changequote(,)dnl
163         i[3-6]86-*pe* | i[3-6]86-*-win32)
164 changequote([,])dnl
165           BUILD_DLLTOOL='$(DLLTOOL_PROG)'
166           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386"
167          ;;
168         esac
169     fi
170 done
171
172 AC_SUBST(NLMCONV_DEFS)
173 AC_SUBST(BUILD_NLMCONV)
174 AC_SUBST(BUILD_SRCONV)
175 AC_SUBST(BUILD_DLLTOOL)
176 AC_SUBST(DLLTOOL_DEFS)
177
178 targ=$target
179 . $srcdir/../bfd/config.bfd
180 if test "x$targ_underscore" = "xyes"; then
181     UNDERSCORE=1
182 else
183     UNDERSCORE=0
184 fi
185 AC_SUBST(UNDERSCORE)
186
187 AC_OUTPUT(Makefile,
188 [case x$CONFIG_HEADERS in xconfig.h) echo > stamp-h ;; esac])