1
# SIM_AC_CHECK_HEADER(HEADER-FILE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
2
# --------------------------------------------------------------------------
3
# Modified AC_CHECK_HEADER to use AC_TRY_COMPILE instead of AC_TRY_CPP,
4
# as we can get false positives and/or false negatives when running under
5
# Cygwin, using the Microsoft Visual C++ compiler (the configure script will
6
# pick the GCC preprocessor).
8
AC_DEFUN([SIM_AS_TR_CPP],
9
[m4_ifdef([AS_TR_CPP],[AS_TR_CPP([$1])],[AC_TR_CPP([$1])])])
11
AC_DEFUN([SIM_AC_CHECK_HEADER],
12
[AC_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])
13
AC_ARG_VAR([CPPFLAGS], [C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir>])
17
[AC_TRY_COMPILE([#include <$1>],
19
[AC_VAR_SET([ac_Header], yes)],
20
[AC_VAR_SET([ac_Header], no)])])
21
if test AC_VAR_GET(ac_Header) = yes; then
22
ifelse([$2], , :, [$2])
24
ifelse([$3], , :, [$3])
26
AC_VAR_POPDEF([ac_Header])
27
])# SIM_AC_CHECK_HEADER
30
# SIM_AC_CHECK_HEADERS(HEADER-FILE...
31
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
32
# ----------------------------------------------------------
33
AC_DEFUN([SIM_AC_CHECK_HEADERS],
38
[AC_DEFINE_UNQUOTED(SIM_AS_TR_CPP(HAVE_$ac_header)) $2],
41
])# SIM_AC_CHECK_HEADERS
44
# SIM_AC_CHECK_SIZEOF(TYPE, [INCLUDES])
45
# --------------------------------------------
46
AC_DEFUN([SIM_AC_CHECK_SIZEOF],
49
_AC_COMPUTE_INT([sizeof ($1)],
51
[AC_INCLUDES_DEFAULT([$2])])
52
], [sim_ac_bytesize=0], [$2])
53
])# SIM_AC_CHECK_SIZEOF
56
# SIM_AC_HAVE_BYTESIZE_TYPES_IFELSE
57
# --------------------
58
AC_DEFUN([SIM_AC_HAVE_BYTESIZE_TYPES_IFELSE],
60
AC_MSG_CHECKING([standard bytesize typedefs])
63
#ifdef HAVE_INTTYPES_H
65
#else /* !HAVE_INTTYPES_H */
68
#endif /* HAVE_STDINT_H */
69
#endif /* !HAVE_INTTYPES_H */
70
#ifdef HAVE_SYS_TYPES_H
71
#include <sys/types.h>
72
#endif /* HAVE_SYS_TYPES_H */
83
[sim_ac_have_have_bytesize_types=true],
84
[sim_ac_have_have_bytesize_types=false])
86
if $sim_ac_have_have_bytesize_types; then
87
AC_MSG_RESULT([available])
88
AC_DEFINE_UNQUOTED([HAVE_INT8_T], [1], [define this if the type is available on the system])
89
AC_DEFINE_UNQUOTED([COIN_INT8_T], [int8_t], [define this to a type of the indicated bitwidth])
90
AC_DEFINE_UNQUOTED([HAVE_UINT8_T], [1], [define this if the type is available on the system])
91
AC_DEFINE_UNQUOTED([COIN_UINT8_T], [uint8_t], [define this to a type of the indicated bitwidth])
92
AC_DEFINE_UNQUOTED([HAVE_INT16_T], [1], [define this if the type is available on the system])
93
AC_DEFINE_UNQUOTED([COIN_INT16_T], [int16_t], [define this to a type of the indicated bitwidth])
94
AC_DEFINE_UNQUOTED([HAVE_UINT16_T], [1], [define this if the type is available on the system])
95
AC_DEFINE_UNQUOTED([COIN_UINT16_T], [uint16_t], [define this to a type of the indicated bitwidth])
96
AC_DEFINE_UNQUOTED([HAVE_INT32_T], [1], [define this if the type is available on the system])
97
AC_DEFINE_UNQUOTED([COIN_INT32_T], [int32_t], [define this to a type of the indicated bitwidth])
98
AC_DEFINE_UNQUOTED([HAVE_UINT32_T], [1], [define this if the type is available on the system])
99
AC_DEFINE_UNQUOTED([COIN_UINT32_T], [uint32_t], [define this to a type of the indicated bitwidth])
100
AC_DEFINE_UNQUOTED([HAVE_INT64_T], [1], [define this if the type is available on the system])
101
AC_DEFINE_UNQUOTED([COIN_INT64_T], [int64_t], [define this to a type of the indicated bitwidth])
102
AC_DEFINE_UNQUOTED([HAVE_UINT64_T], [1], [define this if the type is available on the system])
103
AC_DEFINE_UNQUOTED([COIN_UINT64_T], [uint64_t], [define this to a type of the indicated bitwidth])
106
AC_MSG_RESULT([not available])
109
])# SIM_AC_HAVE_BYTESIZE_TYPES_IFELSE
111
# SIM_AC_BYTESIZE_TYPE(TYPEDEFTYPE, BYTESIZE, ALTERNATE_TYPELIST,
112
# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
113
# ----------------------------------------------------------
115
# FIXME: pretty ugly code with several quick hacks. 20010324 mortene.
116
AC_DEFUN([SIM_AC_BYTESIZE_TYPE],
117
[sim_ac_searching=true
118
for sim_ac_type in $1 $3
120
if $sim_ac_searching; then
121
SIM_AC_CHECK_SIZEOF($sim_ac_type, [
123
#ifdef HAVE_INTTYPES_H
124
#include <inttypes.h>
125
#else /* !HAVE_INTTYPES_H */
128
#endif /* HAVE_STDINT_H */
129
#endif /* !HAVE_INTTYPES_H */
130
#ifdef HAVE_SYS_TYPES_H
131
#include <sys/types.h>
132
#endif /* HAVE_SYS_TYPES_H */
134
if test "$sim_ac_bytesize" = "$2"; then
135
sim_ac_searching=false
136
if test "$sim_ac_type" = "$1"; then
137
AC_DEFINE_UNQUOTED(SIM_AS_TR_CPP(have_$1), 1, [define this if the type is available on the system])
139
AC_DEFINE_UNQUOTED(SIM_AS_TR_CPP(coin_$1), $sim_ac_type, [define this to a type of the indicated bitwidth])
144
if $sim_ac_searching; then
145
ifelse([$5], , :, [$5])
147
ifelse([$4], , :, [$4])
149
])# SIM_AC_BYTESIZE_TYPE
151
# SIM_AC_DEFINE_BYTESIZE_TYPES
152
# ----------------------------------------------------------
154
AC_DEFUN([SIM_AC_DEFINE_BYTESIZE_TYPES],
156
SIM_AC_HAVE_BYTESIZE_TYPES_IFELSE([], [
157
SIM_AC_BYTESIZE_TYPE(int8_t, 1, [char], [], AC_MSG_ERROR([could not find 8-bit type]))
158
SIM_AC_BYTESIZE_TYPE(uint8_t, 1, [u_int8_t "unsigned char"], [], AC_MSG_ERROR([could not find unsigned 8-bit type]))
160
SIM_AC_BYTESIZE_TYPE(int16_t, 2, [short int], [], AC_MSG_ERROR([could not find 16-bit type]))
161
SIM_AC_BYTESIZE_TYPE(uint16_t, 2, [u_int16_t "unsigned short" "unsigned int"], [], AC_MSG_ERROR([could not find unsigned 16-bit type]))
163
SIM_AC_BYTESIZE_TYPE(int32_t, 4, [int long], [], AC_MSG_ERROR([could not find 32-bit type]))
164
SIM_AC_BYTESIZE_TYPE(uint32_t, 4, [u_int32_t "unsigned int" "unsigned long"], [], AC_MSG_ERROR([could not find unsigned 32-bit type]))
166
SIM_AC_BYTESIZE_TYPE(int64_t, 8, [long int "long long" __int64], [], AC_MSG_WARN([could not find 64-bit type]))
167
SIM_AC_BYTESIZE_TYPE(uint64_t, 8, [u_int64_t "unsigned long" "unsigned int" "unsigned long long" "unsigned __int64"], [], AC_MSG_WARN([could not find unsigned 64-bit type]))
169
])# SIM_AC_DEFINE_BYTESIZE_TYPES