1 case $PERL_CONFIG_SH in
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=../../../..;
9 echo "Can't find config.sh."; exit 1
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.
17 */*) cd `expr X$0 : 'X\(.*\)/'` ;;
22 # Add -Wall for the core modules iff gcc and not already -Wall
25 Intel*) ;; # The Intel C++ plays gcc on TV but is not really it.
28 *) warn="$warn -Wall" ;;
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.
37 cat >_cflags.c <<__EOT__
40 /* The stdio.h, errno.h, and setjmp.h should be there in any ANSI C89. */
44 /* Just in case the inclusion of perl.h did not
45 * pull in enough system headers, let's try again. */
65 #include <sys/types.h>
68 #include <sys/param.h>
71 #include <sys/resource.h>
74 #include <sys/select.h>
76 #if defined(HAS_SOCKET) && !defined(VMS) && !defined(WIN32) /* See perl.h. */
77 #include <sys/socket.h>
86 #include <sys/times.h>
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
94 int main(int argc, char *argv[]) {
96 /* Add here test code found to be problematic in some gcc platform. */
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. */
104 int t0c = t0a == t0b;
112 # Further gcc warning options.
113 case "$gccversion" in
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
120 *" $opt "*) ;; # Skip if already there.
121 *) rm -f _cflags$_exe
122 case "`$cc $cflags $opt _cflags.c -o _cflags$_exe 2>&1`" in
125 *"is valid for C"*) ;;
126 *) if test -x _cflags$_exe
129 -std*) stdflags="$stdflags $opt" ;;
130 *) warn="$warn $opt" ;;
140 rm -f _cflags.c _cflags$_exe
142 case "$gccversion" in
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/ /'`"
155 # Using certain features (like the gcc statement expressions)
156 # requires knowing whether -pedantic has been specified.
157 case "$warn$ccflags" in
158 *-pedantic*) warn="$warn -DPERL_GCC_PEDANTIC" ;;
163 # Code to set any extra flags here.
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.
172 $spitshell >cflags <<!GROK!THIS!
175 # Extra warnings, used e.g. for gcc.
177 # Extra standardness.
184 : In the following dollars and backticks do not need the extra backslash.
185 $spitshell >>cflags <<'!NO!SUBS!'
186 case $PERL_CONFIG_SH in
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=../../../..;
194 echo "Can't find config.sh."; exit 1
200 : syntax: cflags [optimize=XXX] [file[.suffix]]
201 : displays the compiler command line for file
204 Xoptimize=*|X"optimize=*")
212 1) also='echo 1>&2 " CCCMD = "'
216 0) set *.c; echo "The current C flags are:" ;;
219 set `echo "$* " | sed -e 's/\.[oc] / /g' -e 's/\.obj / /g' -e "s/\\$obj_ext / /g"`
225 *) echo $n " $file.c $c" ;;
228 : allow variables like toke_cflags to be evaluated
230 if echo $file | grep -v / >/dev/null
232 eval 'eval ${'"${file}_cflags"'-""}'
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
296 ccflags="`echo $ccflags|sed 's/$f/ /'`"
303 # Without -Wno-unused-variable g++ 4.x compiles are rather unwatchable
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
315 *) warn="$warn $o" ;;
321 if test -f .patch; then
322 ccflags="-DPERL_PATCHNUM=`cat .patch` $ccflags"
325 : Can we perhaps use $ansi2knr here
326 echo "$cc -c -DPERL_CORE $ccflags $stdflags $optimize $warn $extra"
327 eval "$also "'"$cc -DPERL_CORE -c $ccflags $stdflags $optimize $warn $extra"'