* config.in: Rename from config.h.in.
[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:config.in)
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 BFD_CC_FOR_BUILD
44
45 AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h)
46 AC_CHECK_FUNCS(sbrk utimes)
47
48 AC_MSG_CHECKING(for time_t in time.h)
49 AC_CACHE_VAL(bu_cv_decl_time_t_time_h,
50 [AC_TRY_COMPILE([#include <time.h>], [time_t i;],
51 bu_cv_decl_time_t_time_h=yes, bu_cv_decl_time_t_time_h=no)])
52 AC_MSG_RESULT($bu_cv_decl_time_t_time_h)
53 if test $bu_cv_decl_time_t_time_h = yes; then
54   AC_DEFINE([HAVE_TIME_T_IN_TIME_H])
55 fi
56
57 AC_MSG_CHECKING(for time_t in sys/types.h)
58 AC_CACHE_VAL(bu_cv_decl_time_t_types_h,
59 [AC_TRY_COMPILE([#include <sys/types.h>], [time_t i;],
60 bu_cv_decl_time_t_types_h=yes, bu_cv_decl_time_t_types_h=no)])
61 AC_MSG_RESULT($bu_cv_decl_time_t_types_h)
62 if test $bu_cv_decl_time_t_types_h = yes; then
63   AC_DEFINE([HAVE_TIME_T_IN_TYPES_H])
64 fi
65
66 # Under Next 3.2 <utime.h> apparently does not define struct utimbuf
67 # by default.
68 AC_MSG_CHECKING([for utime.h])
69 AC_CACHE_VAL(bu_cv_header_utime_h,
70 [AC_TRY_COMPILE([#include <sys/types.h>
71 #ifdef HAVE_TIME_H
72 #include <time.h>
73 #endif
74 #include <utime.h>],
75 [struct utimbuf s;],
76 bu_cv_header_utime_h=yes, bu_cv_header_utime_h=no)])
77 AC_MSG_RESULT($bu_cv_header_utime_h)
78 if test $bu_cv_header_utime_h = yes; then
79   AC_DEFINE(HAVE_GOOD_UTIME_H)
80 fi
81
82 AC_MSG_CHECKING([whether fprintf must be declared])
83 AC_CACHE_VAL(bu_cv_decl_needed_fprintf,
84 [AC_TRY_COMPILE([#include <stdio.h>],
85 [int (*pfn) = (int (*)) fprintf],
86 bu_cv_decl_needed_fprintf=no, bu_cv_decl_needed_fprintf=yes)])
87 AC_MSG_RESULT($bu_cv_decl_needed_fprintf)
88 if test $bu_cv_decl_needed_fprintf = yes; then
89   AC_DEFINE(NEED_DECLARATION_FPRINTF)
90 fi
91
92 BFD_BINARY_FOPEN
93
94 # target-specific stuff:
95
96 # Canonicalize the secondary target names.
97 target_makefile_fragment=/dev/null
98 if test -n "$enable_targets"; then
99     for targ in `echo $enable_targets | sed 's/,/ /g'`
100     do
101         result=`$ac_config_sub $targ 2>/dev/null`
102         if test -n "$result"; then
103             canon_targets="$canon_targets $result"
104         else
105             # Allow targets that config.sub doesn't recognize, like "all".
106             canon_targets="$canon_targets $targ"
107         fi
108     done
109 else
110     # If our target is rs6000 _and nothing else_ then we build only nm!
111     case $target in
112     rs6000-*-lynx*) target_makefile_fragment=${srcdir}/config/rslynx ;;
113     esac
114 fi
115 AC_SUBST_FILE(target_makefile_fragment)
116
117 all_targets=false
118 BUILD_NLMCONV=
119 NLMCONV_DEFS=
120 BUILD_SRCONV=
121 BUILD_DLLTOOL=
122 DLLTOOL_DEFS=
123
124 for targ in $target $canon_targets
125 do
126     if test "x$targ" = "xall"; then
127         all_targets=true
128         BUILD_NLMCONV='$(NLMCONV_PROG)'
129         BUILD_SRCONV='$(SRCONV_PROG)'
130         NLMCONV_DEFS="-DNLMCONV_I386 -DNLMCONV_ALPHA -DNLMCONV_POWERPC -DNLMCONV_SPARC"
131     else
132         case $targ in
133 changequote(,)dnl
134         i[345]86*-*-netware*) 
135 changequote([,])dnl
136           BUILD_NLMCONV='$(NLMCONV_PROG)'
137           NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_I386"
138           ;;
139         alpha*-*-netware*)
140           BUILD_NLMCONV='$(NLMCONV_PROG)'
141           NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_ALPHA"
142           ;;
143         powerpc*-*-netware*)
144           BUILD_NLMCONV='$(NLMCONV_PROG)'
145           NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_POWERPC"
146           ;;
147         sparc*-*-netware*)
148           BUILD_NLMCONV='$(NLMCONV_PROG)'
149           NLMCONV_DEFS="$NLMCONV_DEFS -DNLMCONV_SPARC"
150           ;;
151         esac
152         case $targ in
153         *-*-hms*) BUILD_SRCONV='$(SRCONV_PROG)' ;;
154         esac
155         case $targ in
156         arm-*pe*)
157           BUILD_DLLTOOL='$(DLLTOOL_PROG)'
158           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM"
159          ;;
160 changequote(,)dnl
161         i[3-6]86-*pe* | i[3-6]86-*-win32)
162 changequote([,])dnl
163           BUILD_DLLTOOL='$(DLLTOOL_PROG)'
164           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386"
165          ;;
166         esac
167     fi
168 done
169
170 AC_SUBST(NLMCONV_DEFS)
171 AC_SUBST(BUILD_NLMCONV)
172 AC_SUBST(BUILD_SRCONV)
173 AC_SUBST(BUILD_DLLTOOL)
174 AC_SUBST(DLLTOOL_DEFS)
175
176 targ=$target
177 . $srcdir/../bfd/config.bfd
178 if test "x$targ_underscore" = "xyes"; then
179     UNDERSCORE=1
180 else
181     UNDERSCORE=0
182 fi
183 AC_SUBST(UNDERSCORE)
184
185 AC_OUTPUT(Makefile,
186 [case x$CONFIG_HEADERS in xconfig.h:config.in) echo > stamp-h ;; esac])