Unverified Commit 40af31b4 authored by Roman Usherenko's avatar Roman Usherenko Committed by Mislav Marohnić
Browse files

automatically detect and use Homebrew's libyaml



Co-authored-by: default avatarMislav Marohnić <git@mislav.net>
parent 99cb5e3f
Loading
Loading
Loading
Loading
+22 −19
Original line number Diff line number Diff line
@@ -558,9 +558,22 @@ build_package_standard_build() {
  local PACKAGE_CFLAGS="${package_var_name}_CFLAGS"

  if [ "$package_var_name" = "RUBY" ]; then
      use_homebrew_readline || use_freebsd_pkg ||true
    if [[ "$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--with-readline-dir=* ]]; then
      use_homebrew_readline || use_freebsd_readline || true
    fi
    if [[ "$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--with-libyaml-dir=* ]]; then
      use_homebrew_yaml || true
    fi
    if [[ "$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--with-gmp-dir=* ]]; then
      use_homebrew_gmp || true
    fi
    if [[ "$RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]}" != *--with-openssl-dir=* ]]; then
      if [ "FreeBSD" = "$(uname -s)" ] && [ -f /usr/local/include/openssl/ssl.h ]; then
        # use openssl installed from Ports Collection
        package_option ruby configure --with-openssl-dir="/usr/local"
      fi
    fi
  fi

  ( if [ "${CFLAGS+defined}" ] || [ "${!PACKAGE_CFLAGS+defined}" ]; then
      export CFLAGS="$CFLAGS ${!PACKAGE_CFLAGS}"
@@ -1037,18 +1050,10 @@ use_homebrew_gmp() {
  fi
}

use_freebsd_pkg() {
  # check if FreeBSD
use_freebsd_readline() {
  if [ "FreeBSD" = "$(uname -s)" ]; then
    # use openssl if installed from Ports Collection
    if [ -f /usr/local/include/openssl/ssl.h ]; then
      package_option ruby configure --with-openssl-dir="/usr/local"
    fi

    # check if 11-R or later
    release="$(uname -r)"
    local release="$(uname -r)"
    if [ "${release%%.*}" -ge 11 ]; then
      # prefers readline to compile most of ruby versions
      if pkg info -e readline > /dev/null; then
        # use readline from Ports Collection
        package_option ruby configure --with-readline-dir="/usr/local"
@@ -1062,7 +1067,6 @@ use_freebsd_pkg() {
}

use_homebrew_readline() {
  if [[ "$RUBY_CONFIGURE_OPTS" != *--with-readline-dir=* ]]; then
  local libdir="$(brew --prefix readline 2>/dev/null || true)"
  if [ -d "$libdir" ]; then
    echo "ruby-build: using readline from homebrew"
@@ -1070,7 +1074,6 @@ use_homebrew_readline() {
  else
    return 1
  fi
  fi
}

has_broken_mac_openssl() {
+4 −2
Original line number Diff line number Diff line
@@ -186,10 +186,12 @@ OUT
  mkdir -p "$brew_libdir"

  stub uname '-s : echo Linux'
  stub brew "--prefix libyaml : echo '$brew_libdir'" false false
  stub brew false "--prefix libyaml : echo '$brew_libdir'" false
  stub_make_install

  install_fixture definitions/needs-yaml
  run_inline_definition <<DEF
install_package "ruby-2.0.0" "http://ruby-lang.org/ruby/2.0/ruby-2.0.0.tar.gz"
DEF
  assert_success

  unstub uname