This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
evat => eval as found by Tom Hukins
[metaconfig.git] / U / modified / i_varhdr.U
1 ?RCS: $Id: i_varhdr.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 License,
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 License; 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: 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 varargs 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 varargs 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         return 0;
113 }
114 EOP
115 $cat > varargs <<EOP
116 $startsh
117 if $cc -c $ccflags -D\$1 varargs.c >/dev/null 2>&1; then
118         echo "true"
119 else
120         echo "false"
121 fi
122 $rm -f varargs$_o
123 EOP
124 chmod +x varargs
125
126 : now check which varargs header should be included
127 echo " "
128 i_varhdr=''
129 val=''
130 case "$valstd" in
131 "$define")
132         if `./varargs I_STDARG`; then
133                 val='stdarg.h'
134         elif `./varargs I_VARARGS`; then
135                 val='varargs.h'
136         fi
137         ;;
138 *)
139         if `./varargs I_VARARGS`; then
140                 val='varargs.h'
141         fi
142         ;;
143 esac
144 case "$val" in
145 '')
146         echo " "
147         echo "*** WHOA THERE!!! ***" >&4
148         echo "    Your C compiler \"$cc\" doesn't seem to support stdarg or varargs!" >&4
149         case "$knowitall" in
150         '')
151         echo "    I'm giving up; maybe you can try again with a different compiler?" >&4
152                 exit 1
153                 ;;
154         esac
155 echo "I could not find the definition for va_dcl... You have problems..." >&4
156         val="$undef"; set i_stdarg; eval $setvar
157         val="$undef"; set i_varargs; eval $setvar
158         ;;
159 *)
160         set i_varhdr
161         eval $setvar
162         case "$i_varhdr" in
163         stdarg.h)
164                 val="$define"; set i_stdarg; eval $setvar
165                 val="$undef"; set i_varargs; eval $setvar
166                 ;;
167         varargs.h)
168                 val="$undef"; set i_stdarg; eval $setvar
169                 val="$define"; set i_varargs; eval $setvar
170                 ;;
171         esac
172         echo "We'll include <$i_varhdr> to get va_dcl definition." >&4;;
173 esac
174 $rm -f varargs*
175