X-Git-Url: https://perl5.git.perl.org/perl5.git/blobdiff_plain/78e91e3f8a5c269162712a52608b3b727352d602..54ad4e11aa2a4191637d6f4ef1b878490e4fb6db:/cflags.SH?ds=sidebyside diff --git a/cflags.SH b/cflags.SH index 031b780..3af1e97 100755 --- a/cflags.SH +++ b/cflags.SH @@ -182,9 +182,11 @@ Intel*) ;; # # Is that you, Intel C++? # longer then the ANSI minimum of 509 bytes. # # NOTE 3: the relative order of these options matters: -# -Wextra before -W, and -pedantic* before -Werror=d-a-s. +# -Wextra before -W +# -std=c89 before -ansi +# -pedantic* before -Werror=d-a-s # -*) for opt in -ansi -std=c89 $pedantic \ +*) for opt in -std=c89 -ansi $pedantic \ -Werror=declaration-after-statement \ -Wextra -W \ -Wc++-compat -Wwrite-strings @@ -213,33 +215,42 @@ Intel*) ;; # # Is that you, Intel C++? echo "cflags.SH: Adding $opt." stdflags="$stdflags $opt" ;; - *) 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 - ;; + -ansi) + # -std=c89 is the modern form of -ansi, so add + # -ansi only if -std=c89 is not there already. + case " $stdflags " in + *-std=c89*) ;; + *) + echo "cflags.SH: Adding $opt." + stdflags="$stdflags $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 + ;; + *) + echo "cflags.SH: Adding $opt." + warn="$warn $opt" + ;; esac fi ;; @@ -365,6 +376,29 @@ do 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" @@ -374,6 +408,9 @@ echo "cflags.SH: warn = $warn" # Code to set any extra flags here. extra='' +# Protect double or single quotes for better restoring of ccflags. +myccflags=`echo $ccflags | sed -e 's/"/\\\"/g' -e "s/'/\\\'/g"` + echo "Extracting cflags (with variable substitutions)" # This section of the file will have variable substitutions done on it. # Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!. @@ -388,7 +425,8 @@ $startsh # This file is generated by cflags.SH # Used to restore possible edits by cflags.SH. -myccflags="$ccflags" +myccflags="$myccflags" + # Extra warnings, used e.g. for gcc. warn="$warn" # Extra standardness. @@ -447,14 +485,19 @@ for file do # 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 case "$file" in + regcomp) : work around http://bugs.debian.org/754054 + case $archname in + mips-*|mipsel-*) + optimize="$optimize -fno-tree-vrp";; + esac;; *) ;; # Customization examples follow.