summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBradley Sepos <[email protected]>2016-11-13 19:34:12 -0500
committerBradley Sepos <[email protected]>2016-11-13 19:35:08 -0500
commitd1d83054e3c9d633a3792888f78247faf040f09d (patch)
tree6fbc16b6210eaeea62f92f1cac06b0b422df9c4e
parent7611df7b083d672abb94537c888ad5c189d3c504 (diff)
scripts: Add mac-toolchain-build.
With the exceptions of Xcode and Command Line Tools for Xcode, builds and installs all HandBrake dependencies for macOS.
-rwxr-xr-xscripts/mac-toolchain-build139
1 files changed, 139 insertions, 0 deletions
diff --git a/scripts/mac-toolchain-build b/scripts/mac-toolchain-build
new file mode 100755
index 000000000..c8984f66c
--- /dev/null
+++ b/scripts/mac-toolchain-build
@@ -0,0 +1,139 @@
+#!/bin/bash
+
+# mac only
+if [[ "$(uname)" != "Darwin" ]]; then
+ echo "macOS/Darwin required" >&2
+ exit 1
+fi
+
+# vars
+PREFIX="${1:-/usr/local}"
+CREL=$(echo -e "\r"$(tput el))
+if ! MAKEJOBS=$(sysctl -n hw.ncpu 2>/dev/null); then
+ MAKEJOBS="4"
+fi
+SUDO=
+TOTAL=6
+
+# functions
+function print_fail_and_exit {
+ echo -en " [FAIL]\n"
+ echo "Logs and temporary files remain at: ${TEMP_DIR:-}" >&2
+ exit 1
+}
+
+# permissions
+mkdir -p "${PREFIX}" >/dev/null 2>&1
+if [[ ! -w "${PREFIX}" ]]; then
+ if ! sudo -n date >/dev/null 2>&1; then
+ echo "sudo is required to install files to ${PREFIX}"
+ sudo -v
+ fi
+ sudo mkdir -p "${PREFIX}" >/dev/null 2>&1
+ if sudo touch "${PREFIX}" >/dev/null 2>&1; then
+ SUDO=sudo
+ else
+ echo "Unable to write to directory: ${PREFIX}" >&2
+ exit 1
+ fi
+fi
+PREFIX=$(cd "${PREFIX}" && pwd -P)
+
+# temp dir
+TEMP_DIR=$(mktemp -d "${TMPDIR:-/tmp/}toolchain-XXXXXX")
+if [[ $? -ne 0 ]]; then
+ echo "Unable to create temporary directory" >&2
+ exit 1
+fi
+cd "${TEMP_DIR}"
+
+# download
+printf "Downloading [%02i/%02i] %s" "1" "${TOTAL}" "autoconf 2.69"
+curl https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz -o "autoconf-2.69.tar.gz" >/dev/null 2>&1 || print_fail_and_exit
+echo -en "${CREL}"
+printf "Downloading [%02i/%02i] %s" "2" "${TOTAL}" "automake 1.15"
+curl https://ftp.gnu.org/gnu/automake/automake-1.15.tar.gz -o "automake-1.15.tar.gz" >/dev/null 2>&1 || print_fail_and_exit
+echo -en "${CREL}"
+printf "Downloading [%02i/%02i] %s" "3" "${TOTAL}" "cmake 3.7.0"
+curl https://cmake.org/files/v3.7/cmake-3.7.0.tar.gz -o "cmake-3.7.0.tar.gz" >/dev/null 2>&1 || print_fail_and_exit
+echo -en "${CREL}"
+printf "Downloading [%02i/%02i] %s" "4" "${TOTAL}" "libtool 2.4.6"
+curl https://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.gz -o "libtool-2.4.6.tar.gz" >/dev/null 2>&1 || print_fail_and_exit
+echo -en "${CREL}"
+printf "Downloading [%02i/%02i] %s" "5" "${TOTAL}" "pkg-config 0.29.1"
+curl https://pkg-config.freedesktop.org/releases/pkg-config-0.29.1.tar.gz -o "pkg-config-0.29.1.tar.gz" >/dev/null 2>&1 || print_fail_and_exit
+echo -en "${CREL}"
+printf "Downloading [%02i/%02i] %s" "6" "${TOTAL}" "yasm 1.3.0"
+curl https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz -o "yasm-1.3.0.tar.gz" >/dev/null 2>&1 || print_fail_and_exit
+echo -en "${CREL}"
+printf "Downloading [%02i/%02i] complete.\n" "${TOTAL}" "${TOTAL}"
+
+# autoconf
+cd "${TEMP_DIR}"
+printf "Building [%02i/%02i] %s" "1" "${TOTAL}" "autoconf 2.69"
+tar -xf autoconf-2.69.tar.gz >/dev/null 2>&1 || print_fail_and_exit
+cd autoconf-2.69 >/dev/null 2>&1 || print_fail_and_exit
+./configure --prefix="${PREFIX}" >../autoconf-2.69.log 2>&1 || print_fail_and_exit
+make --jobs="${MAKEJOBS}" >../autoconf-2.69.log 2>&1 || print_fail_and_exit
+${SUDO} make install >../autoconf-2.69.log 2>&1 || print_fail_and_exit
+echo -en "${CREL}"
+
+# automake
+cd "${TEMP_DIR}"
+printf "Building [%02i/%02i] %s" "2" "${TOTAL}" "automake 1.15"
+tar -xf automake-1.15.tar.gz >/dev/null 2>&1 || print_fail_and_exit
+cd automake-1.15 >/dev/null 2>&1 || print_fail_and_exit
+./configure --prefix="${PREFIX}" >../automake-1.15.log 2>&1 || print_fail_and_exit
+make --jobs="${MAKEJOBS}" >../automake-1.15.log 2>&1 || print_fail_and_exit
+${SUDO} make install >../automake-1.15.log 2>&1 || print_fail_and_exit
+echo -en "${CREL}"
+
+# cmake
+cd "${TEMP_DIR}"
+printf "Building [%02i/%02i] %s\n" "3" "${TOTAL}" "cmake 3.7.0"
+echo "You may safely dismiss and ignore any prompt to install Java."
+tar -xf cmake-3.7.0.tar.gz >/dev/null 2>&1 || print_fail_and_exit
+cd cmake-3.7.0 >/dev/null 2>&1 || print_fail_and_exit
+./configure --prefix="${PREFIX}" --no-qt-gui --system-curl >../cmake-3.7.0.log 2>&1 || print_fail_and_exit
+make --jobs="${MAKEJOBS}" >../cmake-3.7.0.log 2>&1 || print_fail_and_exit
+${SUDO} make install >../cmake-3.7.0.log 2>&1 || print_fail_and_exit
+
+# libtool
+cd "${TEMP_DIR}"
+printf "Building [%02i/%02i] %s" "4" "${TOTAL}" "libtool 2.4.6"
+tar -xf libtool-2.4.6.tar.gz >/dev/null 2>&1 || print_fail_and_exit
+cd libtool-2.4.6 >/dev/null 2>&1 || print_fail_and_exit
+./configure --prefix="${PREFIX}" >../libtool-2.4.6.log 2>&1 || print_fail_and_exit
+make --jobs="${MAKEJOBS}" >../libtool-2.4.6.log 2>&1 || print_fail_and_exit
+${SUDO} make install >../libtool-2.4.6.log 2>&1 || print_fail_and_exit
+echo -en "${CREL}"
+
+# pkg-config
+cd "${TEMP_DIR}"
+printf "Building [%02i/%02i] %s" "5" "${TOTAL}" "pkg-config 0.29.1"
+tar -xf pkg-config-0.29.1.tar.gz >/dev/null 2>&1 || print_fail_and_exit
+cd pkg-config-0.29.1 >/dev/null 2>&1 || print_fail_and_exit
+./configure --prefix="${PREFIX}" --with-internal-glib --disable-host-tool >../pkg-config-0.29.1.log 2>&1 || print_fail_and_exit
+make --jobs="${MAKEJOBS}" >../pkg-config-0.29.1.log 2>&1 || print_fail_and_exit
+${SUDO} make install >../pkg-config-0.29.1.log 2>&1 || print_fail_and_exit
+echo -en "${CREL}"
+
+# yasm
+cd "${TEMP_DIR}"
+printf "Building [%02i/%02i] %s" "6" "${TOTAL}" "yasm 1.3.0"
+tar -xf yasm-1.3.0.tar.gz >/dev/null 2>&1 || print_fail_and_exit
+cd yasm-1.3.0 >/dev/null 2>&1 || print_fail_and_exit
+./configure --prefix="${PREFIX}" >../yasm-1.3.0.log 2>&1 || print_fail_and_exit
+make --jobs="${MAKEJOBS}" >../yasm-1.3.0.log 2>&1 || print_fail_and_exit
+${SUDO} make install >../yasm-1.3.0.log 2>&1 || print_fail_and_exit
+echo -en "${CREL}"
+
+# done
+printf "Building [%02i/%02i] complete.\n" "${TOTAL}" "${TOTAL}"
+rm -rf "${TEMP_DIR}"
+if [[ "${PREFIX}" != "/usr/local" ]]; then
+ echo "bin: ${PREFIX}/bin"
+ echo " add to your shell startup script (${HOME}/.bash_profile):"
+ echo " export PATH=\"${PREFIX}/bin:\${PATH}\""
+fi
+exit 0