Rename the old function to test_cmd() and have the new
function set a variable if the test succeeds. Leverage the new
function to simplify some recurring patterns.
---
 configure | 44 +++++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git a/configure b/configure
index 52afaca4b4..7247efd019 100755
--- a/configure
+++ b/configure
@@ -759,11 +759,21 @@ add_compat(){
     map 'add_cppflags -D$v' "$@"
 }
 
-check_cmd(){
+test_cmd(){
     log "$@"
     "$@" >> $logfile 2>&1
 }
 
+check_cmd(){
+    log check_cmd "$@"
+    cmd=$1
+    shift
+    if ! disabled $cmd; then
+        disable $cmd
+        test_cmd $cmd $@ && enable $cmd
+    fi
+}
+
 cc_o(){
     eval printf '%s\\n' $CC_O
 }
@@ -776,21 +786,21 @@ check_cc(){
     log check_cc "$@"
     cat > $TMPC
     log_file $TMPC
-    check_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
+    test_cmd $cc $CPPFLAGS $CFLAGS "$@" $CC_C $(cc_o $TMPO) $TMPC
 }
 
 check_objcc(){
     log check_objcc "$@"
     cat > $TMPC
     log_file $TMPC
-    check_cmd $objcc $CPPFLAGS $CFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) 
$TMPC
+    test_cmd $objcc $CPPFLAGS $CFLAGS $OBJCFLAGS "$@" $OBJCC_C $(cc_o $TMPO) 
$TMPC
 }
 
 check_cpp(){
     log check_cpp "$@"
     cat > $TMPC
     log_file $TMPC
-    check_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
+    test_cmd $cc $CPPFLAGS $CFLAGS "$@" $(cc_e $TMPO) $TMPC
 }
 
 as_o(){
@@ -801,7 +811,7 @@ check_as(){
     log check_as "$@"
     cat > $TMPS
     log_file $TMPS
-    check_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
+    test_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
 }
 
 check_inline_asm(){
@@ -826,7 +836,7 @@ check_x86asm(){
     echo "$1" > $TMPS
     log_file $TMPS
     shift 1
-    check_cmd $x86asmexe $X86ASMFLAGS "$@" -o $TMPO $TMPS
+    test_cmd $x86asmexe $X86ASMFLAGS "$@" -o $TMPO $TMPS
 }
 
 ld_o(){
@@ -840,7 +850,7 @@ check_ld(){
     check_cc $($cflags_filter $flags) || return
     flags=$($ldflags_filter $flags)
     libs=$($ldflags_filter $libs)
-    check_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
+    test_cmd $ld $LDFLAGS $flags $(ld_o $TMPE) $TMPO $libs $extralibs
 }
 
 print_include(){
@@ -915,7 +925,7 @@ test_stripflags(){
     check_cc <<EOF
 int main(void) { return 0; }
 EOF
-    check_cmd $strip $STRIPFLAGS "$@" $TMPO
+    test_cmd $strip $STRIPFLAGS "$@" $TMPO
 }
 
 check_stripflags(){
@@ -1023,7 +1033,7 @@ test_pkg_config(){
     funcs="$4"
     shift 4
     disable $name
-    check_cmd $pkg_config --exists --print-errors $pkg_version || return
+    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 "$@" &&
@@ -1157,14 +1167,14 @@ check_host_cc(){
     log check_host_cc "$@"
     cat > $TMPC
     log_file $TMPC
-    check_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
+    test_cmd $host_cc $host_cflags "$@" $HOSTCC_C $(hostcc_o $TMPO) $TMPC
 }
 
 check_host_cpp(){
     log check_host_cpp "$@"
     cat > $TMPC
     log_file $TMPC
-    check_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
+    test_cmd $host_cc $host_cppflags $host_cflags "$@" $(hostcc_e $TMPO) $TMPC
 }
 
 check_host_cppflags(){
@@ -3035,7 +3045,7 @@ HOSTEXESUF=$(exesuf $host_os)
 : ${TMPDIR:=$TMP}
 : ${TMPDIR:=/tmp}
 
-if ! check_cmd mktemp -u XXXXXX; then
+if ! test_cmd mktemp -u XXXXXX; then
     # simple replacement for missing mktemp
     # NOT SAFE FOR GENERAL USE
     mktemp(){
@@ -4265,7 +4275,7 @@ if enabled_any arm aarch64 || enabled_all ppc altivec && 
enabled asm; then
 
     [ $target_os = "darwin" ] && gaspp_as_type="apple-$gaspp_as_type"
 
-    check_cmd gas-preprocessor.pl -arch $arch -as-type $gaspp_as_type -- $as 
$as_noop &&
+    test_cmd gas-preprocessor.pl -arch $arch -as-type $gaspp_as_type -- $as 
$as_noop &&
         gas="gas-preprocessor.pl -arch $arch -as-type $gaspp_as_type -- $as"
 
     if ! check_gas ; then
@@ -4431,13 +4441,13 @@ EOF
 
     probe_x86asm(){
         x86asmexe_probe=$1
-        if check_cmd $x86asmexe_probe -v; then
+        if test_cmd $x86asmexe_probe -v; then
             x86asmexe=$x86asmexe_probe
             x86asm_type=nasm
             x86asm_debug="-g -F dwarf"
             X86ASMDEP=
             X86ASM_DEPFLAGS='-MD $(@:.o=.d)'
-        elif check_cmd $x86asmexe_probe --version; then
+        elif test_cmd $x86asmexe_probe --version; then
             x86asmexe=$x86asmexe_probe
             x86asm_type=yasm
             x86asm_debug="-g dwarf2"
@@ -4748,8 +4758,8 @@ enabled openssl           && { { check_pkg_config openssl 
openssl openssl/ssl.h
 enabled avplay &&
     test_pkg_config sdl "sdl >= 1.2.1 sdl < 1.3.0" SDL_events.h SDL_PollEvent
 
-! disabled pod2man   && check_cmd pod2man --help     && enable pod2man   || 
disable pod2man
-! disabled texi2html && check_cmd texi2html -version && enable texi2html || 
disable texi2html
+check_cmd pod2man --help
+check_cmd texi2html -version
 
 check_header linux/fb.h
 check_header linux/videodev2.h
-- 
2.11.0

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to