summaryrefslogtreecommitdiffstats
path: root/contrib/bmake/aclocal.m4
blob: 2adafba3dac555a38b773aab5dceb14640a5df07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
dnl RCSid:
dnl	$Id: aclocal.m4,v 1.5 2003/03/06 21:21:30 sjg Exp $
dnl

dnl 
dnl AC_CHECK_HEADER_HAS(HEADER, PATTERN, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]))

AC_DEFUN(AC_CHECK_HEADER_HAS,
[dnl first check if header exists and if so, see if it contains PATTERN
ac_has_hdr=`echo "ac_cv_header_$1" | sed 'y%./+-%__p_%'`
ac_has_it=`echo "ac_cv_header_$1"_$2 | sed 'y%./+-%__p_%'`
if eval "test \"`echo x'$'$ac_has_hdr`\" = x"; then
  AC_CHECK_HEADER($1)
fi
if eval "test \"`echo '$'$ac_has_hdr`\" = yes"; then
  ac_x=HAVE_`echo "$1" | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
  AC_DEFINE_UNQUOTED($ac_x)
  AC_MSG_CHECKING([if $1 has $2])
  AC_CACHE_VAL($ac_has_it,
               [eval $ac_has_it=no
                AC_EGREP_HEADER($2, $1, eval "$ac_has_it=yes")])

  if eval "test \"`echo '$'$ac_has_it`\" = yes"; then
    AC_MSG_RESULT(yes)
    ac_x=HAVE_`echo "$1"_$2 | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
    AC_DEFINE_UNQUOTED($ac_x)
    ifelse([$3], , :, [$3])
  else
    AC_MSG_RESULT(no)
    ifelse([$4], , , [$4
])dnl
  fi
fi
])

dnl AC_EGREP(PATTERN, FILE, ACTION-IF-FOUND [,
dnl                 ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_EGREP,
[
dnl Prevent m4 from eating character classes:
changequote(, )dnl
if egrep "$1" $2 >/dev/null 2>&1; then
changequote([, ])dnl
  ifelse([$3], , :, [$3])
ifelse([$4], , , [else
  $4
])dnl
fi
])

dnl
dnl Test for __attribute__
dnl

AC_DEFUN(AC_C___ATTRIBUTE__, [
AC_MSG_CHECKING(for __attribute__)
AC_CACHE_VAL(ac_cv___attribute__, [
AC_TRY_COMPILE([
#include <stdlib.h>
],
[
static void foo(void) __attribute__ ((noreturn));

static void
foo(void)
{
  exit(1);
}
],
ac_cv___attribute__=yes,
ac_cv___attribute__=no)])
if test "$ac_cv___attribute__" = "yes"; then
  AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
fi
AC_MSG_RESULT($ac_cv___attribute__)
])

OpenPOWER on IntegriCloud