Commit | Line | Data |
a02608de |
1 | case $PERL_CONFIG_SH in |
1c3d792e |
2 | '') |
a0d0e21e |
3 | if test -f config.sh; then TOP=.; |
4 | elif test -f ../config.sh; then TOP=..; |
5 | elif test -f ../../config.sh; then TOP=../..; |
6 | elif test -f ../../../config.sh; then TOP=../../..; |
7 | elif test -f ../../../../config.sh; then TOP=../../../..; |
8 | else |
9 | echo "Can't find config.sh."; exit 1 |
10 | fi |
11 | . $TOP/config.sh |
12 | ;; |
1c3d792e |
13 | esac |
2b317908 |
14 | : This forces SH files to create target in same directory as SH file. |
15 | : This is so that make depend always knows where to find SH derivatives. |
1c3d792e |
16 | case "$0" in |
17 | */*) cd `expr X$0 : 'X\(.*\)/'` ;; |
18 | esac |
bc730b18 |
19 | |
20 | warn='' |
21 | |
22 | # Add -Wall for the core modules iff gcc and not already -Wall |
23 | case "$gccversion" in |
24 | '') ;; |
25 | Intel*) ;; # The Intel C++ plays gcc on TV but is not really it. |
26 | *) case "$ccflags" in |
27 | *-Wall*) ;; |
28 | *) warn="$warn -Wall" ;; |
29 | esac |
30 | ;; |
31 | esac |
32 | |
a07cd53d |
33 | # Create a test source file for testing what options can be fed to |
34 | # gcc in this system; include a selection of most common and commonly |
35 | # hairy include files. |
36 | |
37 | cat >_cflags.c <<__EOT__ |
38 | #include "EXTERN.h" |
39 | #include "perl.h" |
40 | /* The stdio.h, errno.h, and setjmp.h should be there in any ANSI C89. */ |
41 | #include <stdio.h> |
42 | #include <errno.h> |
43 | #include <setjmp.h> |
44 | /* Just in case the inclusion of perl.h did not |
45 | * pull in enough system headers, let's try again. */ |
46 | #ifdef I_STDLIB |
47 | #include <stdlib.h> |
48 | #endif |
49 | #ifdef I_STDDEF |
50 | #include <stddef.h> |
51 | #endif |
52 | #ifdef I_STDARG |
53 | #include <stdarg.h> |
54 | #endif |
55 | #ifdef I_LIMITS |
56 | #include <limits.h> |
57 | #endif |
58 | #ifdef I_DIRENT |
59 | #include <dirent.h> |
60 | #endif |
61 | #ifdef I_UNISTD |
62 | #include <unistd.h> |
63 | #endif |
64 | #ifdef I_SYSTYPES |
65 | #include <sys/types.h> |
66 | #endif |
67 | #ifdef I_SYSPARAM |
68 | #include <sys/param.h> |
69 | #endif |
70 | #ifdef I_SYSRESOURCE |
71 | #include <sys/resource.h> |
72 | #endif |
73 | #ifdef I_SYSSELECT |
74 | #include <sys/select.h> |
75 | #endif |
76 | #if defined(HAS_SOCKET) && !defined(VMS) && !defined(WIN32) /* See perl.h. */ |
77 | #include <sys/socket.h> |
78 | #endif |
79 | #ifdef I_SYSSTAT |
80 | #include <sys/stat.h> |
81 | #endif |
82 | #ifdef I_SYSTIME |
83 | #include <sys/time.h> |
84 | #endif |
85 | #ifdef I_SYSTIMES |
86 | #include <sys/times.h> |
87 | #endif |
88 | #ifdef I_SYSWAIT |
89 | #include <sys/wait.h> |
90 | #endif |
91 | /* The gcc -ansi can cause a lot of noise in Solaris because of: |
92 | /usr/include/sys/resource.h:148: warning: 'struct rlimit64' declared inside parameter list |
93 | */ |
94 | int main(int argc, char *argv[]) { |
95 | |
96 | /* Add here test code found to be problematic in some gcc platform. */ |
97 | |
98 | /* Off_t/off_t is a struct in Solaris with largefiles, and with gcc -ansi |
99 | * that struct cannot be compared in some gcc releases with a flat |
100 | * integer, such as a STRLEN. */ |
101 | |
102 | Off_t t0a = 2; |
103 | STRLEN t0b = 3; |
104 | int t0c = t0a == t0b; |
105 | |
106 | return 0; |
107 | } |
108 | __EOT__ |
109 | |
110 | stdflags='' |
bc730b18 |
111 | |
112 | # Further gcc warning options. |
113 | case "$gccversion" in |
114 | '') ;; |
a07cd53d |
115 | [12]*) ;; # gcc versions 1 (gasp!) and 2 are not good for this. |
116 | Intel*) ;; # # Is that you, Intel C++? |
117 | *) for opt in -ansi -pedantic -std=c89 -W -Wextra -Wdeclaration-after-statement -Wendif-labels |
bc730b18 |
118 | do |
119 | case " $ccflags " in |
a07cd53d |
120 | *" $opt "*) ;; # Skip if already there. |
121 | *) rm -f _cflags$_exe |
122 | case "`$cc $cflags $opt _cflags.c -o _cflags$_exe 2>&1`" in |
bc730b18 |
123 | *"unrecognized"*) ;; |
124 | *"Invalid"*) ;; |
9ac4c107 |
125 | *"is valid for C"*) ;; |
a07cd53d |
126 | *) if test -x _cflags$_exe |
127 | then |
128 | case "$opt" in |
129 | -std*) stdflags="$stdflags $opt" ;; |
130 | *) warn="$warn $opt" ;; |
131 | esac |
132 | fi |
133 | ;; |
bc730b18 |
134 | esac |
135 | ;; |
136 | esac |
bc730b18 |
137 | done |
138 | ;; |
139 | esac |
a07cd53d |
140 | rm -f _cflags.c _cflags$_exe |
bc730b18 |
141 | |
9ac4c107 |
142 | case "$gccversion" in |
143 | '') ;; |
144 | *) |
145 | # If we have -Duse64bitint (or equivalent) in effect and the quadtype |
146 | # has become 'long long', gcc -pedantic becomes unbearable (moreso |
147 | # when combined with -Wall) because long long and LL and %lld|%Ld |
148 | # become warn-worthy. So let's drop the -pedantic in that case. |
149 | case "$quadtype:$sPRId64" in |
150 | "long long"*|*lld*|*Ld*) |
151 | ccflags="`echo $ccflags|sed 's/-pedantic/ /'`" |
152 | warn="`echo $warn|sed 's/-pedantic/ /'`" |
153 | ;; |
154 | esac |
5cf489d6 |
155 | # Using certain features (like the gcc statement expressions) |
156 | # requires knowing whether -pedantic has been specified. |
9ac4c107 |
157 | case "$warn$ccflags" in |
158 | *-pedantic*) warn="$warn -DPERL_GCC_PEDANTIC" ;; |
159 | esac |
a07cd53d |
160 | ;; |
161 | esac |
b1e55cab |
162 | |
10edeb5d |
163 | # Code to set any extra flags here. |
a07cd53d |
164 | extra='' |
11fcce85 |
165 | |
2b317908 |
166 | echo "Extracting cflags (with variable substitutions)" |
167 | : This section of the file will have variable substitutions done on it. |
168 | : Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!. |
169 | : Protect any dollar signs and backticks that you do not want interpreted |
170 | : by putting a backslash in front. You may delete these comments. |
165b7424 |
171 | rm -f cflags |
2b317908 |
172 | $spitshell >cflags <<!GROK!THIS! |
ecfc5424 |
173 | $startsh |
bc730b18 |
174 | |
11fcce85 |
175 | # Extra warnings, used e.g. for gcc. |
bc730b18 |
176 | warn="$warn" |
11fcce85 |
177 | # Extra standardness. |
178 | stdflags="$stdflags" |
b1e55cab |
179 | # Extra extra. |
180 | extra="$extra" |
bc730b18 |
181 | |
2b317908 |
182 | !GROK!THIS! |
183 | |
184 | : In the following dollars and backticks do not need the extra backslash. |
185 | $spitshell >>cflags <<'!NO!SUBS!' |
a02608de |
186 | case $PERL_CONFIG_SH in |
2b317908 |
187 | '') |
a0d0e21e |
188 | if test -f config.sh; then TOP=.; |
189 | elif test -f ../config.sh; then TOP=..; |
190 | elif test -f ../../config.sh; then TOP=../..; |
191 | elif test -f ../../../config.sh; then TOP=../../..; |
192 | elif test -f ../../../../config.sh; then TOP=../../../..; |
193 | else |
194 | echo "Can't find config.sh."; exit 1 |
195 | fi |
196 | . $TOP/config.sh |
197 | ;; |
198 | esac |
199 | |
75550b4e |
200 | : syntax: cflags [optimize=XXX] [file[.suffix]] |
201 | : displays the compiler command line for file |
202 | |
1167a30e |
203 | case "X$1" in |
26102cc7 |
204 | Xoptimize=*|X"optimize=*") |
1167a30e |
205 | eval "$1" |
206 | shift |
207 | ;; |
208 | esac |
209 | |
1c3d792e |
210 | also=': ' |
211 | case $# in |
2b317908 |
212 | 1) also='echo 1>&2 " CCCMD = "' |
1c3d792e |
213 | esac |
214 | |
215 | case $# in |
216 | 0) set *.c; echo "The current C flags are:" ;; |
1c3d792e |
217 | esac |
2b317908 |
218 | |
578789a7 |
219 | set `echo "$* " | sed -e 's/\.[oc] / /g' -e 's/\.obj / /g' -e "s/\\$obj_ext / /g"` |
2b317908 |
220 | |
1c3d792e |
221 | for file do |
222 | |
223 | case "$#" in |
224 | 1) ;; |
2b317908 |
225 | *) echo $n " $file.c $c" ;; |
1c3d792e |
226 | esac |
227 | |
2b317908 |
228 | : allow variables like toke_cflags to be evaluated |
229 | |
8736538c |
230 | if echo $file | grep -v / >/dev/null |
231 | then |
232 | eval 'eval ${'"${file}_cflags"'-""}' |
233 | fi |
2b317908 |
234 | |
235 | : or customize here |
236 | |
1c3d792e |
237 | case "$file" in |
a0d0e21e |
238 | DB_File) ;; |
239 | GDBM_File) ;; |
2304df62 |
240 | NDBM_File) ;; |
241 | ODBM_File) ;; |
242 | POSIX) ;; |
243 | SDBM_File) ;; |
244 | av) ;; |
4b6be2dd |
245 | byterun) ;; |
2304df62 |
246 | deb) ;; |
247 | dl) ;; |
2b317908 |
248 | doio) ;; |
2304df62 |
249 | doop) ;; |
2b317908 |
250 | dump) ;; |
59bea8cf |
251 | globals) ;; |
2304df62 |
252 | gv) ;; |
253 | hv) ;; |
a6ec74c1 |
254 | locale) ;; |
59bea8cf |
255 | madly) ;; |
2304df62 |
256 | main) ;; |
2b317908 |
257 | malloc) ;; |
2304df62 |
258 | mg) ;; |
259 | miniperlmain) ;; |
a6ec74c1 |
260 | numeric) ;; |
2304df62 |
261 | op) ;; |
59bea8cf |
262 | opmini) ;; |
263 | pad) ;; |
2b317908 |
264 | perl) ;; |
6f4183fe |
265 | perlapi) ;; |
2304df62 |
266 | perlmain) ;; |
2b317908 |
267 | perly) ;; |
2304df62 |
268 | pp) ;; |
a0d0e21e |
269 | pp_ctl) ;; |
270 | pp_hot) ;; |
a6ec74c1 |
271 | pp_pack) ;; |
59bea8cf |
272 | pp_sort) ;; |
a0d0e21e |
273 | pp_sys) ;; |
2b317908 |
274 | regcomp) ;; |
275 | regexec) ;; |
2304df62 |
276 | run) ;; |
277 | scope) ;; |
278 | sv) ;; |
279 | taint) ;; |
2b317908 |
280 | toke) ;; |
59bea8cf |
281 | universal) ;; |
2b317908 |
282 | usersub) ;; |
59bea8cf |
283 | utf8) ;; |
2b317908 |
284 | util) ;; |
59bea8cf |
285 | xsutils) ;; |
1c3d792e |
286 | *) ;; |
287 | esac |
288 | |
666ea192 |
289 | case "$cc" in |
7e827271 |
290 | *g++*) |
9ac4c107 |
291 | # Extra paranoia in case people have bad canned ccflags: |
292 | # bad in the sense that the flags are accepted by g++, |
293 | # but then whined about. |
294 | for f in -Wdeclaration-after-statement -std=c89 |
295 | do |
296 | ccflags="`echo $ccflags|sed 's/$f/ /'`" |
297 | done |
7e827271 |
298 | ;; |
299 | esac |
300 | |
301 | case "$cc" in |
302 | *g++*) |
303 | # Without -Wno-unused-variable g++ 4.x compiles are rather unwatchable |
a7ae1e4a |
304 | # because of all the warnings about Perl___notused, and g++ doesn't do |
305 | # __attribute__((unused)) (and even if at some stage it may, people do |
306 | # have older gcc installations), and ((void)x) isn't enough to silence |
307 | # the noises about XS functions not using their cv parameter, so we need |
308 | # the -Wno-unused-parameter too. |
309 | # Yes, we lose some valid warnings, but hopefully other compilers |
310 | # (like gcc) will still pick up those warnings. |
311 | for o in -Wno-unused-variable -Wno-unused-parameter |
7e827271 |
312 | do |
313 | case "$warn" in |
314 | *$o*) ;; |
315 | *) warn="$warn $o" ;; |
316 | esac |
317 | done |
318 | ;; |
666ea192 |
319 | esac |
320 | |
69c7f294 |
321 | if test -f .patch; then |
322 | ccflags="-DPERL_PATCHNUM=`cat .patch` $ccflags" |
323 | fi |
324 | |
c4f23d77 |
325 | : Can we perhaps use $ansi2knr here |
b1e55cab |
326 | echo "$cc -c -DPERL_CORE $ccflags $stdflags $optimize $warn $extra" |
327 | eval "$also "'"$cc -DPERL_CORE -c $ccflags $stdflags $optimize $warn $extra"' |
2b317908 |
328 | |
a0d0e21e |
329 | . $TOP/config.sh |
2b317908 |
330 | |
1c3d792e |
331 | done |
2b317908 |
332 | !NO!SUBS! |
a0d0e21e |
333 | chmod 755 cflags |
2b317908 |
334 | $eunicefix cflags |