]> www.ginac.de Git - cln.git/blob - m4/general.m4
Remove the conversion step .tex -> .texi.
[cln.git] / m4 / general.m4
1 dnl Copyright (C) 1993-2006 Free Software Foundation, Inc.
2 dnl This file is free software, distributed under the terms of the GNU
3 dnl General Public License.  As a special exception to the GNU General
4 dnl Public License, this file may be distributed as part of a program
5 dnl that contains a configuration script generated by Autoconf, under
6 dnl the same distribution terms as the rest of that program.
7
8 dnl From Bruno Haible, Marcus Daniels, Sam Steingold.
9
10 AC_PREREQ(2.13)
11
12 dnl without AC_MSG_...:   with AC_MSG_... and caching:
13 dnl   AC_TRY_CPP          CL_CPP_CHECK
14 dnl   AC_TRY_COMPILE      CL_COMPILE_CHECK
15 dnl   AC_TRY_LINK         CL_LINK_CHECK
16 dnl   AC_TRY_RUN          CL_RUN_CHECK - would require cross-compiling support
17 dnl Usage:
18 dnl AC_TRY_CPP(INCLUDES,
19 dnl            ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
20 dnl CL_CPP_CHECK(ECHO-TEXT, CACHE-ID,
21 dnl              INCLUDES,
22 dnl              ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
23 dnl AC_TRY_xxx(INCLUDES, FUNCTION-BODY,
24 dnl            ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
25 dnl CL_xxx_CHECK(ECHO-TEXT, CACHE-ID,
26 dnl              INCLUDES, FUNCTION-BODY,
27 dnl              ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
28
29 AC_DEFUN([CL_CPP_CHECK],
30 [AC_MSG_CHECKING(for $1)
31 AC_CACHE_VAL($2,[
32 AC_TRY_CPP([$3], $2=yes, $2=no)
33 ])
34 AC_MSG_RESULT([$]$2)
35 if test [$]$2 = yes; then
36   ifelse([$4], , :, [$4])
37 ifelse([$5], , , [else
38   $5
39 ])dnl
40 fi
41 ])
42
43 AC_DEFUN([CL_COMPILE_CHECK],
44 [AC_MSG_CHECKING(for $1)
45 AC_CACHE_VAL($2,[
46 AC_TRY_COMPILE([$3],[$4], $2=yes, $2=no)
47 ])
48 AC_MSG_RESULT([$]$2)
49 if test [$]$2 = yes; then
50   ifelse([$5], , :, [$5])
51 ifelse([$6], , , [else
52   $6
53 ])dnl
54 fi
55 ])
56
57 AC_DEFUN([CL_LINK_CHECK],
58 [AC_MSG_CHECKING(for $1)
59 AC_CACHE_VAL($2,[
60 AC_TRY_LINK([$3],[$4], $2=yes, $2=no)
61 ])
62 AC_MSG_RESULT([$]$2)
63 if test [$]$2 = yes; then
64   ifelse([$5], , :, [$5])
65 ifelse([$6], , , [else
66   $6
67 ])dnl
68 fi
69 ])
70
71 dnl CL_SILENT(ACTION)
72 dnl performs ACTION, with AC_MSG_CHECKING and AC_MSG_RESULT being defined away.
73 AC_DEFUN([CL_SILENT],
74 [pushdef([AC_MSG_CHECKING],[:])dnl
75 pushdef([AC_CHECKING],[:])dnl
76 pushdef([AC_MSG_RESULT],[:])dnl
77 $1[]dnl
78 popdef([AC_MSG_RESULT])dnl
79 popdef([AC_CHECKING])dnl
80 popdef([AC_MSG_CHECKING])dnl
81 ])
82
83 dnl Expands to the "extern ..." prefix used for system declarations.
84 dnl AC_LANG_EXTERN()
85 AC_DEFUN([AC_LANG_EXTERN],
86 [extern
87 #ifdef __cplusplus
88 "C"
89 #endif
90 ])
91
92 AC_DEFUN([CL_CC_WORKS],
93 [AC_CACHE_CHECK(whether CC works at all, cl_cv_prog_cc_works, [
94 AC_LANG_SAVE()
95 AC_LANG_C()
96 AC_TRY_RUN([
97 #include <stdlib.h>
98 int main() { exit(0); }
99 ],
100 cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no,
101 AC_TRY_LINK([], [], cl_cv_prog_cc_works=yes, cl_cv_prog_cc_works=no))
102 AC_LANG_RESTORE()
103 ])
104 case "$cl_cv_prog_cc_works" in
105   *no) echo "Installation or configuration problem: C compiler cannot create executables."; exit 1;;
106   *yes) ;;
107 esac
108 ])
109
110 AC_DEFUN([CL_CONFIG_SUBDIRS],
111 [dnl No AC_CONFIG_AUX_DIR_DEFAULT, so we don't need install.sh.
112 AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])
113 AC_CONFIG_SUBDIRS([$1])dnl
114 ])
115
116 AC_DEFUN([CL_CANONICAL_HOST],
117 [AC_REQUIRE([AC_PROG_CC]) dnl Actually: AC_REQUIRE([CL_CC_WORKS])
118 dnl Set ac_aux_dir before the cache check, because AM_PROG_LIBTOOL needs it.
119 ac_aux_dir=${srcdir}/$1
120 dnl A substitute for AC_CONFIG_AUX_DIR_DEFAULT, so we don't need install.sh.
121 ac_config_guess="$SHELL $ac_aux_dir/config.guess"
122 ac_config_sub="$SHELL $ac_aux_dir/config.sub"
123 dnl We have defined $ac_aux_dir.
124 AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
125 dnl In autoconf-2.52, a single AC_CANONICAL_HOST has the effect of inserting
126 dnl the code of AC_CANONICAL_BUILD *before* CL_CANONICAL_HOST, i.e. before
127 dnl ac_aux_dir has been set. To work around this, we list AC_CANONICAL_BUILD
128 dnl explicitly.
129 AC_CANONICAL_BUILD
130 AC_CANONICAL_HOST
131 ])
132
133 AC_DEFUN([CL_CANONICAL_HOST_CPU],
134 [AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
135 case "$host_cpu" in
136 changequote(,)dnl
137   i[4567]86 )
138     host_cpu=i386
139     ;;
140   alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
141     host_cpu=alpha
142     ;;
143   hppa1.0 | hppa1.1 | hppa2.0* | hppa64 )
144     host_cpu=hppa
145     ;;
146   powerpc )
147     host_cpu=rs6000
148     ;;
149   c1 | c2 | c32 | c34 | c38 | c4 )
150     host_cpu=convex
151     ;;
152   arm* )
153     host_cpu=arm
154     ;;
155 changequote([,])dnl
156   mips )
157     AC_CACHE_CHECK([for 64-bit MIPS], cl_cv_host_mips64, [
158 AC_EGREP_CPP(yes,
159 [#if defined(_MIPS_SZLONG)
160 #if (_MIPS_SZLONG == 64)
161 /* We should also check for (_MIPS_SZPTR == 64), but gcc keeps this at 32. */
162   yes
163 #endif
164 #endif
165 ], cl_cv_host_mips64=yes, cl_cv_host_mips64=no)
166 ])
167 if test $cl_cv_host_mips64 = yes; then
168   host_cpu=mips64
169 fi
170     ;;
171 dnl UltraSPARCs running Linux have `uname -m` = "sparc64", but the C compiler
172 dnl still generates 32-bit code.
173   sparc | sparc64 )
174     AC_CACHE_CHECK([for 64-bit SPARC], cl_cv_host_sparc64, [
175 AC_EGREP_CPP(yes,
176 [#if defined(__sparcv9) || defined(__arch64__)
177   yes
178 #endif
179 ], cl_cv_host_sparc64=yes, cl_cv_host_sparc64=no)
180 ])
181 if test $cl_cv_host_sparc64 = yes; then
182   host_cpu=sparc64
183 else
184   host_cpu=sparc
185 fi
186     ;;
187 dnl AMD64 running Linux have 'uname -m' = "x86_64" even if userland is purely
188 dnl 32-bit.
189   x86_64 )
190     AC_CACHE_CHECK([for 64-bit userland on x86-64], cl_cv_host_x86_64, [
191 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
192 [[#if !defined __x86_64__
193 # error __x86_64__ not defined
194 #endif
195 ]])
196 ], [cl_cv_host_x86_64=yes], [cl_cv_host_x86_64=no])
197 ])
198 if test $cl_cv_host_x86_64 = yes; then
199   host_cpu=x86_64
200 else
201   host_cpu=i386
202 fi
203   ;;
204 dnl PowerPC64 is another case where 'uname -m' and userland may disagree.
205   powerpc64 )
206     AC_CACHE_CHECK([for 64-bit userland on PowerPC64], cl_cv_host_powerpc64, [
207 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
208 [[#if !defined __powerpc64__
209 # error __powerpc64__ not defined
210 #endif
211 ]])
212 ], [cl_cv_host_powerpc64=yes], [cl_cv_host_powerpc64=no])
213 ])
214 if test $cl_cv_host_powerpc64 = yes; then
215   host_cpu=powerpc64
216 else
217   host_cpu=rs6000
218 fi
219   ;;
220 esac
221 dnl was AC_DEFINE_UNQUOTED(__${host_cpu}__) but KAI C++ 3.2d doesn't like this
222 cat >> confdefs.h <<EOF
223 #ifndef __${host_cpu}__
224 #define __${host_cpu}__ 1
225 #endif
226 EOF
227 ])
228
229 AC_DEFUN([CL_CANONICAL_HOST_CPU_FOR_FFCALL],
230 [AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
231 case "$host_cpu" in
232 changequote(,)dnl
233   i[4567]86 )
234     host_cpu=i386
235     ;;
236   alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
237     host_cpu=alpha
238     ;;
239   hppa1.0 | hppa1.1 | hppa2.0* | hppa64 )
240     host_cpu=hppa
241     ;;
242   powerpc )
243     host_cpu=rs6000
244     ;;
245   c1 | c2 | c32 | c34 | c38 | c4 )
246     host_cpu=convex
247     ;;
248   arm* )
249     host_cpu=arm
250     ;;
251 changequote([,])dnl
252   mips )
253     AC_CACHE_CHECK([for 64-bit MIPS], cl_cv_host_mips64, [
254 AC_EGREP_CPP(yes,
255 [#if defined(_MIPS_SZLONG)
256 #if (_MIPS_SZLONG == 64)
257 /* We should also check for (_MIPS_SZPTR == 64), but gcc keeps this at 32. */
258   yes
259 #endif
260 #endif
261 ], cl_cv_host_mips64=yes, cl_cv_host_mips64=no)
262 ])
263 if test $cl_cv_host_mips64 = yes; then
264   host_cpu=mips64
265 else
266   AC_CACHE_CHECK([for MIPS with n32 ABI], cl_cv_host_mipsn32, [
267 dnl Strictly speaking, the MIPS ABI (-32 or -n32) is independent from the CPU
268 dnl identification (-mips[12] or -mips[34]). But -n32 is commonly used together
269 dnl with -mips3, and it's easier to test the CPU identification.
270 AC_EGREP_CPP(yes,
271 [#if __mips >= 3
272   yes
273 #endif
274 ], cl_cv_host_mipsn32=yes, cl_cv_host_mipsn32=no)
275 ])
276 if test $cl_cv_host_mipsn32 = yes; then
277   host_cpu=mipsn32
278 fi
279 fi
280     ;;
281 dnl UltraSPARCs running Linux have `uname -m` = "sparc64", but the C compiler
282 dnl still generates 32-bit code.
283   sparc | sparc64 )
284     AC_CACHE_CHECK([for 64-bit SPARC], cl_cv_host_sparc64, [
285 AC_EGREP_CPP(yes,
286 [#if defined(__sparcv9) || defined(__arch64__)
287   yes
288 #endif
289 ], cl_cv_host_sparc64=yes, cl_cv_host_sparc64=no)
290 ])
291 if test $cl_cv_host_sparc64 = yes; then
292   host_cpu=sparc64
293 else
294   host_cpu=sparc
295 fi
296     ;;
297 esac
298 dnl was AC_DEFINE_UNQUOTED(__${host_cpu}__) but KAI C++ 3.2d doesn't like this
299 cat >> confdefs.h <<EOF
300 #ifndef __${host_cpu}__
301 #define __${host_cpu}__ 1
302 #endif
303 EOF
304 ])