ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-3.0/ac-tools/AC_CXX_STD.m4
Revision: 2510
Committed: Thu Dec 15 14:47:17 2005 UTC (18 years, 7 months ago) by gezelter
File size: 6122 byte(s)
Log Message:
Adding checks for various features used by ANTLR

File Contents

# Content
1 dnl
2 dnl AC_CXX_STD
3 dnl
4 dnl Description
5 dnl
6 dnl Tests for various things that we might expect to find in
7 dnl C++ namespace std.
8 dnl
9 dnl Looks for <iostream> or else <iostream.h>.
10 dnl Looks for <iomanip> or else <iomanip.h>.
11 dnl Looks for <cmath>.
12 dnl Defines macro HAVE_FSTREAM_ATTACH if we have:
13 dnl void ofstream::attach (int FILE)
14 dnl Defines macro HAVE_FSTREAM_OPEN if we have:
15 dnl void ofstream::open (const char* FNAME, int MODE)
16 dnl Defines macro FSTREAM_OPEN_PROT if we have:
17 dnl void ofstream::open (const char* FNAME, int MODE, int PROT)
18 dnl Defines macro HAVE_STD_IOSTREAM if this works:
19 dnl #include <iostream>
20 dnl std::cout<<"Hello World"<<std::endl;
21 dnl Defines macro HAVE_STD_STL if this works:
22 dnl #include <list>
23 dnl std::list<int> foo;
24 dnl
25 dnl Copyright (C) 2003, Alex Tingle <alex.autoconf@firetree.net>
26 dnl
27 dnl License:
28 dnl GNU General Public License
29 dnl [http://www.gnu.org/software/ac-archive/htmldoc/COPYING.html]
30 dnl with this special exception
31 dnl [http://www.gnu.org/software/ac-archive/htmldoc/COPYING-Exception.html].
32 dnl
33
34 AC_DEFUN([AC_CXX_STD],[
35 AC_CXX_HAVE_IOSTREAM
36 AC_CXX_HAVE_IOMANIP
37 AC_CHECK_HEADERS([cmath])
38 AC_CXX_HAVE_STD_IOSTREAM
39 AC_CXX_HAVE_STD_STL
40 AC_CXX_HAVE_FSTREAM_ATTACH
41 AC_CXX_HAVE_FSTREAM_OPEN
42 ])
43
44
45 dnl
46 dnl AC_CXX_HAVE_IOSTREAM
47 dnl Looks for <iostream> or else <iostream.h>.
48 dnl
49
50 AC_DEFUN([AC_CXX_HAVE_IOSTREAM],[
51 AC_CHECK_HEADER([iostream],[
52 AC_DEFINE([HAVE_IOSTREAM],[1],[Define to 1 if you have the <iostream> header file.])
53 ],[
54 AC_CHECK_HEADERS([iostream.h])
55 ])
56 ])
57
58
59 dnl
60 dnl AC_CXX_HAVE_FSTREAM_ATTACH
61 dnl Defines macro HAVE_FSTREAM_ATTACH if we have:
62 dnl void ofstream::attach (int FILE)
63 dnl
64
65 AC_DEFUN([AC_CXX_HAVE_FSTREAM_ATTACH],[
66 AC_REQUIRE([AC_CXX_HAVE_STD_IOSTREAM])
67 AC_CACHE_CHECK([for fstream::attach()],[ac_cv_cxx_have_fstream_attach],[
68 ac_cv_cxx_have_fstream_attach=no
69 AC_LANG_SAVE
70 AC_LANG_CPLUSPLUS
71 AC_TRY_COMPILE([
72 #ifdef HAVE_IOSTREAM
73 #include <fstream>
74 #else
75 #include <fstream.h>
76 #endif
77 #ifdef HAVE_STD_IOSTREAM
78 using namespace std;
79 #endif
80 ],[int fd=0;ofstream s;s.attach(fd);],
81 [ac_cv_cxx_have_fstream_attach=yes])
82 AC_LANG_RESTORE
83 ])
84 if test "$ac_cv_cxx_have_fstream_attach" = yes; then
85 AC_DEFINE([HAVE_FSTREAM_ATTACH],[1],[define if we have fstream::attach().])
86 fi
87 ])
88
89
90 dnl
91 dnl AC_CXX_HAVE_FSTREAM_OPEN
92 dnl Defines macro HAVE_FSTREAM_OPEN if we have:
93 dnl void ofstream::open (const char* FNAME, int MODE)
94 dnl Defines macro FSTREAM_OPEN_PROT if we have:
95 dnl void ofstream::open (const char* FNAME, int MODE, int PROT)
96 dnl
97
98 AC_DEFUN([AC_CXX_HAVE_FSTREAM_OPEN],[
99 AC_REQUIRE([AC_CXX_HAVE_STD_IOSTREAM])
100 AC_CACHE_CHECK([for fstream::open()],[ac_cv_cxx_have_fstream_open],[
101 ac_cv_cxx_have_fstream_open=no
102 ac_cv_cxx_fstream_open_prot=no
103 AC_LANG_SAVE
104 AC_LANG_CPLUSPLUS
105 # Try with 2 parameters
106 AC_TRY_COMPILE([
107 #ifdef HAVE_IOSTREAM
108 #include <fstream>
109 #else
110 #include <fstream.h>
111 #endif
112 #ifdef HAVE_STD_IOSTREAM
113 using namespace std;
114 #endif
115 ],[ofstream s;s.open("conftest.txt",ios::out|ios::trunc);],
116 [ac_cv_cxx_have_fstream_open=yes])
117 # Try with mode parameter
118 AC_TRY_COMPILE([
119 #ifdef HAVE_IOSTREAM
120 #include <fstream>
121 #else
122 #include <fstream.h>
123 #endif
124 #ifdef HAVE_STD_IOSTREAM
125 using namespace std;
126 #endif
127 ],[ofstream s;s.open("conftest.txt",ios::out|ios::trunc,0666);],
128 [ac_cv_cxx_fstream_open_prot=yes])
129 AC_LANG_RESTORE
130 ])
131 if test "$ac_cv_cxx_have_fstream_open" = yes; then
132 AC_DEFINE([HAVE_FSTREAM_OPEN],[1],
133 [define if we have fstream::open().])
134 fi
135 if test "$ac_cv_cxx_fstream_open_prot" = yes; then
136 AC_DEFINE([FSTREAM_OPEN_PROT],[1],
137 [define if fstream::open() accepts third parameter.])
138 fi
139 ])
140
141
142 dnl
143 dnl AC_CXX_HAVE_IOMANIP
144 dnl Looks for <iomanip> or else <iomanip.h>.
145 dnl
146
147 AC_DEFUN([AC_CXX_HAVE_IOMANIP],[
148 AC_CHECK_HEADER([iomanip],[
149 AC_DEFINE([HAVE_IOMANIP],[1],[Define to 1 if you have the <iomanip> header file.])
150 ],[
151 AC_CHECK_HEADERS([iomanip.h])
152 ])
153 ])
154
155
156 dnl
157 dnl AC_CXX_HAVE_STD_IOSTREAM
158 dnl Defines macro HAVE_STD_IOSTREAM if this works:
159 dnl #include <iostream>
160 dnl std::cout<<"Hello World"<<std::endl;
161 dnl
162
163 AC_DEFUN([AC_CXX_HAVE_STD_IOSTREAM],[
164 AC_REQUIRE([AC_CXX_NAMESPACES])
165 AC_REQUIRE([AC_CXX_HAVE_IOSTREAM])
166 AC_CACHE_CHECK([for C++ iostream in namespace std],
167 ac_cv_cxx_have_std_iostream,[
168 ac_cv_cxx_have_std_iostream=no
169 ac_cv_cxx_need_use_std_iostream=no
170 if test "x$ac_cv_cxx_namespaces" = xyes; then
171 AC_LANG_SAVE
172 AC_LANG_CPLUSPLUS
173 AC_TRY_COMPILE([
174 #ifdef HAVE_IOSTREAM
175 #include <iostream>
176 #else
177 #include <iostream.h>
178 #endif
179 ],[std::cout<<"Hello World"<<std::endl;return 0;],
180 [ac_cv_cxx_have_std_iostream=yes])
181 AC_TRY_COMPILE([
182 #define __USE_STD_IOSTREAM 1
183 #ifdef HAVE_IOSTREAM
184 #include <iostream>
185 #else
186 #include <iostream.h>
187 #endif
188 ],[std::cout<<"Hello World"<<std::endl;return 0;],
189 [ac_cv_cxx_have_std_iostream=yes;ac_cv_cxx_need_use_std_iostream=yes])
190 AC_LANG_RESTORE
191 fi
192 ])
193 if test "$ac_cv_cxx_have_std_iostream" = yes; then
194 AC_DEFINE([HAVE_STD_IOSTREAM],[1],[define if C++ iostream is in namespace std.])
195 fi
196 if test "$ac_cv_cxx_need_use_std_iostream" = yes; then
197 AC_DEFINE([__USE_STD_IOSTREAM],[1],[needed by DEC/Compaq/HP cxx to activate ANSI standard iostream.])
198 fi
199 ])
200
201
202 dnl
203 dnl AC_CXX_HAVE_STD_STL
204 dnl Defines macro HAVE_STD_STL if this works:
205 dnl #include <list>
206 dnl std::list<int> foo;
207 dnl
208
209 AC_DEFUN([AC_CXX_HAVE_STD_STL],[
210 AC_REQUIRE([AC_CXX_NAMESPACES])
211 AC_REQUIRE([AC_CXX_HAVE_STL])
212 AC_CACHE_CHECK([for C++ Standard Template Library in namespace std.],
213 ac_cv_cxx_have_std_stl,[
214 ac_cv_cxx_have_std_stl=no
215 if test "x$ac_cv_cxx_namespaces" = xyes; then
216 AC_LANG_SAVE
217 AC_LANG_CPLUSPLUS
218 AC_TRY_COMPILE([#include <list>
219 ],[std::list<int> foo;return 0;],
220 [ac_cv_cxx_have_std_stl=yes])
221 AC_LANG_RESTORE
222 fi
223 ])
224 if test "$ac_cv_cxx_have_std_stl" = yes; then
225 AC_DEFINE([HAVE_STD_STL],[1],[define if C++ Standard Template Library is in namespace std])
226 fi
227 ])
228