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\(.*\)/'` ;;
20 if ! test -f config.h; then
26 # Add -Wall for the core modules iff gcc and not already -Wall
29 Intel*) ;; # The Intel C++ plays gcc on TV but is not really it.
32 *) warn="$warn -Wall" ;;
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.
41 cat >_cflags.c <<__EOT__
44 /* The stdio.h, errno.h, and setjmp.h should be there in any ANSI C89. */
48 /* Just in case the inclusion of perl.h did not
49 * pull in enough system headers, let's try again. */
69 #include <sys/types.h>
72 #include <sys/param.h>
75 #include <sys/resource.h>
78 #include <sys/select.h>
80 #if defined(HAS_SOCKET) && !defined(VMS) && !defined(WIN32) /* See perl.h. */
81 #include <sys/socket.h>
90 #include <sys/times.h>
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
98 int main(int argc, char *argv[]) {
100 /* Add here test code found to be problematic in some gcc platform. */
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. */
108 int t0c = t0a == t0b;
116 # Further gcc warning options.
117 case "$gccversion" in
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
124 *" $opt "*) ;; # Skip if already there.
125 *) rm -f _cflags$_exe
126 case "`$cc $cflags $opt _cflags.c -o _cflags$_exe 2>&1`" in
129 *"is valid for C"*) ;;
130 *) if test -x _cflags$_exe
133 -std*) stdflags="$stdflags $opt" ;;
134 *) warn="$warn $opt" ;;
144 rm -f _cflags.c _cflags$_exe
146 case "$gccversion" in
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/ /'`"
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" ;;
169 # Code to set any extra flags here.
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.
178 $spitshell >cflags <<!GROK!THIS!
181 # Extra warnings, used e.g. for gcc.
183 # Extra standardness.
190 : In the following dollars and backticks do not need the extra backslash.
191 $spitshell >>cflags <<'!NO!SUBS!'
192 case $PERL_CONFIG_SH in
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=../../../..;
200 echo "Can't find config.sh."; exit 1
206 : syntax: cflags [optimize=XXX] [file[.suffix]]
207 : displays the compiler command line for file
210 Xoptimize=*|X"optimize=*")
218 1) also='echo 1>&2 " CCCMD = "'
222 0) set *.c; echo "The current C flags are:" ;;
225 set `echo "$* " | sed -e 's/\.[oc] / /g' -e 's/\.obj / /g' -e "s/\\$obj_ext / /g"`
231 *) echo $n " $file.c $c" ;;
234 : allow variables like toke_cflags to be evaluated
236 if echo $file | grep -v / >/dev/null
238 eval 'eval ${'"${file}_cflags"'-""}'
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
302 ccflags=`echo $ccflags|sed 's/$f/ /'`
309 # Without -Wno-unused-variable g++ 4.x compiles are rather unwatchable
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
321 *) warn="$warn $o" ;;
327 if test -f .patch; then
328 ccflags="-DPERL_PATCHNUM=`cat .patch` $ccflags"
331 : Can we perhaps use $ansi2knr here
332 echo "$cc -c -DPERL_CORE $ccflags $stdflags $optimize $warn $extra"
333 eval "$also "'"$cc -DPERL_CORE -c $ccflags $stdflags $optimize $warn $extra"'