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 | ||
33 | # The gcc -ansi -pedantic require their own dance, too. | |
34 | case "$gccversion" in | |
35 | '') ;; | |
11fcce85 | 36 | Intel*) ;; # Is that you, Intel C++? |
bc730b18 JH |
37 | *) case "$gccansipedantic" in |
38 | define) | |
39 | case "$gccversion" in | |
40 | [12]*) ;; # gcc versions 1 (gasp!) and 2 are not good for this. | |
41 | *) case "$osname" in | |
42 | # Add -ansi -pedantic only for known platforms. | |
43 | aix|dec_osf|freebsd|hpux|irix|linux) | |
44 | ansipedantic="-ansi -pedantic" ;; | |
45 | solaris) | |
46 | # Can't add -ansi for Solaris. | |
47 | # Off_t/off_t is a struct in Solaris with largefiles, and with -ansi | |
48 | # that struct cannot be compared with a flat integer, such as a STRLEN. | |
49 | # The -ansi will also cause a lot of noise in Solaris because of: | |
50 | # /usr/include/sys/resource.h:148: warning: `struct rlimit64' declared inside parameter list | |
51 | ansipedantic="-pedantic" ;; | |
52 | esac | |
53 | for i in $ansipedantic | |
54 | do | |
55 | case "$ccflags" in | |
56 | *$i*) ;; | |
57 | *) warn="$warn $i" ;; | |
58 | esac | |
59 | done | |
60 | case "$warn$ccflags" in | |
61 | *-pedantic*) warn="$warn -DPERL_GCC_PEDANTIC" ;; | |
62 | esac | |
63 | ;; | |
64 | esac | |
65 | ;; | |
66 | esac | |
67 | ;; | |
68 | esac | |
69 | ||
70 | # Further gcc warning options. | |
71 | case "$gccversion" in | |
72 | '') ;; | |
9ab92c42 | 73 | [12]*) ;; |
11fcce85 | 74 | Intel*) ;; # Haven't we been through this already? |
bc730b18 JH |
75 | *) for opt in '' extra declaration-after-statement endif-labels |
76 | do | |
77 | case " $ccflags " in | |
78 | *"-W$opt "*) ;; | |
79 | *) case "`echo >_cflags.c | $cc -W$opt -c _cflags.c -o _cflags.o 2>&1`" in | |
80 | *"unrecognized"*) ;; | |
81 | *"Invalid"*) ;; | |
82 | *) warn="$warn -W$opt" ;; | |
83 | esac | |
84 | ;; | |
85 | esac | |
86 | rm -f _cflags.c cflags.o | |
87 | done | |
88 | ;; | |
89 | esac | |
90 | ||
b1e55cab JH |
91 | # If we have g++, we cannot have the -Wdeclaration-after-statement. |
92 | # Some g++s accept it but then whine about it with every file. | |
93 | case "$cc" in | |
94 | *g++*) warn="`echo $warn|sed 's/-Wdeclaration-after-statement/ /'`" ;; | |
95 | esac | |
96 | ||
10edeb5d JH |
97 | # stdflags currently unused. |
98 | stdflags='' | |
b1e55cab | 99 | |
10edeb5d | 100 | extra='' |
11fcce85 | 101 | |
10edeb5d | 102 | # Code to set any extra flags here. |
11fcce85 | 103 | |
2b317908 LW |
104 | echo "Extracting cflags (with variable substitutions)" |
105 | : This section of the file will have variable substitutions done on it. | |
106 | : Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!. | |
107 | : Protect any dollar signs and backticks that you do not want interpreted | |
108 | : by putting a backslash in front. You may delete these comments. | |
165b7424 | 109 | rm -f cflags |
2b317908 | 110 | $spitshell >cflags <<!GROK!THIS! |
ecfc5424 | 111 | $startsh |
bc730b18 | 112 | |
11fcce85 | 113 | # Extra warnings, used e.g. for gcc. |
bc730b18 | 114 | warn="$warn" |
11fcce85 JH |
115 | # Extra standardness. |
116 | stdflags="$stdflags" | |
b1e55cab JH |
117 | # Extra extra. |
118 | extra="$extra" | |
bc730b18 | 119 | |
2b317908 LW |
120 | !GROK!THIS! |
121 | ||
122 | : In the following dollars and backticks do not need the extra backslash. | |
123 | $spitshell >>cflags <<'!NO!SUBS!' | |
a02608de | 124 | case $PERL_CONFIG_SH in |
2b317908 | 125 | '') |
a0d0e21e LW |
126 | if test -f config.sh; then TOP=.; |
127 | elif test -f ../config.sh; then TOP=..; | |
128 | elif test -f ../../config.sh; then TOP=../..; | |
129 | elif test -f ../../../config.sh; then TOP=../../..; | |
130 | elif test -f ../../../../config.sh; then TOP=../../../..; | |
131 | else | |
132 | echo "Can't find config.sh."; exit 1 | |
133 | fi | |
134 | . $TOP/config.sh | |
135 | ;; | |
136 | esac | |
137 | ||
75550b4e PG |
138 | : syntax: cflags [optimize=XXX] [file[.suffix]] |
139 | : displays the compiler command line for file | |
140 | ||
1167a30e | 141 | case "X$1" in |
26102cc7 | 142 | Xoptimize=*|X"optimize=*") |
1167a30e IZ |
143 | eval "$1" |
144 | shift | |
145 | ;; | |
146 | esac | |
147 | ||
1c3d792e LW |
148 | also=': ' |
149 | case $# in | |
2b317908 | 150 | 1) also='echo 1>&2 " CCCMD = "' |
1c3d792e LW |
151 | esac |
152 | ||
153 | case $# in | |
154 | 0) set *.c; echo "The current C flags are:" ;; | |
1c3d792e | 155 | esac |
2b317908 | 156 | |
578789a7 | 157 | set `echo "$* " | sed -e 's/\.[oc] / /g' -e 's/\.obj / /g' -e "s/\\$obj_ext / /g"` |
2b317908 | 158 | |
1c3d792e LW |
159 | for file do |
160 | ||
161 | case "$#" in | |
162 | 1) ;; | |
2b317908 | 163 | *) echo $n " $file.c $c" ;; |
1c3d792e LW |
164 | esac |
165 | ||
2b317908 LW |
166 | : allow variables like toke_cflags to be evaluated |
167 | ||
8736538c AS |
168 | if echo $file | grep -v / >/dev/null |
169 | then | |
170 | eval 'eval ${'"${file}_cflags"'-""}' | |
171 | fi | |
2b317908 LW |
172 | |
173 | : or customize here | |
174 | ||
1c3d792e | 175 | case "$file" in |
a0d0e21e LW |
176 | DB_File) ;; |
177 | GDBM_File) ;; | |
2304df62 AD |
178 | NDBM_File) ;; |
179 | ODBM_File) ;; | |
180 | POSIX) ;; | |
181 | SDBM_File) ;; | |
182 | av) ;; | |
4b6be2dd | 183 | byterun) ;; |
2304df62 AD |
184 | deb) ;; |
185 | dl) ;; | |
2b317908 | 186 | doio) ;; |
2304df62 | 187 | doop) ;; |
2b317908 | 188 | dump) ;; |
59bea8cf | 189 | globals) ;; |
2304df62 AD |
190 | gv) ;; |
191 | hv) ;; | |
a6ec74c1 | 192 | locale) ;; |
59bea8cf | 193 | madly) ;; |
2304df62 | 194 | main) ;; |
2b317908 | 195 | malloc) ;; |
2304df62 AD |
196 | mg) ;; |
197 | miniperlmain) ;; | |
a6ec74c1 | 198 | numeric) ;; |
2304df62 | 199 | op) ;; |
59bea8cf JH |
200 | opmini) ;; |
201 | pad) ;; | |
2b317908 | 202 | perl) ;; |
6f4183fe | 203 | perlapi) ;; |
2304df62 | 204 | perlmain) ;; |
2b317908 | 205 | perly) ;; |
2304df62 | 206 | pp) ;; |
a0d0e21e LW |
207 | pp_ctl) ;; |
208 | pp_hot) ;; | |
a6ec74c1 | 209 | pp_pack) ;; |
59bea8cf | 210 | pp_sort) ;; |
a0d0e21e | 211 | pp_sys) ;; |
2b317908 LW |
212 | regcomp) ;; |
213 | regexec) ;; | |
2304df62 AD |
214 | run) ;; |
215 | scope) ;; | |
216 | sv) ;; | |
217 | taint) ;; | |
2b317908 | 218 | toke) ;; |
59bea8cf | 219 | universal) ;; |
2b317908 | 220 | usersub) ;; |
59bea8cf | 221 | utf8) ;; |
2b317908 | 222 | util) ;; |
59bea8cf | 223 | xsutils) ;; |
1c3d792e LW |
224 | *) ;; |
225 | esac | |
226 | ||
666ea192 | 227 | case "$cc" in |
7e827271 JH |
228 | *g++*) |
229 | # We need to remove this also in here (removed early earlier). | |
230 | ccflags="`echo $ccflags|sed 's/-Wdeclaration-after-statement/ /'`" | |
231 | ;; | |
232 | esac | |
233 | ||
234 | case "$cc" in | |
235 | *g++*) | |
236 | # Without -Wno-unused-variable g++ 4.x compiles are rather unwatchable | |
a7ae1e4a JH |
237 | # because of all the warnings about Perl___notused, and g++ doesn't do |
238 | # __attribute__((unused)) (and even if at some stage it may, people do | |
239 | # have older gcc installations), and ((void)x) isn't enough to silence | |
240 | # the noises about XS functions not using their cv parameter, so we need | |
241 | # the -Wno-unused-parameter too. | |
242 | # Yes, we lose some valid warnings, but hopefully other compilers | |
243 | # (like gcc) will still pick up those warnings. | |
244 | for o in -Wno-unused-variable -Wno-unused-parameter | |
7e827271 JH |
245 | do |
246 | case "$warn" in | |
247 | *$o*) ;; | |
248 | *) warn="$warn $o" ;; | |
249 | esac | |
250 | done | |
251 | ;; | |
666ea192 JH |
252 | esac |
253 | ||
69c7f294 NC |
254 | if test -f .patch; then |
255 | ccflags="-DPERL_PATCHNUM=`cat .patch` $ccflags" | |
256 | fi | |
257 | ||
c4f23d77 | 258 | : Can we perhaps use $ansi2knr here |
b1e55cab JH |
259 | echo "$cc -c -DPERL_CORE $ccflags $stdflags $optimize $warn $extra" |
260 | eval "$also "'"$cc -DPERL_CORE -c $ccflags $stdflags $optimize $warn $extra"' | |
2b317908 | 261 | |
a0d0e21e | 262 | . $TOP/config.sh |
2b317908 | 263 | |
1c3d792e | 264 | done |
2b317908 | 265 | !NO!SUBS! |
a0d0e21e | 266 | chmod 755 cflags |
2b317908 | 267 | $eunicefix cflags |