[go: up one dir, main page]

File: ost_cxx.m4

package info (click to toggle)
libcommoncpp2 1.0.13-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,740 kB
  • ctags: 2,860
  • sloc: cpp: 18,857; sh: 8,451; ansic: 1,546; makefile: 299; xml: 5
file content (285 lines) | stat: -rw-r--r-- 6,243 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
dnl Copyright (C) 1999-2001 Open Source Telecom Corporation.
dnl  
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2 of the License, or
dnl (at your option) any later version.
dnl 
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl GNU General Public License for more details.
dnl 
dnl You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software 
dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
dnl 
dnl As a special exception to the GNU General Public License, if you 
dnl distribute this file as part of a program that contains a configuration 
dnl script generated by Autoconf, you may include it under the same 
dnl distribution terms that you use for the rest of that program.

AC_DEFUN(OST_CXX_PROGRAMMING,[
 AC_REQUIRE([OST_PROG_CC_POSIX])
 AC_PROG_CPP
 AC_PROG_CXX
 AC_PROG_CXXCPP

  dnl
  dnl Check for common C++ portability problems
  dnl

  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS

  dnl Check whether we have bool
  AC_CACHE_CHECK(whether ${CXX} has built-in bool type,
	ac_cv_cxx_bool_type,
	AC_TRY_COMPILE(,
	     [bool b1=true; bool b2=false;],
             ac_cv_cxx_bool_type=yes,
	     ac_cv_cxx_bool_type=no
        )
  )

  if test $ac_cv_cxx_bool_type = yes ; then
	AC_DEFINE(HAVE_BOOL_TYPE)
  fi

  AC_LANG_RESTORE
])

AC_DEFUN(OST_CXX_NEW_INIT,[
 AC_REQUIRE([OST_PROG_CC_POSIX])
# AC_PROG_CPP
# AC_PROG_CXX
# AC_PROG_CXXCPP

  dnl
  dnl Check for common C++ portability problems
  dnl

  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS

  dnl Check whether we have bool
  AC_CACHE_CHECK([whether ${CXX} has new(size_t,void*)],
        ac_cv_cxx_new_init,
        AC_TRY_COMPILE([#include <new>
#include <iostream>
using namespace std;],
             [int* p1 = new int();
int* p2 = new (p1) int();
return 0;],
             ac_cv_cxx_new_init=yes,
             ac_cv_cxx_new_init=no
        )
  )

  if test $ac_cv_cxx_new_init = yes ; then
        AC_DEFINE(CCXX_HAVE_NEW_INIT)
  fi

  AC_LANG_RESTORE
])

AC_DEFUN(OST_CXX_IOSTREAM,[
  AC_REQUIRE([OST_CXX_PROGRAMMING])
  dnl
  dnl Determine kind of C++ iostream support.
  dnl

  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_CACHE_CHECK(wheather old style iostreams,
        ost_cv_cxx_iostream,
	AC_TRY_COMPILE([
#include <iostream>
using namespace std;

class mystr : public streambuf, public iostream
{
	mystr();
};

mystr::mystr() : streambuf(), iostream((streambuf *)this)
{
}
		],[return 0;],
	ost_cv_cxx_iostream=no,
	ost_cv_cxx_iostream=yes
	)
  )
  if test $ost_cv_cxx_iostream = yes ; then
	AC_DEFINE(HAVE_OLD_IOSTREAM)
  fi

  AC_LANG_RESTORE
])

AC_DEFUN(OST_CXX_NAMESPACE,[
  AC_REQUIRE([OST_CXX_PROGRAMMING])

  dnl
  dnl Determine if C++ supports namespaces.
  dnl

  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_CACHE_CHECK(whether ${CXX} supports namespace,
	ost_cv_cxx_namespace,
	AC_TRY_COMPILE([
#include <iostream>
namespace Test { using namespace std; };],[return 0;],
	ost_cv_cxx_namespace=yes,
	ost_cv_cxx_namespace=no
	)
  )

  if test "$ost_cv_cxx_namespace" = yes ; then
	AC_DEFINE(CCXX_NAMESPACES)
  fi
  AC_LANG_RESTORE
])

