Merge commit '2a096440768b1086bb437939f827b8b7a5716bf7'
authorJames Almer <jamrial@gmail.com>
Sun, 9 Apr 2017 16:11:08 +0000 (13:11 -0300)
committerJames Almer <jamrial@gmail.com>
Sun, 9 Apr 2017 16:11:08 +0000 (13:11 -0300)
* commit '2a096440768b1086bb437939f827b8b7a5716bf7':
  configure: Separate package name and version requirements in helper functions

Merged-by: James Almer <jamrial@gmail.com>
1  2 
configure

diff --cc configure
+++ b/configure
@@@ -1223,17 -1007,9 +1223,17 @@@ check_lib()
      check_func_headers "$headers" "$funcs" "$@" && add_extralibs "$@"
  }
  
 +check_lib_cpp(){
 +    log check_lib_cpp "$@"
 +    headers="$1"
 +    classes="$2"
 +    shift 2
 +    check_class_headers_cpp "$headers" "$classes" "$@" && add_extralibs "$@"
 +}
 +
  check_pkg_config(){
      log check_pkg_config "$@"
-     pkgandversion="$1"
+     pkg_version="$1"
      pkg="${1%% *}"
      headers="$2"
      funcs="$3"
@@@ -1327,45 -1103,14 +1327,45 @@@ require()
      headers="$2"
      func="$3"
      shift 3
-     check_lib "$headers" $func "$@" || die "ERROR: $name not found"
+     check_lib "$headers" $func "$@" || die "ERROR: $name_version not found"
  }
  
 +require_cpp(){
 +    name="$1"
 +    headers="$2"
 +    classes="$3"
 +    shift 3
 +    check_lib_cpp "$headers" "$classes" "$@" || die "ERROR: $name not found"
 +}
 +
 +use_pkg_config(){
 +    log use_pkg_config "$@"
 +    pkg="$1"
 +    check_pkg_config "$@" || return 1
 +    add_cflags    $(get_safe "${pkg}_cflags")
 +    add_extralibs $(get_safe "${pkg}_libs")
 +}
 +
  require_pkg_config(){
 -    log require_pkg_config "$@"
 -    pkg_version="$1"
 -    pkg="${1%% *}"
 -    check_pkg_config "$@" || die "ERROR: $pkg_version not found"
 +    use_pkg_config "$@" || die "ERROR: $pkg not found using pkg-config$pkg_config_fail_message"
 +}
 +
 +require_libfreetype(){
 +    log require_libfreetype "$@"
 +    pkg="freetype2"
 +    check_cmd $pkg_config --exists --print-errors $pkg \
 +      || die "ERROR: $pkg not found"
 +    pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
 +    pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
 +    {
 +        echo "#include <ft2build.h>"
 +        echo "#include FT_FREETYPE_H"
 +        echo "long check_func(void) { return (long) FT_Init_FreeType; }"
 +        echo "int main(void) { return 0; }"
 +    } | check_ld "cc" $pkg_cflags $pkg_libs \
 +      && set_safe "${pkg}_cflags" $pkg_cflags \
 +      && set_safe "${pkg}_libs"   $pkg_libs \
 +      || die "ERROR: $pkg not found"
      add_cflags    $(get_safe "${pkg}_cflags")
      add_extralibs $(get_safe "${pkg}_libs")
  }