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