xref: /netbsd-src/external/gpl3/binutils/dist/gas/acinclude.m4 (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
1dnl GAS_CHECK_DECL_NEEDED(name, typedefname, typedef, headers)
2AC_DEFUN([GAS_CHECK_DECL_NEEDED],[
3AC_MSG_CHECKING(whether declaration is required for $1)
4AC_CACHE_VAL(gas_cv_decl_needed_$1,
5AC_TRY_LINK([$4],
6[
7typedef $3;
8$2 x;
9x = ($2) $1;
10], gas_cv_decl_needed_$1=no, gas_cv_decl_needed_$1=yes))dnl
11AC_MSG_RESULT($gas_cv_decl_needed_$1)
12if test $gas_cv_decl_needed_$1 = yes; then
13 AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
14	   [Define if $1 is not declared in system header files.])
15fi
16])dnl
17dnl
18dnl Some non-ANSI preprocessors botch requoting inside strings.  That's bad
19dnl enough, but on some of those systems, the assert macro relies on requoting
20dnl working properly!
21dnl GAS_WORKING_ASSERT
22AC_DEFUN([GAS_WORKING_ASSERT],
23[AC_MSG_CHECKING([for working assert macro])
24AC_CACHE_VAL(gas_cv_assert_ok,
25AC_TRY_LINK([#include <assert.h>
26#include <string.h>
27#include <stdio.h>], [
28/* check for requoting problems */
29static int a, b, c, d;
30static char *s;
31assert (!strcmp(s, "foo bar baz quux"));
32/* check for newline handling */
33assert (a == b
34        || c == d);
35], gas_cv_assert_ok=yes, gas_cv_assert_ok=no))dnl
36AC_MSG_RESULT($gas_cv_assert_ok)
37test $gas_cv_assert_ok = yes || AC_DEFINE(BROKEN_ASSERT, 1, [assert broken?])
38])dnl
39dnl
40dnl Since many Bourne shell implementations lack subroutines, use this
41dnl hack to simplify the code in configure.ac.
42dnl GAS_UNIQ(listvar)
43AC_DEFUN([GAS_UNIQ],
44[_gas_uniq_list="[$]$1"
45_gas_uniq_newlist=""
46dnl Protect against empty input list.
47for _gas_uniq_i in _gas_uniq_dummy [$]_gas_uniq_list ; do
48  case [$]_gas_uniq_i in
49  _gas_uniq_dummy) ;;
50  *) case " [$]_gas_uniq_newlist " in
51       *" [$]_gas_uniq_i "*) ;;
52       *) _gas_uniq_newlist="[$]_gas_uniq_newlist [$]_gas_uniq_i" ;;
53     esac ;;
54  esac
55done
56$1=[$]_gas_uniq_newlist
57])dnl
58dnl
59dnl Check for existence of member $2 in type $1 in time.h
60dnl
61AC_DEFUN([GAS_HAVE_TIME_TYPE_MEMBER],
62[AC_MSG_CHECKING([for $1.$2 in time.h])
63 AC_CACHE_VAL(gas_cv_have_time_type_member_$2,
64   [AC_TRY_COMPILE([
65#define _BSD_SOURCE 1
66#include <time.h>],
67      [$1 avar; void* aref = (void*) &avar.$2],
68      gas_cv_have_time_type_member_$2=yes,
69      gas_cv_have_time_type_member_$2=no
70   )])
71 if test $gas_cv_have_time_type_member_$2 = yes; then
72   AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z]), 1,
73	     [Define if <time.h> has $1.$2.])
74 fi
75 AC_MSG_RESULT($gas_cv_have_time_type_member_$2)
76])dnl
77dnl
78dnl Check for existence of member $2.$3 in type $1 in sys/stat.h
79dnl
80AC_DEFUN([GAS_HAVE_SYS_STAT_TYPE_MEMBER],
81[AC_MSG_CHECKING([for $1.$2.$3 in sys/stat.h])
82 AC_CACHE_VAL(gas_cv_have_sys_stat_type_member_$2_$3,
83   [AC_TRY_COMPILE([
84#define _BSD_SOURCE 1
85#include <sys/stat.h>],
86      [$1 avar; void* aref = (void*) &avar.$2.$3],
87      gas_cv_have_sys_stat_type_member_$2_$3=yes,
88      gas_cv_have_sys_stat_type_member_$2_$3=no
89   )])
90 if test $gas_cv_have_sys_stat_type_member_$2_$3 = yes; then
91   AC_DEFINE([HAVE_]translit($2, [a-z], [A-Z])[_]translit($3, [a-z], [A-Z]), 1,
92	     [Define if <sys/stat.h> has $1.$2.$3])
93 fi
94 AC_MSG_RESULT($gas_cv_have_sys_stat_type_member_$2_$3)
95])dnl
96