Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 230 lines (200 sloc) 7.147 kB
95edd05 [project @ 2004-11-06 10:45:46 by panne]
panne authored
1 # FP_COMPUTE_INT(EXPRESSION, VARIABLE, INCLUDES, IF-FAILS)
2 # --------------------------------------------------------
3 # Assign VARIABLE the value of the compile-time EXPRESSION using INCLUDES for
4 # compilation. Execute IF-FAILS when unable to determine the value. Works for
5 # cross-compilation, too.
6 #
7 # Implementation note: We are lazy and use an internal autoconf macro, but it
8 # is supported in autoconf versions 2.50 up to the actual 2.57, so there is
9 # little risk.
7b41ac2 @igfoo Use FP_COMPUTE_INT rather than AC_COMPUTE_INT
igfoo authored
10 # The public AC_COMPUTE_INT macro isn't supported by some versions of
11 # autoconf.
95edd05 [project @ 2004-11-06 10:45:46 by panne]
panne authored
12 AC_DEFUN([FP_COMPUTE_INT],
04f9c68 @igfoo Swap FP_COMMUTE_INT argument order to match AC_COMPUTE_INT
igfoo authored
13 [_AC_COMPUTE_INT([$2], [$1], [$3], [$4])[]dnl
95edd05 [project @ 2004-11-06 10:45:46 by panne]
panne authored
14 ])# FP_COMPUTE_INT
15
16
17 # FP_CHECK_CONST(EXPRESSION, [INCLUDES = DEFAULT-INCLUDES], [VALUE-IF-FAIL = -1])
18 # -------------------------------------------------------------------------------
19 # Defines CONST_EXPRESSION to the value of the compile-time EXPRESSION, using
20 # INCLUDES. If the value cannot be determined, use VALUE-IF-FAIL.
21 AC_DEFUN([FP_CHECK_CONST],
22 [AS_VAR_PUSHDEF([fp_Cache], [fp_cv_const_$1])[]dnl
23 AC_CACHE_CHECK([value of $1], fp_Cache,
04f9c68 @igfoo Swap FP_COMMUTE_INT argument order to match AC_COMPUTE_INT
igfoo authored
24 [FP_COMPUTE_INT(fp_check_const_result, [$1], [AC_INCLUDES_DEFAULT([$2])],
95edd05 [project @ 2004-11-06 10:45:46 by panne]
panne authored
25 [fp_check_const_result=m4_default([$3], ['-1'])])
26 AS_VAR_SET(fp_Cache, [$fp_check_const_result])])[]dnl
27 AC_DEFINE_UNQUOTED(AS_TR_CPP([CONST_$1]), AS_VAR_GET(fp_Cache), [The value of $1.])[]dnl
28 AS_VAR_POPDEF([fp_Cache])[]dnl
29 ])# FP_CHECK_CONST
30
31
32 # FP_CHECK_CONSTS_TEMPLATE(EXPRESSION...)
33 # ---------------------------------------
34 # autoheader helper for FP_CHECK_CONSTS
35 m4_define([FP_CHECK_CONSTS_TEMPLATE],
36 [AC_FOREACH([fp_Const], [$1],
37 [AH_TEMPLATE(AS_TR_CPP(CONST_[]fp_Const),
38 [The value of ]fp_Const[.])])[]dnl
39 ])# FP_CHECK_CONSTS_TEMPLATE
40
41
42 # FP_CHECK_CONSTS(EXPRESSION..., [INCLUDES = DEFAULT-INCLUDES], [VALUE-IF-FAIL = -1])
43 # -----------------------------------------------------------------------------------
44 # List version of FP_CHECK_CONST
6732243 [project @ 2005-09-18 10:01:57 by panne]
panne authored
45 AC_DEFUN([FP_CHECK_CONSTS],
95edd05 [project @ 2004-11-06 10:45:46 by panne]
panne authored
46 [FP_CHECK_CONSTS_TEMPLATE([$1])dnl
47 for fp_const_name in $1
48 do
49 FP_CHECK_CONST([$fp_const_name], [$2], [$3])
50 done
51 ])# FP_CHECK_CONSTS
52
53
fd2318b @igfoo Rewrite FPTOOLS_CHECK_HTYPE to be cross-compilation-friendly
igfoo authored
54 dnl FPTOOLS_HTYPE_INCLUDES
55 AC_DEFUN([FPTOOLS_HTYPE_INCLUDES],
56 [
57 #include <stdio.h>
d99b6ec [project @ 2004-11-06 11:10:18 by panne]
panne authored
58 #include <stddef.h>
59
60 #if HAVE_SYS_TYPES_H
61 # include <sys/types.h>
62 #endif
63
64 #if HAVE_UNISTD_H
65 # include <unistd.h>
66 #endif
67
68 #if HAVE_SYS_STAT_H
69 # include <sys/stat.h>
70 #endif
71
72 #if HAVE_FCNTL_H
73 # include <fcntl.h>
74 #endif
75
76 #if HAVE_SIGNAL_H
77 # include <signal.h>
78 #endif
79
80 #if HAVE_TIME_H
81 # include <time.h>
82 #endif
83
84 #if HAVE_TERMIOS_H
85 # include <termios.h>
86 #endif
87
88 #if HAVE_STRING_H
89 # include <string.h>
90 #endif
91
92 #if HAVE_CTYPE_H
93 # include <ctype.h>
94 #endif
95
d5893dc add CIntPtr, CUIntPtr, CIntMax, CUIntMax types
Simon Marlow authored
96 #if HAVE_INTTYPES_H
97 # include <inttypes.h>
98 #else
99 # if HAVE_STDINT_H
100 # include <stdint.h>
101 # endif
102 #endif
103
d99b6ec [project @ 2004-11-06 11:10:18 by panne]
panne authored
104 #if HAVE_SYS_RESOURCE_H
105 # include <sys/resource.h>
106 #endif
107
a6e063f @igfoo Fix warnings in C programs generated by configure; fixes failures wit…
igfoo authored
108 #include <stdlib.h>
fd2318b @igfoo Rewrite FPTOOLS_CHECK_HTYPE to be cross-compilation-friendly
igfoo authored
109 ])
110
111
112 dnl ** Map an arithmetic C type to a Haskell type.
113 dnl Based on autconf's AC_CHECK_SIZEOF.
a6e063f @igfoo Fix warnings in C programs generated by configure; fixes failures wit…
igfoo authored
114
ce31f93 @igfoo Refactor the FPTOOLS_CHECK_HTYPE macro
igfoo authored
115 dnl FPTOOLS_CHECK_HTYPE_ELSE(TYPE, WHAT_TO_DO_IF_TYPE_DOES_NOT_EXIST)
116 AC_DEFUN([FPTOOLS_CHECK_HTYPE_ELSE],[
fd2318b @igfoo Rewrite FPTOOLS_CHECK_HTYPE to be cross-compilation-friendly
igfoo authored
117 changequote(<<, >>)
118 dnl The name to #define.
119 define(<<AC_TYPE_NAME>>, translit(htype_$1, [a-z *], [A-Z_P]))
120 dnl The cache variable names.
121 define(<<AC_CV_NAME>>, translit(fptools_cv_htype_$1, [ *], [_p]))
122 define(<<AC_CV_NAME_supported>>, translit(fptools_cv_htype_sup_$1, [ *], [_p]))
123 changequote([, ])
124
125 AC_MSG_CHECKING(Haskell type for $1)
126 AC_CACHE_VAL(AC_CV_NAME,[
127 AC_CV_NAME_supported=yes
7b41ac2 @igfoo Use FP_COMPUTE_INT rather than AC_COMPUTE_INT
igfoo authored
128 FP_COMPUTE_INT([HTYPE_IS_INTEGRAL],
a09e40f @ggreif Fix detection rule to classify types as non-floating-point
ggreif authored
129 [($1)0.2 - ($1)0.4 < 0 ? 0 : 1],
c726559 @singpolyma Possible fix for detecting Float/Double
singpolyma authored
130 [FPTOOLS_HTYPE_INCLUDES],[HTYPE_IS_INTEGRAL=0])
131
132 if test "$HTYPE_IS_INTEGRAL" -eq 0
fd2318b @igfoo Rewrite FPTOOLS_CHECK_HTYPE to be cross-compilation-friendly
igfoo authored
133 then
c726559 @singpolyma Possible fix for detecting Float/Double
singpolyma authored
134 FP_COMPUTE_INT([HTYPE_IS_FLOAT],[sizeof($1) == sizeof(float)],
135 [FPTOOLS_HTYPE_INCLUDES],
136 [AC_CV_NAME_supported=no])
137 FP_COMPUTE_INT([HTYPE_IS_DOUBLE],[sizeof($1) == sizeof(double)],
138 [FPTOOLS_HTYPE_INCLUDES],
139 [AC_CV_NAME_supported=no])
140 FP_COMPUTE_INT([HTYPE_IS_LDOUBLE],[sizeof($1) == sizeof(long double)],
141 [FPTOOLS_HTYPE_INCLUDES],
142 [AC_CV_NAME_supported=no])
143 if test "$HTYPE_IS_FLOAT" -eq 1
144 then
145 AC_CV_NAME=Float
146 elif test "$HTYPE_IS_DOUBLE" -eq 1
fd2318b @igfoo Rewrite FPTOOLS_CHECK_HTYPE to be cross-compilation-friendly
igfoo authored
147 then
c726559 @singpolyma Possible fix for detecting Float/Double
singpolyma authored
148 AC_CV_NAME=Double
149 elif test "$HTYPE_IS_LDOUBLE" -eq 1
150 then
151 AC_CV_NAME=LDouble
fd2318b @igfoo Rewrite FPTOOLS_CHECK_HTYPE to be cross-compilation-friendly
igfoo authored
152 else
c726559 @singpolyma Possible fix for detecting Float/Double
singpolyma authored
153 AC_CV_NAME_supported=no
154 fi
155 else
156 FP_COMPUTE_INT([HTYPE_IS_SIGNED],[(($1)(-1)) < (($1)0)],
157 [FPTOOLS_HTYPE_INCLUDES],
158 [AC_CV_NAME_supported=no])
159 FP_COMPUTE_INT([HTYPE_SIZE],[sizeof($1) * 8],
160 [FPTOOLS_HTYPE_INCLUDES],
161 [AC_CV_NAME_supported=no])
162 if test "$HTYPE_IS_SIGNED" -eq 0
163 then
164 AC_CV_NAME="Word$HTYPE_SIZE"
165 else
166 AC_CV_NAME="Int$HTYPE_SIZE"
fd2318b @igfoo Rewrite FPTOOLS_CHECK_HTYPE to be cross-compilation-friendly
igfoo authored
167 fi
168 fi
c726559 @singpolyma Possible fix for detecting Float/Double
singpolyma authored
169 ])
c4db815 @igfoo Fix suseconds configure test on Windows
igfoo authored
170 if test "$AC_CV_NAME_supported" = no
171 then
172 $2
173 fi
174
175 dnl Note: evaluating dollar-2 can change the value of
176 dnl $AC_CV_NAME_supported, so we might now get a different answer
fd2318b @igfoo Rewrite FPTOOLS_CHECK_HTYPE to be cross-compilation-friendly
igfoo authored
177 if test "$AC_CV_NAME_supported" = yes; then
178 AC_MSG_RESULT($AC_CV_NAME)
179 AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME,
180 [Define to Haskell type for $1])
181 fi
182 undefine([AC_TYPE_NAME])dnl
183 undefine([AC_CV_NAME])dnl
184 undefine([AC_CV_NAME_supported])dnl
d99b6ec [project @ 2004-11-06 11:10:18 by panne]
panne authored
185 ])
186
ce31f93 @igfoo Refactor the FPTOOLS_CHECK_HTYPE macro
igfoo authored
187 dnl FPTOOLS_CHECK_HTYPE(TYPE)
188 AC_DEFUN([FPTOOLS_CHECK_HTYPE],[
189 FPTOOLS_CHECK_HTYPE_ELSE([$1],[
190 AC_CV_NAME=NotReallyAType
191 AC_MSG_RESULT([not supported])
192 ])
193 ])
194
d99b6ec [project @ 2004-11-06 11:10:18 by panne]
panne authored
195
7ee4b81 @igfoo Fix iconv detection on OpenBSD
igfoo authored
196 # FP_SEARCH_LIBS_PROTO(WHAT, PROTOTYPE, FUNCTION, SEARCH-LIBS,
197 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
198 # [OTHER-LIBRARIES])
199 # --------------------------------------------------------
200 # Search for a library defining FUNC, if it's not already available.
201 # This is a copy of the AC_SEARCH_LIBS definition, but extended to take
202 # the name of the thing we are looking for as its first argument, and
203 # prototype text as its second argument. It also calls AC_LANG_PROGRAM
204 # instead of AC_LANG_CALL
205 AC_DEFUN([FP_SEARCH_LIBS_PROTO],
88579d9 @RossPaterson fix cache variable name used by FP_SEARCH_LIBS_PROTO
RossPaterson authored
206 [AS_VAR_PUSHDEF([ac_Search], [ac_cv_search_$1])dnl
7ee4b81 @igfoo Fix iconv detection on OpenBSD
igfoo authored
207 AC_CACHE_CHECK([for library containing $1], [ac_Search],
208 [ac_func_search_save_LIBS=$LIBS
209 AC_LANG_CONFTEST([AC_LANG_PROGRAM([$2], [$3])])
210 for ac_lib in '' $4; do
211 if test -z "$ac_lib"; then
212 ac_res="none required"
213 else
214 ac_res=-l$ac_lib
215 LIBS="-l$ac_lib $7 $ac_func_search_save_LIBS"
216 fi
217 AC_LINK_IFELSE([], [AS_VAR_SET([ac_Search], [$ac_res])])
c6ac45f @ajdunlap Fixing configure for autoconf 2.64
ajdunlap authored
218 AS_VAR_SET_IF([ac_Search], [break])
7ee4b81 @igfoo Fix iconv detection on OpenBSD
igfoo authored
219 done
c6ac45f @ajdunlap Fixing configure for autoconf 2.64
ajdunlap authored
220 AS_VAR_SET_IF([ac_Search], , [AS_VAR_SET([ac_Search], [no])])
7ee4b81 @igfoo Fix iconv detection on OpenBSD
igfoo authored
221 rm conftest.$ac_ext
222 LIBS=$ac_func_search_save_LIBS])
223 ac_res=AS_VAR_GET([ac_Search])
224 AS_IF([test "$ac_res" != no],
225 [test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
226 $5],
227 [$6])dnl
228 AS_VAR_POPDEF([ac_Search])dnl
229 ])
Something went wrong with that request. Please try again.