This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add the files from dist/meta to perl's repo
[metaconfig.git] / dist / U / voidflags.U
CommitLineData
d8875586
MBT
1?RCS: $Id: voidflags.U 1 2006-08-24 12:32:52Z rmanfredi $
2?RCS:
3?RCS: Copyright (c) 1991-1997, 2004-2006, 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 4.0.
10?RCS:
11?RCS: $Log: voidflags.U,v $
12?RCS: Revision 3.0.1.2 1997/02/28 16:27:58 ram
13?RCS: patch61: don't prompt them if the void support is high enough for us
14?RCS:
15?RCS: Revision 3.0.1.1 1995/01/11 15:37:44 ram
16?RCS: patch45: cosmetic change to avoid spurious blank lines when using -s
17?RCS:
18?RCS: Revision 3.0 1993/08/18 12:10:01 ram
19?RCS: Baseline for dist 3.0 netwide release.
20?RCS:
21?MAKE:voidflags defvoidused: cat sed rm contains +cc +ccflags package \
22 Oldconfig Myread
23?MAKE: -pick add $@ %<
24?S:voidflags:
25?S: This variable contains the eventual value of the VOIDFLAGS symbol,
26?S: which indicates how much support of the void type is given by this
27?S: compiler. See VOIDFLAGS for more info.
28?S:.
29?S:defvoidused:
30?S: This variable contains the default value of the VOIDUSED symbol (15).
31?S:.
32?X: Exceptionally, we have to explicitly alias the symbol name for
33?X: config_h.SH, otherwise the comment would not appear.
34?C:VOIDFLAGS ~ %<:
35?C: This symbol indicates how much support of the void type is given by this
36?C: compiler. What various bits mean:
37?C:
38?C: 1 = supports declaration of void
39?C: 2 = supports arrays of pointers to functions returning void
40?C: 4 = supports comparisons between pointers to void functions and
41?C: addresses of void functions
42?C: 8 = suports declaration of generic void pointers
43?C:
44?C: The package designer should define VOIDUSED to indicate the requirements
45?C: of the package. This can be done either by #defining VOIDUSED before
46?C: including config.h, or by defining defvoidused in Myinit.U. If the
47?C: latter approach is taken, only those flags will be tested. If the
48?C: level of void support necessary is not present, defines void to int.
49?C:.
50?H:?%<:#ifndef VOIDUSED
51?H:?%<:#define VOIDUSED $defvoidused
52?H:?%<:#endif
53?H:?%<:#define VOIDFLAGS $voidflags
54?H:?%<:#if (VOIDFLAGS & VOIDUSED) != VOIDUSED
55?H:?%<:#define void int /* is void to be avoided? */
56?H:?%<:#define M_VOID /* Xenix strikes again */
57?H:?%<:#endif
58?H:.
59?W:%<:void
60?F:!.out !try.c !flags
61?LINT:usefile .out flags try.c
62?INIT:: full support for void wanted by default
63?INIT:defvoidused=15
64?INIT:
65?LINT:known void M_VOID VOIDUSED
66: check for void type
67echo " "
68echo "Checking to see how well your C compiler groks the void type..." >&4
69$cat >flags <<EOM
70
71 Support flag bits are:
72 1: basic void declarations.
73 2: arrays of pointers to functions returning void.
74 4: operations between pointers to and addresses of void functions.
75 8: generic void pointers.
76
77EOM
78case "$voidflags" in
79'')
80 $cat >try.c <<'EOCP'
81#if TRY & 1
82void sub() {
83#else
84sub() {
85#endif
86 extern void moo(); /* function returning void */
87 void (*goo)(); /* ptr to func returning void */
88#if TRY & 8
89 void *hue; /* generic ptr */
90#endif
91#if TRY & 2
92 void (*foo[10])();
93#endif
94
95#if TRY & 4
96 if(goo == moo) {
97 exit(0);
98 }
99#endif
100 exit(0);
101}
102int main() { sub(); }
103EOCP
104?X: This unit used to use cc -S in those tests to try to speed up things, but
105?X: unfortunately, AIX 3.2 does not support this option.
106 if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
107 voidflags=$defvoidused
108 echo "Good. It appears to support void to the level $package wants."
109 if $contains warning .out >/dev/null 2>&1; then
110 echo "However, you might get some warnings that look like this:"
111 $sed -e 's/^/ /' .out
112 fi
113 else
114echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
115 $cat >&4 flags
116 $rm -f flags
117 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
118 echo "It supports 1..."
119 if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
120 echo "It also supports 2..."
121 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
122 voidflags=7
123 echo "And it supports 4 but not 8 definitely."
124 else
125 echo "It doesn't support 4..."
126 if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
127 voidflags=11
128 echo "But it supports 8."
129 else
130 voidflags=3
131 echo "Neither does it support 8."
132 fi
133 fi
134 else
135 echo "It does not support 2..."
136 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
137 voidflags=13
138 echo "But it supports 4 and 8."
139 else
140 if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
141 voidflags=5
142 echo "And it supports 4 but has not heard about 8."
143 else
144 echo "However it supports 8 but not 4."
145 fi
146 fi
147 fi
148 else
149 echo "There is no support at all for void."
150 voidflags=0
151 fi
152 fi
153esac
154?X: Only prompt user if support does not match the level we want
155case "$voidflags" in
156"$defvoidused")
157 echo "Good. I already know it supports void to the level $package wants."
158 ;;
159*)
160 dflt="$voidflags";
161 test -f flags && $cat flags
162 rp="Your void support flags add up to what?"
163 . ./myread
164 voidflags="$ans"
165 ;;
166esac
167$rm -f try.* .out flags
168