[07/12] configure: Move test_foo() and require_foo() helper functions into canonical order

Message ID 20180417081638.3639-8-diego@biurrun.de
State New
Headers show
Series
  • [01/12] build: Group external library protocols separately
Related show

Commit Message

Diego Biurrun April 17, 2018, 8:16 a.m.
---
 configure | 190 +++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 95 insertions(+), 95 deletions(-)

Patch

diff --git a/configure b/configure
index 7c79d80b6e..1afb03b9ce 100755
--- a/configure
+++ b/configure
@@ -876,6 +876,69 @@  EOF
     test_cmd $strip $STRIPFLAGS "$@" $TMPO
 }
 
+test_code(){
+    log test_code "$@"
+    check=$1
+    headers=$2
+    code=$3
+    shift 3
+    {
+        for hdr in $headers; do
+            print_include $hdr
+        done
+        echo "int main(void) { $code; return 0; }"
+    } | test_$check "$@"
+}
+
+test_cpp_condition(){
+    log test_cpp_condition "$@"
+    header=$1
+    condition=$2
+    shift 2
+    test_cpp "$@" <<EOF
+#include <$header>
+#if !($condition)
+#error "unsatisfied condition: $condition"
+#endif
+EOF
+}
+
+test_pkg_config(){
+    log test_pkg_config "$@"
+    name="$1"
+    pkg_version="$2"
+    pkg="${2%% *}"
+    headers="$3"
+    funcs="$4"
+    shift 4
+    disable $name
+    test_cmd $pkg_config --exists --print-errors $pkg_version || return
+    pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
+    pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
+    check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
+        enable $name &&
+        set_sanitized "${name}_cflags"    $pkg_cflags &&
+        set_sanitized "${name}_extralibs" $pkg_libs
+}
+
+test_exec(){
+    log test_exec "$@"
+    test_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
+}
+
+test_host_cpp_condition(){
+    log test_host_cpp_condition "$@"
+    header=$1
+    condition=$2
+    shift 2
+    test_host_cpp "$@" <<EOF
+#include <$header>
+#if !($condition)
+#error "unsatisfied condition: $condition"
+#endif
+EOF
+}
+
 check_cmd(){
     log check_cmd "$@"
     cmd=$1
@@ -935,20 +998,6 @@  print_include(){
         echo "#include <$hdr>"
 }
 
-test_code(){
-    log test_code "$@"
-    check=$1
-    headers=$2
-    code=$3
-    shift 3
-    {
-        for hdr in $headers; do
-            print_include $hdr
-        done
-        echo "int main(void) { $code; return 0; }"
-    } | test_$check "$@"
-}
-
 check_cppflags(){
     log check_cppflags "$@"
     test_cpp "$@" <<EOF && add_cppflags "$@"
@@ -1030,19 +1079,6 @@  check_func_headers(){
     } | test_ld "$@" && enable $funcs && enable_sanitized $headers
 }
 
-test_cpp_condition(){
-    log test_cpp_condition "$@"
-    header=$1
-    condition=$2
-    shift 2
-    test_cpp "$@" <<EOF
-#include <$header>
-#if !($condition)
-#error "unsatisfied condition: $condition"
-#endif
-EOF
-}
-
 check_cpp_condition(){
     log check_cpp_condition "$@"
     name=$1
@@ -1062,24 +1098,6 @@  check_lib(){
         enable $name && eval ${name}_extralibs="\$@"
 }
 
-test_pkg_config(){
-    log test_pkg_config "$@"
-    name="$1"
-    pkg_version="$2"
-    pkg="${2%% *}"
-    headers="$3"
-    funcs="$4"
-    shift 4
-    disable $name
-    test_cmd $pkg_config --exists --print-errors $pkg_version || return
-    pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
-    pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
-    check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
-        enable $name &&
-        set_sanitized "${name}_cflags"    $pkg_cflags &&
-        set_sanitized "${name}_extralibs" $pkg_libs
-}
-
 check_pkg_config(){
     log check_pkg_config "$@"
     name="$1"
@@ -1087,11 +1105,6 @@  check_pkg_config(){
         eval add_cflags \$${name}_cflags
 }
 
-test_exec(){
-    log test_exec "$@"
-    test_ld "$@" && { enabled cross_compile || $TMPE >> $logfile 2>&1; }
-}
-
 check_exec_crash(){
     log check_exec_crash "$@"
     code=$(cat)
@@ -1169,38 +1182,6 @@  check_cc(){
     test_code cc "$@" && enable "$name"
 }
 
-require(){
-    log require "$@"
-    name_version="$1"
-    name="${1%% *}"
-    shift
-    check_lib $name "$@" || die "ERROR: $name_version not found"
-}
-
-require_cc(){
-    log require_cc "$@"
-    name="$1"
-    check_cc "$@" || die "ERROR: $name failed"
-}
-
-require_header(){
-    log require_header "$@"
-    headers="$1"
-    check_headers "$@" || die "ERROR: $headers not found"
-}
-
-require_cpp_condition(){
-    log require_cpp_condition "$@"
-    condition="$2"
-    check_cpp_condition "$@" || die "ERROR: $condition not satisfied"
-}
-
-require_pkg_config(){
-    log require_pkg_config "$@"
-    pkg_version="$2"
-    check_pkg_config "$@" || die "ERROR: $pkg_version not found"
-}
-
 test_host_cc(){
     log test_host_cc "$@"
     cat > $TMPC
@@ -1230,19 +1211,6 @@  int x;
 EOF
 }
 
-test_host_cpp_condition(){
-    log test_host_cpp_condition "$@"
-    header=$1
-    condition=$2
-    shift 2
-    test_host_cpp "$@" <<EOF
-#include <$header>
-#if !($condition)
-#error "unsatisfied condition: $condition"
-#endif
-EOF
-}
-
 check_host_cpp_condition(){
     log check_host_cpp_condition "$@"
     name=$1
@@ -1251,6 +1219,38 @@  check_host_cpp_condition(){
     test_host_cpp_condition "$@" && enable $name
 }
 
+require(){
+    log require "$@"
+    name_version="$1"
+    name="${1%% *}"
+    shift
+    check_lib $name "$@" || die "ERROR: $name_version not found"
+}
+
+require_cc(){
+    log require_cc "$@"
+    name="$1"
+    check_cc "$@" || die "ERROR: $name failed"
+}
+
+require_header(){
+    log require_header "$@"
+    headers="$1"
+    check_headers "$@" || die "ERROR: $headers not found"
+}
+
+require_cpp_condition(){
+    log require_cpp_condition "$@"
+    condition="$2"
+    check_cpp_condition "$@" || die "ERROR: $condition not satisfied"
+}
+
+require_pkg_config(){
+    log require_pkg_config "$@"
+    pkg_version="$2"
+    check_pkg_config "$@" || die "ERROR: $pkg_version not found"
+}
+
 cp_if_changed(){
     cmp -s "$1" "$2" && { test "$quiet" != "yes" && echo "$2 is unchanged"; } && return
     mkdir -p "$(dirname $2)"