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 #!/bin/sh
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
#FIXME What platforms for MacOS? #FIXME What platforms for MacOS?
MISC_DARWIN_PLATFORMS="powerpc powerpc64 powerpc64le powerpcle" 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. # 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}" MINGW_PLATFORMS="${X86_PLATFORMS} ${MISC_MINGW_PLATFORMS}"
LINUX_PLATFORMS="${X86_PLATFORMS} ${MISC_LINUX_PLATFORMS}" LINUX_PLATFORMS="${X86_PLATFORMS} ${MISC_LINUX_PLATFORMS}"
FREEBSD_PLATFORMS="${X86_PLATFORMS} ${MISC_FREEBSD_PLATFORMS}" FREEBSD_PLATFORMS="${X86_PLATFORMS} ${MISC_FREEBSD_PLATFORMS}"
@@ -62,142 +65,142 @@ DARWIN_PLATFORMS="core2 corei"
# Set the version to 5.0.2 for OSX because AFAIK there are only 64bit capable CPUs for the Intel Macs # Set the version to 5.0.2 for OSX because AFAIK there are only 64bit capable CPUs for the Intel Macs
if [ `uname -s |grep Darwin` ]; then if [ `uname -s |grep Darwin` ]; then
VER=5.0.2 VER=5.0.2
else 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 fi
if [ "$VER" = "" ] ; then if [ "$VER" = "" ] ; then
echo "ERROR! Can't find gmp source tarball." $ECHO "ERROR! Can't find gmp source tarball."
exit 1 exit 1
fi fi
case `uname -sr` in case `uname -sr` in
MINGW*) MINGW*)
PLATFORM_LIST="${MINGW_PLATFORMS}" PLATFORM_LIST="${MINGW_PLATFORMS}"
NAME="jbigi" NAME="jbigi"
TYPE="dll" TYPE="dll"
TARGET="-windows-" TARGET="-windows-"
echo "Building windows .dlls for all architectures";; $ECHO "Building windows .dlls for all architectures";;
Darwin*) Darwin*)
PLATFORM_LIST="${DARWIN_PLATFORMS}" PLATFORM_LIST="${DARWIN_PLATFORMS}"
NAME="libjbigi" NAME="libjbigi"
TYPE="jnilib" TYPE="jnilib"
TARGET="-osx-" TARGET="-osx-"
echo "Building ${TARGET} .jnilibs for all architectures";; $ECHO "Building ${TARGET} .jnilibs for all architectures";;
Linux*) Linux*)
NAME="libjbigi" NAME="libjbigi"
TYPE="so" TYPE="so"
PLATFORM_LIST="" PLATFORM_LIST=""
TARGET="-linux-" TARGET="-linux-"
arch=$(uname -m | cut -f1 -d" ") arch=$(uname -m | cut -f1 -d" ")
case ${arch} in case ${arch} in
i[3-6]86) i[3-6]86)
arch="x86";; arch="x86";;
esac esac
case ${arch} in case ${arch} in
x86_64 | amd64) x86_64 | amd64)
PLATFORM_LIST="${X86_64_PLATFORMS}" PLATFORM_LIST="${X86_64_PLATFORMS}"
TARGET="-linux-X86_64-";; TARGET="-linux-X86_64-";;
ia64) ia64)
PLATFORM_LIST="${X86_64_PLATFORMS}" PLATFORM_LIST="${X86_64_PLATFORMS}"
TARGET="-linux-ia64-";; TARGET="-linux-ia64-";;
x86) x86)
PLATFORM_LIST="${X86_PLATFORMS}" PLATFORM_LIST="${X86_PLATFORMS}"
TARGET="-linux-x86-";; TARGET="-linux-x86-";;
*) *)
PLATFORM_LIST="${LINUX_PLATFORMS}";; PLATFORM_LIST="${LINUX_PLATFORMS}";;
esac esac
echo "Building ${TARGET} .so's for ${arch}";; $ECHO "Building ${TARGET} .sos for ${arch}";;
NetBSD*|FreeBSD*|OpenBSD*) NetBSD*|FreeBSD*|OpenBSD*)
NAME="libjbigi" NAME="libjbigi"
TYPE="so" TYPE="so"
PLATFORM_LIST="" PLATFORM_LIST=""
BSDTYPE=$(uname -s | tr "[A-Z]" "[a-z]") BSDTYPE=$(uname -s | tr "[A-Z]" "[a-z]")
arch=$(uname -m | cut -f1 -d" ") arch=$(uname -m | cut -f1 -d" ")
case ${arch} in case ${arch} in
i[3-6]86) i[3-6]86)
arch="x86";; arch="x86";;
esac esac
case ${arch} in case ${arch} in
x86_64|amd64) x86_64|amd64)
PLATFORM_LIST="${X86_64_PLATFORMS}" PLATFORM_LIST="${X86_64_PLATFORMS}"
TARGET="-${BSDTYPE}-X86_64-";; TARGET="-${BSDTYPE}-X86_64-";;
ia64) ia64)
PLATFORM_LIST="${X86_64_PLATFORMS}" PLATFORM_LIST="${X86_64_PLATFORMS}"
TARGET="-${BSDTYPE}-ia64-";; TARGET="-${BSDTYPE}-ia64-";;
x86) x86)
PLATFORM_LIST="${X86_PLATFORMS}" PLATFORM_LIST="${X86_PLATFORMS}"
TARGET="-${BSDTYPE}-x86-";; TARGET="-${BSDTYPE}-x86-";;
*) *)
case ${BSDTYPE} in case ${BSDTYPE} in
netbsd) netbsd)
PLATFORM_LIST="${NETBSD_PLATFORMS}";; PLATFORM_LIST="${NETBSD_PLATFORMS}";;
openbsd) openbsd)
PLATFORM_LIST="${OPENBSD_PLATFORMS}";; PLATFORM_LIST="${OPENBSD_PLATFORMS}";;
freebsd) freebsd)
PLATFORM_LIST="${FREEBSD_PLATFORMS}";; PLATFORM_LIST="${FREEBSD_PLATFORMS}";;
*) *)
echo "Unsupported build environment" $ECHO "Unsupported build environment"
exit 1;; exit 1;;
esac esac
esac esac
echo "Building ${BSDTYPE} .so's for ${arch}";; $ECHO "Building ${BSDTYPE} .sos for ${arch}";;
*) *)
echo "Unsupported build environment" $ECHO "Unsupported build environment"
exit;; exit;;
esac esac
function make_static { make_static () {
echo "Attempting .${4} creation for ${3}${5}${2}" $ECHO "Attempting .${4} creation for ${3}${5}${2}"
../../mbuild_jbigi.sh static || return 1 ../../mbuild_jbigi.sh static || return 1
cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}.${4} cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}.${4}
return 0 return 0
} }
function make_file { make_file () {
# Nonfatal bail out on Failed build. # Nonfatal bail out on Failed build.
echo "Attempting build for ${3}${5}${2}" $ECHO "Attempting build for ${3}${5}${2}"
make && return 0 make && return 0
cd .. cd ..
rm -R "$2" 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 sleep 10
return 1 return 1
} }
function configure_file { configure_file () {
echo -e "\n\n\nAttempting configure for ${3}${5}${2}\n\n\n" $ECHO -e "\n\n\nAttempting configure for ${3}${5}${2}\n\n\n"
sleep 10 sleep 10
# Nonfatal bail out on unsupported platform. # Nonfatal bail out on unsupported platform.
if [ `uname -s |grep Darwin` ]; then if [ `uname -s |grep Darwin` ]; then
../../gmp-${1}/configure --build=${2}-apple-darwin --with-pic && return 0 ../../gmp-${1}/configure --build=${2}-apple-darwin --with-pic && return 0
else else
../../gmp-${1}/configure --build=${2} --with-pic && return 0 ../../gmp-${1}/configure --build=${2} --with-pic && return 0
fi fi
cd .. cd ..
rm -R "$2" 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 sleep 10
return 1 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 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 sleep 10
return 1 return 1
} }
echo "Extracting GMP Version $VER ..." $ECHO "Extracting GMP Version $VER ..."
tar -xjf gmp-$VER.tar.bz2 || ( echo "Error in tarball file!" ; exit 1 ) tar -xjf gmp-$VER.tar.bz2 || ( $ECHO "Error in tarball file!" ; exit 1 )
if [ ! -d bin ]; then if [ ! -d bin ]; then
mkdir bin mkdir bin
fi fi
if [ ! -d lib/net/i2p/util ]; then if [ ! -d lib/net/i2p/util ]; then
mkdir -p lib/net/i2p/util mkdir -p lib/net/i2p/util
fi fi
# Don't touch this one. # Don't touch this one.
@@ -205,18 +208,18 @@ NO_PLATFORM=none
for x in $NO_PLATFORM $PLATFORM_LIST for x in $NO_PLATFORM $PLATFORM_LIST
do do
( (
if [ ! -d bin/$x ]; then if [ ! -d bin/$x ]; then
mkdir bin/$x mkdir bin/$x
cd bin/$x cd bin/$x
else else
cd bin/$x cd bin/$x
rm -Rf * rm -Rf *
fi fi
build_file "$VER" "$x" "$NAME" "$TYPE" "$TARGET" build_file "$VER" "$x" "$NAME" "$TYPE" "$TARGET"
) )
done done
echo "Success!" $ECHO "Success!"
exit 0 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 Mingw: Produces a jbigi.dll
# When executed in Linux/FreeBSD: Produces a libjbigi.so # When executed in Linux/FreeBSD: Produces a libjbigi.so
# When executed in OSX: Produces a libjbigi.jnilib # When executed in OSX: Produces a libjbigi.jnilib
@@ -6,17 +6,17 @@ CC="gcc"
case `uname -sr` in case `uname -sr` in
MINGW*) MINGW*)
JAVA_HOME="c:/software/j2sdk1.4.2_05" JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall" COMPILEFLAGS="-Wall"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/" INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at" LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";; LIBFILE="jbigi.dll";;
CYGWIN*) CYGWIN*)
JAVA_HOME="c:/software/j2sdk1.4.2_05" JAVA_HOME="c:/software/j2sdk1.4.2_05"
COMPILEFLAGS="-Wall -mno-cygwin" COMPILEFLAGS="-Wall -mno-cygwin"
INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/" INCLUDES="-I. -I../../jbigi/include -I$JAVA_HOME/include/win32/ -I$JAVA_HOME/include/"
LINKFLAGS="-shared -Wl,--kill-at" LINKFLAGS="-shared -Wl,--kill-at"
LIBFILE="jbigi.dll";; LIBFILE="jbigi.dll";;
Darwin*) Darwin*)
JAVA_HOME=$(/usr/libexec/java_home) JAVA_HOME=$(/usr/libexec/java_home)
COMPILEFLAGS="-fPIC -Wall" COMPILEFLAGS="-fPIC -Wall"
@@ -56,12 +56,12 @@ SunOS*|OpenBSD*|NetBSD*|FreeBSD*|Linux*)
esac esac
if [ "$1" = "dynamic" ] ; then if [ "$1" = "dynamic" ] ; then
echo "Building a jbigi lib that is dynamically linked to GMP" echo "Building a jbigi lib that is dynamically linked to GMP"
LIBPATH="-L.libs" LIBPATH="-L.libs"
INCLUDELIBS="-lgmp" INCLUDELIBS="-lgmp"
else else
echo "Building a jbigi lib that is statically linked to GMP" echo "Building a jbigi lib that is statically linked to GMP"
STATICLIBS=".libs/libgmp.a" STATICLIBS=".libs/libgmp.a"
fi fi
echo "Compiling C code..." echo "Compiling C code..."