factor.sh: add g++ to deps-apt-get. Add all() function to make sure we have both gcc and g++ (since they install separately). Add any() function to tell which of the commands it finds. Fix bug with wget/curl where the function was not meant to accept multiple arguments.

db4
Doug Coleman 2015-08-26 04:11:19 +00:00
parent 8db66d9dd3
commit 7a75694d91
1 changed files with 59 additions and 26 deletions

View File

@ -16,6 +16,7 @@ GIT_PROTOCOL=${GIT_PROTOCOL:="git"}
GIT_URL=${GIT_URL:=$GIT_PROTOCOL"://factorcode.org/git/factor.git"} GIT_URL=${GIT_URL:=$GIT_PROTOCOL"://factorcode.org/git/factor.git"}
SCRIPT_ARGS="$*" SCRIPT_ARGS="$*"
# return 1 on found
test_program_installed() { test_program_installed() {
if ! [[ -n `type -p $1` ]] ; then if ! [[ -n `type -p $1` ]] ; then
return 0; return 0;
@ -23,6 +24,26 @@ test_program_installed() {
return 1; return 1;
} }
# return 1 on found
test_programs_installed() {
installed=0;
$ECHO -n "Checking for all($*)..."
for i in $* ;
do
test_program_installed $i
if [[ $? -eq 1 ]]; then
installed=$(( $installed + 1 ))
fi
done
if [[ $installed -eq $# ]] ; then
$ECHO "found!"
return 1
else
$ECHO "all not found."
return 0
fi
}
exit_script() { exit_script() {
if [[ $FIND_MAKE_TARGET = true ]] ; then if [[ $FIND_MAKE_TARGET = true ]] ; then
# Must be echo not $ECHO # Must be echo not $ECHO
@ -33,32 +54,30 @@ exit_script() {
ensure_program_installed() { ensure_program_installed() {
installed=0; installed=0;
$ECHO -n "Checking for any($*)..."
for i in $* ; for i in $* ;
do do
$ECHO -n "Checking for $i..."
test_program_installed $i test_program_installed $i
if [[ $? -eq 0 ]]; then if [[ $? -eq 1 ]]; then
$ECHO -n "not " $ECHO "found $i!"
else
installed=$(( $installed + 1 )) installed=$(( $installed + 1 ))
return
fi fi
$ECHO "found!"
done done
if [[ $installed -eq 0 ]] ; then $ECHO "none found."
$ECHO -n "Install " $ECHO -n "Install "
if [[ $# -eq 1 ]] ; then if [[ $# -eq 1 ]] ; then
$ECHO -n $1 $ECHO -n $1
else else
$ECHO -n "any of [ $* ]" $ECHO -n "any of [ $* ]"
fi
$ECHO " and try again."
if [[ $OS == macosx ]] ; then
$ECHO "If you have Xcode 4.3 or higher installed, you must install the"
$ECHO "Command Line Tools from Xcode Preferences > Downloads in order"
$ECHO "to build Factor."
fi
exit_script 1;
fi fi
$ECHO " and try again."
if [[ $OS == macosx ]] ; then
$ECHO "If you have Xcode 4.3 or higher installed, you must install the"
$ECHO "Command Line Tools from Xcode Preferences > Downloads in order"
$ECHO "to build Factor."
fi
exit_script 1;
} }
check_ret() { check_ret() {
@ -70,12 +89,18 @@ check_ret() {
} }
set_downloader() { set_downloader() {
test_program_installed wget curl test_program_installed wget
if [[ $? -ne 0 ]] ; then if [[ $? -ne 0 ]] ; then
DOWNLOADER=wget DOWNLOADER=wget
else return
DOWNLOADER="curl -f -O"
fi fi
test_program_installed curl
if [[ $? -ne 0 ]] ; then
DOWNLOADER="curl -f -O"
return
fi
$ECHO "error: wget or curl required"
exit_script 11
} }
set_md5sum() { set_md5sum() {
@ -88,14 +113,22 @@ set_md5sum() {
} }
set_cc() { set_cc() {
test_program_installed clang gcc test_programs_installed clang clang++
if [[ $? -ne 0 ]] ; then if [[ $? -ne 0 ]] ; then
[ -z "$CC" ] && CC=clang [ -z "$CC" ] && CC=clang
[ -z "$CXX" ] && CXX=clang++ [ -z "$CXX" ] && CXX=clang++
else return
fi
test_programs_installed gcc g++
if [[ $? -ne 0 ]] ; then
[ -z "$CC" ] && CC=gcc [ -z "$CC" ] && CC=gcc
[ -z "$CXX" ] && CXX=g++ [ -z "$CXX" ] && CXX=g++
return
fi fi
$ECHO "error: both (clang/clang++) or (gcc/g++) required!"
exit_script 10
} }
set_make() { set_make() {
@ -129,7 +162,7 @@ check_library_exists() {
$ECHO "int main(){return 0;}" > $GCC_TEST $ECHO "int main(){return 0;}" > $GCC_TEST
$CC $GCC_TEST -o $GCC_OUT -l $1 2>&- $CC $GCC_TEST -o $GCC_OUT -l $1 2>&-
if [[ $? -ne 0 ]] ; then if [[ $? -ne 0 ]] ; then
$ECHO "not found!" $ECHO "not found."
$ECHO "***Factor will compile NO_UI=1" $ECHO "***Factor will compile NO_UI=1"
NO_UI=1 NO_UI=1
else else
@ -556,7 +589,7 @@ make_boot_image() {
} }
install_deps_apt_get() { install_deps_apt_get() {
sudo apt-get --yes install libc6-dev libpango1.0-dev libx11-dev xorg-dev libgtk2.0-dev gtk2-engines-pixbuf libgtkglext1-dev wget git git-doc rlwrap clang gcc make screen tmux libssl-dev sudo apt-get --yes install libc6-dev libpango1.0-dev libx11-dev xorg-dev libgtk2.0-dev gtk2-engines-pixbuf libgtkglext1-dev wget git git-doc rlwrap clang gcc make screen tmux libssl-dev g++
check_ret sudo check_ret sudo
} }