This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix .gitignore: only ignore 'perl' in root of repo, not U/perl subdir
[metaconfig.git] / U / perl / use64bits.U
CommitLineData
959f3c4c
JH
1?RCS: $Id$
2?RCS:
3?RCS: Copyright (c) 1998 Andy Dougherty
4?RCS:
5?RCS: You may distribute under the terms of either the GNU General Public
6?RCS: License or the Artistic License, as specified in the README file.
7?RCS:
33b2427b 8?MAKE:use64bitint use64bitall archname64: Myread Oldconfig Setvar test \
9c11722e 9 usemorebits longsize ccflags d_quad uquadtype Compile rm_try run
959f3c4c
JH
10?MAKE: -pick add $@ %<
11?Y:TOP
33b2427b
JH
12?S:use64bitint:
13?S: This variable conditionally defines the USE_64_BIT_INT symbol,
f062a9c5 14?S: and indicates that 64-bit integer types should be used
0fdea05a
JH
15?S: when available. The minimal possible 64-bitness
16?S: is employed, just enough to get 64-bit integers into Perl.
17?S: This may mean using for example "long longs", while your memory
18?S: may still be limited to 2 gigabytes.
0fdea05a 19?S:.
33b2427b
JH
20?S:use64bitall:
21?S: This variable conditionally defines the USE_64_BIT_ALL symbol,
0fdea05a
JH
22?S: and indicates that 64-bit integer types should be used
23?S: when available. The maximal possible
24?S: 64-bitness is employed: LP64 or ILP64, meaning that you will
25?S: be able to use more than 2 gigabytes of memory. This mode is
33b2427b 26?S: even more binary incompatible than USE_64_BIT_INT. You may not
0fdea05a
JH
27?S: be able to run the resulting executable in a 32-bit CPU at all or
28?S: you may need at least to reboot your OS to 64-bit mode.
959f3c4c
JH
29?S:.
30?S:archname64:
31?S: This variable is used for the 64-bitness part of $archname.
32?S:.
33b2427b 33?C:USE_64_BIT_INT:
f062a9c5
JH
34?C: This symbol, if defined, indicates that 64-bit integers should
35?C: be used when available. If not defined, the native integers
0fdea05a
JH
36?C: will be employed (be they 32 or 64 bits). The minimal possible
37?C: 64-bitness is used, just enough to get 64-bit integers into Perl.
38?C: This may mean using for example "long longs", while your memory
39?C: may still be limited to 2 gigabytes.
0fdea05a 40?C:.
33b2427b 41?C:USE_64_BIT_ALL:
0fdea05a
JH
42?C: This symbol, if defined, indicates that 64-bit integers should
43?C: be used when available. If not defined, the native integers
44?C: will be used (be they 32 or 64 bits). The maximal possible
45?C: 64-bitness is employed: LP64 or ILP64, meaning that you will
46?C: be able to use more than 2 gigabytes of memory. This mode is
33b2427b 47?C: even more binary incompatible than USE_64_BIT_INT. You may not
0fdea05a
JH
48?C: be able to run the resulting executable in a 32-bit CPU at all or
49?C: you may need at least to reboot your OS to 64-bit mode.
959f3c4c 50?C:.
33b2427b
JH
51?H:?%<:#ifndef USE_64_BIT_INT
52?H:?%<:#$use64bitint USE_64_BIT_INT /**/
a38738d1 53?H:?%<:#endif
33b2427b
JH
54?H:?%<:#ifndef USE_64_BIT_ALL
55?H:?%<:#$use64bitall USE_64_BIT_ALL /**/
0fdea05a
JH
56?H:?%<:#endif
57?H:.
662bdb9a 58?INIT:archname64=''
42979b28 59?LINT:extern ccflags
f062a9c5 60?LINT:use usemorebits
ef22c3d9 61?LINT:extern use64bits
2bdc7c0c 62?LINT:extern uselonglong
ef22c3d9 63?LINT:extern uselonglongs
ef22c3d9 64?LINT:extern use64bitints
ef22c3d9 65?LINT:extern use64bitsint
ef22c3d9 66?LINT:extern use64bitsall
d50afec3
MBT
67?T:libcquad
68?F:!try
33b2427b
JH
69?F:!use64bitint.cbu
70?F:!use64bitall.cbu
2f125bce 71: Do we want 64bit support
027391d4
JH
72case "$uselonglong" in
73"$define"|true|[yY]*)
74 cat <<EOM >&4
75
33b2427b 76*** Configure -Duselonglong is deprecated, using -Duse64bitint instead.
027391d4 77EOM
33b2427b 78 use64bitint="$define"
027391d4 79 ;;
4c42341b 80esac
33b2427b
JH
81case "$use64bits" in
82"$define"|true|[yY]*)
83 cat <<EOM >&4
84
85*** Configure -Duse64bits is deprecated, using -Duse64bitint instead.
33b2427b
JH
86EOM
87 use64bitint="$define"
88 ;;
4c42341b 89esac
33b2427b
JH
90case "$use64bitints" in
91"$define"|true|[yY]*)
92 cat <<EOM >&4
93
94*** There is no Configure -Duse64bitints, using -Duse64bitint instead.
33b2427b
JH
95EOM
96 use64bitint="$define"
97 ;;
4c42341b 98esac
ef22c3d9
JH
99case "$use64bitsint" in
100"$define"|true|[yY]*)
101 cat <<EOM >&4
102
103*** There is no Configure -Duse64bitsint, using -Duse64bitint instead.
104EOM
105 use64bitint="$define"
106 ;;
4c42341b 107esac
ef22c3d9
JH
108case "$uselonglongs" in
109"$define"|true|[yY]*)
110 cat <<EOM >&4
111
112*** There is no Configure -Duselonglongs, using -Duse64bitint instead.
113EOM
114 use64bitint="$define"
115 ;;
4c42341b 116esac
429bdab9
JH
117case "$use64bitsall" in
118"$define"|true|[yY]*)
119 cat <<EOM >&4
120
121*** There is no Configure -Duse64bitsall, using -Duse64bitall instead.
122EOM
123 use64bitall="$define"
124 ;;
4c42341b 125esac
33b2427b 126
027391d4 127case "$ccflags" in
33b2427b 128*-DUSE_LONG_LONG*|*-DUSE_64_BIT_INT*|*-DUSE_64_BIT_ALL*) use64bitint="$define";;
027391d4 129esac
33b2427b
JH
130case "$use64bitall" in
131"$define"|true|[yY]*) use64bitint="$define" ;;
027391d4
JH
132esac
133
134case "$longsize" in
1358) cat <<EOM
f062a9c5 136
027391d4 137You have natively 64-bit long integers.
f062a9c5 138EOM
2bdc7c0c
JH
139 val="$define"
140 ;;
33b2427b 141*) case "$use64bitint" in
027391d4 142 "$define"|true|[yY]*) dflt='y';;
2bdc7c0c
JH
143 *) dflt='n';;
144 esac
dcf40b7d
JH
145 case "$d_quad" in
146 "$define") ;;
147 *) dflt='n' ;;
148 esac
0fdea05a 149 cat <<EOM
f062a9c5
JH
150
151Perl can be built to take advantage of 64-bit integer types
33b2427b 152on some systems. To do so, Configure can be run with -Duse64bitint.
0fdea05a 153Choosing this option will most probably introduce binary incompatibilities.
959f3c4c 154
2bdc7c0c 155If this doesn't make any sense to you, just accept the default '$dflt'.
dcf40b7d 156(The default has been chosen based on your configuration.)
959f3c4c 157EOM
2bdc7c0c
JH
158 rp='Try to use 64-bit integers, if available?'
159 . ./myread
160 case "$ans" in
161 [yY]*) val="$define" ;;
162 *) val="$undef" ;;
163 esac
164 ;;
959f3c4c 165esac
33b2427b 166set use64bitint
959f3c4c
JH
167eval $setvar
168
08b5bf24
JH
169case "$use64bitall" in
170"$define"|true|[yY]*) dflt='y' ;;
171*) case "$longsize" in
172 8) dflt='y' ;;
173 *) dflt='n' ;;
174 esac
175 ;;
4c42341b 176esac
eb9ee163
JH
177cat <<EOM
178
179You may also choose to try maximal 64-bitness. It means using as much
18064-bitness as possible on the platform. This in turn means even more
181binary incompatibilities. On the other hand, your platform may not
182have any more 64-bitness available than what you already have chosen.
183
184If this doesn't make any sense to you, just accept the default '$dflt'.
dcf40b7d 185(The default has been chosen based on your configuration.)
eb9ee163
JH
186EOM
187rp='Try to use maximal 64-bit support, if available?'
188. ./myread
189case "$ans" in
190[yY]*) val="$define" ;;
191*) val="$undef" ;;
192esac
33b2427b 193set use64bitall
0fdea05a 194eval $setvar
eb9ee163
JH
195case "$use64bitall" in
196"$define")
197 case "$use64bitint" in
198 "$undef")
199 cat <<EOM
200
201Since you have chosen a maximally 64-bit build, I'm also turning on
202the use of 64-bit integers.
203EOM
204 use64bitint="$define" ;;
205 esac
206 ;;
207esac
0fdea05a 208
959f3c4c 209: Look for a hint-file generated 'call-back-unit'. If the
f062a9c5 210: user has specified that a 64-bit perl is to be built,
959f3c4c 211: we may need to set or change some other defaults.
57f835c9
MB
212if $test -f use64bitint.cbu; then
213 echo "Your platform has some specific hints regarding 64-bit integers, using them..."
214 . ./use64bitint.cbu
215fi
216case "$use64bitint" in
217"$define"|true|[yY]*)
d50afec3
MBT
218 : This test was common to all the OpenBSD forks, and seems harmless for
219 : other platforms:
220 echo " "
221 echo "Checking if your C library has broken 64-bit functions..." >&4
222 cat >try.c <<EOCP
223#include <stdio.h>
224typedef $uquadtype myULL;
225int main (void)
226{
227 struct {
228 double d;
229 myULL u;
230 } *p, test[] = {
231 {4294967303.15, 4294967303ULL},
232 {4294967294.2, 4294967294ULL},
233 {4294967295.7, 4294967295ULL},
234 {0.0, 0ULL}
235 };
236 for (p = test; p->u; p++) {
237 myULL x = (myULL)p->d;
238 if (x != p->u) {
239 printf("buggy\n");
240 return 0;
241 }
242 }
243 printf("ok\n");
244 return 0;
245}
246EOCP
247 set try
248 if eval $compile_ok; then
9c11722e 249 libcquad=`$run ./try`
d50afec3
MBT
250 echo "Your C library's 64-bit functions are $libcquad."
251 else
252 echo "(I can't seem to compile the test program.)"
253 echo "Assuming that your C library's 64-bit functions are ok."
254 libcquad="ok"
255 fi
256 $rm_try
257
258 case "$libcquad" in
259 buggy*)
260 cat >&4 <<EOM
261
262*** You have a C library with broken 64-bit functions.
263*** 64-bit support does not work reliably in this configuration.
264*** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
265*** Cannot continue, aborting.
266
267EOM
268 exit 1
269 ;;
270 esac
0fdea05a 271 case "$longsize" in
f218e781 272 4) case "$archname64" in
33b2427b 273 '') archname64=64int ;;
0fdea05a
JH
274 esac
275 ;;
027391d4 276 esac
959f3c4c
JH
277 ;;
278esac
279
0fdea05a 280: Look for a hint-file generated 'call-back-unit'. If the
eb9ee163 281: user has specified that a maximally 64-bit perl is to be built,
0fdea05a 282: we may need to set or change some other defaults.
57f835c9
MB
283if $test -f use64bitall.cbu; then
284 echo "Your platform has some specific hints regarding 64-bit builds, using them..."
285 . ./use64bitall.cbu
286fi
287case "$use64bitall" in
288"$define"|true|[yY]*)
0fdea05a 289 case "$longsize" in
faa3593a 290 4) case "$archname64" in
df7dac98 291 ''|64int) archname64=64all ;;
0fdea05a
JH
292 esac
293 ;;
294 esac
295 ;;
027391d4
JH
296esac
297
4b62dc2e
JH
298case "$d_quad:$use64bitint" in
299$undef:$define)
300 cat >&4 <<EOF
301
302*** You have chosen to use 64-bit integers,
6e998565 303*** but none can be found.
907ef768 304*** Please rerun Configure without -Duse64bitint and/or -Dusemorebits.
4b62dc2e
JH
305*** Cannot continue, aborting.
306
307EOF
308 exit 1
309 ;;
310esac
311