#!/usr/bin/env bash if [[ "$rvm_trace_flag" -eq 2 ]] ; then set -x ; export rvm_trace_flag ; fi rvm_base_except="selector" source "$rvm_path/scripts/base" # Tools to make managing ruby dependencies inside of rvm easier. args=($*) action="${args[0]:-""}" library="${args[1]:-""}" args="$(echo ${args[@]:2})" install_package() { __rvm_db "${package}_url" "package_url" if [[ ! -z "$rvm_make_flags_flag" ]] ; then __rvm_make_flags ; fi ( builtin cd "${rvm_src_path:-"$rvm_path/src"}" "$rvm_path/scripts/log" "info" "Fetching $package-$version.$archive_format to ${rvm_archives_path:-"$rvm_path/archives"}" if [[ "$archive_format" = "tar.gz" ]] || [[ "$archive_format" = "tgz" ]] ; then "$rvm_path/scripts/fetch" \ "$package_url/$package-$version.$archive_format" || (result=$? && return $result) __rvm_run "$package/extract" \ "tar zxf ${rvm_archives_path:-"$rvm_path/archives"}/$package-$version.$archive_format -C ${rvm_src_path:-"$rvm_path/src"}" "Extracting $package-$version.$archive_format to ${rvm_src_path:-"$rvm_path/src"}" elif [[ "$archive_format" = "tar.bz2" ]] ; then "$rvm_path/scripts/fetch" \ "$package_url/$package-$version.$archive_format" || (result=$? && return $result) __rvm_run "$package/extract" \ "tar jxf ${rvm_archives_path:-"$rvm_path/archives"}/$package-$version.$archive_format -C ${rvm_src_path:-"$rvm_path/src"}" "Extracting $package-$version.$archive_format to ${rvm_src_path:-"$rvm_path/src"}" elif [[ "$archive_format" = "zip" ]] ; then "$rvm_path/scripts/fetch" \ "$package_url/$package-$version.$archive_format" || (result=$? && return $result) __rvm_run "$package/extract" \ "unzip -q -o ${rvm_archives_path:-"$rvm_path/archives"}/$package-$version.$archive_format -d ${rvm_src_path:-"$rvm_path/src"}/$package-$version" "Extracting $package-$version.$archive_format to ${rvm_src_path:-"$rvm_path/src"}" else printf "\nUnrecognized archive format '$archive_format'" ; return 1 fi builtin cd "${rvm_src_path:-"$rvm_path/src"}/$package-$version" __rvm_run "$package/configure" \ "${configure:-"./configure --prefix=${prefix_path:-"${rvm_usr_path:-"$rvm_path/usr"}"}"} $configure_flags" "Configuring $package in ${rvm_src_path:-"$rvm_path/src"}/$package-$version." unset configure_flags if [[ "$action" = "uninstall" ]] ; then __rvm_run "$package/make.uninstall" \ "/usr/bin/make uninstall" "Uninstalling $package from ${rvm_usr_path:-"$rvm_path/usr"}" else __rvm_run "$package/make" \ "/usr/bin/make $rvm_make_flags" "Compiling $package in ${rvm_src_path:-"$rvm_path/src"}/$package-$version." __rvm_run "$package/make.install" \ "/usr/bin/make install" "Installing $package to ${rvm_usr_path:-"$rvm_path/usr"}" fi touch "$rvm_path/config/packages" "$rvm_path/scripts/db" "$rvm_path/config/packages" "${package}" "${version}" ) result=$? return ${result:-0} } readline() { package="readline" ; archive_format="tar.gz" for version in 5.2 6.0 ; do configure_flags="--disable-dependency-tracking --disable-static --enable-shared" install_package done } iconv() { package="libiconv" ; version=1.13.1 ; archive_format="tar.gz" install_package } curl() { package="curl" ; version=7.19.7 ; archive_format="tar.gz" install_package } openssl() { package="openssl" ; version="0.9.8n" ; archive_format="tar.gz" if [[ "Darwin" = "$(uname)" ]] ; then if [[ ! -z "$rvm_archflags" ]]; then if "$rvm_path/scripts/match" "$rvm_archflags" "64"; then hw_cpu64bit=1 fi if "$rvm_path/scripts/match" "$rvm_archflags" "ppc"; then hw_machine="Power Macintosh" fi else hw_machine=$(sysctl hw.machine | awk -F: '{print $2}' | sed 's/^ //') hw_cpu64bit=$(sysctl hw.cpu64bit_capable | awk '{print $2}') fi if [[ "Power Macintosh" = "$hw_machine" ]] ; then if [[ $hw_cpu64bit = 1 ]]; then openssl_os="darwin64-ppc-cc" else openssl_os="darwin-ppc-cc" fi else if [[ $hw_cpu64bit = 1 ]]; then openssl_os="darwin64-x86_64-cc" else openssl_os="darwin-i386-cc" fi fi configure_command="./Configure" patches="$rvm_path/patches/$package/Makefile.org.patch,$rvm_patch/patches/$package/crypto-Makefile.patch" # Don't use -j option for make OpenSSL if [[ ! -z "$rvm_make_flags" ]] ; then rvm_make_flags=$(echo "$rvm_make_flags" | sed -e "s/-j[[:space:]]*[[0-9]]*//") fi else configure_command="./config" fi configure="$configure_command $openssl_os -I${rvm_usr_path:-"$rvm_path/usr"}/include -L${rvm_usr_path:-"$rvm_path/usr"}/lib --prefix=${rvm_usr_path:-"$rvm_path/usr"} zlib no-asm no-krb5 shared" install_package } zlib() { package="zlib" ; version="1.2.5" ; archive_format="tar.gz" install_package } autoconf() { package="autoconf" ; version="2.65" ; archive_format="tar.gz" prefix_path="${rvm_usr_path:-"$rvm_path/usr"}" install_package } ncurses() { package="ncurses" ; version="5.7" ; archive_format="tar.gz" configure_flags="--with-shared --disable-rpath --without-debug --without-ada --enable-safe-sprintf --enable-sigwinch --without-progs" install_package } pkgconfig() { package="pkg-config" ; version="0.23" archive_format="tar.gz" install_package } gettext() { package="gettext" ; version="0.17" ; archive_format="tar.gz" install_package } libxml2() { package="libxml2" ; version="2.7.3" ; archive_format="tar.gz" if [[ "Darwin" = "$(uname)" ]] ; then configure="./configure --prefix=${rvm_usr_path:-"$rvm_path/usr"} --build=i686-apple-darwin$(uname -r) --host=i686-apple-darwin$(uname -r)" fi install_package unset prefix_path } glib() { pkgconfig gettext package="glib" ; version="2.23.1" ; archive_format="tar.gz" configure="CC=\"cc -L${rvm_usr_path:-"$rvm_path/usr"}/lib -I${rvm_usr_path:-"$rvm_path/usr"}/include\" PKG_CONFIG=\"${rvm_usr_path:-"$rvm_path/usr"}/bin/pkg-config\" ./configure --prefix=${rvm_usr_path:-"$rvm_path/usr"}" install_package } mono() { glib __rvm_mono_env package="mono" ; version="2.6.1" ; archive_format="tar.bz2" install_package } llvm() { package="llvm" ; version="89156" if [[ ! -z "$rvm_make_flags_flag" ]] ; then __rvm_make_flags ; fi ( builtin cd ${rvm_src_path:-"$rvm_path/src"} if [[ ! -d "${rvm_src_path:-"$rvm_path/src"}/llvm/.svn" ]] ; then __rvm_db "${package}_url" "package_url" \rm -rf "${rvm_src_path:-"$rvm_path/src"}/llvm" svn co -r "$version" "$package_url" llvm builtin cd "${rvm_src_path:-"$rvm_path/src"}/llvm" ./configure --enable-bindings=none UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make -j2 sudo env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make install fi ) } if [[ -n "$library" ]] ; then case $library in readline|iconv|curl|openssl|zlib|autoconf|ncurses|pkgconfig|gettext|glib|mono|llvm|libxml2) ${library} ;; *) "$rvm_path/scripts/log" "error" "Package '${library}' is unknown." ;; esac exit $? else "$rvm_path/scripts/log" "info" \ "Usage: 'rvm package {install,uninstall} {readline,iconv,curl,openssl,zlib,autoconf,ncurses,pkgconfig,gettext,glib,mono,llvm,libxml2}'" exit 1 fi