/[svn]/vendor/pxys2-2.0.0/libopas/acinclude.m4
ViewVC logotype

Contents of /vendor/pxys2-2.0.0/libopas/acinclude.m4

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3252 - (show annotations)
Wed Apr 2 20:41:43 2014 UTC (7 years, 1 month ago) by michael
File size: 14747 byte(s)
- Imported pxys2-2.0.0

1 dnl AC_COMPILE_CHECK_SIZEOF
2 dnl Written by Kaveh Ghazi <ghazi@caip.rutgers.edu>
3 dnl
4 AC_DEFUN([AC_COMPILE_CHECK_SIZEOF],
5 [changequote(<<, >>)dnl
6 dnl The name to #define.
7 define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl
8 dnl The cache variable name.
9 define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl
10 changequote([, ])dnl
11 AC_MSG_CHECKING(size of $1)
12 AC_CACHE_VAL(AC_CV_NAME,
13 [for ac_size in 4 8 1 2 16 $2 ; do # List sizes in rough order of prevalence.
14 AC_TRY_COMPILE([#include "confdefs.h"
15 #include <sys/types.h>
16 $2
17 ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size)
18 if test x$AC_CV_NAME != x ; then break; fi
19 done
20 ])
21 if test x$AC_CV_NAME = x ; then
22 AC_MSG_ERROR([cannot determine a size for $1])
23 fi
24 AC_MSG_RESULT($AC_CV_NAME)
25 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1])
26 undefine([AC_TYPE_NAME])dnl
27 undefine([AC_CV_NAME])dnl
28 ])
29
30 dnl Written by Guido Draheim <guidod@gmx.de>
31 dnl
32 AC_DEFUN([AC_CREATE_STDINT_H],
33 [# ------ AC CREATE STDINT H -------------------------------------
34 AC_MSG_CHECKING([for stdint-types....])
35 ac_stdint_h=`echo ifelse($1, , _stdint.h, $1)`
36 if test "$ac_stdint_h" = "stdint.h" ; then
37 AC_MSG_RESULT("(are you sure you want them in ./stdint.h?)")
38 elif test "$ac_stdint_h" = "inttypes.h" ; then
39 AC_MSG_RESULT("(are you sure you want them in ./inttypes.h?)")
40 else
41 AC_MSG_RESULT("(putting them into $ac_stdint_h)")
42 fi
43
44 inttype_headers=`echo inttypes.h sys/inttypes.h sys/inttypes.h $2 \
45 | sed -e 's/,/ /g'`
46
47 ac_cv_header_stdint_x="no-file"
48 ac_cv_header_stdint_o="no-file"
49 ac_cv_header_stdint_u="no-file"
50 for i in stdint.h $inttype_headers ; do
51 unset ac_cv_type_uintptr_t
52 unset ac_cv_type_uint64_t
53 _AC_CHECK_TYPE_NEW(uintptr_t,[ac_cv_header_stdint_x=$i],dnl
54 continue,[#include <$i>])
55 AC_CHECK_TYPE(uint64_t,[and64="(uint64_t too)"],[and64=""],[#include<$i>])
56 AC_MSG_RESULT(... seen our uintptr_t in $i $and64)
57 break;
58 done
59 if test "$ac_cv_header_stdint_x" = "no-file" ; then
60 for i in stdint.h $inttype_headers ; do
61 unset ac_cv_type_uint32_t
62 unset ac_cv_type_uint64_t
63 AC_CHECK_TYPE(uint32_t,[ac_cv_header_stdint_o=$i],dnl
64 continue,[#include <$i>])
65 AC_CHECK_TYPE(uint64_t,[and64="(uint64_t too)"],[and64=""],[#include<$i>])
66 AC_MSG_RESULT(... seen our uint32_t in $i $and64)
67 break;
68 done
69 if test "$ac_cv_header_stdint_o" = "no-file" ; then
70 for i in sys/types.h $inttype_headers ; do
71 unset ac_cv_type_u_int32_t
72 unset ac_cv_type_u_int64_t
73 AC_CHECK_TYPE(u_int32_t,[ac_cv_header_stdint_u=$i],dnl
74 continue,[#include <$i>])
75 AC_CHECK_TYPE(uint64_t,[and64="(u_int64_t too)"],[and64=""],[#include<$i>])
76 AC_MSG_RESULT(... seen our u_int32_t in $i $and64)
77 break;
78 done
79 fi
80 fi
81
82 # ----------------- DONE inttypes.h checks MAYBE C basic types --------
83
84 if test "$ac_cv_header_stdint_x" = "no-file" ; then
85 AC_COMPILE_CHECK_SIZEOF(char)
86 AC_COMPILE_CHECK_SIZEOF(short)
87 AC_COMPILE_CHECK_SIZEOF(int)
88 AC_COMPILE_CHECK_SIZEOF(long)
89 AC_COMPILE_CHECK_SIZEOF(void*)
90 ac_cv_header_stdint_test="yes"
91 else
92 ac_cv_header_stdint_test="no"
93 fi
94
95 # ----------------- DONE inttypes.h checks START header -------------
96 _ac_stdint_h=AS_TR_CPP(_$ac_stdint_h)
97 AC_MSG_RESULT(creating $ac_stdint_h : $_ac_stdint_h)
98 echo "#ifndef" $_ac_stdint_h >$ac_stdint_h
99 echo "#define" $_ac_stdint_h "1" >>$ac_stdint_h
100 echo "#ifndef" _GENERATED_STDINT_H >>$ac_stdint_h
101 echo "#define" _GENERATED_STDINT_H '"'$PACKAGE $VERSION'"' >>$ac_stdint_h
102 if test "$GCC" = "yes" ; then
103 echo "/* generated using a gnu compiler version" `$CC --version` "*/" \
104 >>$ac_stdint_h
105 else
106 echo "/* generated using $CC */" >>$ac_stdint_h
107 fi
108 echo "" >>$ac_stdint_h
109
110 if test "$ac_cv_header_stdint_x" != "no-file" ; then
111 ac_cv_header_stdint="$ac_cv_header_stdint_x"
112 elif test "$ac_cv_header_stdint_o" != "no-file" ; then
113 ac_cv_header_stdint="$ac_cv_header_stdint_o"
114 elif test "$ac_cv_header_stdint_u" != "no-file" ; then
115 ac_cv_header_stdint="$ac_cv_header_stdint_u"
116 else
117 ac_cv_header_stdint="stddef.h"
118 fi
119
120 # ----------------- See if int_least and int_fast types are present
121 unset ac_cv_type_int_least32_t
122 unset ac_cv_type_int_fast32_t
123 AC_CHECK_TYPE(int_least32_t,,,[#include <$ac_cv_header_stdint>])
124 AC_CHECK_TYPE(int_fast32_t,,,[#include<$ac_cv_header_stdint>])
125
126 if test "$ac_cv_header_stdint" != "stddef.h" ; then
127 if test "$ac_cv_header_stdint" != "stdint.h" ; then
128 AC_MSG_RESULT(..adding include stddef.h)
129 echo "#include <stddef.h>" >>$ac_stdint_h
130 fi ; fi
131 AC_MSG_RESULT(..adding include $ac_cv_header_stdint)
132 echo "#include <$ac_cv_header_stdint>" >>$ac_stdint_h
133 echo "" >>$ac_stdint_h
134
135 # ----------------- DONE header START basic int types -------------
136 if test "$ac_cv_header_stdint_x" = "no-file" ; then
137 AC_MSG_RESULT(... need to look at C basic types)
138 dnl ac_cv_header_stdint_test="yes" # moved up before creating the file
139 else
140 AC_MSG_RESULT(... seen good stdint.h inttypes)
141 dnl ac_cv_header_stdint_test="no" # moved up before creating the file
142 fi
143
144 if test "$ac_cv_header_stdint_u" != "no-file" ; then
145 AC_MSG_RESULT(... seen bsd/sysv typedefs)
146 cat >>$ac_stdint_h <<EOF
147
148 /* int8_t int16_t int32_t defined by inet code, redeclare the u_intXX types */
149 typedef u_int8_t uint8_t;
150 typedef u_int16_t uint16_t;
151 typedef u_int32_t uint32_t;
152 EOF
153 cat >>$ac_stdint_h <<EOF
154
155 /* glibc compatibility */
156 #ifndef __int8_t_defined
157 #define __int8_t_defined
158 #endif
159 EOF
160 fi
161
162 ac_cv_sizeof_x="$ac_cv_sizeof_char:$ac_cv_sizeof_short"
163 ac_cv_sizeof_X="$ac_cv_sizeof_x:$ac_cv_sizeof_int"
164 ac_cv_sizeof_X="$ac_cv_sizeof_X:$ac_cv_sizeof_voidp:$ac_cv_sizeof_long"
165 if test "$ac_cv_header_stdint" = "stddef.h" ; then
166 # we must guess all the basic types. Apart from byte-adressable system,
167 # there a few 32-bit-only dsp-systems. nibble-addressable systems are way off.
168 cat >>$ac_stdint_h <<EOF
169 /* ------------ BITSPECIFIC INTTYPES SECTION --------------- */
170 EOF
171 t="typedefs for a"
172 case "$ac_cv_sizeof_X" in
173 1:2:2:2:4) AC_MSG_RESULT(..adding $t normal 16-bit system)
174 cat >>$ac_stdint_h <<EOF
175 /* a normal 16-bit system */
176 typedef unsigned char uint8_t;
177 typedef unsigned short uint16_t;
178 typedef unsigned long uint32_t;
179 #ifndef __int8_t_defined
180 #define __int8_t_defined
181 typedef char int8_t;
182 typedef short int16_t;
183 typedef long int32_t;
184 #endif
185 EOF
186 ;;
187 1:2:2:4:4) AC_MSG_RESULT(..adding $t 32-bit system derived from a 16-bit)
188 cat >>$ac_stdint_h <<EOF
189 /* a 32-bit system derived from a 16-bit */
190 typedef unsigned char uint8_t;
191 typedef unsigned short uint16_t;
192 typedef unsigned int uint32_t;
193 #ifndef __int8_t_defined
194 #define __int8_t_defined
195 typedef char int8_t;
196 typedef short int16_t;
197 typedef int int32_t;
198 #endif
199 EOF
200 ;;
201 1:2:4:4:4) AC_MSG_RESULT(..adding $t normal 32-bit system)
202 cat >>$ac_stdint_h <<EOF
203 /* a normal 32-bit system */
204 typedef unsigned char uint8_t;
205 typedef unsigned short uint16_t;
206 typedef unsigned int uint32_t;
207 #ifndef __int8_t_defined
208 #define __int8_t_defined
209 typedef char int8_t;
210 typedef short int16_t;
211 typedef int int32_t;
212 #endif
213 EOF
214 ;;
215 1:2:4:4:8) AC_MSG_RESULT(..adding $t 32-bit system prepared for 64-bit)
216 cat >>$ac_stdint_h <<EOF
217
218 /* a 32-bit system prepared for 64-bit */
219 typedef unsigned char uint8_t;
220 typedef unsigned short uint16_t;
221 typedef unsigned int uint32_t;
222 #ifndef __int8_t_defined
223 #define __int8_t_defined
224 typedef char int8_t;
225 typedef short int16_t;
226 typedef int int32_t;
227 #endif
228 EOF
229 ;;
230 1:2:4:8:8) AC_MSG_RESULT(..adding $t normal 64-bit system)
231 cat >>$ac_stdint_h <<EOF
232
233 /* a normal 64-bit system */
234 typedef unsigned char uint8_t;
235 typedef unsigned short uint16_t;
236 typedef unsigned int uint32_t;
237 #ifndef __int8_t_defined
238 #define __int8_t_defined
239 typedef char int8_t;
240 typedef short int16_t;
241 typedef int int32_t;
242 #endif
243 EOF
244 ;;
245 1:2:4:8:4) AC_MSG_RESULT(..adding $t 64-bit system derived from a 32-bit)
246 cat >>$ac_stdint_h <<EOF
247
248 /* a 64-bit system derived from a 32-bit system */
249 typedef unsigned char uint8_t;
250 typedef unsigned short uint16_t;
251 typedef unsigned int uint32_t;
252 #ifndef __int8_t_defined
253 #define __int8_t_defined
254 typedef char int8_t;
255 typedef short int16_t;
256 typedef int int32_t;
257 #endif
258 EOF
259 ;;
260 *)
261 AC_MSG_ERROR([ $ac_cv_sizeof_X dnl
262 what is that a system? contact the author, quick! http://ac-archive.sf.net])
263 exit 1
264 ;;
265 esac
266 fi
267
268 # ------------- DONE basic int types START int64_t types ------------
269 if test "$ac_cv_type_uint64_t" = "yes"
270 then AC_MSG_RESULT(... seen good uint64_t)
271 cat >>$ac_stdint_h <<EOF
272
273 /* system headers have good uint64_t */
274 #ifndef _HAVE_UINT64_T
275 #define _HAVE_UINT64_T
276 #endif
277 EOF
278
279 elif test "$ac_cv_type_u_int64_t" = "yes"
280 then AC_MSG_RESULT(..adding typedef u_int64_t uint64_t)
281 cat >>$ac_stdint_h <<EOF
282
283 /* system headers have an u_int64_t */
284 #ifndef _HAVE_UINT64_T
285 #define _HAVE_UINT64_T
286 typedef u_int64_t uint64_t;
287 #endif
288 EOF
289 else AC_MSG_RESULT(..adding generic uint64_t runtime checks)
290 cat >>$ac_stdint_h <<EOF
291
292 /* -------------------- 64 BIT GENERIC SECTION -------------------- */
293 /* here are some common heuristics using compiler runtime specifics */
294 #if defined __STDC_VERSION__ && defined __STDC_VERSION__ > 199901L
295
296 #ifndef _HAVE_UINT64_T
297 #define _HAVE_UINT64_T
298 typedef long long int64_t;
299 typedef unsigned long long uint64_t;
300 #endif
301
302 #elif !defined __STRICT_ANSI__
303 #if defined _MSC_VER || defined __WATCOMC__ || defined __BORLANDC__
304
305 #ifndef _HAVE_UINT64_T
306 #define _HAVE_UINT64_T
307 typedef __int64 int64_t;
308 typedef unsigned __int64 uint64_t;
309 #endif
310
311 #elif defined __GNUC__ || defined __MWERKS__ || defined __ELF__
312 dnl /* note: all ELF-systems seem to have loff-support which needs 64-bit */
313
314 #if !defined _NO_LONGLONG
315 #ifndef _HAVE_UINT64_T
316 #define _HAVE_UINT64_T
317 typedef long long int64_t;
318 typedef unsigned long long uint64_t;
319 #endif
320 #endif
321
322 #elif defined __alpha || (defined __mips && defined _ABIN32)
323
324 #if !defined _NO_LONGLONG
325 #ifndef _HAVE_UINT64_T
326 #define _HAVE_UINT64_T
327 typedef long int64_t;
328 typedef unsigned long uint64_t;
329 #endif
330 #endif
331 /* compiler/cpu type ... or just ISO C99 */
332 #endif
333 #endif
334 EOF
335
336 # plus a default 64-bit for systems that are likely to be 64-bit ready
337 case "$ac_cv_sizeof_x:$ac_cv_sizeof_voidp:$ac_cv_sizeof_long" in
338 1:2:8:8) AC_MSG_RESULT(..adding uint64_t default, normal 64-bit system)
339 cat >>$ac_stdint_h <<EOF
340 /* DEFAULT: */
341 /* seen normal 64-bit system, CC has sizeof(long and void*) == 8 bytes */
342 #ifndef _HAVE_UINT64_T
343 #define _HAVE_UINT64_T
344 typedef long int64_t;
345 typedef unsigned long uint64_t;
346 #endif
347 EOF
348 ;;
349 1:2:4:8) AC_MSG_RESULT(..adding uint64_t default, typedef to long)
350 cat >>$ac_stdint_h <<EOF
351 /* DEFAULT: */
352 /* seen 32-bit system prepared for 64-bit, CC has sizeof(long) == 8 bytes */
353 #ifndef _HAVE_UINT64_T
354 #define _HAVE_UINT64_T
355 typedef long int64_t;
356 typedef unsigned long uint64_t;
357 #endif
358 EOF
359 ;;
360 1:2:8:4) AC_MSG_RESULT(..adding uint64_t default, typedef long long)
361 cat >>$ac_stdint_h <<EOF
362 /* DEFAULT: */
363 /* seen 64-bit derived from a 32-bit, CC has sizeof(long) == 4 bytes */
364 #ifndef _HAVE_UINT64_T
365 #define _HAVE_UINT64_T
366 typedef long long int64_t;
367 typedef unsigned long long uint64_t;
368 #endif
369 EOF
370 ;;
371 *)
372 cat >>$ac_stdint_h <<EOF
373 /* NOTE: */
374 /* the configure-checks for the basic types did not make us believe */
375 /* that we could add a fallback to a 'long long' typedef to int64_t */
376 EOF
377 esac
378 fi
379
380 # ------------- DONE int64_t types START intptr types ------------
381 if test "$ac_cv_header_stdint_x" = "no-file" ; then
382 cat >>$ac_stdint_h <<EOF
383
384 /* -------------------------- INPTR SECTION --------------------------- */
385 EOF
386 case "$ac_cv_sizeof_x:$ac_cv_sizeof_voidp" in
387 1:2:2)
388 a="int16_t" ; cat >>$ac_stdint_h <<EOF
389 /* we tested sizeof(void*) to be of 2 chars, hence we declare it 16-bit */
390
391 typedef uint16_t uintptr_t;
392 typedef int16_t intptr_t;
393 EOF
394 ;;
395 1:2:4)
396 a="int32_t" ; cat >>$ac_stdint_h <<EOF
397 /* we tested sizeof(void*) to be of 4 chars, hence we declare it 32-bit */
398
399 typedef uint32_t uintptr_t;
400 typedef int32_t intptr_t;
401 EOF
402 ;;
403 1:2:8)
404 a="int64_t" ; cat >>$ac_stdint_h <<EOF
405 /* we tested sizeof(void*) to be of 8 chars, hence we declare it 64-bit */
406
407 typedef uint64_t uintptr_t;
408 typedef int64_t intptr_t;
409 EOF
410 ;;
411 *)
412 a="long" ; cat >>$ac_stdint_h <<EOF
413 /* we tested sizeof(void*) but got no guess, hence we declare it as if long */
414
415 typedef unsigned long uintptr_t;
416 typedef long intptr_t;
417 EOF
418 ;;
419 esac
420 AC_MSG_RESULT(..adding typedef $a intptr_t)
421 fi
422
423 # ------------- DONE intptr types START int_least types ------------
424 if test "$ac_cv_type_int_least32_t" = "no"; then
425 AC_MSG_RESULT(..adding generic int_least-types)
426 cat >>$ac_stdint_h <<EOF
427
428 /* --------------GENERIC INT_LEAST ------------------ */
429
430 typedef int8_t int_least8_t;
431 typedef int16_t int_least16_t;
432 typedef int32_t int_least32_t;
433 #ifdef _HAVE_UINT64_T
434 typedef int64_t int_least64_t;
435 #endif
436
437 typedef uint8_t uint_least8_t;
438 typedef uint16_t uint_least16_t;
439 typedef uint32_t uint_least32_t;
440 #ifdef _HAVE_UINT64_T
441 typedef uint64_t uint_least64_t;
442 #endif
443 EOF
444 fi
445
446 # ------------- DONE intptr types START int_least types ------------
447 if test "$ac_cv_type_int_fast32_t" = "no"; then
448 AC_MSG_RESULT(..adding generic int_fast-types)
449 cat >>$ac_stdint_h <<EOF
450
451 /* --------------GENERIC INT_FAST ------------------ */
452
453 typedef int8_t int_fast8_t;
454 typedef int32_t int_fast16_t;
455 typedef int32_t int_fast32_t;
456 #ifdef _HAVE_UINT64_T
457 typedef int64_t int_fast64_t;
458 #endif
459
460 typedef uint8_t uint_fast8_t;
461 typedef uint32_t uint_fast16_t;
462 typedef uint32_t uint_fast32_t;
463 #ifdef _HAVE_UINT64_T
464 typedef uint64_t uint_fast64_t;
465 #endif
466 EOF
467 fi
468
469 if test "$ac_cv_header_stdint_x" = "no-file" ; then
470 cat >>$ac_stdint_h <<EOF
471
472 #ifdef _HAVE_UINT64_T
473 typedef int64_t intmax_t;
474 typedef uint64_t uintmax_t;
475 #else
476 typedef long int intmax_t;
477 typedef unsigned long uintmax_t;
478 #endif
479 EOF
480 fi
481
482 AC_MSG_RESULT(... DONE $ac_stdint_h)
483 cat >>$ac_stdint_h <<EOF
484
485 /* once */
486 #endif
487 #endif
488 EOF
489 ])
490
491 dnl quote from SunOS-5.8 sys/inttypes.h:
492 dnl Use at your own risk. As of February 1996, the committee is squarely
493 dnl behind the fixed sized types; the "least" and "fast" types are still being
494 dnl discussed. The probability that the "fast" types may be removed before
495 dnl the standard is finalized is high enough that they are not currently
496 dnl implemented.
497
498

svnadmin@ircd-hybrid.org
ViewVC Help
Powered by ViewVC 1.1.28