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.SH -a ! -f config.h; then
27 # Add -Wall for the core modules iff gcc and not already -Wall
30 Intel*) ;; # The Intel C++ plays gcc on TV but is not really it.
33 *) warn="$warn -Wall" ;;
38 # Create a test source file for testing what options can be fed to
39 # gcc in this system; include a selection of most common and commonly
40 # hairy include files.
42 cat >_cflags.c <<__EOT__
45 /* The stdio.h, errno.h, and setjmp.h should be there in any ANSI C89. */
49 /* Just in case the inclusion of perl.h did not
50 * pull in enough system headers, let's try again. */
70 #include <sys/types.h>
73 #include <sys/param.h>
76 #include <sys/resource.h>
79 #include <sys/select.h>
81 #if defined(HAS_SOCKET) && !defined(VMS) && !defined(WIN32) /* See perl.h. */
82 #include <sys/socket.h>
91 #include <sys/times.h>
96 /* The gcc -ansi can cause a lot of noise in Solaris because of:
97 /usr/include/sys/resource.h:148: warning: 'struct rlimit64' declared inside parameter list
99 int main(int argc, char *argv[]) {
101 /* Add here test code found to be problematic in some gcc platform. */
103 /* Off_t/off_t is a struct in Solaris with largefiles, and with gcc -ansi
104 * that struct cannot be compared in some gcc releases with a flat
105 * integer, such as a STRLEN. */
109 int t0c = t0a == t0b;
117 # Further gcc warning options.
118 case "$gccversion" in
120 [12]*) ;; # gcc versions 1 (gasp!) and 2 are not good for this.
121 Intel*) ;; # # Is that you, Intel C++?
122 *) for opt in -ansi -pedantic -std=c89 -W -Wextra -Wdeclaration-after-statement -Wendif-labels -Wc++-compat
125 *" $opt "*) ;; # Skip if already there.
126 *) rm -f _cflags$_exe
127 case "`$cc $cflags $opt _cflags.c -o _cflags$_exe 2>&1`" in
130 *"is valid for C"*) ;;
131 *) if test -x _cflags$_exe
134 -std*) stdflags="$stdflags $opt" ;;
135 *) warn="$warn $opt" ;;
145 rm -f _cflags.c _cflags$_exe
147 case "$gccversion" in
150 if [ "$gccansipedantic" = "" ]; then
151 # If we have -Duse64bitint (or equivalent) in effect and the quadtype
152 # has become 'long long', gcc -pedantic becomes unbearable (moreso
153 # when combined with -Wall) because long long and LL and %lld|%Ld
154 # become warn-worthy. So let's drop the -pedantic in that case.
155 case "$quadtype:$sPRId64" in
156 "long long"*|*lld*|*Ld*)
157 ccflags="`echo $ccflags|sed 's/-pedantic/ /'`"
158 warn="`echo $warn|sed 's/-pedantic/ /'`"
162 # Using certain features (like the gcc statement expressions)
163 # requires knowing whether -pedantic has been specified.
164 case "$warn$ccflags" in
165 *-pedantic*) warn="$warn -DPERL_GCC_PEDANTIC" ;;
170 # Code to set any extra flags here.
173 echo "Extracting cflags (with variable substitutions)"
174 : This section of the file will have variable substitutions done on it.
175 : Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!.
176 : Protect any dollar signs and backticks that you do not want interpreted
177 : by putting a backslash in front. You may delete these comments.
179 $spitshell >cflags <<!GROK!THIS!
182 # Extra warnings, used e.g. for gcc.
184 # Extra standardness.
191 : In the following dollars and backticks do not need the extra backslash.
192 $spitshell >>cflags <<'!NO!SUBS!'
193 case $PERL_CONFIG_SH in
195 if 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 elif test -f ../../../../config.sh; then TOP=../../../..;
201 echo "Can't find config.sh."; exit 1
207 : syntax: cflags [optimize=XXX] [file[.suffix]]
208 : displays the compiler command line for file
211 Xoptimize=*|X"optimize=*")
219 1) also='echo 1>&2 " CCCMD = "'
223 0) set *.c; echo "The current C flags are:" ;;
226 set `echo "$* " | sed -e 's/\.[oc] / /g' -e 's/\.obj / /g' -e "s/\\$obj_ext / /g"`
232 *) echo $n " $file.c $c" ;;
235 : allow variables like toke_cflags to be evaluated
237 if echo $file | grep -v / >/dev/null
239 eval 'eval ${'"${file}_cflags"'-""}'
298 # Extra paranoia in case people have bad canned ccflags:
299 # bad in the sense that the flags are accepted by g++,
300 # but then whined about.
301 for f in -Wdeclaration-after-statement -std=c89
303 ccflags=`echo $ccflags|sed 's/$f/ /'`
307 cppflags=`echo $cppflags|sed 's/-Wdeclaration-after-statement/ /'`
311 # Without -Wno-unused-variable g++ 4.x compiles are rather unwatchable
312 # because of all the warnings about Perl___notused, and g++ doesn't do
313 # __attribute__((unused)) (and even if at some stage it may, people do
314 # have older gcc installations), and ((void)x) isn't enough to silence
315 # the noises about XS functions not using their cv parameter, so we need
316 # the -Wno-unused-parameter too.
317 # Yes, we lose some valid warnings, but hopefully other compilers
318 # (like gcc) will still pick up those warnings.
319 for o in -Wno-unused-variable -Wno-unused-parameter
323 *) warn="$warn $o" ;;
329 if test -f .patch; then
330 ccflags="-DPERL_PATCHNUM=`cat .patch` $ccflags"
333 : Can we perhaps use $ansi2knr here
334 echo "$cc -c -DPERL_CORE $ccflags $stdflags $optimize $warn $extra"
335 eval "$also "'"$cc -DPERL_CORE -c $ccflags $stdflags $optimize $warn $extra"'