configure.ac 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. dnl Process this file with autoconf to produce a configure script
  2. dnl
  3. dnl Copyright (C) 2012-2015 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
  19. AC_PREREQ(2.59)
  20. m4_include([../bfd/version.m4])
  21. AC_INIT([ld], BFD_VERSION)
  22. AC_CONFIG_SRCDIR(ldmain.c)
  23. AC_CANONICAL_TARGET
  24. AC_CANONICAL_BUILD
  25. AC_ISC_POSIX
  26. AM_INIT_AUTOMAKE
  27. AM_MAINTAINER_MODE
  28. AC_PROG_CC
  29. AC_PROG_CXX
  30. AC_PROG_GREP
  31. AC_GNU_SOURCE
  32. AC_USE_SYSTEM_EXTENSIONS
  33. AC_PROG_INSTALL
  34. LT_INIT
  35. ACX_LARGEFILE
  36. AC_ARG_WITH(lib-path, [ --with-lib-path=dir1:dir2... set default LIB_PATH],LIB_PATH=$withval)
  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
  45. AC_ARG_ENABLE(64-bit-bfd,
  46. [ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)],
  47. [case "${enableval}" in
  48. yes) want64=true ;;
  49. no) want64=false ;;
  50. *) AC_MSG_ERROR(bad value ${enableval} for 64-bit-bfd option) ;;
  51. esac],[want64=false])dnl
  52. AC_ARG_WITH(sysroot,
  53. [ --with-sysroot[=DIR] Search for usr/lib et al within DIR.],
  54. [
  55. case ${with_sysroot} in
  56. yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_alias}/sys-root' ;;
  57. *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
  58. esac
  59. TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"'
  60. use_sysroot=yes
  61. if test "x$prefix" = xNONE; then
  62. test_prefix=/usr/local
  63. else
  64. test_prefix=$prefix
  65. fi
  66. if test "x$exec_prefix" = xNONE; then
  67. test_exec_prefix=$test_prefix
  68. else
  69. test_exec_prefix=$exec_prefix
  70. fi
  71. case ${TARGET_SYSTEM_ROOT} in
  72. "${test_prefix}"|"${test_prefix}/"*|\
  73. "${test_exec_prefix}"|"${test_exec_prefix}/"*|\
  74. '${prefix}'|'${prefix}/'*|\
  75. '${exec_prefix}'|'${exec_prefix}/'*)
  76. t="$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE"
  77. TARGET_SYSTEM_ROOT_DEFINE="$t"
  78. ;;
  79. esac
  80. ], [
  81. use_sysroot=no
  82. TARGET_SYSTEM_ROOT=
  83. TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"\"'
  84. ])
  85. AC_SUBST(use_sysroot)
  86. AC_SUBST(TARGET_SYSTEM_ROOT)
  87. AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
  88. dnl Use --enable-gold to decide if this linker should be the default.
  89. dnl "install_as_default" is set to false if gold is the default linker.
  90. dnl "installed_linker" is the installed BFD linker name.
  91. AC_ARG_ENABLE(gold,
  92. [[ --enable-gold[=ARG] build gold [ARG={default,yes,no}]]],
  93. [case "${enableval}" in
  94. default)
  95. install_as_default=no
  96. installed_linker=ld.bfd
  97. ;;
  98. yes|no)
  99. install_as_default=yes
  100. installed_linker=ld.bfd
  101. ;;
  102. *)
  103. AC_MSG_ERROR([invalid --enable-gold argument])
  104. ;;
  105. esac],
  106. [install_as_default=yes
  107. installed_linker=ld.bfd])
  108. AC_SUBST(install_as_default)
  109. AC_SUBST(installed_linker)
  110. AC_ARG_ENABLE([got],
  111. AS_HELP_STRING([--enable-got=<type>],
  112. [GOT handling scheme (target, single, negative, multigot)]),
  113. [case "${enableval}" in
  114. target | single | negative | multigot) got_handling=$enableval ;;
  115. *) AC_MSG_ERROR(bad value ${enableval} for --enable-got option) ;;
  116. esac],
  117. [got_handling=target])
  118. case "${got_handling}" in
  119. target)
  120. AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_TARGET_DEFAULT],
  121. [Define to choose default GOT handling scheme]) ;;
  122. single)
  123. AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_SINGLE],
  124. [Define to choose default GOT handling scheme]) ;;
  125. negative)
  126. AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_NEGATIVE],
  127. [Define to choose default GOT handling scheme]) ;;
  128. multigot)
  129. AC_DEFINE([GOT_HANDLING_DEFAULT], [GOT_HANDLING_MULTIGOT],
  130. [Define to choose default GOT handling scheme]) ;;
  131. *) AC_MSG_ERROR(bad value ${got_handling} for --enable-got option) ;;
  132. esac
  133. # PR gas/19109
  134. # Decide the default method for compressing debug sections.
  135. ac_default_compressed_debug_sections=unset
  136. # Provide a configure time option to override our default.
  137. AC_ARG_ENABLE(compressed_debug_sections,
  138. [ --enable-compressed-debug-sections={all,ld,none} compress debug sections by default],
  139. [case "${enableval}" in
  140. yes | all | ld) ac_default_compressed_debug_sections=yes ;;
  141. no | none) ac_default_compressed_debug_sections=no ;;
  142. *) ac_default_compressed_debug_sections=unset ;;
  143. esac])dnl
  144. AM_BINUTILS_WARNINGS
  145. AM_LC_MESSAGES
  146. AC_CONFIG_HEADERS([config.h:config.in])
  147. # PR 14072
  148. AH_VERBATIM([00_CONFIG_H_CHECK],
  149. [/* Check that config.h is #included before system headers
  150. (this works only for glibc, but that should be enough). */
  151. #if defined(__GLIBC__) && !defined(__FreeBSD_kernel__) && !defined(__CONFIG_H__)
  152. # error config.h must be #included before system headers
  153. #endif
  154. #define __CONFIG_H__ 1])
  155. if test -z "$target" ; then
  156. AC_MSG_ERROR(Unrecognized target system type; please check config.sub.)
  157. fi
  158. if test -z "$host" ; then
  159. AC_MSG_ERROR(Unrecognized host system type; please check config.sub.)
  160. fi
  161. # host-specific stuff:
  162. ALL_LINGUAS="fr sv tr es da vi zh_CN zh_TW ga fi id bg it uk"
  163. ZW_GNU_GETTEXT_SISTER_DIR
  164. AM_PO_SUBDIRS
  165. AC_EXEEXT
  166. AC_PROG_YACC
  167. AM_PROG_LEX
  168. AM_MAINTAINER_MODE
  169. AM_CONDITIONAL(GENINSRC_NEVER, false)
  170. ACX_PROG_CMP_IGNORE_INITIAL
  171. . ${srcdir}/configure.host
  172. AC_SUBST(HDEFINES)
  173. AC_SUBST(HOSTING_CRT0)
  174. AC_SUBST(HOSTING_SCRT0)
  175. AC_SUBST(HOSTING_LIBS)
  176. AC_SUBST(HOSTING_SLIBS)
  177. AC_SUBST(NATIVE_LIB_DIRS)
  178. AC_CHECK_HEADERS(string.h strings.h stdlib.h unistd.h elf-hints.h limits.h locale.h sys/param.h)
  179. AC_CHECK_HEADERS(fcntl.h sys/file.h sys/time.h sys/stat.h)
  180. ACX_HEADER_STRING
  181. AC_CHECK_FUNCS(glob mkstemp realpath sbrk setlocale waitpid)
  182. AC_CHECK_FUNCS(open lseek close)
  183. AC_HEADER_DIRENT
  184. dnl AC_CHECK_HEADERS(sys/mman.h)
  185. AC_FUNC_MMAP
  186. AC_SEARCH_LIBS([dlopen], [dl])
  187. AM_CONDITIONAL([ENABLE_PLUGINS], [test x$plugins = xyes])
  188. AC_ARG_ENABLE(initfini-array,
  189. [ --enable-initfini-array use .init_array/.fini_array sections],
  190. [], [
  191. AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
  192. gcc_cv_initfini_array, [dnl
  193. if test "x${build}" = "x${target}" ; then
  194. AC_RUN_IFELSE([AC_LANG_SOURCE([
  195. static int x = -1;
  196. int main (void) { return x; }
  197. int foo (void) { x = 0; }
  198. int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;])],
  199. [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
  200. [gcc_cv_initfini_array=no])
  201. else
  202. gcc_cv_initfini_array=no
  203. fi])
  204. enable_initfini_array=$gcc_cv_initfini_array
  205. ])
  206. AC_SUBST(enable_initfini_array)
  207. if test $enable_initfini_array = yes; then
  208. AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
  209. [Define .init_array/.fini_array sections are available and working.])
  210. fi
  211. AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
  212. AC_CACHE_VAL(ld_cv_decl_getopt_unistd_h,
  213. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
  214. ld_cv_decl_getopt_unistd_h=yes, ld_cv_decl_getopt_unistd_h=no)])
  215. AC_MSG_RESULT($ld_cv_decl_getopt_unistd_h)
  216. if test $ld_cv_decl_getopt_unistd_h = yes; then
  217. AC_DEFINE([HAVE_DECL_GETOPT], 1,
  218. [Is the prototype for getopt in <unistd.h> in the expected format?])
  219. fi
  220. BFD_BINARY_FOPEN
  221. AC_CHECK_DECLS([strstr, free, sbrk, getenv, environ])
  222. # When converting linker scripts into strings for use in emulation
  223. # files, use astring.sed if the compiler supports ANSI string
  224. # concatenation, or ostring.sed otherwise. This is to support the
  225. # broken Microsoft MSVC compiler, which limits the length of string
  226. # constants, while still supporting pre-ANSI compilers which do not
  227. # support string concatenation.
  228. AC_MSG_CHECKING([whether ANSI C string concatenation works])
  229. AC_CACHE_VAL(ld_cv_string_concatenation,
  230. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [char *a = "a" "a";])],
  231. ld_cv_string_concatenation=yes,
  232. ld_cv_string_concatenation=no)])
  233. AC_MSG_RESULT($ld_cv_string_concatenation)
  234. if test "$ld_cv_string_concatenation" = "yes"; then
  235. STRINGIFY=astring.sed
  236. else
  237. STRINGIFY=ostring.sed
  238. fi
  239. AC_SUBST(STRINGIFY)
  240. # target-specific stuff:
  241. all_targets=
  242. EMUL=
  243. all_emuls=
  244. all_emul_extras=
  245. all_libpath=
  246. dnl We need to get an arbitrary number of tdir definitions into
  247. dnl Makefile. We can't do it using AC_SUBST, because autoconf does
  248. dnl not permit literal newlines in an AC_SUBST variables. So we use a
  249. dnl file.
  250. rm -f tdirs
  251. # If the host is 64-bit, then we enable 64-bit targets by default.
  252. # This is consistent with what ../bfd/configure.ac does.
  253. if test x${want64} = xfalse; then
  254. AC_CHECK_SIZEOF(void *)
  255. if test "x${ac_cv_sizeof_void_p}" = "x8"; then
  256. want64=true
  257. fi
  258. fi
  259. elf_list_options=FALSE
  260. elf_shlib_list_options=FALSE
  261. elf_plt_unwind_list_options=FALSE
  262. for targ_alias in `echo $target_alias $enable_targets | sed 's/,/ /g'`
  263. do
  264. if test "$targ_alias" = "all"; then
  265. all_targets=true
  266. elf_list_options=TRUE
  267. elf_shlib_list_options=TRUE
  268. elf_plt_unwind_list_options=TRUE
  269. else
  270. # Canonicalize the secondary target names.
  271. result=`$ac_config_sub $targ_alias 2>/dev/null`
  272. if test -n "$result"; then
  273. targ=$result
  274. else
  275. targ=$targ_alias
  276. fi
  277. . ${srcdir}/configure.tgt
  278. if test "$targ" = "$target"; then
  279. EMUL=$targ_emul
  280. fi
  281. if test x${want64} = xfalse; then
  282. . ${srcdir}/../bfd/config.bfd
  283. fi
  284. if test x${want64} = xtrue; then
  285. targ_extra_emuls="$targ_extra_emuls $targ64_extra_emuls"
  286. targ_extra_libpath="$targ_extra_libpath $targ64_extra_libpath"
  287. fi
  288. for i in $targ_emul $targ_extra_emuls $targ_extra_libpath; do
  289. case " $all_emuls " in
  290. *" e${i}.o "*) ;;
  291. *)
  292. all_emuls="$all_emuls e${i}.o"
  293. eval result=\$tdir_$i
  294. test -z "$result" && result=$targ_alias
  295. echo tdir_$i=$result >> tdirs
  296. case "${i}" in
  297. *elf*)
  298. elf_list_options=TRUE
  299. ;;
  300. *)
  301. if $GREP "TEMPLATE_NAME=elf32" ${srcdir}/emulparams/${i}.sh >/dev/null 2>/dev/null; then
  302. elf_list_options=TRUE
  303. fi
  304. ;;
  305. esac
  306. if test "$elf_list_options" = "TRUE"; then
  307. . ${srcdir}/emulparams/${i}.sh
  308. if test x${GENERATE_SHLIB_SCRIPT} = xyes; then
  309. elf_shlib_list_options=TRUE
  310. fi
  311. if test x${PLT_UNWIND} = xyes; then
  312. elf_plt_unwind_list_options=TRUE
  313. fi
  314. fi
  315. ;;
  316. esac
  317. done
  318. for i in $targ_emul $targ_extra_libpath; do
  319. case " $all_libpath " in
  320. *" ${i} "*) ;;
  321. *)
  322. if test -z "$all_libpath"; then
  323. all_libpath=${i}
  324. else
  325. all_libpath="$all_libpath ${i}"
  326. fi
  327. ;;
  328. esac
  329. done
  330. for i in $targ_extra_ofiles; do
  331. case " $all_emul_extras " in
  332. *" ${i} "*) ;;
  333. *)
  334. all_emul_extras="$all_emul_extras ${i}"
  335. ;;
  336. esac
  337. done
  338. fi
  339. done
  340. if test x$ac_default_compressed_debug_sections == xyes ; then
  341. AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.])
  342. fi
  343. AC_SUBST(elf_list_options)
  344. AC_SUBST(elf_shlib_list_options)
  345. AC_SUBST(elf_plt_unwind_list_options)
  346. AC_SUBST(EMUL)
  347. TDIRS=tdirs
  348. AC_SUBST_FILE(TDIRS)
  349. if test x${all_targets} = xtrue; then
  350. if test x${want64} = xtrue; then
  351. EMULATION_OFILES='$(ALL_EMULATIONS) $(ALL_64_EMULATIONS)'
  352. EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES) $(ALL_64_EMUL_EXTRA_OFILES)'
  353. else
  354. EMULATION_OFILES='$(ALL_EMULATIONS)'
  355. EMUL_EXTRA_OFILES='$(ALL_EMUL_EXTRA_OFILES)'
  356. fi
  357. else
  358. EMULATION_OFILES=$all_emuls
  359. EMUL_EXTRA_OFILES=$all_emul_extras
  360. fi
  361. AC_SUBST(EMULATION_OFILES)
  362. AC_SUBST(EMUL_EXTRA_OFILES)
  363. AC_SUBST(LIB_PATH)
  364. EMULATION_LIBPATH=$all_libpath
  365. AC_SUBST(EMULATION_LIBPATH)
  366. if test x${enable_static} = xno; then
  367. TESTBFDLIB="--rpath ../bfd/.libs ../bfd/.libs/libbfd.so"
  368. else
  369. TESTBFDLIB="../bfd/.libs/libbfd.a"
  370. fi
  371. AC_SUBST(TESTBFDLIB)
  372. target_vendor=${target_vendor=$host_vendor}
  373. case "$target_vendor" in
  374. hp) EXTRA_SHLIB_EXTENSION=".sl" ;;
  375. *) EXTRA_SHLIB_EXTENSION= ;;
  376. esac
  377. case "$target_os" in
  378. lynxos) EXTRA_SHLIB_EXTENSION=".a" ;;
  379. esac
  380. if test x${EXTRA_SHLIB_EXTENSION} != x ; then
  381. AC_DEFINE_UNQUOTED(EXTRA_SHLIB_EXTENSION, "$EXTRA_SHLIB_EXTENSION",
  382. [Additional extension a shared object might have.])
  383. fi
  384. dnl Required by html, pdf, install-pdf and install-html
  385. AC_SUBST(datarootdir)
  386. AC_SUBST(docdir)
  387. AC_SUBST(htmldir)
  388. AC_SUBST(pdfdir)
  389. AC_CONFIG_FILES(Makefile po/Makefile.in:po/Make-in)
  390. AC_OUTPUT