comparison configure @ 31547:05537cb15be6

Add convenience function to check for compiler flags directly and use it.
author diego
date Thu, 01 Jul 2010 23:03:40 +0000
parents e7aa0fde4e34
children 0c9300413b28
comparison
equal deleted inserted replaced
31546:e7aa0fde4e34 31547:05537cb15be6
77 compile_check $TMPC $@ 77 compile_check $TMPC $@
78 } 78 }
79 79
80 cxx_check() { 80 cxx_check() {
81 compile_check $TMPCPP $@ -lstdc++ 81 compile_check $TMPCPP $@ -lstdc++
82 }
83
84 cflag_check() {
85 cat > $TMPC << EOF
86 int main(void) { return 0; }
87 EOF
88 compile_check $TMPC $@
82 } 89 }
83 90
84 function_check() { 91 function_check() {
85 cat > $TMPC << EOF 92 cat > $TMPC << EOF
86 #include <$1> 93 #include <$1>
2098 proc=error;; 2105 proc=error;;
2099 esac 2106 esac
2100 fi # test "$_runtime_cpudetection" = no 2107 fi # test "$_runtime_cpudetection" = no
2101 2108
2102 echocheck "GCC & CPU optimization abilities" 2109 echocheck "GCC & CPU optimization abilities"
2103 cat > $TMPC << EOF
2104 int main(void) { return 0; }
2105 EOF
2106 # This is a stripped-down version of the i386 fallback. 2110 # This is a stripped-down version of the i386 fallback.
2107 if test "$_runtime_cpudetection" = no ; then 2111 if test "$_runtime_cpudetection" = no ; then
2108 if test $cc_vendor != "intel" && test $cc_vendor != "clang" ; then 2112 if test $cc_vendor != "intel" && test $cc_vendor != "clang" ; then
2109 cc_check -march=native && proc=native 2113 cflag_check -march=native && proc=native
2110 fi 2114 fi
2111 # --- AMD processors --- 2115 # --- AMD processors ---
2112 if test "$proc" = "amdfam10"; then 2116 if test "$proc" = "amdfam10"; then
2113 cc_check -march=$proc $cpuopt=$proc || proc=k8 2117 cflag_check -march=$proc $cpuopt=$proc || proc=k8
2114 fi 2118 fi
2115 if test "$proc" = "k8"; then 2119 if test "$proc" = "k8"; then
2116 cc_check -march=$proc $cpuopt=$proc || proc=athlon-xp 2120 cflag_check -march=$proc $cpuopt=$proc || proc=athlon-xp
2117 fi 2121 fi
2118 # This will fail if gcc version < 3.3, which is ok because earlier 2122 # This will fail if gcc version < 3.3, which is ok because earlier
2119 # versions don't really support 64-bit on amd64. 2123 # versions don't really support 64-bit on amd64.
2120 # Is this a valid assumption? -Corey 2124 # Is this a valid assumption? -Corey
2121 if test "$proc" = "athlon-xp"; then 2125 if test "$proc" = "athlon-xp"; then
2122 cc_check -march=$proc $cpuopt=$proc || proc=error 2126 cflag_check -march=$proc $cpuopt=$proc || proc=error
2123 fi 2127 fi
2124 # --- Intel processors --- 2128 # --- Intel processors ---
2125 if test "$proc" = "core2"; then 2129 if test "$proc" = "core2"; then
2126 cc_check -march=$proc $cpuopt=$proc || proc=x86-64 2130 cflag_check -march=$proc $cpuopt=$proc || proc=x86-64
2127 fi 2131 fi
2128 if test "$proc" = "x86-64"; then 2132 if test "$proc" = "x86-64"; then
2129 cc_check -march=$proc $cpuopt=$proc || proc=nocona 2133 cflag_check -march=$proc $cpuopt=$proc || proc=nocona
2130 fi 2134 fi
2131 if test "$proc" = "nocona"; then 2135 if test "$proc" = "nocona"; then
2132 cc_check -march=$proc $cpuopt=$proc || proc=pentium4 2136 cflag_check -march=$proc $cpuopt=$proc || proc=pentium4
2133 fi 2137 fi
2134 if test "$proc" = "pentium4"; then 2138 if test "$proc" = "pentium4"; then
2135 cc_check -march=$proc $cpuopt=$proc || proc=error 2139 cflag_check -march=$proc $cpuopt=$proc || proc=error
2136 fi 2140 fi
2137 2141
2138 _march="-march=$proc" 2142 _march="-march=$proc"
2139 _mcpu="$cpuopt=$proc" 2143 _mcpu="$cpuopt=$proc"
2140 if test "$proc" = "error" ; then 2144 if test "$proc" = "error" ; then
2144 fi 2148 fi
2145 else # if test "$_runtime_cpudetection" = no 2149 else # if test "$_runtime_cpudetection" = no
2146 # x86-64 is an undocumented option, an intersection of k8 and nocona. 2150 # x86-64 is an undocumented option, an intersection of k8 and nocona.
2147 _march="-march=x86-64" 2151 _march="-march=x86-64"
2148 _mcpu="$cpuopt=generic" 2152 _mcpu="$cpuopt=generic"
2149 cc_check $_mcpu || _mcpu="x86-64" 2153 cflag_check $_mcpu || _mcpu="x86-64"
2150 cc_check $_mcpu || _mcpu="" 2154 cflag_check $_mcpu || _mcpu=""
2151 cc_check $_march $_mcpu || _march="" 2155 cflag_check $_march $_mcpu || _march=""
2152 fi 2156 fi
2153 2157
2154 _optimizing="$proc" 2158 _optimizing="$proc"
2155 test $_fast_cmov = "auto" && _fast_cmov=yes 2159 test $_fast_cmov = "auto" && _fast_cmov=yes
2156 test $_fast_clz = "auto" && _fast_clz=yes 2160 test $_fast_clz = "auto" && _fast_clz=yes
2484 def_extern_prefix="#define EXTERN_PREFIX \"$extern_prefix\"" 2488 def_extern_prefix="#define EXTERN_PREFIX \"$extern_prefix\""
2485 echores $extern_prefix 2489 echores $extern_prefix
2486 2490
2487 2491
2488 echocheck "assembler support of -pipe option" 2492 echocheck "assembler support of -pipe option"
2489 cat > $TMPC << EOF
2490 int main(void) { return 0; }
2491 EOF
2492 # -I. helps to detect compilers that just misunderstand -pipe like Sun C 2493 # -I. helps to detect compilers that just misunderstand -pipe like Sun C
2493 cc_check -pipe -I. && _pipe="-pipe" && echores "yes" || echores "no" 2494 cflag_check -pipe -I. && _pipe="-pipe" && echores "yes" || echores "no"
2494 2495
2495 2496
2496 echocheck "compiler support of named assembler arguments" 2497 echocheck "compiler support of named assembler arguments"
2497 _named_asm_args=yes 2498 _named_asm_args=yes
2498 def_named_asm_args="#define NAMED_ASM_ARGS 1" 2499 def_named_asm_args="#define NAMED_ASM_ARGS 1"
2541 fi 2542 fi
2542 else 2543 else
2543 warn_cflags=yes 2544 warn_cflags=yes
2544 fi 2545 fi
2545 2546
2546 cat > $TMPC << EOF
2547 int main(void) { return 0; }
2548 EOF
2549 if test "$cc_vendor" = "gnu" ; then 2547 if test "$cc_vendor" = "gnu" ; then
2550 cc_check -std=gnu99 && CFLAGS="-std=gnu99 $CFLAGS" 2548 cflag_check -std=gnu99 && CFLAGS="-std=gnu99 $CFLAGS"
2551 cc_check -Wdeclaration-after-statement && CFLAGS="-Wdeclaration-after-statement $CFLAGS" 2549 cflag_check -Wdeclaration-after-statement && CFLAGS="-Wdeclaration-after-statement $CFLAGS"
2552 cc_check -Wno-pointer-sign && CFLAGS="-Wno-pointer-sign $CFLAGS" 2550 cflag_check -Wno-pointer-sign && CFLAGS="-Wno-pointer-sign $CFLAGS"
2553 cc_check -Wdisabled-optimization && CFLAGS="-Wdisabled-optimization $CFLAGS" 2551 cflag_check -Wdisabled-optimization && CFLAGS="-Wdisabled-optimization $CFLAGS"
2554 cc_check -Wundef && CFLAGS="-Wundef $CFLAGS" 2552 cflag_check -Wundef && CFLAGS="-Wundef $CFLAGS"
2555 cc_check -Wmissing-prototypes && CFLAGS="-Wmissing-prototypes $CFLAGS" 2553 cflag_check -Wmissing-prototypes && CFLAGS="-Wmissing-prototypes $CFLAGS"
2556 cc_check -Wstrict-prototypes && CFLAGS="-Wstrict-prototypes $CFLAGS" 2554 cflag_check -Wstrict-prototypes && CFLAGS="-Wstrict-prototypes $CFLAGS"
2557 else 2555 else
2558 CFLAGS="-D_ISOC99_SOURCE -D_BSD_SOURCE $CFLAGS" 2556 CFLAGS="-D_ISOC99_SOURCE -D_BSD_SOURCE $CFLAGS"
2559 fi 2557 fi
2560 2558
2561 cc_check -mno-omit-leaf-frame-pointer && cflags_no_omit_leaf_frame_pointer="-mno-omit-leaf-frame-pointer" 2559 cflag_check -mno-omit-leaf-frame-pointer && cflags_no_omit_leaf_frame_pointer="-mno-omit-leaf-frame-pointer"
2562 cc_check -MD -MP && CFLAGS="-MD -MP $CFLAGS" 2560 cflag_check -MD -MP && CFLAGS="-MD -MP $CFLAGS"
2563 2561
2564 2562
2565 if test -n "$LDFLAGS" ; then 2563 if test -n "$LDFLAGS" ; then
2566 extra_ldflags="$extra_ldflags $LDFLAGS" 2564 extra_ldflags="$extra_ldflags $LDFLAGS"
2567 warn_cflags=yes 2565 warn_cflags=yes
2736 def_altivec_h='#define HAVE_ALTIVEC_H 0' 2734 def_altivec_h='#define HAVE_ALTIVEC_H 0'
2737 if ppc && ( test "$_altivec" = yes || test "$_runtime_cpudetection" = yes ) ; then 2735 if ppc && ( test "$_altivec" = yes || test "$_runtime_cpudetection" = yes ) ; then
2738 2736
2739 # check if AltiVec is supported by the compiler, and how to enable it 2737 # check if AltiVec is supported by the compiler, and how to enable it
2740 echocheck "GCC AltiVec flags" 2738 echocheck "GCC AltiVec flags"
2741 cat > $TMPC << EOF 2739 if $(cflag_check -maltivec -mabi=altivec) ; then
2742 int main(void) { return 0; }
2743 EOF
2744 if $(cc_check -maltivec -mabi=altivec) ; then
2745 _altivec_gcc_flags="-maltivec -mabi=altivec" 2740 _altivec_gcc_flags="-maltivec -mabi=altivec"
2746 # check if <altivec.h> should be included 2741 # check if <altivec.h> should be included
2747 if $(header_check altivec.h $_altivec_gcc_flags) ; then 2742 if $(header_check altivec.h $_altivec_gcc_flags) ; then
2748 def_altivec_h='#define HAVE_ALTIVEC_H 1' 2743 def_altivec_h='#define HAVE_ALTIVEC_H 1'
2749 inc_altivec_h='#include <altivec.h>' 2744 inc_altivec_h='#include <altivec.h>'
2750 else 2745 else
2751 cat > $TMPC << EOF 2746 if $(cflag_check -faltivec) ; then
2752 int main(void) { return 0; }
2753 EOF
2754 if $(cc_check -faltivec) ; then
2755 _altivec_gcc_flags="-faltivec" 2747 _altivec_gcc_flags="-faltivec"
2756 else 2748 else
2757 _altivec=no 2749 _altivec=no
2758 _altivec_gcc_flags="none, AltiVec disabled" 2750 _altivec_gcc_flags="none, AltiVec disabled"
2759 fi 2751 fi
2916 # MAIN TESTS GO HERE # 2908 # MAIN TESTS GO HERE #
2917 ###################### 2909 ######################
2918 2910
2919 2911
2920 echocheck "-lposix" 2912 echocheck "-lposix"
2921 cat > $TMPC <<EOF 2913 if cflag_check -lposix ; then
2922 int main(void) { return 0; }
2923 EOF
2924 if cc_check -lposix ; then
2925 extra_ldflags="$extra_ldflags -lposix" 2914 extra_ldflags="$extra_ldflags -lposix"
2926 echores "yes" 2915 echores "yes"
2927 else 2916 else
2928 echores "no" 2917 echores "no"
2929 fi 2918 fi
2930 2919
2931 echocheck "-lm" 2920 echocheck "-lm"
2932 cat > $TMPC <<EOF 2921 if cflag_check -lm ; then
2933 int main(void) { return 0; }
2934 EOF
2935 if cc_check -lm ; then
2936 _ld_lm="-lm" 2922 _ld_lm="-lm"
2937 echores "yes" 2923 echores "yes"
2938 else 2924 else
2939 _ld_lm="" 2925 _ld_lm=""
2940 echores "no" 2926 echores "no"
8255 _crash_debug=no 8241 _crash_debug=no
8256 fi 8242 fi
8257 echores "$_crash_debug" 8243 echores "$_crash_debug"
8258 8244
8259 echocheck "compiler support for noexecstack" 8245 echocheck "compiler support for noexecstack"
8260 cat > $TMPC <<EOF 8246 if cflag_check -Wl,-z,noexecstack ; then
8261 int main(void) { return 0; }
8262 EOF
8263 if cc_check -Wl,-z,noexecstack ; then
8264 extra_ldflags="-Wl,-z,noexecstack $extra_ldflags" 8247 extra_ldflags="-Wl,-z,noexecstack $extra_ldflags"
8265 echores "yes" 8248 echores "yes"
8266 else 8249 else
8267 echores "no" 8250 echores "no"
8268 fi 8251 fi
8269 8252
8270 echocheck "linker support for --nxcompat --no-seh --dynamicbase" 8253 echocheck "linker support for --nxcompat --no-seh --dynamicbase"
8271 if cc_check "-Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase" ; then 8254 if cflag_check "-Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase" ; then
8272 extra_ldflags="-Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase $extra_ldflags" 8255 extra_ldflags="-Wl,--nxcompat -Wl,--no-seh -Wl,--dynamicbase $extra_ldflags"
8273 echores "yes" 8256 echores "yes"
8274 else 8257 else
8275 echores "no" 8258 echores "no"
8276 fi 8259 fi