Makefile: don't store dependency information in git
[nasm.git] / aclocal.m4
bloba5263cffe6ef2bdb09d3419208ce63ef8162c721
1 dnl --------------------------------------------------------------------------
2 dnl PA_SYM(prefix, string)
3 dnl
4 dnl Convert a (semi-) arbitrary string to a CPP symbol
5 dnl --------------------------------------------------------------------------
6 AC_DEFUN(PA_SYM,
7 [[$1]m4_bpatsubsts(m4_toupper([$2]),[[^ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]+],[_],[^._?\(.*\)_.$],[[\1]])])
9 dnl --------------------------------------------------------------------------
10 dnl PA_ADD_CFLAGS(flag [,actual_flag])
11 dnl
12 dnl Attempt to add the given option to CFLAGS, if it doesn't break
13 dnl compilation.  If the option to be tested is different than the
14 dnl option that should actually be added, add the option to be
15 dnl actually added as a second argument.
16 dnl --------------------------------------------------------------------------
17 AC_DEFUN(PA_ADD_CFLAGS,
18 [AC_MSG_CHECKING([if $CC accepts $1])
19  pa_add_cflags__old_cflags="$CFLAGS"
20  CFLAGS="$CFLAGS $1"
21  AC_TRY_LINK(AC_INCLUDES_DEFAULT,
22  [printf("Hello, World!\n");],
23  [AC_MSG_RESULT([yes])
24   CFLAGS="$pa_add_cflags__old_cflags ifelse([$2],[],[$1],[$2])"
25   AC_DEFINE(PA_SYM([CFLAG_],[$1]), 1,
26    [Define to 1 if compiled with the `$1' compiler flag])],
27  [AC_MSG_RESULT([no])
28   CFLAGS="$pa_add_cflags__old_cflags"])])
30 dnl --------------------------------------------------------------------------
31 dnl PA_ADD_CLDFLAGS(flag [,actual_flag])
32 dnl
33 dnl Attempt to add the given option to CFLAGS and LDFLAGS,
34 dnl if it doesn't break compilation
35 dnl --------------------------------------------------------------------------
36 AC_DEFUN(PA_ADD_CLDFLAGS,
37 [AC_MSG_CHECKING([if $CC accepts $1])
38  pa_add_cldflags__old_cflags="$CFLAGS"
39  CFLAGS="$CFLAGS $1"
40  pa_add_cldflags__old_ldflags="$LDFLAGS"
41  LDFLAGS="$LDFLAGS $1"
42  AC_TRY_LINK(AC_INCLUDES_DEFAULT,
43  [printf("Hello, World!\n");],
44  [AC_MSG_RESULT([yes])
45   CFLAGS="$pa_add_cldflags__old_cflags ifelse([$2],[],[$1],[$2])"
46   LDFLAGS="$pa_add_cldflags__old_ldflags ifelse([$2],[],[$1],[$2])"
47   AC_DEFINE(PA_SYM([CFLAG_],[$1]), 1,
48    [Define to 1 if compiled with the `$1' compiler flag])],
49  [AC_MSG_RESULT([no])
50   CFLAGS="$pa_add_cldflags__old_cflags"
51   LDFLAGS="$pa_add_cldflags__old_ldflags"])])
53 dnl --------------------------------------------------------------------------
54 dnl PA_HAVE_FUNC(func_name)
55 dnl
56 dnl Look for a function with the specified arguments which could be
57 dnl a builtin/intrinsic function.
58 dnl --------------------------------------------------------------------------
59 AC_DEFUN(PA_HAVE_FUNC,
60 [AC_MSG_CHECKING([for $1])
61 AC_TRY_LINK([], [(void)$1$2;],
62 AC_MSG_RESULT([yes])
63 AC_DEFINE(AS_TR_CPP([HAVE_$1]), 1,
64   [Define to 1 if you have the `$1' intrinsic function.]),
65 AC_MSG_RESULT([no]))])
67 dnl --------------------------------------------------------------------------
68 dnl PA_LIBEXT
69 dnl
70 dnl Guess the library extension based on the object extension
71 dnl --------------------------------------------------------------------------
72 AC_DEFUN(PA_LIBEXT,
73 [AC_MSG_CHECKING([for suffix of library files])
74 if test x"$LIBEXT" = x; then
75   case "$OBJEXT" in
76     obj )
77       LIBEXT=lib
78       ;;
79     *)
80       LIBEXT=a
81       ;;
82   esac
84 AC_MSG_RESULT([$LIBEXT])
85 AC_SUBST([LIBEXT])])
87 dnl --------------------------------------------------------------------------
88 dnl PA_FUNC_ATTRIBUTE(attribute_name)
89 dnl
90 dnl See if this compiler supports the equivalent of a specific gcc
91 dnl attribute on a function, using the __attribute__(()) syntax.
92 dnl All arguments except the attribute name are optional.
93 dnl PA_FUNC_ATTRIBUTE(attribute, attribute_opts, return_type,
94 dnl                   prototype_args, call_args)
95 dnl --------------------------------------------------------------------------
96 AC_DEFUN(PA_FUNC_ATTRIBUTE,
97 [AC_MSG_CHECKING([if $CC supports the $1 function attribute])
98  AC_COMPILE_IFELSE([AC_LANG_SOURCE([
99 AC_INCLUDES_DEFAULT
100 extern ifelse([$3],[],[void *],[$3])  __attribute__(($1$2))
101   bar(ifelse([$4],[],[int],[$4]));
102 void *foo(void);
103 void *foo(void)
105         return bar(ifelse([$5],[],[1],[$5]));
107  ])],
108  [AC_MSG_RESULT([yes])
109   AC_DEFINE(PA_SYM([HAVE_FUNC_ATTRIBUTE_],[$1]), 1,
110     [Define to 1 if your compiler supports __attribute__(($1)) on functions])],
111  [AC_MSG_RESULT([no])])
114 dnl --------------------------------------------------------------------------
115 dnl PA_FUNC_ATTRIBUTE_ERROR
117 dnl See if this compiler supports __attribute__((error("foo")))
118 dnl The generic version of this doesn't work as it makes the compiler
119 dnl throw an error by design.
120 dnl --------------------------------------------------------------------------
121 AC_DEFUN(PA_FUNC_ATTRIBUTE_ERROR,
122 [AC_MSG_CHECKING([if $CC supports the error function attribute])
123  AC_COMPILE_IFELSE([AC_LANG_SOURCE([
124 AC_INCLUDES_DEFAULT
125 extern void __attribute__((error("message"))) barf(void);
126 void foo(void);
127 void foo(void)
129         if (0)
130                 barf();
132  ])],
133  [AC_MSG_RESULT([yes])
134   AC_DEFINE([HAVE_FUNC_ATTRIBUTE_ERROR], 1,
135     [Define to 1 if your compiler supports __attribute__((error)) on functions])],
136  [AC_MSG_RESULT([no])])
139 dnl --------------------------------------------------------------------------
140 dnl PA_ARG_ENABLED(option, helptext [,enabled_action [,disabled_action]])
141 dnl PA_ARG_DISABLED(option, helptext [,disabled_action [,enabled_action]])
143 dnl  Simpler-to-use versions of AC_ARG_ENABLED, that include the
144 dnl  test for $enableval and the AS_HELP_STRING definition
145 dnl --------------------------------------------------------------------------
146 AC_DEFUN(PA_ARG_ENABLED,
147 [AC_ARG_ENABLE([$1], [AS_HELP_STRING([--enable-$1],[$2])], [], [enableval=no])
148  AS_IF([test x"$enableval" != xno], [$3], [$4])
151 AC_DEFUN(PA_ARG_DISABLED,
152 [AC_ARG_ENABLE([$1],[AS_HELP_STRING([--disable-$1],[$2])], [], [enableval=yes])
153  AS_IF([test x"$enableval" = xno], [$3], [$4])
156 dnl --------------------------------------------------------------------------
157 dnl PA_ADD_HEADERS(headers...)
159 dnl Call AC_CHECK_HEADERS(), and add to ac_includes_default if found
160 dnl --------------------------------------------------------------------------
161 AC_DEFUN(_PA_ADD_HEADER,
162 [AC_CHECK_HEADERS([$1],[ac_includes_default="$ac_includes_default
163 #include <$1>"
164 ])])
166 AC_DEFUN(PA_ADD_HEADERS,
167 [m4_map_args_w([$1],[_PA_ADD_HEADER(],[)])])