acinclude.m4 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. dnl Copyright (C) 2005-2015 Free Software Foundation, Inc.
  2. dnl
  3. dnl This file is part of GCC.
  4. dnl
  5. dnl GCC 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, or (at your option)
  8. dnl any later version.
  9. dnl
  10. dnl GCC 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 GCC; see the file COPYING3. If not see
  17. dnl <http://www.gnu.org/licenses/>.
  18. dnl See whether we need a declaration for a function.
  19. dnl The result is highly dependent on the INCLUDES passed in, so make sure
  20. dnl to use a different cache variable name in this macro if it is invoked
  21. dnl in a different context somewhere else.
  22. dnl gcc_AC_CHECK_DECL(SYMBOL,
  23. dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
  24. AC_DEFUN([gcc_AC_CHECK_DECL],
  25. [AC_MSG_CHECKING([whether $1 is declared])
  26. AC_CACHE_VAL(gcc_cv_have_decl_$1,
  27. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$4],
  28. [#ifndef $1
  29. char *(*pfn) = (char *(*)) $1 ;
  30. #endif])], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
  31. if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
  32. AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
  33. else
  34. AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
  35. fi
  36. ])dnl
  37. dnl Check multiple functions to see whether each needs a declaration.
  38. dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
  39. dnl gcc_AC_CHECK_DECLS(SYMBOLS,
  40. dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
  41. AC_DEFUN([gcc_AC_CHECK_DECLS],
  42. [AC_FOREACH([gcc_AC_Func], [$1],
  43. [AH_TEMPLATE(AS_TR_CPP(HAVE_DECL_[]gcc_AC_Func),
  44. [Define to 1 if we found a declaration for ']gcc_AC_Func[', otherwise
  45. define to 0.])])dnl
  46. for ac_func in $1
  47. do
  48. ac_tr_decl=AS_TR_CPP([HAVE_DECL_$ac_func])
  49. gcc_AC_CHECK_DECL($ac_func,
  50. [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
  51. [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
  52. dnl It is possible that the include files passed in here are local headers
  53. dnl which supply a backup declaration for the relevant prototype based on
  54. dnl the definition of (or lack of) the HAVE_DECL_ macro. If so, this test
  55. dnl will always return success. E.g. see libiberty.h's handling of
  56. dnl `basename'. To avoid this, we define the relevant HAVE_DECL_ macro to
  57. dnl 1 so that any local headers used do not provide their own prototype
  58. dnl during this test.
  59. #undef $ac_tr_decl
  60. #define $ac_tr_decl 1
  61. $4
  62. )
  63. done
  64. ])
  65. dnl 'make compare' can be significantly faster, if cmp itself can
  66. dnl skip bytes instead of using tail. The test being performed is
  67. dnl "if cmp --ignore-initial=2 t1 t2 && ! cmp --ignore-initial=1 t1 t2"
  68. dnl but we need to sink errors and handle broken shells. We also test
  69. dnl for the parameter format "cmp file1 file2 skip1 skip2" which is
  70. dnl accepted by cmp on some systems.
  71. AC_DEFUN([gcc_AC_PROG_CMP_IGNORE_INITIAL],
  72. [AC_CACHE_CHECK([for cmp's capabilities], gcc_cv_prog_cmp_skip,
  73. [ echo abfoo >t1
  74. echo cdfoo >t2
  75. gcc_cv_prog_cmp_skip=slowcompare
  76. if cmp --ignore-initial=2 t1 t2 > /dev/null 2>&1; then
  77. if cmp --ignore-initial=1 t1 t2 > /dev/null 2>&1; then
  78. :
  79. else
  80. gcc_cv_prog_cmp_skip=gnucompare
  81. fi
  82. fi
  83. if test $gcc_cv_prog_cmp_skip = slowcompare ; then
  84. if cmp t1 t2 2 2 > /dev/null 2>&1; then
  85. if cmp t1 t2 1 1 > /dev/null 2>&1; then
  86. :
  87. else
  88. gcc_cv_prog_cmp_skip=fastcompare
  89. fi
  90. fi
  91. fi
  92. rm t1 t2
  93. ])
  94. make_compare_target=$gcc_cv_prog_cmp_skip
  95. AC_SUBST(make_compare_target)
  96. ])
  97. dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
  98. AC_DEFUN([gcc_AC_PROG_LN_S],
  99. [AC_MSG_CHECKING(whether ln -s works)
  100. AC_CACHE_VAL(gcc_cv_prog_LN_S,
  101. [rm -f conftestdata_t
  102. echo >conftestdata_f
  103. if ln -s conftestdata_f conftestdata_t 2>/dev/null
  104. then
  105. gcc_cv_prog_LN_S="ln -s"
  106. else
  107. if ln conftestdata_f conftestdata_t 2>/dev/null
  108. then
  109. gcc_cv_prog_LN_S=ln
  110. else
  111. if cp -p conftestdata_f conftestdata_t 2>/dev/null
  112. then
  113. gcc_cv_prog_LN_S="cp -p"
  114. else
  115. gcc_cv_prog_LN_S=cp
  116. fi
  117. fi
  118. fi
  119. rm -f conftestdata_f conftestdata_t
  120. ])dnl
  121. LN_S="$gcc_cv_prog_LN_S"
  122. if test "$gcc_cv_prog_LN_S" = "ln -s"; then
  123. AC_MSG_RESULT(yes)
  124. else
  125. if test "$gcc_cv_prog_LN_S" = "ln"; then
  126. AC_MSG_RESULT([no, using ln])
  127. else
  128. AC_MSG_RESULT([no, and neither does ln, so using $gcc_cv_prog_LN_S])
  129. fi
  130. fi
  131. AC_SUBST(LN_S)dnl
  132. ])
  133. dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
  134. dnl of the usual 2.
  135. AC_DEFUN([gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG],
  136. [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
  137. [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
  138. #include <sys/types.h>
  139. #ifdef HAVE_SYS_STAT_H
  140. # include <sys/stat.h>
  141. #endif
  142. #ifdef HAVE_UNISTD_H
  143. # include <unistd.h>
  144. #endif
  145. #ifdef HAVE_DIRECT_H
  146. # include <direct.h>
  147. #endif], [mkdir ("foo", 0);])],
  148. gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
  149. if test $gcc_cv_mkdir_takes_one_arg = yes ; then
  150. AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
  151. fi
  152. ])
  153. AC_DEFUN([gcc_AC_PROG_INSTALL],
  154. [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
  155. # Find a good install program. We prefer a C program (faster),
  156. # so one script is as good as another. But avoid the broken or
  157. # incompatible versions:
  158. # SysV /etc/install, /usr/sbin/install
  159. # SunOS /usr/etc/install
  160. # IRIX /sbin/install
  161. # AIX /bin/install
  162. # AFS /usr/afsws/bin/install, which mishandles nonexistent args
  163. # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
  164. # ./install, which can be erroneously created by make from ./install.sh.
  165. AC_MSG_CHECKING(for a BSD compatible install)
  166. if test -z "$INSTALL"; then
  167. AC_CACHE_VAL(ac_cv_path_install,
  168. [ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
  169. for ac_dir in $PATH; do
  170. # Account for people who put trailing slashes in PATH elements.
  171. case "$ac_dir/" in
  172. /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
  173. *)
  174. # OSF1 and SCO ODT 3.0 have their own names for install.
  175. for ac_prog in ginstall scoinst install; do
  176. if test -f $ac_dir/$ac_prog; then
  177. if test $ac_prog = install &&
  178. grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
  179. # AIX install. It has an incompatible calling convention.
  180. # OSF/1 installbsd also uses dspmsg, but is usable.
  181. :
  182. else
  183. ac_cv_path_install="$ac_dir/$ac_prog -c"
  184. break 2
  185. fi
  186. fi
  187. done
  188. ;;
  189. esac
  190. done
  191. IFS="$ac_save_IFS"
  192. ])dnl
  193. if test "${ac_cv_path_install+set}" = set; then
  194. INSTALL="$ac_cv_path_install"
  195. else
  196. # As a last resort, use the slow shell script. We don't cache a
  197. # path for INSTALL within a source directory, because that will
  198. # break other packages using the cache if that directory is
  199. # removed, or if the path is relative.
  200. INSTALL="$ac_install_sh"
  201. fi
  202. fi
  203. dnl We do special magic for INSTALL instead of AC_SUBST, to get
  204. dnl relative paths right.
  205. AC_MSG_RESULT($INSTALL)
  206. AC_SUBST(INSTALL)dnl
  207. # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
  208. # It thinks the first close brace ends the variable substitution.
  209. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
  210. AC_SUBST(INSTALL_PROGRAM)dnl
  211. test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
  212. AC_SUBST(INSTALL_DATA)dnl
  213. ])
  214. dnl Determine if enumerated bitfields are unsigned. ISO C says they can
  215. dnl be either signed or unsigned.
  216. dnl
  217. AC_DEFUN([gcc_AC_C_ENUM_BF_UNSIGNED],
  218. [AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned,
  219. [AC_RUN_IFELSE([AC_LANG_SOURCE([#include <stdlib.h>
  220. enum t { BLAH = 128 } ;
  221. struct s_t { enum t member : 8; } s ;
  222. int main(void)
  223. {
  224. s.member = BLAH;
  225. if (s.member < 0) exit(1);
  226. exit(0);
  227. }])], gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)])
  228. if test $gcc_cv_enum_bf_unsigned = yes; then
  229. AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1,
  230. [Define if enumerated bitfields are treated as unsigned values.])
  231. fi])
  232. dnl Probe number of bits in a byte.
  233. dnl Note C89 requires CHAR_BIT >= 8.
  234. dnl
  235. AC_DEFUN([gcc_AC_C_CHAR_BIT],
  236. [AC_CACHE_CHECK(for CHAR_BIT, gcc_cv_decl_char_bit,
  237. [AC_EGREP_CPP(found,
  238. [#ifdef HAVE_LIMITS_H
  239. #include <limits.h>
  240. #endif
  241. #ifdef CHAR_BIT
  242. found
  243. #endif], gcc_cv_decl_char_bit=yes, gcc_cv_decl_char_bit=no)
  244. ])
  245. if test $gcc_cv_decl_char_bit = no; then
  246. AC_CACHE_CHECK(number of bits in a byte, gcc_cv_c_nbby,
  247. [i=8
  248. gcc_cv_c_nbby=
  249. while test $i -lt 65; do
  250. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,
  251. [switch(0) {
  252. case (unsigned char)((unsigned long)1 << $i) == ((unsigned long)1 << $i):
  253. case (unsigned char)((unsigned long)1<<($i-1)) == ((unsigned long)1<<($i-1)):
  254. ; }])],
  255. [gcc_cv_c_nbby=$i; break])
  256. i=`expr $i + 1`
  257. done
  258. test -z "$gcc_cv_c_nbby" && gcc_cv_c_nbby=failed
  259. ])
  260. if test $gcc_cv_c_nbby = failed; then
  261. AC_MSG_ERROR(cannot determine number of bits in a byte)
  262. else
  263. AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby,
  264. [Define as the number of bits in a byte, if `limits.h' doesn't.])
  265. fi
  266. fi])
  267. AC_DEFUN([gcc_AC_INITFINI_ARRAY],
  268. [AC_REQUIRE([gcc_SUN_LD_VERSION])dnl
  269. AC_ARG_ENABLE(initfini-array,
  270. [ --enable-initfini-array use .init_array/.fini_array sections],
  271. [], [
  272. AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
  273. gcc_cv_initfini_array, [dnl
  274. if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then
  275. case "${target}" in
  276. ia64-*)
  277. AC_RUN_IFELSE([AC_LANG_SOURCE([
  278. #ifndef __ELF__
  279. #error Not an ELF OS
  280. #endif
  281. /* We turn on .preinit_array/.init_array/.fini_array support for ia64
  282. if it can be used. */
  283. static int x = -1;
  284. int main (void) { return x; }
  285. int foo (void) { x = 0; }
  286. int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;
  287. ])],
  288. [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
  289. [gcc_cv_initfini_array=no]);;
  290. *)
  291. gcc_cv_initfini_array=no
  292. if test $in_tree_ld = yes ; then
  293. if test "$gcc_cv_gld_major_version" -eq 2 \
  294. -a "$gcc_cv_gld_minor_version" -ge 22 \
  295. -o "$gcc_cv_gld_major_version" -gt 2 \
  296. && test $in_tree_ld_is_elf = yes; then
  297. gcc_cv_initfini_array=yes
  298. fi
  299. elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then
  300. cat > conftest.s <<\EOF
  301. .section .dtors,"a",%progbits
  302. .balign 4
  303. .byte 'A', 'A', 'A', 'A'
  304. .section .ctors,"a",%progbits
  305. .balign 4
  306. .byte 'B', 'B', 'B', 'B'
  307. .section .fini_array.65530,"a",%progbits
  308. .balign 4
  309. .byte 'C', 'C', 'C', 'C'
  310. .section .init_array.65530,"a",%progbits
  311. .balign 4
  312. .byte 'D', 'D', 'D', 'D'
  313. .section .dtors.64528,"a",%progbits
  314. .balign 4
  315. .byte 'E', 'E', 'E', 'E'
  316. .section .ctors.64528,"a",%progbits
  317. .balign 4
  318. .byte 'F', 'F', 'F', 'F'
  319. .section .fini_array.01005,"a",%progbits
  320. .balign 4
  321. .byte 'G', 'G', 'G', 'G'
  322. .section .init_array.01005,"a",%progbits
  323. .balign 4
  324. .byte 'H', 'H', 'H', 'H'
  325. .text
  326. .globl _start
  327. _start:
  328. EOF
  329. if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
  330. && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
  331. && $gcc_cv_objdump -s -j .init_array conftest \
  332. | grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \
  333. && $gcc_cv_objdump -s -j .fini_array conftest \
  334. | grep GGGGEEEECCCCAAAA > /dev/null 2>&1; then
  335. gcc_cv_initfini_array=yes
  336. fi
  337. changequote(,)dnl
  338. rm -f conftest conftest.*
  339. changequote([,])dnl
  340. fi
  341. AC_PREPROC_IFELSE([AC_LANG_SOURCE([
  342. #ifndef __ELF__
  343. # error Not an ELF OS
  344. #endif
  345. #include <stdlib.h>
  346. #if defined __GLIBC_PREREQ
  347. # if __GLIBC_PREREQ (2, 4)
  348. # else
  349. # error GLIBC 2.4 required
  350. # endif
  351. #else
  352. # if defined __sun__ && defined __svr4__
  353. /* Solaris ld.so.1 supports .init_array/.fini_array since Solaris 8. */
  354. # else
  355. # error The C library not known to support .init_array/.fini_array
  356. # endif
  357. #endif
  358. ])],, [gcc_cv_initfini_array=no]);;
  359. esac
  360. else
  361. AC_MSG_CHECKING(cross compile... guessing)
  362. gcc_cv_initfini_array=no
  363. fi])
  364. enable_initfini_array=$gcc_cv_initfini_array
  365. ])
  366. if test $enable_initfini_array = yes; then
  367. AC_DEFINE(HAVE_INITFINI_ARRAY_SUPPORT, 1,
  368. [Define .init_array/.fini_array sections are available and working.])
  369. fi])
  370. dnl # _gcc_COMPUTE_GAS_VERSION
  371. dnl # Used by gcc_GAS_VERSION_GTE_IFELSE
  372. dnl #
  373. dnl # WARNING:
  374. dnl # gcc_cv_as_gas_srcdir must be defined before this.
  375. dnl # This gross requirement will go away eventually.
  376. AC_DEFUN([_gcc_COMPUTE_GAS_VERSION],
  377. [gcc_cv_as_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
  378. for f in $gcc_cv_as_bfd_srcdir/configure \
  379. $gcc_cv_as_gas_srcdir/configure \
  380. $gcc_cv_as_gas_srcdir/configure.in \
  381. $gcc_cv_as_gas_srcdir/Makefile.in ; do
  382. gcc_cv_gas_version=`sed -n -e 's/^[[ ]]*VERSION=[[^0-9A-Za-z_]]*\([[0-9]]*\.[[0-9]]*.*\)/VERSION=\1/p' < $f`
  383. if test x$gcc_cv_gas_version != x; then
  384. break
  385. fi
  386. done
  387. case $gcc_cv_gas_version in
  388. VERSION=[[0-9]]*) ;;
  389. *) AC_MSG_ERROR([[cannot find version of in-tree assembler]]);;
  390. esac
  391. gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([[0-9]]*\)"`
  392. gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : "VERSION=[[0-9]]*\.\([[0-9]]*\)"`
  393. gcc_cv_gas_patch_version=`expr "$gcc_cv_gas_version" : "VERSION=[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)"`
  394. case $gcc_cv_gas_patch_version in
  395. "") gcc_cv_gas_patch_version="0" ;;
  396. esac
  397. gcc_cv_gas_vers=`expr \( \( $gcc_cv_gas_major_version \* 1000 \) \
  398. + $gcc_cv_gas_minor_version \) \* 1000 \
  399. + $gcc_cv_gas_patch_version`
  400. ]) []dnl # _gcc_COMPUTE_GAS_VERSION
  401. dnl # gcc_GAS_VERSION_GTE_IFELSE([elf,] major, minor, patchlevel,
  402. dnl # [command_if_true = :], [command_if_false = :])
  403. dnl # Check to see if the version of GAS is greater than or
  404. dnl # equal to the specified version.
  405. dnl #
  406. dnl # The first ifelse() shortens the shell code if the patchlevel
  407. dnl # is unimportant (the usual case). The others handle missing
  408. dnl # commands. Note that the tests are structured so that the most
  409. dnl # common version number cases are tested first.
  410. AC_DEFUN([_gcc_GAS_VERSION_GTE_IFELSE],
  411. [ifelse([$1], elf,
  412. [if test $in_tree_gas_is_elf = yes \
  413. &&],
  414. [if]) test $gcc_cv_gas_vers -ge `expr \( \( $2 \* 1000 \) + $3 \) \* 1000 + $4`
  415. then dnl
  416. ifelse([$5],,:,[$5])[]dnl
  417. ifelse([$6],,,[
  418. else $6])
  419. fi])
  420. AC_DEFUN([gcc_GAS_VERSION_GTE_IFELSE],
  421. [AC_REQUIRE([_gcc_COMPUTE_GAS_VERSION])dnl
  422. ifelse([$1], elf, [_gcc_GAS_VERSION_GTE_IFELSE($@)],
  423. [_gcc_GAS_VERSION_GTE_IFELSE(,$@)])])
  424. dnl # gcc_GAS_FLAGS
  425. dnl # Used by gcc_GAS_CHECK_FEATURE
  426. dnl #
  427. AC_DEFUN([gcc_GAS_FLAGS],
  428. [AC_CACHE_CHECK([assembler flags], gcc_cv_as_flags,
  429. [ case "$target" in
  430. i[[34567]]86-*-linux*)
  431. dnl Override the default, which may be incompatible.
  432. gcc_cv_as_flags=--32
  433. ;;
  434. x86_64-*-linux-gnux32)
  435. dnl Override the default, which may be incompatible.
  436. gcc_cv_as_flags=--x32
  437. ;;
  438. x86_64-*-linux*)
  439. dnl Override the default, which may be incompatible.
  440. gcc_cv_as_flags=--64
  441. ;;
  442. powerpc*-*-darwin*)
  443. dnl Always pass -arch ppc to assembler.
  444. gcc_cv_as_flags="-arch ppc"
  445. ;;
  446. *)
  447. gcc_cv_as_flags=" "
  448. ;;
  449. esac])
  450. ])
  451. dnl gcc_GAS_CHECK_FEATURE(description, cv, [[elf,]major,minor,patchlevel],
  452. dnl [extra switches to as], [assembler input],
  453. dnl [extra testing logic], [command if feature available])
  454. dnl
  455. dnl Checks for an assembler feature. If we are building an in-tree
  456. dnl gas, the feature is available if the associated assembler version
  457. dnl is greater than or equal to major.minor.patchlevel. If not, then
  458. dnl ASSEMBLER INPUT is fed to the assembler and the feature is available
  459. dnl if assembly succeeds. If EXTRA TESTING LOGIC is not the empty string,
  460. dnl then it is run instead of simply setting CV to "yes" - it is responsible
  461. dnl for doing so, if appropriate.
  462. AC_DEFUN([gcc_GAS_CHECK_FEATURE],
  463. [AC_REQUIRE([gcc_GAS_FLAGS])dnl
  464. AC_CACHE_CHECK([assembler for $1], [$2],
  465. [[$2]=no
  466. ifelse([$3],,,[dnl
  467. if test $in_tree_gas = yes; then
  468. gcc_GAS_VERSION_GTE_IFELSE($3, [[$2]=yes])
  469. el])if test x$gcc_cv_as != x; then
  470. AS_ECHO([ifelse(m4_substr([$5],0,1),[$], "[$5]", '[$5]')]) > conftest.s
  471. if AC_TRY_COMMAND([$gcc_cv_as $gcc_cv_as_flags $4 -o conftest.o conftest.s >&AS_MESSAGE_LOG_FD])
  472. then
  473. ifelse([$6],, [$2]=yes, [$6])
  474. else
  475. echo "configure: failed program was" >&AS_MESSAGE_LOG_FD
  476. cat conftest.s >&AS_MESSAGE_LOG_FD
  477. fi
  478. rm -f conftest.o conftest.s
  479. fi])
  480. ifelse([$7],,,[dnl
  481. if test $[$2] = yes; then
  482. $7
  483. fi])])
  484. dnl gcc_SUN_LD_VERSION
  485. dnl
  486. dnl Determines Sun linker version numbers, setting gcc_cv_sun_ld_vers to
  487. dnl the complete version number and gcc_cv_sun_ld_vers_{major, minor} to
  488. dnl the corresponding fields.
  489. dnl
  490. dnl ld and ld.so.1 are guaranteed to be updated in lockstep, so ld version
  491. dnl numbers can be used in ld.so.1 feature checks even if a different
  492. dnl linker is configured.
  493. dnl
  494. AC_DEFUN([gcc_SUN_LD_VERSION],
  495. [changequote(,)dnl
  496. if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then
  497. case "${target}" in
  498. *-*-solaris2*)
  499. #
  500. # Solaris 2 ld -V output looks like this for a regular version:
  501. #
  502. # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1699
  503. #
  504. # but test versions add stuff at the end:
  505. #
  506. # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1701:onnv-ab196087-6931056-03/25/10
  507. #
  508. gcc_cv_sun_ld_ver=`/usr/ccs/bin/ld -V 2>&1`
  509. if echo "$gcc_cv_sun_ld_ver" | grep 'Solaris Link Editors' > /dev/null; then
  510. gcc_cv_sun_ld_vers=`echo $gcc_cv_sun_ld_ver | sed -n \
  511. -e 's,^.*: 5\.[0-9][0-9]*-\([0-9]\.[0-9][0-9]*\).*$,\1,p'`
  512. gcc_cv_sun_ld_vers_major=`expr "$gcc_cv_sun_ld_vers" : '\([0-9]*\)'`
  513. gcc_cv_sun_ld_vers_minor=`expr "$gcc_cv_sun_ld_vers" : '[0-9]*\.\([0-9]*\)'`
  514. fi
  515. ;;
  516. esac
  517. fi
  518. changequote([,])dnl
  519. ])
  520. dnl GCC_TARGET_TEMPLATE(KEY)
  521. dnl ------------------------
  522. dnl Define KEY as a valid configure key on the target machine.
  523. m4_define([GCC_TARGET_TEMPLATE],
  524. [m4_define([GCC_TARGET_TEMPLATE($1)],[])])
  525. dnl AH_TEMPLATE(KEY, DESCRIPTION)
  526. dnl -----------------------------
  527. dnl Issue an autoheader template for KEY, i.e., a comment composed of
  528. dnl DESCRIPTION (properly wrapped), and then #undef KEY. Redefinition
  529. dnl of the macro in autoheader.m4, to support definition of only a few
  530. dnl keys while compiling target libraries.
  531. m4_define([AH_TEMPLATE],
  532. [AH_VERBATIM([$1],m4_text_wrap([$2 */], [ ], [/* ])
  533. m4_ifdef([GCC_TARGET_TEMPLATE($1)],[],[#ifndef USED_FOR_TARGET
  534. ])[#undef $1]m4_ifdef([GCC_TARGET_TEMPLATE($1)],[],[
  535. #endif
  536. ]))])
  537. dnl Make sure that build_exeext is looked for
  538. AC_DEFUN([gcc_AC_BUILD_EXEEXT], [
  539. ac_executable_extensions="$build_exeext"])
  540. dnl GCC_GLIBC_VERSION_GTE_IFELSE(MAJOR, MINOR, IF-TRUE, IF-FALSE)
  541. dnl -------------------------------------------------------------
  542. dnl If the target glibc version ($glibc_version_major.$glibc_version_minor)
  543. dnl is at least MAJOR.MINOR, call IF-TRUE, otherwise call IF-FALSE.
  544. AC_DEFUN([GCC_GLIBC_VERSION_GTE_IFELSE],
  545. [
  546. AS_IF([test $glibc_version_major -gt $1 \
  547. || ( test $glibc_version_major -eq $1 && test $glibc_version_minor -ge $2 )],
  548. [$3], [$4])])