#!/usr/bin/env bash
################################################################################
# ffmpeg windows cross compile helper/downloader script
################################################################################
# Copyright (C) 2012 Roger Pack
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see .
#
# The GNU General Public License can be found in the LICENSE file.
yes_no_sel () {
unset user_input
local question="$1"
shift
while [[ "$user_input" != [YyNn] ]]; do
echo -n "$question"
read user_input
if [[ "$user_input" != [YyNn] ]]; then
clear; echo 'Your selection was not vaild, please try again.'; echo
fi
done
# downcase it
user_input=$(echo $user_input | tr '[A-Z]' '[a-z]')
}
check_missing_packages () {
local check_packages=('curl' 'pkg-config' 'make' 'git' 'svn' 'cmake' 'gcc' 'autoconf' 'libtool' 'automake' 'yasm' 'cvs' 'flex' 'bison' 'makeinfo')
for package in "${check_packages[@]}"; do
type -P "$package" >/dev/null || missing_packages=("$package" "${missing_packages[@]}")
done
if [[ -n "${missing_packages[@]}" ]]; then
clear
echo "Could not find the following execs: ${missing_packages[@]}"
echo 'Install the missing packages before running this script.'
exit 1
fi
local out=`cmake --version` # like cmake version 2.8.7
local version_have=`echo "$out" | cut -d " " -f 3`
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
if [[ $(version $version_have) < $(version '2.8.10') ]]; then
echo "your cmake version is too old $version_have wanted 2.8.10"
exit 1
fi
}
cur_dir="$(pwd)/sandbox"
cpu_count="$(grep -c processor /proc/cpuinfo)" # linux only
if [ -z "$cpu_count" ]; then
cpu_count=`sysctl -n hw.ncpu | tr -d '\n'` # OS X
if [ -z "$cpu_count" ]; then
echo "warning, unable to determine cpu count, defaulting to 1"
cpu_count=1 # boxes where we don't know how to determine cpu count [OS X for instance], default to just 1, instead of blank, which means infinite
fi
fi
original_cpu_count=$cpu_count # save it away for some that revert it temporarily
intro() {
cat