TIVI-153: Add as dependency for iputils
[profile/ivi/opensp.git] / acinclude.m4
1 dnl OJ_CHECK_SIZEOF(TYPE, HEADER [, CROSS-SIZE])
2 AC_DEFUN([OJ_CHECK_SIZEOF],
3 [changequote(<<, >>)dnl
4 dnl The name to #define.
5 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
6 dnl The cache variable name.
7 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
8 changequote([, ])dnl
9 AC_MSG_CHECKING(size of $1)
10 AC_CACHE_VAL(AC_CV_NAME,
11 [AC_TRY_RUN([#include <stdio.h>
12 #include <$2>
13 main()
14 {
15   FILE *f=fopen("conftestval", "w");
16   if (!f) exit(1);
17   fprintf(f, "%d\n", sizeof($1));
18   exit(0);
19 }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$3] , , AC_CV_NAME=$3))])dnl
20 AC_MSG_RESULT($AC_CV_NAME)
21 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME)
22 undefine([AC_TYPE_NAME])dnl
23 undefine([AC_CV_NAME])dnl
24 ])
25
26
27 dnl @synopsis AC_CXX_PLACEMENT_OPERATOR_DELETE
28 dnl
29 dnl If the compiler supports void delete(size_t,void*), define
30 dnl HAVE_PLACEMENT_OPERATOR_DELETE.
31 dnl
32 dnl @author Matthias Clasen
33 dnl
34 AC_DEFUN([AC_CXX_PLACEMENT_OPERATOR_DELETE],
35 [AC_CACHE_CHECK(whether the compiler supports placement operator delete,
36 ac_cv_cxx_placement_operator_delete,
37 [AC_LANG_SAVE
38  AC_LANG_CPLUSPLUS
39  AC_TRY_COMPILE([#include <stddef.h>],
40   [class Thing {
41    public:
42     Thing() { };
43     void *operator new(size_t,bool) { };
44     void operator delete(size_t,void*) { };
45    };],
46    ac_cv_cxx_placement_operator_delete=yes, 
47    ac_cv_cxx_placement_operator_delete=no)
48  AC_LANG_RESTORE
49 ])
50 if test "$ac_cv_cxx_placement_operator_delete" = yes; then
51   AC_DEFINE(HAVE_PLACEMENT_OPERATOR_DELETE,,
52             [define if the compiler supports placement operator delete])
53 fi
54 ])
55
56
57 dnl @synopsis AC_CXX_BOOL
58 dnl
59 dnl If the compiler recognizes bool as a separate built-in type,
60 dnl define HAVE_BOOL. Note that a typedef is not a separate
61 dnl type since you cannot overload a function such that it accepts either
62 dnl the basic type or the typedef.
63 dnl
64 dnl @version $Id: acinclude.m4,v 1.9.2.1 2004/06/30 13:16:25 keichwa Exp $
65 dnl @author Luc Maisonobe
66 dnl
67 AC_DEFUN([AC_CXX_BOOL],
68 [AC_CACHE_CHECK(whether the compiler recognizes bool as a built-in type,
69 ac_cv_cxx_bool,
70 [AC_LANG_SAVE
71  AC_LANG_CPLUSPLUS
72  AC_TRY_COMPILE([
73 int f(int  x){return 1;}
74 int f(char x){return 1;}
75 int f(bool x){return 1;}
76 ],[bool b = true; return f(b);],
77  ac_cv_cxx_bool=yes, ac_cv_cxx_bool=no)
78  AC_LANG_RESTORE
79 ])
80 if test "$ac_cv_cxx_bool" = yes; then
81   AC_DEFINE(HAVE_BOOL,,[define if bool is a built-in type])
82 fi
83 ])
84
85 dnl @synopsis AC_CXX_TYPENAME
86 dnl
87 dnl If the compiler recognizes the typename keyword, define HAVE_TYPENAME.
88 dnl
89 dnl @version $Id: acinclude.m4,v 1.9.2.1 2004/06/30 13:16:25 keichwa Exp $
90 dnl @author Luc Maisonobe
91 dnl
92 AC_DEFUN([AC_CXX_TYPENAME],
93 [AC_CACHE_CHECK(whether the compiler recognizes typename,
94 ac_cv_cxx_typename,
95 [AC_LANG_SAVE
96  AC_LANG_CPLUSPLUS
97  AC_TRY_COMPILE([template<typename T>class X {public:X(){}};],
98 [X<float> z; return 0;],
99  ac_cv_cxx_typename=yes, ac_cv_cxx_typename=no)
100  AC_LANG_RESTORE
101 ])
102 if test "$ac_cv_cxx_typename" = yes; then
103   AC_DEFINE(HAVE_TYPENAME,,[define if the compiler recognizes typename])
104 fi
105 ])
106
107 dnl @synopsis AC_CXX_NEW_FOR_SCOPING
108 dnl
109 dnl If the compiler accepts the new for scoping rules (the scope of a
110 dnl variable declared inside the parentheses is restricted to the
111 dnl for-body), define HAVE_NEW_FOR_SCOPING.
112 dnl
113 dnl @version $Id: acinclude.m4,v 1.9.2.1 2004/06/30 13:16:25 keichwa Exp $
114 dnl @author Luc Maisonobe
115 dnl
116 AC_DEFUN([AC_CXX_NEW_FOR_SCOPING],
117 [AC_CACHE_CHECK(whether the compiler accepts the new for scoping rules,
118 ac_cv_cxx_new_for_scoping,
119 [AC_LANG_SAVE
120  AC_LANG_CPLUSPLUS
121  AC_TRY_COMPILE(,[
122   int z = 0;
123   for (int i = 0; i < 10; ++i)
124     z = z + i;
125   for (int i = 0; i < 10; ++i)
126     z = z - i;
127   return z;],
128  ac_cv_cxx_new_for_scoping=yes, ac_cv_cxx_new_for_scoping=no)
129  AC_LANG_RESTORE
130 ])
131 if test "$ac_cv_cxx_new_for_scoping" = yes; then
132   AC_DEFINE(HAVE_NEW_FOR_SCOPING,,[define if the compiler accepts the new for scoping rules])
133 fi
134 ])
135
136
137 dnl @synopsis AC_CXX_DYNAMIC_CAST
138 dnl
139 dnl If the compiler supports dynamic_cast<>, define HAVE_DYNAMIC_CAST.
140 dnl
141 dnl @version $Id: acinclude.m4,v 1.9.2.1 2004/06/30 13:16:25 keichwa Exp $
142 dnl @author Luc Maisonobe
143 dnl
144 AC_DEFUN([AC_CXX_DYNAMIC_CAST],
145 [AC_CACHE_CHECK(whether the compiler supports dynamic_cast<>,
146 ac_cv_cxx_dynamic_cast,
147 [AC_LANG_SAVE
148  AC_LANG_CPLUSPLUS
149  AC_TRY_COMPILE([#include <typeinfo>
150 class Base { public : Base () {} virtual void f () = 0;};
151 class Derived : public Base { public : Derived () {} virtual void f () {} };],[
152 Derived d; Base& b=d; return dynamic_cast<Derived*>(&b) ? 0 : 1;],
153  ac_cv_cxx_dynamic_cast=yes, ac_cv_cxx_dynamic_cast=no)
154  AC_LANG_RESTORE
155 ])
156 if test "$ac_cv_cxx_dynamic_cast" = yes; then
157   AC_DEFINE(HAVE_DYNAMIC_CAST,,[define if the compiler supports dynamic_cast<>])
158 fi
159 ])
160
161
162 dnl @synopsis AC_CXX_NAMESPACES
163 dnl
164 dnl If the compiler can prevent names clashes using namespaces, define
165 dnl HAVE_NAMESPACES.
166 dnl
167 dnl @version $Id: acinclude.m4,v 1.9.2.1 2004/06/30 13:16:25 keichwa Exp $
168 dnl @author Luc Maisonobe
169 dnl
170 AC_DEFUN([AC_CXX_NAMESPACES],
171 [AC_CACHE_CHECK(whether the compiler implements namespaces,
172 ac_cv_cxx_namespaces,
173 [AC_LANG_SAVE
174  AC_LANG_CPLUSPLUS
175  AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
176                 [using namespace Outer::Inner; return i;],
177  ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
178  AC_LANG_RESTORE
179 ])
180 if test "$ac_cv_cxx_namespaces" = yes; then
181   AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
182 fi
183 ])
184
185
186 dnl @synopsis ACX_CHECK_PATHNAME_STYLE_DOS
187 dnl
188 dnl Check if host OS uses DOS-style pathnames. This includes the use
189 dnl of drive letters and backslashes. Under DOS, Windows, and OS/2,
190 dnl defines HAVE_PATHNAME_STYLE_DOS and PATH_SEPARATOR to ';'.
191 dnl Otherwise, defines PATH_SEPARATOR to ':'.
192 dnl
193 dnl Use for enabling code to handle drive letters, backslashes in
194 dnl filenames and semicolons in the PATH.
195 dnl
196 dnl @version $Id: acinclude.m4,v 1.9.2.1 2004/06/30 13:16:25 keichwa Exp $
197 dnl @author Mark Elbrecht <snowball3@bigfoot.com>
198 dnl
199 AC_DEFUN([ACX_CHECK_PATHNAME_STYLE_DOS],
200 [AC_MSG_CHECKING(for Windows and DOS and OS/2 style pathnames)
201 AC_CACHE_VAL(acx_cv_pathname_style_dos,
202 [AC_REQUIRE([AC_CANONICAL_HOST])
203
204 acx_cv_pathname_style_dos="no"
205 case ${host_os} in
206   *djgpp | *mingw32 | *emx*) acx_cv_pathname_style_dos="yes" ;;
207 esac
208 ])
209 AC_MSG_RESULT($acx_cv_pathname_style_dos)
210 if test $acx_cv_pathname_style_dos = "yes"; then
211   AC_DEFINE(HAVE_PATHNAME_STYLE_DOS)
212   AC_DEFINE(PATH_SEPARATOR, ';')
213 else
214   AC_DEFINE(PATH_SEPARATOR, ':')
215 fi
216 ])
217
218
219 dnl @synopsis AC_CXX_EXPLICIT_INSTANTIATIONS
220 dnl
221 dnl If the C++ compiler supports explicit instanciations syntax,
222 dnl define HAVE_INSTANTIATIONS.
223 dnl
224 dnl @version $Id: acinclude.m4,v 1.9.2.1 2004/06/30 13:16:25 keichwa Exp $
225 dnl @author Luc Maisonobe
226 dnl
227 AC_DEFUN([AC_CXX_EXPLICIT_INSTANTIATIONS],
228 [AC_CACHE_CHECK(whether the compiler supports explicit instantiations,
229 ac_cv_cxx_explinst,
230 [AC_LANG_SAVE
231  AC_LANG_CPLUSPLUS
232  AC_TRY_COMPILE([template <class T> class A { T t; }; template class A<int>;],
233  [], ac_cv_cxx_explinst=yes, ac_cv_cxx_explinst=no)
234  AC_LANG_RESTORE
235 ])
236 if test "$ac_cv_cxx_explinst" = yes; then
237   AC_DEFINE(HAVE_INSTANTIATIONS,,
238             [define if the compiler supports explicit instantiations])
239 fi
240 ])
241
242 AC_DEFUN([AC_DEFINE_DIR], [ 
243   ac_expanded=`( 
244     test "x$prefix" = xNONE && prefix="$ac_default_prefix" 
245     test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" 
246     eval echo \""[$]$2"\" 
247   )` 
248   ifelse($3, , 
249     AC_DEFINE_UNQUOTED($1, "$ac_expanded"), 
250     AC_DEFINE_UNQUOTED($1, "$ac_expanded", $3)) 
251 ]) 
252
253 dnl @synopsis AC_CXX_MUTABLE
254 dnl
255 dnl If the compiler allows modifying class data members flagged with
256 dnl the mutable keyword even in const objects (for example in the
257 dnl body of a const member function), define HAVE_MUTABLE.
258 dnl
259 dnl @version $Id: acinclude.m4,v 1.9.2.1 2004/06/30 13:16:25 keichwa Exp $
260 dnl @author Luc Maisonobe
261 dnl
262 AC_DEFUN([AC_CXX_MUTABLE],
263 [AC_CACHE_CHECK(whether the compiler supports the mutable keyword,
264 ac_cv_cxx_mutable,
265 [AC_LANG_SAVE
266  AC_LANG_CPLUSPLUS
267  AC_TRY_COMPILE([
268 class A { mutable int i;
269           public:
270           int f (int n) const { i = n; return i; }
271         };
272 ],[A a; return a.f (1);],
273  ac_cv_cxx_mutable=yes, ac_cv_cxx_mutable=no)
274  AC_LANG_RESTORE
275 ])
276 if test "$ac_cv_cxx_mutable" = yes; then
277   AC_DEFINE(HAVE_MUTABLE,,[define if the compiler supports the mutable keyword])
278 fi
279 ])