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 JH |
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 JH |
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 JH |
111 | |
112 | # Further gcc warning options. | |
113 | case "$gccversion" in | |
114 | '') ;; | |
a07cd53d JH |
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 JH |
118 | do |
119 | case " $ccflags " in | |
a07cd53d JH |
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 JH |
123 | *"unrecognized"*) ;; |
124 | *"Invalid"*) ;; | |
a07cd53d JH |
125 | *) if test -x _cflags$_exe |
126 | then | |
127 | case "$opt" in | |
128 | -std*) stdflags="$stdflags $opt" ;; | |
129 | *) warn="$warn $opt" ;; | |
130 | esac | |
131 | fi | |
132 | ;; | |
bc730b18 JH |
133 | esac |
134 | ;; | |
135 | esac | |
bc730b18 JH |
136 | done |
137 | ;; | |
138 | esac | |
a07cd53d | 139 | rm -f _cflags.c _cflags$_exe |
bc730b18 | 140 | |
b1e55cab JH |
141 | # If we have g++, we cannot have the -Wdeclaration-after-statement. |
142 | # Some g++s accept it but then whine about it with every file. | |
a07cd53d | 143 | # This removal is also done "later", in cflags run time. |
b1e55cab JH |
144 | case "$cc" in |
145 | *g++*) warn="`echo $warn|sed 's/-Wdeclaration-after-statement/ /'`" ;; | |
146 | esac | |
147 | ||
a07cd53d JH |
148 | # If we have -Duse64bitint (or equivalent) in effect and the quadtype |
149 | # has become 'long long', gcc -pedantic becomes unbearable (moreso | |
150 | # when combined with -Wall) because long long and LL and %lld|%Ld | |
151 | # become warn-worthy. So let's drop the -pedantic in that case. | |
152 | case "$quadtype:$sPRId64" in | |
153 | "long long"*|*lld*|*Ld*) | |
154 | ccflags="`echo $ccflags|sed 's/-pedantic/ /'`" | |
155 | warn="`echo $warn|sed 's/-pedantic/ /'`" | |
156 | ;; | |
157 | esac | |
b1e55cab | 158 | |
a07cd53d JH |
159 | case "$warn$ccflags" in |
160 | *-pedantic*) warn="$warn -DPERL_GCC_PEDANTIC" ;; | |
161 | esac | |
11fcce85 | 162 | |
10edeb5d | 163 | # Code to set any extra flags here. |
a07cd53d | 164 | extra='' |
11fcce85 | 165 | |
2b317908 LW |
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 JH |
177 | # Extra standardness. |
178 | stdflags="$stdflags" | |
b1e55cab JH |
179 | # Extra extra. |
180 | extra="$extra" | |
bc730b18 | 181 | |
2b317908 LW |
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 LW |
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 PG |
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 IZ |
205 | eval "$1" |
206 | shift | |
207 | ;; | |
208 | esac | |
209 | ||
1c3d792e LW |
210 | also=': ' |
211 | case $# in | |
2b317908 | 212 | 1) also='echo 1>&2 " CCCMD = "' |
1c3d792e LW |
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 LW |
221 | for file do |
222 | ||
223 | case "$#" in | |
224 | 1) ;; | |
2b317908 | 225 | *) echo $n " $file.c $c" ;; |
1c3d792e LW |
226 | esac |
227 | ||
2b317908 LW |
228 | : allow variables like toke_cflags to be evaluated |
229 | ||
8736538c AS |
230 | if echo $file | grep -v / >/dev/null |
231 | then | |
232 | eval 'eval ${'"${file}_cflags"'-""}' | |
233 | fi | |
2b317908 LW |
234 | |
235 | : or customize here | |
236 | ||
1c3d792e | 237 | case "$file" in |
a0d0e21e LW |
238 | DB_File) ;; |
239 | GDBM_File) ;; | |
2304df62 AD |
240 | NDBM_File) ;; |
241 | ODBM_File) ;; | |
242 | POSIX) ;; | |
243 | SDBM_File) ;; | |
244 | av) ;; | |
4b6be2dd | 245 | byterun) ;; |
2304df62 AD |
246 | deb) ;; |
247 | dl) ;; | |
2b317908 | 248 | doio) ;; |
2304df62 | 249 | doop) ;; |
2b317908 | 250 | dump) ;; |
59bea8cf | 251 | globals) ;; |
2304df62 AD |
252 | gv) ;; |
253 | hv) ;; | |
a6ec74c1 | 254 | locale) ;; |
59bea8cf | 255 | madly) ;; |
2304df62 | 256 | main) ;; |
2b317908 | 257 | malloc) ;; |
2304df62 AD |
258 | mg) ;; |
259 | miniperlmain) ;; | |
a6ec74c1 | 260 | numeric) ;; |
2304df62 | 261 | op) ;; |
59bea8cf JH |
262 | opmini) ;; |
263 | pad) ;; | |
2b317908 | 264 | perl) ;; |
6f4183fe | 265 | perlapi) ;; |
2304df62 | 266 | perlmain) ;; |
2b317908 | 267 | perly) ;; |
2304df62 | 268 | pp) ;; |
a0d0e21e LW |
269 | pp_ctl) ;; |
270 | pp_hot) ;; | |
a6ec74c1 | 271 | pp_pack) ;; |
59bea8cf | 272 | pp_sort) ;; |
a0d0e21e | 273 | pp_sys) ;; |
2b317908 LW |
274 | regcomp) ;; |
275 | regexec) ;; | |
2304df62 AD |
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 LW |
286 | *) ;; |
287 | esac | |
288 | ||
666ea192 | 289 | case "$cc" in |
7e827271 | 290 | *g++*) |
a07cd53d | 291 | # We need to remove this also in here (removed also earlier in cflags.SH). |
7e827271 JH |
292 | ccflags="`echo $ccflags|sed 's/-Wdeclaration-after-statement/ /'`" |
293 | ;; | |
294 | esac | |
295 | ||
296 | case "$cc" in | |
297 | *g++*) | |
298 | # Without -Wno-unused-variable g++ 4.x compiles are rather unwatchable | |
a7ae1e4a JH |
299 | # because of all the warnings about Perl___notused, and g++ doesn't do |
300 | # __attribute__((unused)) (and even if at some stage it may, people do | |
301 | # have older gcc installations), and ((void)x) isn't enough to silence | |
302 | # the noises about XS functions not using their cv parameter, so we need | |
303 | # the -Wno-unused-parameter too. | |
304 | # Yes, we lose some valid warnings, but hopefully other compilers | |
305 | # (like gcc) will still pick up those warnings. | |
306 | for o in -Wno-unused-variable -Wno-unused-parameter | |
7e827271 JH |
307 | do |
308 | case "$warn" in | |
309 | *$o*) ;; | |
310 | *) warn="$warn $o" ;; | |
311 | esac | |
312 | done | |
313 | ;; | |
666ea192 JH |
314 | esac |
315 | ||
69c7f294 NC |
316 | if test -f .patch; then |
317 | ccflags="-DPERL_PATCHNUM=`cat .patch` $ccflags" | |
318 | fi | |
319 | ||
c4f23d77 | 320 | : Can we perhaps use $ansi2knr here |
b1e55cab JH |
321 | echo "$cc -c -DPERL_CORE $ccflags $stdflags $optimize $warn $extra" |
322 | eval "$also "'"$cc -DPERL_CORE -c $ccflags $stdflags $optimize $warn $extra"' | |
2b317908 | 323 | |
a0d0e21e | 324 | . $TOP/config.sh |
2b317908 | 325 | |
1c3d792e | 326 | done |
2b317908 | 327 | !NO!SUBS! |
a0d0e21e | 328 | chmod 755 cflags |
2b317908 | 329 | $eunicefix cflags |