AC_DEFUN(OST_CXX_MUTABLE,[
  AC_REQUIRE([OST_CXX_PROGRAMMING])

  dnl
  dnl Determine if C++ supports mutable members.
  dnl

  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS

  AC_CACHE_CHECK(whether ${CXX} supports mutable,
	ost_cv_cxx_mutable,
	AC_TRY_COMPILE([
class t {mutable int i;};], [return 0;],
	ost_cv_cxx_mutable=yes,
	ost_cv_cxx_mutable=no
	)
  )

  if test $ost_cv_cxx_mutable = no ; then
	CXXFLAGS="$CXXFLAGS -Dmutable"
  fi

  AC_LANG_RESTORE
])

AC_DEFUN(OST_CXX_EXCEPTIONS,[
  AC_REQUIRE([OST_CXX_PROGRAMMING])

  dnl 
  dnl Enable C++ exception handling whenever possible.
  dnl 

  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS

  dnl strip -fno-exceptions flag if used
  optflags=$CXXFLAGS
  if test ! -z "$optflags" ; then
	CXXFLAGS=""
	for opt in $optflags ; do
 		case $opt in
		*no-rtti*)
			;;
		*omit-frame-pointer*)
			;;
		*no-exceptions*)
			;;
		*)
			CXXFLAGS="$CXXFLAGS $opt"
			;;
		esac
	done
  fi
  CXXFLAGS="$CXXFLAGS -D_GNU_SOURCE"

  dnl Check for exception handling
  AC_CACHE_CHECK(whether ${CXX} supports -fhandle-exceptions,
	ac_cv_cxx_exception_flag,
	[echo 'void f(){}' >conftest.c
	 if test -z "`${CXX} -fhandle-exceptions -c conftest.c 2>&1`"; then
		ac_cv_cxx_exception_flag=yes
		CXXFLAGS="$CXXFLAGS -fhandle-exceptions"
	 else
		ac_cv_cxx_exception_flag=no
	 fi
	 rm -f conftest*
	 ])

  if test $ac_cv_cxx_exception_flag = "yes" ; then
    ac_cv_cxx_exception_handling=yes
  else
    AC_CACHE_CHECK(whether ${CXX} supports exception handling,
	ac_cv_cxx_exception_handling,
	AC_TRY_COMPILE(
	    [void f(void) 
	     { 
		throw "abc";
	     } 
	     void g(void) 
	     { 
		try 
		{ 
		   f(); 
		} 
		catch(char*){} 
	    }
	    ],,
	    ac_cv_cxx_exception_handling=yes,
	    ac_cv_cxx_exception_handling=no
	)
    )
  fi

  if test $ac_cv_cxx_exception_handling = yes ; then
	AC_DEFINE(HAVE_EXCEPTION_HANDLING)
	AC_CHECK_HEADERS(exception)
  fi

  AC_LANG_RESTORE
])

dnl ACCONFIG TEMPLATE
dnl #undef CCXX_HAVE_NEW_INIT
dnl #undef HAVE_OLD_IOSTREAM
dnl #undef CCXX_NAMESPACES
dnl #undef HAVE_BOOL_TYPE
dnl #undef HAVE_EXCEPTION_HANDLING
dnl #undef HAVE_EXCEPTION
dnl END ACCONFIG

dnl ACCONFIG BOTTOM
dnl  
dnl // Add bool support if missing
dnl #ifndef HAVE_BOOL_TYPE
dnl typedef enum { true=1, false=0 } bool;
dnl #endif
dnl 
dnl // replace 'throw' with abort for libs on broken C++
dnl #ifndef HAVE_EXCEPTION_HANDLING
dnl /* throw - replacement to throw an exception */
dnl #define THROW(x) abort()
dnl /* throw - replacement to declare an exception */
dnl #define THROWS(x)
dnl /*
dnl  * work around dangeling if/else combinations:
dnl  */
dnl #define try if(0) ; else
dnl #define catch(x) if(1) ; else
dnl #else
dnl #define THROW(x) throw x
dnl #define THROWS(x) throw(x)
dnl #endif
dnl 
dnl #ifdef CCXX_NAMESPACES
dnl #define USING(x) using namespace x;
dnl #else
dnl #define USING(x)
dnl #endif
dnl END ACCONFIG