Redo functions to remove the dependency on bash

This commit is contained in:
kytv
2011-12-11 12:50:24 +00:00
parent f8a3afd672
commit 6c4dbc545d
2 changed files with 148 additions and 145 deletions

View File

@@ -1,12 +1,4 @@
#!/usr/bin/env bash
if [ -z "$BASH_VERSION" ]; then
echo "This script needs to be run with Bash."
echo
echo "Please install bash and then run this script with"
echo "bash $0"
exit 1
fi
#!/bin/sh
#FIXME What platforms for MacOS?
MISC_DARWIN_PLATFORMS="powerpc powerpc64 powerpc64le powerpcle"
@@ -50,6 +42,17 @@ X86_PLATFORMS="pentium pentiummmx pentium2 pentium3 pentiumm k6 k62 k63 athlon g
# You should not need to edit anything below this comment.
#
# The built-in echo in /bin/sh (the real bourne shell) on BSD systems supports -e.
# The built-in echo in dash (the default /bin/sh on Debian) does not support -e
# but /bin/echo always supports -e in Linux; therefore, let's set echo to /bin/echo
# whenever we're on Linux and use the shell's built-in "echo" on everything else.
if [ $(uname -s |tr "[A-Z]" "[a-z]") = "linux" ]; then
ECHO="/bin/echo"
else
ECHO="echo"
fi
MINGW_PLATFORMS="${X86_PLATFORMS} ${MISC_MINGW_PLATFORMS}"
LINUX_PLATFORMS="${X86_PLATFORMS} ${MISC_LINUX_PLATFORMS}"
FREEBSD_PLATFORMS="${X86_PLATFORMS} ${MISC_FREEBSD_PLATFORMS}"
@@ -64,11 +67,11 @@ DARWIN_PLATFORMS="core2 corei"
if [ `uname -s |grep Darwin` ]; then
VER=5.0.2
else
VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | tail -n 1)
VER=$($ECHO gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | tail -n 1)
fi
if [ "$VER" = "" ] ; then
echo "ERROR! Can't find gmp source tarball."
$ECHO "ERROR! Can't find gmp source tarball."
exit 1
fi
@@ -79,13 +82,13 @@ MINGW*)
NAME="jbigi"
TYPE="dll"
TARGET="-windows-"
echo "Building windows .dlls for all architectures";;
$ECHO "Building windows .dlls for all architectures";;
Darwin*)
PLATFORM_LIST="${DARWIN_PLATFORMS}"
NAME="libjbigi"
TYPE="jnilib"
TARGET="-osx-"
echo "Building ${TARGET} .jnilibs for all architectures";;
$ECHO "Building ${TARGET} .jnilibs for all architectures";;
Linux*)
NAME="libjbigi"
TYPE="so"
@@ -109,7 +112,7 @@ Linux*)
*)
PLATFORM_LIST="${LINUX_PLATFORMS}";;
esac
echo "Building ${TARGET} .so's for ${arch}";;
$ECHO "Building ${TARGET} .sos for ${arch}";;
NetBSD*|FreeBSD*|OpenBSD*)
NAME="libjbigi"
TYPE="so"
@@ -139,36 +142,36 @@ NetBSD*|FreeBSD*|OpenBSD*)
freebsd)
PLATFORM_LIST="${FREEBSD_PLATFORMS}";;
*)
echo "Unsupported build environment"
$ECHO "Unsupported build environment"
exit 1;;
esac
esac
echo "Building ${BSDTYPE} .so's for ${arch}";;
$ECHO "Building ${BSDTYPE} .sos for ${arch}";;
*)
echo "Unsupported build environment"
$ECHO "Unsupported build environment"
exit;;
esac
function make_static {
echo "Attempting .${4} creation for ${3}${5}${2}"
make_static () {
$ECHO "Attempting .${4} creation for ${3}${5}${2}"
../../mbuild_jbigi.sh static || return 1
cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}.${4}
return 0
}
function make_file {
make_file () {
# Nonfatal bail out on Failed build.
echo "Attempting build for ${3}${5}${2}"
$ECHO "Attempting build for ${3}${5}${2}"
make && return 0
cd ..
rm -R "$2"
echo -e "\n\nFAILED! ${3}${5}${2} not made.\a"
$ECHO -e "\n\nFAILED! ${3}${5}${2} not made.\a"
sleep 10
return 1
}
function configure_file {
echo -e "\n\n\nAttempting configure for ${3}${5}${2}\n\n\n"
configure_file () {
$ECHO -e "\n\n\nAttempting configure for ${3}${5}${2}\n\n\n"
sleep 10
# Nonfatal bail out on unsupported platform.
if [ `uname -s |grep Darwin` ]; then
@@ -178,20 +181,20 @@ function configure_file {
fi
cd ..
rm -R "$2"
echo -e "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a"
$ECHO -e "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a"
sleep 10
return 1
}
function build_file {
build_file () {
configure_file "$1" "$2" "$3" "$4" "$5" && make_file "$1" "$2" "$3" "$4" "$5" && make_static "$1" "$2" "$3" "$4" "$5" && return 0
echo -e "\n\n\nError building static!\n\n\a"
$ECHO -e "\n\n\nError building static!\n\n\a"
sleep 10
return 1
}
echo "Extracting GMP Version $VER ..."
tar -xjf gmp-$VER.tar.bz2 || ( echo "Error in tarball file!" ; exit 1 )
$ECHO "Extracting GMP Version $VER ..."
tar -xjf gmp-$VER.tar.bz2 || ( $ECHO "Error in tarball file!" ; exit 1 )
if [ ! -d bin ]; then
mkdir bin
@@ -218,5 +221,5 @@ do
)
done
echo "Success!"
$ECHO "Success!"
exit 0

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env bash
#!/bin/sh
# When executed in Mingw: Produces a jbigi.dll
# When executed in Linux/FreeBSD: Produces a libjbigi.so
# When executed in OSX: Produces a libjbigi.jnilib