This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Put pthread in front of libswanted and add cl
[metaconfig.git] / U / modified / cppstdin.U
1 ?RCS: $Id: cppstdin.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: cppstdin.U,v $
12 ?RCS: Revision 3.0.1.4  1994/10/29  16:08:34  ram
13 ?RCS: patch36: added ?F: line for metalint file checking
14 ?RCS:
15 ?RCS: Revision 3.0.1.3  1994/01/24  14:05:38  ram
16 ?RCS: patch16: comment for CPPLAST was missing
17 ?RCS:
18 ?RCS: Revision 3.0.1.2  1993/12/15  08:18:58  ram
19 ?RCS: patch15: new variables cpprun and cpplast, guaranteed wrapper-free
20 ?RCS: patch15: cppstdin now tries to use cc, even at the cost of a wrapper
21 ?RCS:
22 ?RCS: Revision 3.0.1.1  1993/08/25  14:00:53  ram
23 ?RCS: patch6: remove wrapper when not actually used
24 ?RCS:
25 ?RCS: Revision 3.0  1993/08/18  12:05:38  ram
26 ?RCS: Baseline for dist 3.0 netwide release.
27 ?RCS:
28 ?MAKE:cppstdin cppminus cpprun cpplast: contains test \
29         Myread Oldconfig Loc cpp +cc rm hint osname gccversion
30 ?MAKE:  -pick add $@ %<
31 ?S:cppstdin:
32 ?S:     This variable contains the command which will invoke the C
33 ?S:     preprocessor on standard input and put the output to stdout.
34 ?S:     It is primarily used by other Configure units that ask about
35 ?S:     preprocessor symbols.
36 ?S:.
37 ?S:cppminus:
38 ?S:     This variable contains the second part of the string which will invoke
39 ?S:     the C preprocessor on the standard input and produce to standard
40 ?S:     output.  This variable will have the value "-" if cppstdin needs
41 ?S:     a minus to specify standard input, otherwise the value is "".
42 ?S:.
43 ?S:cpprun:
44 ?S:     This variable contains the command which will invoke a C preprocessor
45 ?S:     on standard input and put the output to stdout. It is guaranteed not
46 ?S:     to be a wrapper and may be a null string if no preprocessor can be
47 ?S:     made directly available. This preprocessor might be different from the
48 ?S:     one used by the C compiler. Don't forget to append cpplast after the
49 ?S:     preprocessor options.
50 ?S:.
51 ?S:cpplast:
52 ?S:     This variable has the same functionality as cppminus, only it applies
53 ?S:     to cpprun and not cppstdin.
54 ?S:.
55 ?C:CPPSTDIN:
56 ?C:     This symbol contains the first part of the string which will invoke
57 ?C:     the C preprocessor on the standard input and produce to standard
58 ?C:     output.  Typical value of "cc -E" or "/lib/cpp", but it can also
59 ?C:     call a wrapper. See CPPRUN.
60 ?C:.
61 ?C:CPPMINUS:
62 ?C:     This symbol contains the second part of the string which will invoke
63 ?C:     the C preprocessor on the standard input and produce to standard
64 ?C:     output.  This symbol will have the value "-" if CPPSTDIN needs a minus
65 ?C:     to specify standard input, otherwise the value is "".
66 ?C:.
67 ?C:CPPRUN:
68 ?C:     This symbol contains the string which will invoke a C preprocessor on
69 ?C:     the standard input and produce to standard output. It needs to end
70 ?C:     with CPPLAST, after all other preprocessor flags have been specified.
71 ?C:     The main difference with CPPSTDIN is that this program will never be a
72 ?C:     pointer to a shell wrapper, i.e. it will be empty if no preprocessor is
73 ?C:     available directly to the user. Note that it may well be different from
74 ?C:     the preprocessor used to compile the C program.
75 ?C:.
76 ?C:CPPLAST:
77 ?C:     This symbol is intended to be used along with CPPRUN in the same manner
78 ?C:     symbol CPPMINUS is used with CPPSTDIN. It contains either "-" or "".
79 ?C:.
80 ?H:#define CPPSTDIN "$cppstdin"
81 ?H:#define CPPMINUS "$cppminus"
82 ?H:#define CPPRUN "$cpprun"
83 ?H:#define CPPLAST "$cpplast"
84 ?H:.
85 ?F:cppstdin !testcpp.out !testcpp.c
86 ?T:wrapper x_cpp x_minus ok
87 ?LINT:extern cppflags
88 : see how we invoke the C preprocessor
89 echo " "
90 echo "Now, how can we feed standard input to your C preprocessor..." >&4
91 cat <<'EOT' >testcpp.c
92 #define ABC abc
93 #define XYZ xyz
94 ABC.XYZ
95 EOT
96 cd ..
97 if test ! -f cppstdin; then
98         if test "X$osname" = "Xaix" -a "X$gccversion" = X; then
99                 # AIX cc -E doesn't show the absolute headerfile
100                 # locations but we'll cheat by using the -M flag.
101                 echo 'cat >.$$.c; rm -f .$$.u; '"$cc"' ${1+"$@"} -M -c .$$.c 2>/dev/null; test -s .$$.u && awk '"'"'$2 ~ /\.h$/ { print "# 0 \""$2"\"" }'"'"' .$$.u; rm -f .$$.o .$$.u; '"$cc"' -E ${1+"$@"} .$$.c; rm .$$.c' > cppstdin
102         else
103                 echo 'cat >.$$.c; '"$cc $cppflags"' -E ${1+"$@"} .$$.c; rm .$$.c' >cppstdin
104         fi
105 else
106         echo "Keeping your $hint cppstdin wrapper."
107 fi
108 chmod 755 cppstdin
109 wrapper=`pwd`/cppstdin
110 ok='false'
111 cd UU
112
113 ?X:
114 ?X: We'll run the cpp tests again if we don't have any valid C preprocessor
115 ?X: yet or don't know how to proceed without a wrapper (in which case cpprun
116 ?X: is empty and that's really annoying...)
117 ?X:
118 if $test "X$cppstdin" != "X" && \
119         $cppstdin $cppminus <testcpp.c >testcpp.out 2>&1 && \
120         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
121 then
122         echo "You used to use $cppstdin $cppminus so we'll use that again."
123         case "$cpprun" in
124         '') echo "But let's see if we can live without a wrapper..." ;;
125         *)
126                 if $cpprun $cpplast <testcpp.c >testcpp.out 2>&1 && \
127                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
128                 then
129                         echo "(And we'll use $cpprun $cpplast to preprocess directly.)"
130                         ok='true'
131                 else
132                         echo "(However, $cpprun $cpplast does not work, let's see...)"
133                 fi
134                 ;;
135         esac
136 else
137         case "$cppstdin" in
138         '') ;;
139         *)
140                 echo "Good old $cppstdin $cppminus does not seem to be of any help..."
141                 ;;
142         esac
143 fi
144
145 if $ok; then
146         : nothing
147 elif echo 'Maybe "'"$cc"' -E" will work...'; \
148         $cc -E <testcpp.c >testcpp.out 2>&1; \
149         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
150         echo "Yup, it does."
151         x_cpp="$cc $cppflags -E"
152         x_minus='';
153 elif echo 'Nope...maybe "'"$cc"' -E -" will work...'; \
154         $cc -E - <testcpp.c >testcpp.out 2>&1; \
155         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
156         echo "Yup, it does."
157         x_cpp="$cc $cppflags -E"
158         x_minus='-';
159 elif echo 'Nope...maybe "'"$cc"' -P" will work...'; \
160         $cc -P <testcpp.c >testcpp.out 2>&1; \
161         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
162         echo "Yipee, that works!"
163         x_cpp="$cc $cppflags -P"
164         x_minus='';
165 elif echo 'Nope...maybe "'"$cc"' -P -" will work...'; \
166         $cc -P - <testcpp.c >testcpp.out 2>&1; \
167         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
168         echo "At long last!"
169         x_cpp="$cc $cppflags -P"
170         x_minus='-';
171 elif echo 'No such luck, maybe "'$cpp'" will work...'; \
172         $cpp <testcpp.c >testcpp.out 2>&1; \
173         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
174         echo "It works!"
175         x_cpp="$cpp $cppflags"
176         x_minus='';
177 elif echo 'Nixed again...maybe "'$cpp' -" will work...'; \
178         $cpp - <testcpp.c >testcpp.out 2>&1; \
179         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
180         echo "Hooray, it works!  I was beginning to wonder."
181         x_cpp="$cpp $cppflags"
182         x_minus='-';
183 elif echo 'Uh-uh.  Time to get fancy.  Trying a wrapper...'; \
184         $wrapper <testcpp.c >testcpp.out 2>&1; \
185         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
186         x_cpp="$wrapper"
187         x_minus=''
188         echo "Eureka!"
189 else
190         dflt=''
191         rp="No dice.  I can't find a C preprocessor.  Name one:"
192         . ./myread
193         x_cpp="$ans"
194         x_minus=''
195         $x_cpp <testcpp.c >testcpp.out 2>&1
196         if $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1 ; then
197                 echo "OK, that will do." >&4
198         else
199 echo "Sorry, I can't get that to work.  Go find one and rerun Configure." >&4
200                 exit 1
201         fi
202 fi
203
204 case "$ok" in
205 false)
206         cppstdin="$x_cpp"
207         cppminus="$x_minus"
208         cpprun="$x_cpp"
209         cpplast="$x_minus"
210 ?X:
211 ?X: If /lib/cpp is used, try using a wrapper to increase our chances to have
212 ?X: the C compiler and our $cppstdin agree on the same symbols... However,
213 ?X: since cpprun is guaranteed not to be a wrapper, we must clear it if the
214 ?X: only preprocessor we found was a wrapper, with all our luck...
215 ?X:
216         set X $x_cpp
217         shift
218         case "$1" in
219         "$cpp")
220                 echo "Perhaps can we force $cc -E using a wrapper..."
221                 if $wrapper <testcpp.c >testcpp.out 2>&1; \
222                         $contains 'abc.*xyz' testcpp.out >/dev/null 2>&1
223                 then
224                         echo "Yup, we can."
225                         cppstdin="$wrapper"
226                         cppminus='';
227                 else
228                         echo "Nope, we'll have to live without it..."
229                 fi
230                 ;;
231         esac
232         case "$cpprun" in
233         "$wrapper")
234                 cpprun=''
235                 cpplast=''
236                 ;;
237         esac
238         ;;
239 esac
240
241 case "$cppstdin" in
242 "$wrapper"|'cppstdin') ;;
243 *) $rm -f $wrapper;;
244 esac
245 $rm -f testcpp.c testcpp.out
246