#include <setjmp.h>
/* Just in case the inclusion of perl.h did not
* pull in enough system headers, let's try again. */
-#ifdef I_STDLIB
#include <stdlib.h>
-#endif
-#ifdef I_STDDEF
#include <stddef.h>
-#endif
-#ifdef I_STDARG
#include <stdarg.h>
-#endif
-#ifdef I_LIMITS
#include <limits.h>
-#endif
#ifdef I_DIRENT
#include <dirent.h>
#endif
case "$gccversion" in
'') ;;
-[12]*) ;; # gcc versions 1 (gasp!) and 2 are not good for this.
+[12].*) ;; # gcc versions 1 (gasp!) and 2 are not good for this.
Intel*) ;; # # Is that you, Intel C++?
#
# NOTE 1: the -std=c89 without -pedantic is a bit pointless.
# -std=c89 before -ansi
# -pedantic* before -Werror=d-a-s
#
-*) for opt in -std=c89 -ansi $pedantic \
- -Werror=declaration-after-statement \
- -Wextra -W \
- -Wc++-compat -Wwrite-strings
+*) warns="-std=c89 -ansi $pedantic \
+ -Werror=pointer-arith \
+ -Wextra -W \
+ -Wc++-compat -Wwrite-strings"
+ # declaration after statement is normal in C++ rather than an
+ # extension and compilers complain if we try to warn about it
+ case "$d_cplusplus" in
+ define) ;;
+ *) warns="$warns -Werror=declaration-after-statement" ;;
+ esac
+ for opt in $warns
do
case " $ccflags " in
*" $opt "*) ;; # Skip if already there.
;;
esac
;;
- *) case "$opt" in
- -W)
- # -Wextra is the modern form of -W, so add
- # -W only if -Wextra is not there already.
- case " $warn " in
- *-Wextra*) ;;
- *)
- echo "cflags.SH: Adding $opt."
- warn="$warn $opt"
- ;;
- esac
- ;;
- -Werror=declaration-after-statement)
- # -pedantic* (with -std=c89) covers -Werror=d-a-s.
- case "$stdflags$warn" in
- *-std=c89*-pedantic*|*-pedantic*-std=c89*) ;;
- *)
- echo "cflags.SH: Adding $opt."
- warn="$warn $opt"
- ;;
- esac
- ;;
+ -W)
+ # -Wextra is the modern form of -W, so add
+ # -W only if -Wextra is not there already.
+ case " $warn " in
+ *-Wextra*) ;;
+ *)
+ echo "cflags.SH: Adding $opt."
+ warn="$warn $opt"
+ ;;
+ esac
+ ;;
+ -Werror=declaration-after-statement)
+ # -pedantic* (with -std=c89) covers -Werror=d-a-s.
+ case "$stdflags$warn" in
+ *-std=c89*-pedantic*|*-pedantic*-std=c89*) ;;
*)
echo "cflags.SH: Adding $opt."
warn="$warn $opt"
;;
esac
+ ;;
+ -Werror=pointer-arith)
+ # -pedantic* covers -Werror=p-a
+ case "$warn" in
+ *-pedantic*) ;;
+ *)
+ echo "cflags.SH: Adding $opt."
+ warn="$warn $opt"
+ ;;
+ esac
+ ;;
+ *)
+ echo "cflags.SH: Adding $opt."
+ warn="$warn $opt"
+ ;;
esac
fi
;;
;;
esac
-for f in -Wdeclaration-after-statement -Werror=declaration-after-statement
+for f in -Wdeclaration-after-statement -Werror=declaration-after-statement \
+ -Wpointer-arith -Werror=pointer-arith
do
case "$cppflags" in
*"$f"*)
esac
done
+# If usethreads and clang, add -Wthread-safety for clang 3.6 or later.
+# gccversion is defined also for clang, because compat, use that for matching.
+# Apple overwrites clang version with XCode version, see hints/darwin.sh
+# for the gory details. Aggressively forward-proofing.
+case "$usethreads" in
+define)
+case "$gccversion" in
+*" Clang 3."[56789]*|*" Clang "[456]*|*"Apple LLVM 6.1"*|*"Apple LLVM "[789]*)
+ for f in -Wthread-safety
+ do
+ case " $warn " in
+ *" $f "*) ;; # Skip if already there.
+ *)
+ echo "cflags.SH: Adding $f because usethreads and clang and gccversion '$gccversion'"
+ warn="$warn $f"
+ ;;
+ esac
+ done
+;;
+esac
+;;
+esac
+
echo "cflags.SH: cc = $cc"
echo "cflags.SH: ccflags = $ccflags"
echo "cflags.SH: stdflags = $stdflags"
# allow variables like toke_cflags to be evaluated
- if echo $file | grep -v / >/dev/null
- then
- eval 'eval ${'"${file}_cflags"'-""}'
- fi
+ case "$file" in
+ */*) ;;
+ *) eval 'eval ${'"${file}_cflags"'-""}' ;;
+ esac
# or customize here
toke) optimize=-O0 ;;
esac
- # Can we perhaps use $ansi2knr here
echo "$cc -c -DPERL_CORE $ccflags $stdflags $optimize $warn $extra"
. $TOP/config.sh