configure: factorize gcc machine option checks
authorJames Zern <jzern@google.com>
Wed, 19 Mar 2014 00:22:35 +0000 (17:22 -0700)
committerJames Zern <jzern@google.com>
Wed, 19 Mar 2014 00:25:31 +0000 (17:25 -0700)
check_gcc_machine_option() replaces individual -m* checks

Change-Id: I0f4a82020c0541b99209321907e80e071d1245e1

build/make/configure.sh

index 7991fb3..8cdc9aa 100755 (executable)
@@ -378,6 +378,19 @@ EOF
     fi
 }
 
+# tests for -m$1 toggling the feature given in $2. If $2 is empty $1 is used.
+check_gcc_machine_option() {
+    local opt="$1"
+    local feature="$2"
+    [ -n "$feature" ] || feature="$opt"
+
+    if enabled gcc && ! disabled "$feature" && ! check_cflags "-m$opt"; then
+        RTCD_OPTIONS="${RTCD_OPTIONS}--disable-$feature "
+    else
+        soft_enable "$feature"
+    fi
+}
+
 write_common_config_banner() {
     print_webm_license config.mk "##" ""
     echo '# This file automatically generated by configure. Do not edit!' >> config.mk
@@ -1096,23 +1109,9 @@ EOF
         soft_enable ssse3
         # We can't use 'check_cflags' until the compiler is configured and CC is
         # populated.
-        if enabled gcc && ! disabled sse4_1 && ! check_cflags -msse4; then
-            RTCD_OPTIONS="${RTCD_OPTIONS}--disable-sse4_1 "
-        else
-            soft_enable sse4_1
-        fi
-
-        if enabled gcc && ! disabled avx && ! check_cflags -mavx; then
-            RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx "
-        else
-            soft_enable avx
-        fi
-
-        if enabled gcc && ! disabled avx2 && ! check_cflags -mavx2; then
-            RTCD_OPTIONS="${RTCD_OPTIONS}--disable-avx2 "
-        else
-            soft_enable avx2
-        fi
+        check_gcc_machine_option sse4 sse4_1
+        check_gcc_machine_option avx
+        check_gcc_machine_option avx2
 
         case "${AS}" in
             auto|"")