This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Populate metaconfig branch.
[metaconfig.git] / dist-3.0at70 / mcon / U / intsize.U
1 ?RCS: $Id: intsize.U,v 3.0.1.2 1997/02/28 15:55:26 ram Exp $
2 ?RCS:
3 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
4 ?RCS: 
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 3.0.
10 ?RCS:
11 ?RCS: $Log: intsize.U,v $
12 ?RCS: Revision 3.0.1.2  1997/02/28  15:55:26  ram
13 ?RCS: patch61: avoid prompting the user if the test runs ok
14 ?RCS: patch61: moved code from longsize.U into there
15 ?RCS: patch61: new tests for shortsize as well
16 ?RCS:
17 ?RCS: Revision 3.0.1.1  1994/10/29  16:21:06  ram
18 ?RCS: patch36: added ?F: line for metalint file checking
19 ?RCS:
20 ?RCS: Revision 3.0  1993/08/18  12:08:52  ram
21 ?RCS: Baseline for dist 3.0 netwide release.
22 ?RCS:
23 ?MAKE:intsize longsize shortsize: \
24         Myread cat rm +cc +optimize +ccflags +ldflags +libs
25 ?MAKE:  -pick add $@ %<
26 ?S:intsize:
27 ?S:     This variable contains the value of the INTSIZE symbol, which
28 ?S:     indicates to the C program how many bytes there are in an int.
29 ?S:.
30 ?S:longsize:
31 ?S:     This variable contains the value of the LONGSIZE symbol, which
32 ?S:     indicates to the C program how many bytes there are in a long.
33 ?S:.
34 ?S:shortsize:
35 ?S:     This variable contains the value of the SHORTSIZE symbol which
36 ?S:     indicates to the C program how many bytes there are in a short.
37 ?S:.
38 ?C:INTSIZE:
39 ?C:     This symbol contains the value of sizeof(int) so that the C
40 ?C:     preprocessor can make decisions based on it.
41 ?C:.
42 ?C:LONGSIZE:
43 ?C:     This symbol contains the value of sizeof(long) so that the C
44 ?C:     preprocessor can make decisions based on it.
45 ?C:.
46 ?C:SHORTSIZE:
47 ?C:     This symbol contains the value of sizeof(short) so that the C
48 ?C:     preprocessor can make decisions based on it.
49 ?C:.
50 ?H:#define INTSIZE $intsize             /**/
51 ?H:#define LONGSIZE $longsize           /**/
52 ?H:#define SHORTSIZE $shortsize         /**/
53 ?H:.
54 ?F:!intsize.out
55 : check for lengths of integral types
56 echo " "
57 case "$intsize" in
58 '')
59         echo "Checking to see how big your integers are..." >&4
60         $cat >intsize.c <<'EOCP'
61 #include <stdio.h>
62 main()
63 {
64 @if INTSIZE || intsize
65         printf("intsize=%d;\n", sizeof(int));
66 @end
67 @if LONGSIZE || longsize
68         printf("longsize=%d;\n", sizeof(long));
69 @end
70 @if SHORTSIZE || shortsize
71         printf("shortsize=%d;\n", sizeof(short));
72 @end
73         fflush(stdout);
74         exit(0);
75 }
76 EOCP
77 #       If $libs contains -lsfio, and sfio is mis-configured, then it
78 #       sometimes (apparently) runs and exits with a 0 status, but with no
79 #       output!.  Thus we check with test -s whether we actually got any
80 #       output.  I think it has to do with sfio's use of _exit vs. exit,
81 #       but I don't know for sure.  --Andy Dougherty  1/27/97.
82         if $cc $optimize $ccflags $ldflags -o intsize intsize.c $libs >/dev/null 2>&1 &&
83         ./intsize > intsize.out 2>/dev/null && test -s intsize.out ; then
84                 eval `$cat intsize.out`
85 @if INTSIZE || intsize
86                 echo "Your integers are $intsize bytes long."
87 @end
88 @if LONGSIZE || longsize
89                 echo "Your long integers are $longsize bytes long."
90 @end
91 @if SHORTSIZE || shortsize
92                 echo "Your short integers are $shortsize bytes long."
93 @end
94         else
95                 $cat >&4 <<EOM
96 !
97 Help! I can't compile and run the intsize test program: please enlighten me!
98 (This is probably a misconfiguration in your system or libraries, and
99 you really ought to fix it.  Still, I'll try anyway.)
100 !
101 EOM
102 @if INTSIZE || intsize
103                 dflt=4
104                 rp="What is the size of an integer (in bytes)?"
105                 . ./myread
106                 intsize="$ans"
107 @end
108 @if LONGSIZE || longsize
109                 dflt=$intsize
110                 rp="What is the size of a long integer (in bytes)?"
111                 . ./myread
112                 longsize="$ans"
113 @end
114 @if SHORTSIZE || shortsize
115                 dflt=2
116                 rp="What is the size of a short integer (in bytes)?"
117                 . ./myread
118                 shortsize="$ans"
119 @end
120         fi
121         ;;
122 esac
123 $rm -f intsize intsize.[co] intsize.out
124