@@ -106,6 +106,15 @@ is_mac() {
106106 [ $# -eq 0 ] || [ " $( osx_version) " " $@ " ]
107107}
108108
109+ is_freebsd () {
110+ [ " $( uname -s) " = " FreeBSD" ]
111+ }
112+
113+ freebsd_package_prefix () {
114+ local package=" $1 "
115+ pkg info --prefix " $package " 2> /dev/null | cut -wf2
116+ }
117+
109118# 9.1 -> 901
110119# 10.9 -> 1009
111120# 10.10 -> 1010
@@ -561,14 +570,17 @@ build_package_standard_build() {
561570 if [[ " $RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]} " != * --with-readline-dir= * ]]; then
562571 use_homebrew_readline || use_freebsd_readline || true
563572 fi
573+ if [[ " $RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]} " != * --with-libffi-dir= * ]]; then
574+ use_freebsd_libffi || true
575+ fi
564576 if [[ " $RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]} " != * --with-libyaml-dir= * ]]; then
565- use_homebrew_yaml || true
577+ use_homebrew_yaml || use_freebsd_yaml || true
566578 fi
567579 if [[ " $RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]} " != * --with-gmp-dir= * ]]; then
568580 use_homebrew_gmp || true
569581 fi
570582 if [[ " $RUBY_CONFIGURE_OPTS ${RUBY_CONFIGURE_OPTS_ARRAY[*]} " != * --with-openssl-dir= * ]]; then
571- if [ " FreeBSD " = " $( uname -s ) " ] && [ -f /usr/local/include/openssl/ssl.h ]; then
583+ if is_freebsd && [ -f /usr/local/include/openssl/ssl.h ]; then
572584 # use openssl installed from Ports Collection
573585 package_option ruby configure --with-openssl-dir=" /usr/local"
574586 fi
@@ -1040,6 +1052,15 @@ use_homebrew_yaml() {
10401052 fi
10411053}
10421054
1055+ use_freebsd_yaml () {
1056+ if is_freebsd; then
1057+ local libyaml_prefix=" $( freebsd_package_prefix libyaml) "
1058+ if [ -n " $libyaml_prefix " ]; then
1059+ package_option ruby configure --with-libyaml-dir=" $libyaml_prefix "
1060+ fi
1061+ fi
1062+ }
1063+
10431064use_homebrew_gmp () {
10441065 local libdir=" $( brew --prefix gmp 2> /dev/null || true) "
10451066 if [ -d " $libdir " ]; then
@@ -1051,17 +1072,14 @@ use_homebrew_gmp() {
10511072}
10521073
10531074use_freebsd_readline () {
1054- if [ " FreeBSD" = " $( uname -s) " ]; then
1055- local release=" $( uname -r) "
1056- if [ " ${release%% .* } " -ge 11 ]; then
1057- if pkg info -e readline > /dev/null; then
1058- # use readline from Ports Collection
1059- package_option ruby configure --with-readline-dir=" /usr/local"
1060- elif pkg info -e libedit > /dev/null; then
1061- # use libedit from Ports Collection
1062- package_option ruby configure --enable-libedit
1063- package_option ruby configure --with-libedit-dir=" /usr/local"
1064- fi
1075+ if is_freebsd; then
1076+ local readline_prefix=" $( freebsd_package_prefix readline) "
1077+ local libedit_prefix=" $( freebsd_package_prefix libedit) "
1078+ if [ -n " $readline_prefix " ]; then
1079+ package_option ruby configure --with-readline-dir=" $readline_prefix "
1080+ elif [ -n " $libedit_prefix " ]; then
1081+ package_option ruby configure --enable-libedit
1082+ package_option ruby configure --with-libedit-dir=" $libedit_prefix "
10651083 fi
10661084 fi
10671085}
@@ -1076,6 +1094,15 @@ use_homebrew_readline() {
10761094 fi
10771095}
10781096
1097+ use_freebsd_libffi () {
1098+ if is_freebsd; then
1099+ local libffi_prefix=" $( freebsd_package_prefix libffi) "
1100+ if [ -n " $libffi_prefix " ]; then
1101+ package_option ruby configure --with-libffi-dir=" $libffi_prefix "
1102+ fi
1103+ fi
1104+ }
1105+
10791106has_broken_mac_openssl () {
10801107 is_mac || return 1
10811108 local openssl_version=" $( /usr/bin/openssl version 2> /dev/null || true) "
@@ -1474,7 +1501,7 @@ if [ -z "$(locate_gcc)" ]; then
14741501fi
14751502
14761503if [ -z " $MAKE " ]; then
1477- if [ " FreeBSD " = " $( uname -s ) " ] ; then
1504+ if is_freebsd ; then
14781505 # Workaround for Ruby bug 16331: https://bugs.ruby-lang.org/issues/16331
14791506 # Due to this bug, build will fail with FreeBSD's make after #1368
14801507 # The bug is already fixed in upstream but GNU make is still required
0 commit comments