mirror of
https://github.com/rbenv/ruby-build.git
synced 2025-09-18 07:01:12 +02:00
automatically detect and use Homebrew's libyaml
Co-authored-by: Mislav Marohnić <git@mislav.net>
This commit is contained in:
parent
99cb5e3fa1
commit
40af31b46b
2 changed files with 26 additions and 21 deletions
|
@ -558,8 +558,21 @@ 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
|
||||
|
@ -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,14 +1067,12 @@ 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"
|
||||
package_option ruby configure --with-readline-dir="$libdir"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
local libdir="$(brew --prefix readline 2>/dev/null || true)"
|
||||
if [ -d "$libdir" ]; then
|
||||
echo "ruby-build: using readline from homebrew"
|
||||
package_option ruby configure --with-readline-dir="$libdir"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue