openwcom.mak: BR 3392381: update to work for the current master
[nasm.git] / aclocal.m4
blobe5f0895902a05f3c478bbd6bc726a33ff975d0d5
1 dnl --------------------------------------------------------------------------
2 dnl PA_ADD_CFLAGS()
3 dnl
4 dnl Attempt to add the given option to CFLAGS, if it doesn't break compilation
5 dnl --------------------------------------------------------------------------
6 AC_DEFUN(PA_ADD_CFLAGS,
7 [AC_MSG_CHECKING([if $CC accepts $1])
8  pa_add_cflags__old_cflags="$CFLAGS"
9  CFLAGS="$CFLAGS $1"
10  AC_TRY_LINK([#include <stdio.h>],
11  [printf("Hello, World!\n");],
12  AC_MSG_RESULT([yes])
13  CFLAGS="$pa_add_cflags__old_cflags ifelse([$2],[],[$1],[$2])",
14  AC_MSG_RESULT([no])
15  CFLAGS="$pa_add_cflags__old_cflags")])
17 dnl --------------------------------------------------------------------------
18 dnl PA_HAVE_FUNC
19 dnl
20 dnl Look for a function with the specified arguments which could be
21 dnl a builtin/intrinsic function.
22 dnl --------------------------------------------------------------------------
23 AC_DEFUN(PA_HAVE_FUNC,
24 [AC_MSG_CHECKING([for $1])
25 AC_TRY_LINK([], [(void)$1$2;],
26 AC_MSG_RESULT([yes])
27 AC_DEFINE(m4_toupper([HAVE_$1]), [1],
28   [Define to 1 if you have the `$1' intrinsic function.]),
29 AC_MSG_RESULT([no]))])
31 dnl --------------------------------------------------------------------------
32 dnl PA_LIBEXT
33 dnl
34 dnl Guess the library extension based on the object extension
35 dnl --------------------------------------------------------------------------
36 AC_DEFUN(PA_LIBEXT,
37 [AC_MSG_CHECKING([for suffix of library files])
38 if test x"$LIBEXT" = x; then
39   case "$OBJEXT" in
40     obj )
41       LIBEXT=lib
42       ;;
43     *)
44       LIBEXT=a
45       ;;
46   esac
48 AC_MSG_RESULT([$LIBEXT])
49 AC_SUBST([LIBEXT])])
51 dnl --------------------------------------------------------------------------
52 dnl PA_FUNC_ATTRIBUTE
53 dnl
54 dnl See if this compiler supports the equivalent of a specific gcc
55 dnl attribute on a function, using the __attribute__(()) syntax.
56 dnl All arguments except the attribute name are optional.
57 dnl PA_FUNC_ATTRIBUTE(attribute, attribute_opts, return_type,
58 dnl                   prototype_args, call_args)
59 dnl --------------------------------------------------------------------------
60 AC_DEFUN(PA_FUNC_ATTRIBUTE,
61 [AC_MSG_CHECKING([if $CC supports the $1 function attribute])
62  AC_COMPILE_IFELSE([AC_LANG_SOURCE([
63 #include <stdarg.h>
64 extern ifelse([$3],[],[void *],[$3])  __attribute__(($1$2))
65   bar(ifelse([$4],[],[int],[$4]));
66 void *foo(void);
67 void *foo(void)
69         return bar(ifelse([$5],[],[1],[$5]));
71  ])],
72  [AC_MSG_RESULT([yes])
73   AC_DEFINE(m4_toupper([HAVE_FUNC_ATTRIBUTE_$1]), 1,
74     [Define to 1 if your compiler supports __attribute__(($1)) on functions])],
75  [AC_MSG_RESULT([no])])
78 dnl --------------------------------------------------------------------------
79 dnl PA_FUNC_ATTRIBUTE_ERROR
80 dnl
81 dnl See if this compiler supports __attribute__((error("foo")))
82 dnl The generic version of this doesn't work as it makes the compiler
83 dnl throw an error by design.
84 dnl --------------------------------------------------------------------------
85 AC_DEFUN(PA_FUNC_ATTRIBUTE_ERROR,
86 [AC_MSG_CHECKING([if $CC supports the error function attribute])
87  AC_COMPILE_IFELSE([AC_LANG_SOURCE([
88 #include <stdarg.h>
89 extern void __attribute__((error("message"))) barf(void);
90 void foo(void);
91 void foo(void)
93         if (0)
94                 barf();
96  ])],
97  [AC_MSG_RESULT([yes])
98   AC_DEFINE(m4_toupper([HAVE_FUNC_ATTRIBUTE_ERROR]), 1,
99     [Define to 1 if your compiler supports __attribute__((error)) on functions])],
100  [AC_MSG_RESULT([no])])