]> www.ginac.de Git - cln.git/blob - m4/general.m4
Update and clean up autoconf template files.
[cln.git] / m4 / general.m4
1 dnl Copyright (C) 1993-2019 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.69])
11
12 dnl Usage:
13 dnl CL_LINK_CHECK(ECHO-TEXT, CACHE-ID, INCLUDES, FUNCTION-BODY, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
14 AC_DEFUN([CL_LINK_CHECK],
15 [AC_MSG_CHECKING(for $1)
16 AC_CACHE_VAL($2,[
17 AC_LINK_IFELSE([AC_LANG_PROGRAM([[$3]], [[$4]])], [$2=yes], [$2=no])
18 ])
19 AC_MSG_RESULT([$]$2)
20 if test [$]$2 = yes; then
21   ifelse([$5], , :, [$5])
22 ifelse([$6], , , [else
23   $6
24 ])dnl
25 fi
26 ])
27
28 dnl Expands to the "extern ..." prefix used for system declarations.
29 dnl AC_LANG_EXTERN()
30 AC_DEFUN([AC_LANG_EXTERN],
31 [extern
32 #ifdef __cplusplus
33 "C"
34 #endif
35 ])
36
37 AC_DEFUN([CL_CANONICAL_HOST],
38 [AC_REQUIRE([AC_PROG_CC])
39 AC_CANONICAL_HOST
40 ])
41
42 AC_DEFUN([CL_CANONICAL_HOST_CPU],
43 [AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
44 case "$host_cpu" in
45 changequote(,)dnl
46   i[4567]86 )
47     host_cpu=i386
48     ;;
49   alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
50     host_cpu=alpha
51     ;;
52   hppa1.0 | hppa1.1 | hppa2.0* | hppa64 )
53     host_cpu=hppa
54     ;;
55   powerpc )
56     host_cpu=rs6000
57     ;;
58   c1 | c2 | c32 | c34 | c38 | c4 )
59     host_cpu=convex
60     ;;
61   arm* )
62     host_cpu=arm
63     ;;
64 changequote([,])dnl
65   mips* )
66     AC_CACHE_CHECK([for 64-bit MIPS], cl_cv_host_mips64, [
67 AC_EGREP_CPP(yes,
68 [#if defined(_MIPS_SZLONG)
69 #if (_MIPS_SZLONG == 64)
70 /* We should also check for (_MIPS_SZPTR == 64), but gcc keeps this at 32. */
71   yes
72 #endif
73 #endif
74 ], cl_cv_host_mips64=yes, cl_cv_host_mips64=no)
75 ])
76 if test $cl_cv_host_mips64 = yes; then
77   host_cpu=mips64
78 fi
79     ;;
80 dnl UltraSPARCs running Linux have `uname -m` = "sparc64", but the C compiler
81 dnl still generates 32-bit code.
82   sparc | sparc64 )
83     AC_CACHE_CHECK([for 64-bit SPARC], cl_cv_host_sparc64, [
84 AC_EGREP_CPP(yes,
85 [#if defined(__sparcv9) || defined(__arch64__)
86   yes
87 #endif
88 ], cl_cv_host_sparc64=yes, cl_cv_host_sparc64=no)
89 ])
90 if test $cl_cv_host_sparc64 = yes; then
91   host_cpu=sparc64
92 else
93   host_cpu=sparc
94 fi
95     ;;
96 dnl MacOS X 10.5 machines on x86_64 platforms have 'uname -m' = "i386" even
97 dnl if 64-bit programs are fully supported.
98 dnl AMD64 running Linux have 'uname -m' = "x86_64" even if userland is purely
99 dnl 32-bit.
100   i386 | x86_64 )
101     AC_CACHE_CHECK([for 64-bit userland on x86-64], cl_cv_host_x86_64, [
102 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
103 [[#if !defined __x86_64__
104 # error __x86_64__ not defined
105 #endif
106 ]])
107 ], [cl_cv_host_x86_64=yes], [cl_cv_host_x86_64=no])
108 ])
109 if test $cl_cv_host_x86_64 = yes; then
110   host_cpu=x86_64
111 else
112   host_cpu=i386
113 fi
114   ;;
115 dnl PowerPC64 is another case where 'uname -m' and userland may disagree.
116   powerpc64 )
117     AC_CACHE_CHECK([for 64-bit userland on PowerPC64], cl_cv_host_powerpc64, [
118 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
119 [[#if !defined __powerpc64__
120 # error __powerpc64__ not defined
121 #endif
122 ]])
123 ], [cl_cv_host_powerpc64=yes], [cl_cv_host_powerpc64=no])
124 ])
125 if test $cl_cv_host_powerpc64 = yes; then
126   host_cpu=powerpc64
127 else
128   host_cpu=rs6000
129 fi
130   ;;
131 esac
132 dnl was AC_DEFINE_UNQUOTED(__${host_cpu}__) but KAI C++ 3.2d doesn't like this
133 cat >> confdefs.h <<EOF
134 #ifndef __${host_cpu}__
135 #define __${host_cpu}__ 1
136 #endif
137 EOF
138 ])
139
140 AC_DEFUN([CL_CANONICAL_HOST_CPU_FOR_FFCALL],
141 [AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
142 case "$host_cpu" in
143 changequote(,)dnl
144   i[4567]86 )
145     host_cpu=i386
146     ;;
147   alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] )
148     host_cpu=alpha
149     ;;
150   hppa1.0 | hppa1.1 | hppa2.0* | hppa64 )
151     host_cpu=hppa
152     ;;
153   powerpc )
154     host_cpu=rs6000
155     ;;
156   c1 | c2 | c32 | c34 | c38 | c4 )
157     host_cpu=convex
158     ;;
159   arm* )
160     host_cpu=arm
161     ;;
162 changequote([,])dnl
163   mips )
164     AC_CACHE_CHECK([for 64-bit MIPS], cl_cv_host_mips64, [
165 AC_EGREP_CPP(yes,
166 [#if defined(_MIPS_SZLONG)
167 #if (_MIPS_SZLONG == 64)
168 /* We should also check for (_MIPS_SZPTR == 64), but gcc keeps this at 32. */
169   yes
170 #endif
171 #endif
172 ], cl_cv_host_mips64=yes, cl_cv_host_mips64=no)
173 ])
174 if test $cl_cv_host_mips64 = yes; then
175   host_cpu=mips64
176 else
177   AC_CACHE_CHECK([for MIPS with n32 ABI], cl_cv_host_mipsn32, [
178 dnl Strictly speaking, the MIPS ABI (-32 or -n32) is independent from the CPU
179 dnl identification (-mips[12] or -mips[34]). But -n32 is commonly used together
180 dnl with -mips3, and it's easier to test the CPU identification.
181 AC_EGREP_CPP(yes,
182 [#if __mips >= 3
183   yes
184 #endif
185 ], cl_cv_host_mipsn32=yes, cl_cv_host_mipsn32=no)
186 ])
187 if test $cl_cv_host_mipsn32 = yes; then
188   host_cpu=mipsn32
189 fi
190 fi
191     ;;
192 dnl UltraSPARCs running Linux have `uname -m` = "sparc64", but the C compiler
193 dnl still generates 32-bit code.
194   sparc | sparc64 )
195     AC_CACHE_CHECK([for 64-bit SPARC], cl_cv_host_sparc64, [
196 AC_EGREP_CPP(yes,
197 [#if defined(__sparcv9) || defined(__arch64__)
198   yes
199 #endif
200 ], cl_cv_host_sparc64=yes, cl_cv_host_sparc64=no)
201 ])
202 if test $cl_cv_host_sparc64 = yes; then
203   host_cpu=sparc64
204 else
205   host_cpu=sparc
206 fi
207     ;;
208 esac
209 dnl was AC_DEFINE_UNQUOTED(__${host_cpu}__) but KAI C++ 3.2d doesn't like this
210 cat >> confdefs.h <<EOF
211 #ifndef __${host_cpu}__
212 #define __${host_cpu}__ 1
213 #endif
214 EOF
215 ])