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 / i_varhdr.U
1 ?RCS: $Id: i_varhdr.U,v 3.0.1.3 1997/02/28 15:54:42 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: i_varhdr.U,v $
12 ?RCS: Revision 3.0.1.3  1997/02/28  15:54:42  ram
13 ?RCS: patch61: varargs script now starts with leading "startsh"
14 ?RCS:
15 ?RCS: Revision 3.0.1.2  1994/10/29  16:21:02  ram
16 ?RCS: patch36: added ?F: line for metalint file checking
17 ?RCS:
18 ?RCS: Revision 3.0.1.1  1994/05/13  15:26:05  ram
19 ?RCS: patch27: this unit now supersedes old i_stdarg.U and i_varargs.U
20 ?RCS: patch27: modified to avoid spurious Whoa warnings (ADO)
21 ?RCS:
22 ?RCS: Revision 3.0  1993/08/18  12:08:49  ram
23 ?RCS: Baseline for dist 3.0 netwide release.
24 ?RCS:
25 ?MAKE:i_stdarg i_varargs i_varhdr: cat +cc +ccflags rm test Setvar \
26         Findhdr startsh _o
27 ?MAKE:  -pick add $@ %<
28 ?S:i_stdarg:
29 ?S:     This variable conditionally defines the I_STDARG symbol, which
30 ?S:     indicates to the C program that <stdarg.h> exists and should
31 ?S:     be included.
32 ?S:.
33 ?S:i_varargs:
34 ?S:     This variable conditionally defines I_VARARGS, which indicates
35 ?S:     to the C program that it should include <varargs.h>.
36 ?S:.
37 ?S:i_varhdr:
38 ?S:     Contains the name of the header to be included to get va_dcl definition.
39 ?S:     Typically one of varargs.h or stdarg.h.
40 ?S:.
41 ?C:I_STDARG:
42 ?C:     This symbol, if defined, indicates that <stdarg.h> exists and should
43 ?C:     be included.
44 ?C:.
45 ?C:I_VARARGS:
46 ?C:     This symbol, if defined, indicates to the C program that it should
47 ?C:     include <varargs.h>.
48 ?C:.
49 ?H:#$i_stdarg I_STDARG          /**/
50 ?H:#$i_varargs I_VARARGS        /**/
51 ?H:.
52 ?W:%<:va_dcl
53 ?F:!varargs
54 ?T:valstd
55 ?LINT:set i_stdarg i_varargs
56 ?X:
57 ?X: Don't use setvar because the varags test below might override these.
58 ?X: Actually, the messages here are just informative. We don't wish to set
59 ?X: i_varargs or i_stdarg to their final value before knowing which of the
60 ?X: two we'll include.
61 ?X:
62 : see if stdarg is available
63 echo " "
64 if $test `./findhdr stdarg.h`; then
65         echo "<stdarg.h> found." >&4
66         valstd="$define"
67 else
68         echo "<stdarg.h> NOT found." >&4
69         valstd="$undef"
70 fi
71
72 : see if varags is available
73 echo " "
74 if $test `./findhdr varargs.h`; then
75         echo "<varargs.h> found." >&4
76 else
77         echo "<varargs.h> NOT found, but that's ok (I hope)." >&4
78 fi
79
80 ?X:
81 ?X: if you have stdarg.h, you need to support prototypes to actually use it;
82 ?X: but if stdarg.h exists and the compiler doesn't support prototypes (for some
83 ?X: bizarre reason), we'll fall back to varargs.h anyway so it's not so bad.
84 ?X:
85 : set up the varargs testing programs
86 $cat > varargs.c <<EOP
87 #ifdef I_STDARG
88 #include <stdarg.h>
89 #endif
90 #ifdef I_VARARGS
91 #include <varargs.h>
92 #endif
93
94 #ifdef I_STDARG
95 int f(char *p, ...)
96 #else
97 int f(va_alist)
98 va_dcl
99 #endif
100 {
101         va_list ap;
102 #ifndef I_STDARG
103         char *p;
104 #endif
105 #ifdef I_STDARG
106         va_start(ap,p);
107 #else
108         va_start(ap);
109         p = va_arg(ap, char *);
110 #endif
111         va_end(ap);
112 }
113 EOP
114 $cat > varargs <<EOP
115 $startsh
116 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
117         echo "true"
118 else
119         echo "false"
120 fi
121 $rm -f varargs$_o
122 EOP
123 chmod +x varargs
124
125 : now check which varargs header should be included
126 echo " "
127 i_varhdr=''
128 case "$valstd" in
129 "$define")
130         if `./varargs I_STDARG`; then
131                 val='stdarg.h'
132         elif `./varargs I_VARARGS`; then
133                 val='varargs.h'
134         fi
135         ;;
136 *)
137         if `./varargs I_VARARGS`; then
138                 val='varargs.h'
139         fi
140         ;;
141 esac
142 case "$val" in
143 '')
144 echo "I could not find the definition for va_dcl... You have problems..." >&4
145         val="$undef"; set i_stdarg; eval $setvar
146         val="$undef"; set i_varargs; eval $setvar
147         ;;
148 *) 
149         set i_varhdr
150         eval $setvar
151         case "$i_varhdr" in
152         stdarg.h)
153                 val="$define"; set i_stdarg; eval $setvar
154                 val="$undef"; set i_varargs; eval $setvar
155                 ;;
156         varargs.h)
157                 val="$undef"; set i_stdarg; eval $setvar
158                 val="$define"; set i_varargs; eval $setvar
159                 ;;
160         esac
161         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
162 esac
163 $rm -f varargs*
164