[1/2] configure: add test_pkg_config()

Message ID 20170929174657.5352-1-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer Sept. 29, 2017, 5:46 p.m.
This helper is split off check_pkg_config(), setting pkg but not global
cflags and extralibs. This is useful for checks that don't require or
benefit from setting the latter.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 configure | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Luca Barbato Sept. 29, 2017, 7:37 p.m. | #1
On 29/09/2017 19:46, James Almer wrote:
> This helper is split off check_pkg_config(), setting pkg but not global
> cflags and extralibs. This is useful for checks that don't require or
> benefit from setting the latter.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   configure | 16 ++++++++++++----
>   1 file changed, 12 insertions(+), 4 deletions(-)
> 

The set sounds good, possibly we could handle _cflags like we do for 
_extralibs though ...

lu
James Almer Sept. 30, 2017, 12:35 a.m. | #2
On 9/29/2017 2:46 PM, James Almer wrote:
> This helper is split off check_pkg_config(), setting pkg but not global
> cflags and extralibs. This is useful for checks that don't require or
> benefit from setting the latter.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  configure | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/configure b/configure
> index a3cfe3768..b9b243362 100755
> --- a/configure
> +++ b/configure
> @@ -1025,8 +1025,8 @@ check_lib(){
>          enable $name && eval ${name}_extralibs="\$@"
>  }
>  
> -check_pkg_config(){
> -    log check_pkg_config "$@"
> +test_pkg_config(){
> +    log test_pkg_config "$@"
>      name="$1"
>      pkg_version="$2"
>      pkg="${2%% *}"
> @@ -1039,8 +1039,16 @@ check_pkg_config(){
>      pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
>      check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
>          enable $name &&
> -        add_cflags    "$pkg_cflags" &&
> -        eval $(sanitize_var_name ${name}_extralibs)="\$pkg_libs"
> +        set_sanitized "${pkg}_cflags"    $pkg_cflags &&
> +        set_sanitized "${pkg}_extralibs" $pkg_libs

Looking at this again after Lucas' comment, guess this should be ${name}
and not ${pkg}? I tried only with SDL (Since it's autodetected) and it
worked, but probably because name and pkg are the same.

Will send a new version if that's indeed the case.

> +}
> +
> +check_pkg_config(){
> +    log check_pkg_config "$@"
> +    pkg="${2%% *}"
> +    test_pkg_config "$@" || return
> +    add_cflags    $(get_sanitized "${pkg}_cflags")
> +    add_extralibs $(get_sanitized "${pkg}_extralibs")
>  }
>  
>  check_exec(){
>

Patch

diff --git a/configure b/configure
index a3cfe3768..b9b243362 100755
--- a/configure
+++ b/configure
@@ -1025,8 +1025,8 @@  check_lib(){
         enable $name && eval ${name}_extralibs="\$@"
 }
 
-check_pkg_config(){
-    log check_pkg_config "$@"
+test_pkg_config(){
+    log test_pkg_config "$@"
     name="$1"
     pkg_version="$2"
     pkg="${2%% *}"
@@ -1039,8 +1039,16 @@  check_pkg_config(){
     pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
         enable $name &&
-        add_cflags    "$pkg_cflags" &&
-        eval $(sanitize_var_name ${name}_extralibs)="\$pkg_libs"
+        set_sanitized "${pkg}_cflags"    $pkg_cflags &&
+        set_sanitized "${pkg}_extralibs" $pkg_libs
+}
+
+check_pkg_config(){
+    log check_pkg_config "$@"
+    pkg="${2%% *}"
+    test_pkg_config "$@" || return
+    add_cflags    $(get_sanitized "${pkg}_cflags")
+    add_extralibs $(get_sanitized "${pkg}_extralibs")
 }
 
 check_exec(){