change and rename gmp_string_asprintf to return an std::string
[binutils-gdb.git] / binutils / configure.ac
blob24bf102019d2f31a571330587564d643c91a4b57
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 dnl   Copyright (C) 2012-2020 Free Software Foundation, Inc.
4 dnl
5 dnl This file is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3 of the License, or
8 dnl (at your option) any later version.
9 dnl
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl GNU General Public License for more details.
14 dnl
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program; see the file COPYING3.  If not see
17 dnl <http://www.gnu.org/licenses/>.
18 dnl
20 m4_include([../bfd/version.m4])
21 m4_include([../config/debuginfod.m4])
22 AC_INIT([binutils], BFD_VERSION)
23 AC_CONFIG_SRCDIR(ar.c)
25 AC_CANONICAL_TARGET
26 AC_ISC_POSIX
28 AM_INIT_AUTOMAKE
30 AC_PROG_CC
31 AC_GNU_SOURCE
32 AC_USE_SYSTEM_EXTENSIONS
34 LT_INIT
35 ACX_LARGEFILE
37 AC_ARG_ENABLE(targets,
38 [  --enable-targets        alternative target configurations],
39 [case "${enableval}" in
40   yes | "") AC_MSG_ERROR(enable-targets option must specify target names or 'all')
41             ;;
42   no)       enable_targets= ;;
43   *)        enable_targets=$enableval ;;
44 esac])dnl
47 AC_ARG_ENABLE(deterministic-archives,
48 [AS_HELP_STRING([--enable-deterministic-archives],
49                 [ar and ranlib default to -D behavior])], [
50 if test "${enableval}" = no; then
51   default_ar_deterministic=0
52 else
53   default_ar_deterministic=1
54 fi], [default_ar_deterministic=0])
56 AC_DEFINE_UNQUOTED(DEFAULT_AR_DETERMINISTIC, $default_ar_deterministic,
57                    [Should ar and ranlib use -D behavior by default?])
60 AC_ARG_ENABLE(default-strings-all,
61 [AS_HELP_STRING([--disable-default-strings-all],
62                 [strings defaults to --data behavior])], [
63 if test "${enableval}" = no; then
64   default_strings_all=0
65 else
66   default_strings_all=1
67 fi], [default_strings_all=1])
69 AC_DEFINE_UNQUOTED(DEFAULT_STRINGS_ALL, $default_strings_all,
70                    [Should strings use -a behavior by default?])
73 AC_ARG_ENABLE(f-for-ifunc-symbols,
74 [AS_HELP_STRING([--enable-f-for-ifunc-symbols],
75         [Have nm use F and f for global and local ifunc symbols])], [
76 if test "${enableval}" = no; then
77   default_f_for_ifunc=0
78 else
79   default_f_for_ifunc=1
80 fi], [default_f_for_ifunc=0])
82 AC_DEFINE_UNQUOTED(DEFAULT_F_FOR_IFUNC_SYMBOLS, $default_f_for_ifunc,
83                    [Have nm use F and f for global and local ifunc symbols])
85 AC_DEBUGINFOD
87 GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections])
88 if test "${enable_libctf}" = yes; then
89     AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections])
91 AM_CONDITIONAL(ENABLE_LIBCTF, test "${enable_libctf}" = yes)
93 AM_BINUTILS_WARNINGS
95 AC_CONFIG_HEADERS(config.h:config.in)
97 AH_VERBATIM([00_CONFIG_H_CHECK],
98 [/* Check that config.h is #included before system headers
99    (this works only for glibc, but that should be enough).  */
100 #if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
101 #  error config.h must be #included before system headers
102 #endif
103 #define __CONFIG_H__ 1])
105 if test -z "$target" ; then
106     AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
108 if test -z "$host" ; then
109     AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
112 AC_PROG_YACC
113 AM_PROG_LEX
115 ALL_LINGUAS="bg ca da es fi fr hr id it ja pt ro ru rw sk sr sv tr uk vi zh_CN zh_TW"
116 ZW_GNU_GETTEXT_SISTER_DIR
117 AM_PO_SUBDIRS
119 AM_MAINTAINER_MODE
120 AM_CONDITIONAL(GENINSRC_NEVER, false)
121 AC_EXEEXT
122 if test -n "$EXEEXT"; then
123   AC_DEFINE(HAVE_EXECUTABLE_SUFFIX, 1,
124             [Does the platform use an executable suffix?])
126 AC_DEFINE_UNQUOTED(EXECUTABLE_SUFFIX, "${EXEEXT}",
127                    [Suffix used for executables, if any.])
129 # host-specific stuff:
131 HDEFINES=
133 . ${srcdir}/../bfd/configure.host
135 AC_SUBST(HDEFINES)
136 AR=${AR-ar}
137 AC_SUBST(AR)
138 AC_PROG_RANLIB
139 AC_PROG_INSTALL
141 BFD_CC_FOR_BUILD
143 DEMANGLER_NAME=c++filt
144 case "${host}" in
145   *-*-go32* | *-*-msdos*)
146     DEMANGLER_NAME=cxxfilt
147 esac
148 AC_SUBST(DEMANGLER_NAME)
150 AC_CHECK_SIZEOF([long])
151 AC_CHECK_TYPES([long long], [AC_CHECK_SIZEOF(long long)])
153 AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h fcntl.h sys/file.h limits.h locale.h sys/param.h wchar.h)
154 AC_HEADER_SYS_WAIT
155 ACX_HEADER_STRING
156 AC_FUNC_ALLOCA
157 AC_FUNC_MMAP
158 AC_CHECK_FUNCS(sbrk utimes setmode getc_unlocked strcoll setlocale)
159 AC_CHECK_FUNC([mkstemp],
160               AC_DEFINE([HAVE_MKSTEMP], 1,
161               [Define to 1 if you have the `mkstemp' function.]))
162 AC_CHECK_FUNC([mkdtemp],
163               AC_DEFINE([HAVE_MKDTEMP], 1,
164               [Define to 1 if you have the `mkdtemp' function.]))
165   AC_MSG_CHECKING([for mbstate_t])
166   AC_TRY_COMPILE([#include <wchar.h>],
167   [mbstate_t teststate;],
168   have_mbstate_t=yes, have_mbstate_t=no)
169   AC_MSG_RESULT($have_mbstate_t)
170   if test x"$have_mbstate_t" = xyes; then
171     AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.])
172   fi
174 # Some systems have frexp only in -lm, not in -lc.
175 AC_SEARCH_LIBS(frexp, m)
177 AM_LC_MESSAGES
179 AC_MSG_CHECKING(for time_t in time.h)
180 AC_CACHE_VAL(bu_cv_decl_time_t_time_h,
181 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <time.h>], [time_t i;])],
182 bu_cv_decl_time_t_time_h=yes, bu_cv_decl_time_t_time_h=no)])
183 AC_MSG_RESULT($bu_cv_decl_time_t_time_h)
184 if test $bu_cv_decl_time_t_time_h = yes; then
185   AC_DEFINE([HAVE_TIME_T_IN_TIME_H], 1,
186             [Is the type time_t defined in <time.h>?])
189 AC_MSG_CHECKING(for time_t in sys/types.h)
190 AC_CACHE_VAL(bu_cv_decl_time_t_types_h,
191 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>], [time_t i;])],
192 bu_cv_decl_time_t_types_h=yes, bu_cv_decl_time_t_types_h=no)])
193 AC_MSG_RESULT($bu_cv_decl_time_t_types_h)
194 if test $bu_cv_decl_time_t_types_h = yes; then
195   AC_DEFINE([HAVE_TIME_T_IN_TYPES_H], 1,
196             [Is the type time_t defined in <sys/types.h>?])
199 AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
200 AC_CACHE_VAL(bu_cv_decl_getopt_unistd_h,
201 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
202 bu_cv_decl_getopt_unistd_h=yes, bu_cv_decl_getopt_unistd_h=no)])
203 AC_MSG_RESULT($bu_cv_decl_getopt_unistd_h)
204 if test $bu_cv_decl_getopt_unistd_h = yes; then
205   AC_DEFINE([HAVE_DECL_GETOPT], 1,
206             [Is the prototype for getopt in <unistd.h> in the expected format?])
209 # Under Next 3.2 <utime.h> apparently does not define struct utimbuf
210 # by default.
211 AC_MSG_CHECKING([for utime.h])
212 AC_CACHE_VAL(bu_cv_header_utime_h,
213 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
214 #ifdef HAVE_TIME_H
215 #include <time.h>
216 #endif
217 #include <utime.h>],
218 [struct utimbuf s;])],
219 bu_cv_header_utime_h=yes, bu_cv_header_utime_h=no)])
220 AC_MSG_RESULT($bu_cv_header_utime_h)
221 if test $bu_cv_header_utime_h = yes; then
222   AC_DEFINE(HAVE_GOOD_UTIME_H, 1, [Does <utime.h> define struct utimbuf?])
225 AC_CHECK_DECLS([asprintf, environ, fprintf, getc_unlocked, getenv,
226                 sbrk, snprintf, stpcpy, strnlen, strstr, vsnprintf])
228 # Link in zlib if we can.  This allows us to read compressed debug
229 # sections.  This is used only by readelf.c (objdump uses bfd for
230 # reading compressed sections).
231 AM_ZLIB
233 BFD_BINARY_FOPEN
235 # target-specific stuff:
237 # Canonicalize the secondary target names.
238 if test -n "$enable_targets"; then
239     for targ in `echo $enable_targets | sed 's/,/ /g'`
240     do
241         result=`$ac_config_sub $targ 2>/dev/null`
242         if test -n "$result"; then
243             canon_targets="$canon_targets $result"
244         else
245             # Allow targets that config.sub doesn't recognize, like "all".
246             canon_targets="$canon_targets $targ"
247         fi
248     done
251 AC_CHECK_HEADER(iconv.h)
252 AM_ICONV
254 all_targets=false
255 BUILD_SRCONV=
256 BUILD_DLLTOOL=
257 DLLTOOL_DEFS=
258 DLLTOOL_DEFAULT=
259 BUILD_WINDRES=
260 BUILD_WINDMC=
261 BUILD_DLLWRAP=
262 BUILD_MISC=
263 BUILD_INSTALL_MISC=
264 OBJDUMP_DEFS=
265 OBJDUMP_PRIVATE_VECTORS=
266 OBJDUMP_PRIVATE_OFILES=
267 od_vectors=
269 for targ in $target $canon_targets
271     if test "x$targ" = "xall"; then
272         all_targets=true
273         BUILD_SRCONV='$(SRCONV_PROG)'
274         BUILD_MISC="${BUILD_MISC} "'bin2c$(EXEEXT_FOR_BUILD)'
275         BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
276         BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
277         BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
278         if test -z "$DLLTOOL_DEFAULT"; then
279           DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_I386"
280         fi
281         DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386"
282         BUILD_DLLWRAP='$(DLLWRAP_PROG)$(EXEEXT)'
283         od_vectors="$od_vectors objdump_private_desc_xcoff"
284     else
285         case $targ in
286         *-*-hms*) BUILD_SRCONV='$(SRCONV_PROG)' ;;
287         esac
289         case $targ in
290         arm-wince-pe* | arm-*-wince | arm*-*-cegcc* | arm*-*-mingw32ce*)
291           BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
292           if test -z "$DLLTOOL_DEFAULT"; then
293             DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_ARM_WINCE"
294           fi
295           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM_WINCE -DDLLTOOL_ARM"
296           BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
297           BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
298           ;;
299         arm-*-pe*)
300           BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
301           if test -z "$DLLTOOL_DEFAULT"; then
302             DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_ARM"
303           fi
304           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_ARM"
305           BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
306           BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
307           ;;
308         x86_64-*-mingw* | x86_64-*-cygwin*)
309           BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
310           if test -z "$DLLTOOL_DEFAULT"; then
311             DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_MX86_64"
312           fi
313           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MX86_64"
314           BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
315           BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
316           BUILD_DLLWRAP='$(DLLWRAP_PROG)$(EXEEXT)'
317           ;;
318 changequote(,)dnl
319         i[3-7]86-*-pe* | i[3-7]86-*-cygwin* | i[3-7]86-*-mingw32** | i[3-7]86-*-netbsdpe*)
320 changequote([,])dnl
321           BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
322           if test -z "$DLLTOOL_DEFAULT"; then
323             DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_I386"
324           fi
325           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386"
326           BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
327           BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
328           BUILD_DLLWRAP='$(DLLWRAP_PROG)$(EXEEXT)'
329           ;;
330 changequote(,)dnl
331         i[3-7]86-*-interix)
332 changequote([,])dnl
333           BUILD_DLLTOOL='$(DLLTOOL_PROG)'
334           if test -z "$DLLTOOL_DEFAULT"; then
335             DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_I386"
336           fi
337           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_I386"
338           ;;
339 changequote(,)dnl
340         powerpc*-aix5.[01])
341 changequote([,])dnl
342           ;;
343 changequote(,)dnl
344         powerpc*-aix[5-9].*)
345 changequote([,])dnl
346           OBJDUMP_DEFS="-DAIX_WEAK_SUPPORT"
347           ;;
348         powerpc*-*-linux* | powerpc*-*-elf* | powerpc*-*-eabi*)
349           case "$BUILD_INSTALL_MISC" in
350             *embedspu*) ;;
351             *) BUILD_INSTALL_MISC="${BUILD_INSTALL_MISC} embedspu"
352           esac
353           ;;
354         sh*-*-pe)
355           BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
356           if test -z "$DLLTOOL_DEFAULT"; then
357             DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_SH"
358           fi
359           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_SH"
360           BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
361           BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
362           ;;
363         spu-*-*)
364           BUILD_MISC="${BUILD_MISC} "'bin2c$(EXEEXT_FOR_BUILD)'
365           ;;
366         mips*-*-pe)
367           BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
368           if test -z "$DLLTOOL_DEFAULT"; then
369             DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_MIPS"
370           fi
371           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MIPS"
372           BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
373           BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
374           ;;
375         mcore-*-pe)
376           BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
377           if test -z "$DLLTOOL_DEFAULT"; then
378             DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_MCORE"
379           fi
380           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MCORE"
381           BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
382           BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
383           ;;
384         mcore-*-elf)
385           BUILD_DLLTOOL='$(DLLTOOL_PROG)$(EXEEXT)'
386           if test -z "$DLLTOOL_DEFAULT"; then
387             DLLTOOL_DEFAULT="-DDLLTOOL_DEFAULT_MCORE_ELF"
388           fi
389           DLLTOOL_DEFS="$DLLTOOL_DEFS -DDLLTOOL_MCORE_ELF"
390           ;;
391         mep-*)
392           OBJDUMP_DEFS="-DSKIP_ZEROES=256 -DSKIP_ZEROES_AT_END=0"
393           ;;
394         esac
396         # Add objdump private vectors.
397         case $targ in
398         avr-*-*)
399           od_vectors="$od_vectors objdump_private_desc_elf32_avr"
400           ;;
401         powerpc*-*-aix* | rs6000-*-aix*)
402           od_vectors="$od_vectors objdump_private_desc_xcoff"
403           ;;
404         *-*-darwin*)
405           od_vectors="$od_vectors objdump_private_desc_mach_o"
406           ;;
407         esac
408     fi
409 done
411 # Uniq objdump private vector, build objdump target ofiles.
412 od_files=
413 f=""
414 for i in $od_vectors ; do
415     case " $f " in
416     *" $i "*) ;;
417     *)
418         f="$f $i"
419         OBJDUMP_PRIVATE_VECTORS="$OBJDUMP_PRIVATE_VECTORS &$i,"
420         case $i in
421         objdump_private_desc_elf32_avr)
422             od_files="$od_files od-elf32_avr" ;;
423         objdump_private_desc_xcoff)
424             od_files="$od_files od-xcoff" ;;
425         objdump_private_desc_mach_o)
426             od_files="$od_files od-macho" ;;
427         *) AC_MSG_ERROR(*** unknown private vector $i) ;;
428         esac
429         ;;
430     esac
431 done
433 # Uniq objdump target ofiles
434 f=""
435 for i in $od_files ; do
436     case " $f " in
437     *" $i "*) ;;
438     *)
439         f="$f $i"
440         OBJDUMP_PRIVATE_OFILES="$OBJDUMP_PRIVATE_OFILES $i.$objext"
441         ;;
442     esac
443 done
445 DLLTOOL_DEFS="$DLLTOOL_DEFS $DLLTOOL_DEFAULT"
447 if test "${with_windres+set}" = set; then
448           BUILD_WINDRES='$(WINDRES_PROG)$(EXEEXT)'
451 if test "${with_windmc+set}" = set; then
452           BUILD_WINDMC='$(WINDMC_PROG)$(EXEEXT)'
455 OBJDUMP_DEFS="${OBJDUMP_DEFS} -DOBJDUMP_PRIVATE_VECTORS=\"${OBJDUMP_PRIVATE_VECTORS}\""
457 AC_SUBST(BUILD_SRCONV)
458 AC_SUBST(BUILD_DLLTOOL)
459 AC_SUBST(DLLTOOL_DEFS)
460 AC_SUBST(BUILD_WINDRES)
461 AC_SUBST(BUILD_WINDMC)
462 AC_SUBST(BUILD_DLLWRAP)
463 AC_SUBST(BUILD_MISC)
464 AC_SUBST(BUILD_INSTALL_MISC)
465 AC_SUBST(OBJDUMP_DEFS)
466 AC_SUBST(OBJDUMP_PRIVATE_OFILES)
468 AC_DEFINE_UNQUOTED(TARGET, "${target}", [Configured target name.])
470 targ=$target
471 . $srcdir/../bfd/config.bfd
472 if test "x$targ_underscore" = "xyes"; then
473     UNDERSCORE=1
474 else
475     UNDERSCORE=0
477 AC_DEFINE_UNQUOTED(TARGET_PREPENDS_UNDERSCORE, $UNDERSCORE,
478  [Define to 1 if user symbol names have a leading underscore, 0 if not.])
480 # Emulation
481 targ=$target
482 . ${srcdir}/configure.tgt
483 EMULATION=$targ_emul
484 EMULATION_VECTOR=$targ_emul_vector
486 AC_SUBST(EMULATION)
487 AC_SUBST(EMULATION_VECTOR)
489 # Required for html and install-html
490 AC_SUBST(datarootdir)
491 AC_SUBST(docdir)
492 AC_SUBST(htmldir)
493 AC_SUBST(pdfdir)
495 AC_CONFIG_FILES(Makefile doc/Makefile po/Makefile.in:po/Make-in)
496 AC_OUTPUT