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