Commit | Line | Data |
---|---|---|
5f51ce50 AD |
1 | ?RCS: $Id: ccflags.U,v 3.0.1.6 1994/10/29 16:07:02 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: This is the same as dist's ccflags unit except that perl uses | |
12 | ?RCS: -DDEBUGGING rather than -DDEBUG, and I also suggest a few other | |
13 | ?RCS: flags the user might set, such as -DCRIPPLED_CC and -D_POSIX_SOURCE. | |
14 | ?RCS: | |
15 | ?RCS: $Log: ccflags.U,v $ | |
16 | ?RCS: Revision 3.0.1.6 1994/10/29 16:07:02 ram | |
17 | ?RCS: patch36: gcc versionning no longer relies on the C compiler's name | |
18 | ?RCS: patch36: simplified check for gcc version checking (ADO) | |
19 | ?RCS: | |
20 | ?RCS: Revision 3.0.1.5 1994/08/29 16:06:35 ram | |
21 | ?RCS: patch32: propagate -posix flag from ccflags to ldflags | |
22 | ?RCS: | |
23 | ?RCS: Revision 3.0.1.4 1994/05/06 14:28:45 ram | |
24 | ?RCS: patch23: -fpcc-struct-return only needed in gcc 1.x (ADO) | |
25 | ?RCS: patch23: cppflags now computed on an option-by-option basis | |
26 | ?RCS: patch23: magically added cc flags now only done the first time | |
27 | ?RCS: | |
28 | ?RCS: Revision 3.0.1.3 1993/09/13 15:58:29 ram | |
29 | ?RCS: patch10: explicitely mention -DDEBUG just in case they need it (WAD) | |
30 | ?RCS: patch10: removed all the "tans" variable usage (WAD) | |
31 | ?RCS: | |
32 | ?RCS: Revision 3.0.1.2 1993/08/27 14:39:38 ram | |
33 | ?RCS: patch7: added support for OSF/1 machines | |
34 | ?RCS: | |
35 | ?RCS: Revision 3.0.1.1 1993/08/25 14:00:24 ram | |
36 | ?RCS: patch6: added defaults for cppflags, ccflags and ldflags | |
37 | ?RCS: | |
38 | ?RCS: Revision 3.0 1993/08/18 12:05:31 ram | |
39 | ?RCS: Baseline for dist 3.0 netwide release. | |
40 | ?RCS: | |
41 | ?MAKE:ccflags ldflags lkflags cppflags optimize: test cat Myread Guess \ | |
42 | Oldconfig +gccversion mips_type +usrinc package contains rm \ | |
43 | cppstdin cppminus cpprun cpplast | |
44 | ?MAKE: -pick add $@ %< | |
45 | ?S:ccflags: | |
46 | ?S: This variable contains any additional C compiler flags desired by | |
47 | ?S: the user. It is up to the Makefile to use this. | |
48 | ?S:. | |
49 | ?S:cppflags: | |
50 | ?S: This variable holds the flags that will be passed to the C pre- | |
51 | ?S: processor. It is up to the Makefile to use it. | |
52 | ?S:. | |
53 | ?S:optimize: | |
54 | ?S: This variable contains any optimizer/debugger flag that should be used. | |
55 | ?S: It is up to the Makefile to use it. | |
56 | ?S:. | |
57 | ?S:ldflags: | |
58 | ?S: This variable contains any additional C loader flags desired by | |
59 | ?S: the user. It is up to the Makefile to use this. | |
60 | ?S:. | |
61 | ?S:lkflags: | |
62 | ?S: This variable contains any additional C partial linker flags desired by | |
63 | ?S: the user. It is up to the Makefile to use this. | |
64 | ?S:. | |
65 | ?T:inctest thisincl xxx flag inclwanted ftry previous | |
66 | ?D:cppflags='' | |
67 | ?D:ccflags='' | |
68 | ?D:ldflags='' | |
69 | ?INIT:: no include file wanted by default | |
70 | ?INIT:inclwanted='' | |
71 | ?INIT: | |
72 | : determine optimize, if desired, or use for debug flag also | |
73 | case "$optimize" in | |
74 | ' ') dflt='none';; | |
75 | '') dflt='-O';; | |
76 | *) dflt="$optimize";; | |
77 | esac | |
78 | $cat <<EOH | |
79 | ||
80 | Some C compilers have problems with their optimizers, by default, $package | |
81 | compiles with the -O flag to use the optimizer. Alternately, you might want | |
82 | to use the symbolic debugger, which uses the -g flag (on traditional Unix | |
83 | systems). Either flag can be specified here. To use neither flag, specify | |
84 | the word "none". | |
85 | ||
86 | EOH | |
87 | rp="What optimizer/debugger flag should be used?" | |
88 | . ./myread | |
89 | optimize="$ans" | |
90 | case "$optimize" in | |
91 | 'none') optimize=" ";; | |
92 | esac | |
93 | ||
94 | dflt='' | |
95 | case "$ccflags" in | |
96 | '') | |
97 | case "$gccversion" in | |
98 | 1*) dflt='-fpcc-struct-return' ;; | |
99 | esac | |
100 | case "$optimize" in | |
101 | *-g*) dflt="$dflt -DDEBUGGING";; | |
102 | esac | |
103 | ?X: check for POSIXized ISC | |
104 | case "$gccversion" in | |
105 | 2*) if test -d /etc/conf/kconfig.d && | |
106 | $contains _POSIX_VERSION $usrinc/sys/unistd.h >/dev/null 2>&1 | |
107 | then | |
108 | dflt="$dflt -posix" | |
109 | fi | |
110 | ;; | |
111 | esac | |
112 | ;; | |
113 | esac | |
114 | ||
115 | ?X: In USG mode, a MIPS system may need some BSD includes | |
116 | case "$mips_type" in | |
117 | *BSD*) ;; | |
118 | '') ;; | |
119 | *) inclwanted="$inclwanted $usrinc/bsd";; | |
120 | esac | |
121 | for thisincl in $inclwanted; do | |
122 | if $test -d $thisincl; then | |
123 | if $test x$thisincl != x$usrinc; then | |
124 | case "$dflt" in | |
125 | *$thisincl*);; | |
126 | *) dflt="$dflt -I$thisincl";; | |
127 | esac | |
128 | fi | |
129 | fi | |
130 | done | |
131 | ||
132 | ?X: Include test function (header, symbol) | |
133 | inctest='if $contains $2 $usrinc/$1 >/dev/null 2>&1; then | |
134 | xxx=true; | |
135 | elif $contains $2 $usrinc/sys/$1 >/dev/null 2>&1; then | |
136 | xxx=true; | |
137 | else | |
138 | xxx=false; | |
139 | fi; | |
140 | if $xxx; then | |
141 | case "$dflt" in | |
142 | *$2*);; | |
143 | *) dflt="$dflt -D$2";; | |
144 | esac; | |
145 | fi' | |
146 | ||
147 | ?X: | |
148 | ?X: SCO unix uses NO_PROTOTYPE instead of _NO_PROTO | |
149 | ?X: OSF/1 uses __LANGUAGE_C__ instead of LANGUAGE_C | |
150 | ?X: | |
151 | if ./osf1; then | |
152 | set signal.h __LANGUAGE_C__; eval $inctest | |
153 | else | |
154 | set signal.h LANGUAGE_C; eval $inctest | |
155 | fi | |
156 | set signal.h NO_PROTOTYPE; eval $inctest | |
157 | set signal.h _NO_PROTO; eval $inctest | |
158 | ||
159 | case "$dflt" in | |
160 | '') dflt=none;; | |
161 | esac | |
162 | case "$ccflags" in | |
163 | '') ;; | |
164 | *) dflt="$ccflags";; | |
165 | esac | |
166 | $cat <<EOH | |
167 | ||
168 | Your C compiler may want other flags. For this question you should include | |
169 | -I/whatever and -DWHATEVER flags and any other flags used by the C compiler, | |
170 | but you should NOT include libraries or ld flags like -lwhatever. If you | |
171 | want $package to honor its debug switch, you should include -DDEBUGGING here. | |
172 | Your C compiler might also need additional flags, such as -D_POSIX_SOURCE, | |
173 | -DHIDEMYMALLOC or -DCRIPPLED_CC. | |
174 | ||
175 | To use no flags, specify the word "none". | |
176 | ||
177 | EOH | |
178 | ?X: strip leading space | |
179 | set X $dflt | |
180 | shift | |
181 | dflt=${1+"$@"} | |
182 | rp="Any additional cc flags?" | |
183 | . ./myread | |
184 | case "$ans" in | |
185 | none) ccflags='';; | |
186 | *) ccflags="$ans";; | |
187 | esac | |
188 | ||
189 | : the following weeds options from ccflags that are of no interest to cpp | |
190 | cppflags="$ccflags" | |
191 | case "$gccversion" in | |
192 | 1*) cppflags="$cppflags -D__GNUC__" | |
193 | esac | |
194 | case "$mips_type" in | |
195 | '');; | |
196 | *BSD*) cppflags="$cppflags -DSYSTYPE_BSD43";; | |
197 | esac | |
198 | case "$cppflags" in | |
199 | '');; | |
200 | *) | |
201 | echo " " | |
202 | echo "Let me guess what the preprocessor flags are..." >&4 | |
203 | set X $cppflags | |
204 | shift | |
205 | cppflags='' | |
206 | $cat >cpp.c <<'EOM' | |
207 | #define BLURFL foo | |
208 | ||
209 | BLURFL xx LFRULB | |
210 | EOM | |
211 | ?X: | |
212 | ?X: For each cc flag, try it out with both cppstdin and cpprun, since the | |
213 | ?X: first is almost surely a cc wrapper. We have to try both in case | |
214 | ?X: of cc flags like '-Olimit 2900' that are actually two words... | |
215 | ?X: | |
216 | previous='' | |
217 | for flag in $* | |
218 | do | |
219 | case "$flag" in | |
220 | -*) ftry="$flag";; | |
221 | *) ftry="$previous $flag";; | |
222 | esac | |
223 | if $cppstdin -DLFRULB=bar $ftry $cppminus <cpp.c \ | |
224 | >cpp1.out 2>/dev/null && \ | |
225 | $cpprun -DLFRULB=bar $ftry $cpplast <cpp.c \ | |
226 | >cpp2.out 2>/dev/null && \ | |
227 | $contains 'foo.*xx.*bar' cpp1.out >/dev/null 2>&1 && \ | |
228 | $contains 'foo.*xx.*bar' cpp2.out >/dev/null 2>&1 | |
229 | then | |
230 | cppflags="$cppflags $ftry" | |
231 | previous='' | |
232 | else | |
233 | previous="$flag" | |
234 | fi | |
235 | done | |
236 | set X $cppflags | |
237 | shift | |
238 | cppflags=${1+"$@"} | |
239 | case "$cppflags" in | |
240 | *-*) echo "They appear to be: $cppflags";; | |
241 | esac | |
242 | $rm -f cpp.c cpp?.out | |
243 | ;; | |
244 | esac | |
245 | ||
246 | : flags used in final linking phase | |
247 | case "$ldflags" in | |
248 | '') if ./venix; then | |
249 | dflt='-i -z' | |
250 | else | |
251 | dflt='' | |
252 | fi | |
253 | case "$ccflags" in | |
254 | *-posix*) dflt="$dflt -posix" ;; | |
255 | esac | |
256 | case "$dflt" in | |
257 | '') dflt='none' ;; | |
258 | esac | |
259 | ;; | |
260 | *) dflt="$ldflags";; | |
261 | esac | |
262 | echo " " | |
263 | rp="Any additional ld flags (NOT including libraries)?" | |
264 | . ./myread | |
265 | case "$ans" in | |
266 | none) ldflags='';; | |
267 | *) ldflags="$ans";; | |
268 | esac | |
269 | rmlist="$rmlist pdp11" | |
270 | ||
271 | @if lkflags | |
272 | : partial linking may need other flags | |
273 | case "$lkflags" in | |
274 | '') case "$ldflags" in | |
275 | '') dflt='none';; | |
276 | *) dflt="$ldflags";; | |
277 | esac;; | |
278 | *) dflt="$lkflags";; | |
279 | esac | |
280 | echo " " | |
281 | rp="Partial linking flags to be used (NOT including -r)?" | |
282 | . ./myread | |
283 | case "$ans" in | |
284 | none) lkflags='';; | |
285 | *) lkflags="$ans";; | |
286 | esac | |
287 | ||
288 | @end |