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