xref: /freebsd/contrib/bmake/aclocal.m4 (revision 2e3f49888ec8851bafb22011533217487764fdb0)
1dnl RCSid:
2dnl	$Id: aclocal.m4,v 1.6 2017/11/26 22:39:20 sjg Exp $
3dnl
4
5dnl
6dnl AC_CHECK_HEADER_HAS(HEADER, PATTERN, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]))
7
8AC_DEFUN(AC_CHECK_HEADER_HAS,
9[dnl first check if header exists and if so, see if it contains PATTERN
10ac_has_hdr=`echo "ac_cv_header_$1" | sed 'y%./+-%__p_%'`
11ac_has_it=`echo "ac_cv_header_$1"_$2 | sed 'y%./+-%__p_%'`
12if eval "test \"`echo x'$'$ac_has_hdr`\" = x"; then
13  AC_CHECK_HEADER($1)
14fi
15if eval "test \"`echo '$'$ac_has_hdr`\" = yes"; then
16  ac_x=HAVE_`echo "$1" | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
17  AC_DEFINE_UNQUOTED($ac_x)
18  AC_MSG_CHECKING([if $1 has $2])
19  AC_CACHE_VAL($ac_has_it,
20               [eval $ac_has_it=no
21                AC_EGREP_HEADER($2, $1, eval "$ac_has_it=yes")])
22
23  if eval "test \"`echo '$'$ac_has_it`\" = yes"; then
24    AC_MSG_RESULT(yes)
25    ac_x=HAVE_`echo "$1"_$2 | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
26    AC_DEFINE_UNQUOTED($ac_x)
27    ifelse([$3], , :, [$3])
28  else
29    AC_MSG_RESULT(no)
30    ifelse([$4], , , [$4
31])dnl
32  fi
33fi
34])
35
36dnl AC_EGREP(PATTERN, FILE, ACTION-IF-FOUND [,
37dnl                 ACTION-IF-NOT-FOUND])
38AC_DEFUN(AC_EGREP,
39[
40dnl Prevent m4 from eating character classes:
41changequote(, )dnl
42if egrep "$1" $2 >/dev/null 2>&1; then
43changequote([, ])dnl
44  ifelse([$3], , :, [$3])
45ifelse([$4], , , [else
46  $4
47])dnl
48fi
49])
50
51dnl
52dnl Test for __attribute__
53dnl
54
55AC_DEFUN(AC_C___ATTRIBUTE__, [
56AC_MSG_CHECKING(for __attribute__)
57AC_CACHE_VAL(ac_cv___attribute__, [
58AC_LINK_IFELSE([
59#include <stdlib.h>
60
61static void foo(void) __attribute__ ((noreturn));
62
63static void
64foo(void)
65{
66  exit(1);
67}
68
69int
70main(int argc, char **argv)
71{
72	foo();
73}
74],
75ac_cv___attribute__=yes,
76ac_cv___attribute__=no)])
77if test "$ac_cv___attribute__" = "yes"; then
78  AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
79fi
80AC_MSG_RESULT($ac_cv___attribute__)
81])
82
83