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 / voidflags.U
1 ?RCS: $Id: voidflags.U,v 3.0.1.2 1997/02/28 16:27:58 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: 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 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 ?X:     Exceptionally, we have to explicitely alias the symbol name for
30 ?X: config_h.SH, otherwise the comment would not appear.
31 ?C:VOIDFLAGS ~ %<:
32 ?C:     This symbol indicates how much support of the void type is given by this
33 ?C:     compiler.  What various bits mean:
34 ?C:
35 ?C:         1 = supports declaration of void
36 ?C:         2 = supports arrays of pointers to functions returning void
37 ?C:         4 = supports comparisons between pointers to void functions and
38 ?C:                 addresses of void functions
39 ?C:         8 = suports declaration of generic void pointers
40 ?C:
41 ?C:     The package designer should define VOIDUSED to indicate the requirements
42 ?C:     of the package.  This can be done either by #defining VOIDUSED before
43 ?C:     including config.h, or by defining defvoidused in Myinit.U.  If the
44 ?C:     latter approach is taken, only those flags will be tested.  If the
45 ?C:     level of void support necessary is not present, defines void to int.
46 ?C:.
47 ?H:?%<:#ifndef VOIDUSED
48 ?H:?%<:#define VOIDUSED $defvoidused
49 ?H:?%<:#endif
50 ?H:?%<:#define VOIDFLAGS $voidflags
51 ?H:?%<:#if (VOIDFLAGS & VOIDUSED) != VOIDUSED
52 ?H:?%<:#define void int         /* is void to be avoided? */
53 ?H:?%<:#define M_VOID                   /* Xenix strikes again */
54 ?H:?%<:#endif
55 ?H:.
56 ?W:%<:void
57 ?INIT:: full support for void wanted by default
58 ?INIT:defvoidused=15
59 ?INIT:
60 ?LINT:describe defvoidused
61 ?LINT:known void M_VOID VOIDUSED
62 : check for void type
63 echo " "
64 echo "Checking to see how well your C compiler groks the void type..." >&4
65 echo " "
66 $cat >&4 <<EOM
67   Support flag bits are:
68     1: basic void declarations.
69     2: arrays of pointers to functions returning void.
70     4: operations between pointers to and addresses of void functions.
71     8: generic void pointers.
72 EOM
73 echo " "
74 case "$voidflags" in
75 '')
76         $cat >try.c <<'EOCP'
77 #if TRY & 1
78 void sub() {
79 #else
80 sub() {
81 #endif
82         extern void moo();      /* function returning void */
83         void (*goo)();          /* ptr to func returning void */
84 #if TRY & 8
85         void *hue;              /* generic ptr */
86 #endif
87 #if TRY & 2
88         void (*foo[10])();
89 #endif
90
91 #if TRY & 4
92         if(goo == moo) {
93                 exit(0);
94         }
95 #endif
96         exit(0);
97 }
98 main() { sub(); }
99 EOCP
100 ?X: This unit used to use cc -S in those tests to try to speed up things, but
101 ?X: unfortunately, AIX 3.2 does not support this option.
102         if $cc $ccflags -c -DTRY=$defvoidused try.c >.out 2>&1 ; then
103                 voidflags=$defvoidused
104         echo "It appears to support void to the level $package wants ($defvoidused)."
105                 if $contains warning .out >/dev/null 2>&1; then
106                         echo "However, you might get some warnings that look like this:"
107                         $cat .out
108                 fi
109         else
110 echo "Hmm, your compiler has some difficulty with void. Checking further..." >&4
111                 if $cc $ccflags -c -DTRY=1 try.c >/dev/null 2>&1; then
112                         echo "It supports 1..."
113                         if $cc $ccflags -c -DTRY=3 try.c >/dev/null 2>&1; then
114                                 echo "It also supports 2..."
115                                 if $cc $ccflags -c -DTRY=7 try.c >/dev/null 2>&1; then
116                                         voidflags=7
117                                         echo "And it supports 4 but not 8 definitely."
118                                 else
119                                         echo "It doesn't support 4..."
120                                         if $cc $ccflags -c -DTRY=11 try.c >/dev/null 2>&1; then
121                                                 voidflags=11
122                                                 echo "But it supports 8."
123                                         else
124                                                 voidflags=3
125                                                 echo "Neither does it support 8."
126                                         fi
127                                 fi
128                         else
129                                 echo "It does not support 2..."
130                                 if $cc $ccflags -c -DTRY=13 try.c >/dev/null 2>&1; then
131                                         voidflags=13
132                                         echo "But it supports 4 and 8."
133                                 else
134                                         if $cc $ccflags -c -DTRY=5 try.c >/dev/null 2>&1; then
135                                                 voidflags=5
136                                                 echo "And it supports 4 but has not heard about 8."
137                                         else
138                                                 echo "However it supports 8 but not 4."
139                                         fi
140                                 fi
141                         fi
142                 else
143                         echo "There is no support at all for void."
144                         voidflags=0
145                 fi
146         fi
147 esac
148 ?X: Only prompt user if support does not match the level we want
149 case "$voidflags" in
150 "$defvoidused") ;;
151 *)
152         dflt="$voidflags";
153         rp="Your void support flags add up to what?"
154         . ./myread
155         voidflags="$ans"
156         ;;
157 esac
158 $rm -f try.* .out
159