nasm_delete(): ugly hack to make it side-effect-free
[nasm.git] / aclocal.m4
blob1ec6e7f80635b2114d84ae1d3e63a24613528a92
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)
68         return bar(ifelse([$5],[],[1],[$5]));
70  ])],
71  [AC_MSG_RESULT([yes])
72   AC_DEFINE(m4_toupper([HAVE_FUNC_ATTRIBUTE_$1]), 1,
73     [Define to 1 if your compiler supports __attribute__(($1)) on functions])],
74  [AC_MSG_RESULT([no])])
77 dnl --------------------------------------------------------------------------
78 dnl PA_FUNC_ATTRIBUTE_ERROR
79 dnl
80 dnl See if this compiler supports __attribute__((error("foo")))
81 dnl The generic version of this doesn't work as it makes the compiler
82 dnl throw an error by design.
83 dnl --------------------------------------------------------------------------
84 AC_DEFUN(PA_FUNC_ATTRIBUTE_ERROR,
85 [AC_MSG_CHECKING([if $CC supports the error function attribute])
86  AC_COMPILE_IFELSE([AC_LANG_SOURCE([
87 #include <stdarg.h>
88 extern void __attribute__((error("message"))) barf(void);
89 void foo(void)
91         if (0)
92                 barf();
94  ])],
95  [AC_MSG_RESULT([yes])
96   AC_DEFINE(m4_toupper([HAVE_FUNC_ATTRIBUTE_ERROR]), 1,
97     [Define to 1 if your compiler supports __attribute__((error)) on functions])],
98  [AC_MSG_RESULT([no])])