2011-12-11 12:50:24 +00:00
|
|
|
#!/bin/sh
|
2014-11-30 21:19:28 +00:00
|
|
|
#
|
|
|
|
# Run with BITS=32 to generate 32-bit libs on a 64-bit platform
|
|
|
|
# On Ubuntu you will need sudo apt-get install gcc-multilib libc6-i386 libc6-dev-i386
|
|
|
|
#
|
2011-10-07 21:13:39 +00:00
|
|
|
|
2013-05-12 00:08:52 +00:00
|
|
|
# ON Solaris 11 (at least) this variable must be set.
|
|
|
|
# Linux and *BSD will do the right thing.
|
|
|
|
#
|
|
|
|
#BITS=32
|
2012-11-19 22:41:54 +00:00
|
|
|
|
2014-11-30 21:19:28 +00:00
|
|
|
#
|
|
|
|
# look in configure file in gmp source for supported host CPUs, at about line 5000
|
|
|
|
#
|
|
|
|
|
2013-05-12 00:08:52 +00:00
|
|
|
# FIXME Is this all?
|
|
|
|
DARWIN_PLATFORMS="core2 corei"
|
2011-09-19 12:23:43 +00:00
|
|
|
MISC_DARWIN_PLATFORMS="powerpc powerpc64 powerpc64le powerpcle"
|
2009-03-30 05:31:40 +00:00
|
|
|
|
|
|
|
# Note: You will have to add the CPU ID for the platform in the CPU ID code
|
|
|
|
# for a new CPU. Just adding them here won't let I2P use the code!
|
|
|
|
|
|
|
|
#
|
2011-09-18 16:56:10 +00:00
|
|
|
# If you know of other platforms i2p on linux works on,
|
2009-03-30 05:31:40 +00:00
|
|
|
# please add them here.
|
|
|
|
# Do NOT add any X86 platforms, do that below in the x86 platform list.
|
|
|
|
#
|
2011-05-21 18:26:10 +00:00
|
|
|
MISC_LINUX_PLATFORMS="hppa2.0 alphaev56 armv5tel mips64el itanium itanium2 ultrasparc2 ultrasparc2i alphaev6 powerpc970 powerpc7455 powerpc7447"
|
2009-03-30 05:31:40 +00:00
|
|
|
|
|
|
|
#
|
2011-09-19 12:23:43 +00:00
|
|
|
# If you know of other platforms i2p on *BSD works on,
|
2009-03-30 05:31:40 +00:00
|
|
|
# please add them here.
|
|
|
|
# Do NOT add any X86 platforms, do that below in the x86 platform list.
|
|
|
|
#
|
2011-05-21 18:26:10 +00:00
|
|
|
MISC_FREEBSD_PLATFORMS="alphaev56 ultrasparc2i"
|
2011-09-20 01:18:16 +00:00
|
|
|
MISC_NETBSD_PLATFORMS="armv5tel mips64el ultrasparc2i sgi hppa2.0 alphaev56 powerpc powerpc64 powerpc64le powerpcle atari amiga m68knommu" # and many, many more
|
|
|
|
MISC_OPENBSD_PLATFORMS="alphaev56 ultrasparc2i sgi powerpc powerpc64 hppa2.0 alphaev56 armv5tel mips64el"
|
2009-03-30 05:31:40 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# MINGW/Windows??
|
|
|
|
#
|
|
|
|
MISC_MINGW_PLATFORMS=""
|
|
|
|
|
|
|
|
#
|
|
|
|
# Are there any other X86 platforms that work on i2p? Add them here.
|
|
|
|
#
|
2011-05-23 04:52:29 +00:00
|
|
|
# Note! these build on 32bit as 32bit when operating as 32bit...
|
2014-11-30 21:19:28 +00:00
|
|
|
# starting with k10 added for 6.0.0
|
|
|
|
# As of GMP 6.0.0, libgmp 3,
|
|
|
|
# the following architectures appear to build to identical code:
|
2015-04-22 22:10:42 +00:00
|
|
|
# coreisbr coreihwl coreibwl
|
2014-11-30 21:19:28 +00:00
|
|
|
# core2 corei
|
|
|
|
# bulldozer piledriver streamroller excavator
|
|
|
|
# bobcat jaguar
|
|
|
|
# k62 k63
|
|
|
|
# viac32 pentium3
|
|
|
|
#
|
|
|
|
# Even more duplicates are in 32-bit mode, so it doesn't pay to have everything for 32 bit.
|
|
|
|
#
|
2015-04-22 22:10:42 +00:00
|
|
|
X86_64_PLATFORMS="coreisbr coreihwl coreibwl bobcat jaguar bulldozer piledriver steamroller excavator atom athlon64 core2 corei nano pentium4 k10"
|
2011-05-23 04:52:29 +00:00
|
|
|
|
2015-04-22 22:10:42 +00:00
|
|
|
# Note! these are 32bit _ONLY_ (after the 64 bit ones)
|
|
|
|
X86_PLATFORMS="${X86_64_PLATFORMS} pentium pentiummmx pentium2 pentium3 pentiumm k6 k62 k63 athlon geode viac3 viac32"
|
2009-03-30 05:31:40 +00:00
|
|
|
|
2013-05-12 00:08:52 +00:00
|
|
|
MINGW_PLATFORMS="${X86_PLATFORMS} ${MISC_MINGW_PLATFORMS}"
|
|
|
|
LINUX_PLATFORMS="${X86_PLATFORMS} ${MISC_LINUX_PLATFORMS}"
|
|
|
|
FREEBSD_PLATFORMS="${X86_PLATFORMS} ${MISC_FREEBSD_PLATFORMS}"
|
|
|
|
# As they say, "Of course it runs NetBSD!"
|
|
|
|
NETBSD_PLATFORMS="${FREEBSD_PLATFORMS} ${MISC_LINUX_PLATFORMS} ${MISC_NETBSD_PLATFORMS}"
|
|
|
|
OPENBSD_PLATFORM="${X86_PLATFORMS} ${MISC_OPENBSD_PLATFORMS}"
|
2009-03-30 05:31:40 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# You should not need to edit anything below this comment.
|
|
|
|
#
|
|
|
|
|
2013-05-12 00:08:52 +00:00
|
|
|
# If JAVA_HOME isn't set we'll try to figure it out
|
|
|
|
[ -z $JAVA_HOME ] && . ../find-java-home
|
|
|
|
if [ ! -f "$JAVA_HOME/include/jni.h" ]; then
|
|
|
|
echo "Cannot find jni.h! Looked in '$JAVA_HOME/include/jni.h'" >&2
|
|
|
|
echo "Please set JAVA_HOME to a java home that has the JNI" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2011-12-11 12:50:24 +00:00
|
|
|
|
2013-05-12 00:08:52 +00:00
|
|
|
if [ ! $(which m4) ]; then
|
|
|
|
printf "\aWARNING: \`m4\` not found. If this process fails to complete, install m4 " >&2
|
|
|
|
printf "and re-run this script.\n\n\n\a" >&2
|
|
|
|
sleep 10
|
2011-12-11 12:50:24 +00:00
|
|
|
fi
|
|
|
|
|
2011-09-19 12:23:43 +00:00
|
|
|
|
2013-05-12 00:08:52 +00:00
|
|
|
# Allow TARGET to be overridden (e.g. for use with cross compilers)
|
|
|
|
[ -z $TARGET ] && TARGET=$(uname -s |tr "[A-Z]" "[a-z]")
|
|
|
|
|
2011-07-30 23:18:39 +00:00
|
|
|
|
2011-12-11 11:47:48 +00:00
|
|
|
# Set the version to 5.0.2 for OSX because AFAIK there are only 64bit capable CPUs for the Intel Macs
|
2013-05-12 00:08:52 +00:00
|
|
|
# FIXME do this without sed (and tail) (= portably)
|
|
|
|
if [ `echo $TARGET|grep darwin` ]; then
|
2011-12-11 12:50:24 +00:00
|
|
|
VER=5.0.2
|
2013-05-12 00:08:52 +00:00
|
|
|
elif [ `echo $TARGET|grep sunos` ]; then
|
|
|
|
VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | /usr/xpg4/bin/tail -n 1)
|
2011-07-30 23:18:39 +00:00
|
|
|
else
|
2013-05-12 00:08:52 +00:00
|
|
|
VER=$(echo gmp-*.tar.bz2 | sed -e "s/\(.*-\)\(.*\)\(.*.tar.bz2\)$/\2/" | tail -n 1)
|
2011-07-30 23:18:39 +00:00
|
|
|
fi
|
2009-03-30 05:31:40 +00:00
|
|
|
|
2011-09-18 16:56:10 +00:00
|
|
|
if [ "$VER" = "" ] ; then
|
2013-05-12 00:08:52 +00:00
|
|
|
echo "ERROR! Can't find gmp source tarball."
|
2011-12-11 12:50:24 +00:00
|
|
|
exit 1
|
2009-03-30 05:31:40 +00:00
|
|
|
fi
|
|
|
|
|
2013-05-12 00:08:52 +00:00
|
|
|
# If the BITS variable isn't set above we'll proceed without setting the *FLAGS
|
|
|
|
# variables ourselves.
|
|
|
|
[ -z $BITS ] && BITS=0
|
|
|
|
|
|
|
|
if [ $BITS -eq 32 ]; then
|
|
|
|
export CC="gcc -m32"
|
|
|
|
export CFLAGS="-m32"
|
|
|
|
export LDFLAGS="-m32"
|
|
|
|
SUFFIX=
|
|
|
|
elif [ $BITS -eq 64 ]; then
|
|
|
|
export CC="gcc -m64"
|
|
|
|
export CFLAGS="-m64"
|
|
|
|
fi
|
2009-03-30 05:31:40 +00:00
|
|
|
|
2013-05-12 00:08:52 +00:00
|
|
|
case "$TARGET" in
|
|
|
|
mingw*)
|
2011-12-11 12:50:24 +00:00
|
|
|
PLATFORM_LIST="${MINGW_PLATFORMS}"
|
|
|
|
NAME="jbigi"
|
|
|
|
TYPE="dll"
|
2012-11-19 22:41:54 +00:00
|
|
|
TARGET="windows"
|
2013-05-12 00:08:52 +00:00
|
|
|
echo "Building windows .dlls for all architectures";;
|
|
|
|
darwin*)
|
2011-12-11 12:50:24 +00:00
|
|
|
PLATFORM_LIST="${DARWIN_PLATFORMS}"
|
|
|
|
NAME="libjbigi"
|
|
|
|
TYPE="jnilib"
|
2012-11-19 22:41:54 +00:00
|
|
|
TARGET="osx"
|
2013-05-12 00:08:52 +00:00
|
|
|
echo "Building ${TARGET} .jnilibs for all architectures";;
|
|
|
|
sunos*)
|
|
|
|
PLATFORM_LIST="${X86_64_PLATFORMS}"
|
|
|
|
NAME="libjbigi"
|
|
|
|
TYPE="so"
|
|
|
|
UNIXTYPE="solaris"
|
|
|
|
TARGET="${UNIXTYPE}"
|
|
|
|
if $(echo "$CFLAGS" | grep -q "\-m64") ; then
|
|
|
|
[ -z $SUFFIX ] && SUFFIX="_64"
|
|
|
|
PLATFORM_LIST="${X86_64_PLATFORMS}"
|
|
|
|
else
|
|
|
|
PLATFORM_LIST="${X86_PLATFORMS}"
|
|
|
|
fi
|
|
|
|
echo "Building ${TARGET} .sos for all architectures";;
|
|
|
|
linux*|*kfreebsd)
|
2011-12-11 12:50:24 +00:00
|
|
|
NAME="libjbigi"
|
|
|
|
TYPE="so"
|
|
|
|
PLATFORM_LIST=""
|
2013-05-12 00:08:52 +00:00
|
|
|
case "$TARGET" in
|
|
|
|
*kfreebsd)
|
2012-11-19 22:41:54 +00:00
|
|
|
TARGET="kfreebsd"
|
2013-05-12 00:08:52 +00:00
|
|
|
;;
|
|
|
|
*)
|
2012-11-19 22:41:54 +00:00
|
|
|
TARGET="linux"
|
2013-05-12 00:08:52 +00:00
|
|
|
;;
|
|
|
|
esac
|
2011-12-11 12:50:24 +00:00
|
|
|
arch=$(uname -m | cut -f1 -d" ")
|
|
|
|
case ${arch} in
|
|
|
|
i[3-6]86)
|
|
|
|
arch="x86";;
|
|
|
|
esac
|
|
|
|
case ${arch} in
|
|
|
|
x86_64 | amd64)
|
|
|
|
PLATFORM_LIST="${X86_64_PLATFORMS}"
|
2013-05-12 00:08:52 +00:00
|
|
|
if [ $BITS -ne 32 ]; then
|
|
|
|
[ -z $SUFFIX ] && SUFFIX="_64"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
#ia64)
|
|
|
|
# PLATFORM_LIST="${X86_64_PLATFORMS}"
|
|
|
|
# TARGET="$TARGET-ia64";;
|
2011-12-11 12:50:24 +00:00
|
|
|
x86)
|
2013-05-12 00:08:52 +00:00
|
|
|
PLATFORM_LIST="${X86_PLATFORMS}";;
|
2011-12-11 12:50:24 +00:00
|
|
|
*)
|
|
|
|
PLATFORM_LIST="${LINUX_PLATFORMS}";;
|
|
|
|
esac
|
2013-05-12 00:08:52 +00:00
|
|
|
echo "Building ${TARGET} .sos for ${arch}";;
|
|
|
|
netbsd*|freebsd*|openbsd*)
|
2011-12-11 12:50:24 +00:00
|
|
|
NAME="libjbigi"
|
|
|
|
TYPE="so"
|
2013-05-12 00:08:52 +00:00
|
|
|
PLATFORM_LIST=
|
2011-12-11 12:50:24 +00:00
|
|
|
arch=$(uname -m | cut -f1 -d" ")
|
|
|
|
case ${arch} in
|
|
|
|
i[3-6]86)
|
|
|
|
arch="x86";;
|
|
|
|
esac
|
|
|
|
case ${arch} in
|
|
|
|
x86_64|amd64)
|
|
|
|
PLATFORM_LIST="${X86_64_PLATFORMS}"
|
2013-05-12 00:08:52 +00:00
|
|
|
[ -z $SUFFIX ] && SUFFIX="_64";;
|
|
|
|
#ia64)
|
|
|
|
# PLATFORM_LIST="${X86_64_PLATFORMS}"
|
|
|
|
# SUFFIX="{SYS}-ia64";;
|
2011-12-11 12:50:24 +00:00
|
|
|
x86)
|
2013-05-12 00:08:52 +00:00
|
|
|
PLATFORM_LIST="${X86_PLATFORMS}";;
|
2011-12-11 12:50:24 +00:00
|
|
|
*)
|
2013-05-12 00:08:52 +00:00
|
|
|
case ${TARGET} in
|
2011-12-11 12:50:24 +00:00
|
|
|
netbsd)
|
|
|
|
PLATFORM_LIST="${NETBSD_PLATFORMS}";;
|
|
|
|
openbsd)
|
|
|
|
PLATFORM_LIST="${OPENBSD_PLATFORMS}";;
|
|
|
|
freebsd)
|
|
|
|
PLATFORM_LIST="${FREEBSD_PLATFORMS}";;
|
|
|
|
*)
|
2013-05-12 00:08:52 +00:00
|
|
|
echo "Unsupported build environment"
|
2011-12-11 12:50:24 +00:00
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
esac
|
2013-05-12 00:08:52 +00:00
|
|
|
echo "Building ${TARGET} .sos for ${arch}";;
|
2009-03-30 05:31:40 +00:00
|
|
|
*)
|
2013-05-12 00:08:52 +00:00
|
|
|
echo "Unsupported build environment"
|
2011-12-11 12:50:24 +00:00
|
|
|
exit;;
|
2009-03-30 05:31:40 +00:00
|
|
|
esac
|
|
|
|
|
2013-05-12 00:08:52 +00:00
|
|
|
#####################
|
|
|
|
# In the below functions:
|
|
|
|
# $1 = gmp version
|
|
|
|
# $2 = platform: such as athlon64
|
|
|
|
# $3 = basename: "jbigi" on Windows, "libjbigi" everywhere else
|
|
|
|
# $4 = type/extension: windows = "dll". osx = "jnilib". Everything else = "so"
|
|
|
|
# $5 = target: "linux", "freebsd", "kfreebsd", "osx", "windows", etc.
|
|
|
|
# $6 = suffix: null if 32bit, _64 if 64bit
|
|
|
|
|
2011-12-11 12:50:24 +00:00
|
|
|
make_static () {
|
2013-05-12 00:08:52 +00:00
|
|
|
echo "Attempting .${4} creation for ${3}${5}${2}${6}"
|
2012-01-08 23:23:00 +00:00
|
|
|
../../build_jbigi.sh static || return 1
|
2013-05-12 00:08:52 +00:00
|
|
|
cp ${3}.${4} ../../lib/net/i2p/util/${3}${5}${2}${6}.${4}
|
2011-12-11 12:50:24 +00:00
|
|
|
return 0
|
2009-03-30 05:31:40 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 12:50:24 +00:00
|
|
|
make_file () {
|
|
|
|
# Nonfatal bail out on Failed build.
|
2013-05-12 00:08:52 +00:00
|
|
|
echo "Attempting build for ${3}${5}${2}"
|
2015-05-25 17:49:11 +00:00
|
|
|
make -j && return 0
|
2011-12-11 12:50:24 +00:00
|
|
|
cd ..
|
|
|
|
rm -R "$2"
|
2013-05-12 00:08:52 +00:00
|
|
|
printf "\n\nFAILED! ${3}${5}${2} not made.\a"
|
2011-12-11 12:50:24 +00:00
|
|
|
sleep 10
|
|
|
|
return 1
|
2009-03-30 05:31:40 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 12:50:24 +00:00
|
|
|
configure_file () {
|
2013-05-12 00:08:52 +00:00
|
|
|
printf "\n\n\nAttempting configure for ${3}${5}${2}${6}\n\n\n"
|
|
|
|
if [ $BITS -eq 32 ] && [ "$2" = "none" ]; then
|
|
|
|
unset ABI
|
|
|
|
elif [ $BITS -eq 32 ] && [ "$2" != "none" ]; then
|
|
|
|
export ABI=32
|
|
|
|
fi
|
2015-05-25 17:49:11 +00:00
|
|
|
sleep 1
|
|
|
|
|
2011-12-11 12:50:24 +00:00
|
|
|
# Nonfatal bail out on unsupported platform.
|
2015-05-25 18:16:19 +00:00
|
|
|
(cd ../../gmp-${1}; make clean)
|
2013-05-12 00:08:52 +00:00
|
|
|
if [ $(echo $TARGET| grep -q osx) ]; then
|
2011-12-11 12:50:24 +00:00
|
|
|
../../gmp-${1}/configure --build=${2}-apple-darwin --with-pic && return 0
|
|
|
|
else
|
|
|
|
../../gmp-${1}/configure --build=${2} --with-pic && return 0
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
rm -R "$2"
|
2013-05-12 00:08:52 +00:00
|
|
|
printf "\n\nSorry, ${3}${5}${2} is not supported on your build environment.\a"
|
2011-12-11 12:50:24 +00:00
|
|
|
sleep 10
|
|
|
|
return 1
|
2009-03-30 05:31:40 +00:00
|
|
|
}
|
|
|
|
|
2011-12-11 12:50:24 +00:00
|
|
|
build_file () {
|
2013-05-12 00:08:52 +00:00
|
|
|
configure_file "$1" "$2" "$3" "$4" "$5" "$6" && make_file "$1" "$2" "$3" "$4" "$5" "$6" && make_static "$1" "$2" "$3" "$4" "$5" "$6" && return 0
|
|
|
|
printf "\n\n\nError building static!\n\n\a"
|
2011-12-11 12:50:24 +00:00
|
|
|
sleep 10
|
|
|
|
return 1
|
2009-03-30 05:31:40 +00:00
|
|
|
}
|
|
|
|
|
2015-05-23 18:48:35 +00:00
|
|
|
if [ ! -d gmp-$VER ]; then
|
|
|
|
echo "Extracting GMP Version $VER ..."
|
|
|
|
if [ -e gmp-$VER.tar.bz2 ]; then
|
2013-05-12 00:08:52 +00:00
|
|
|
tar -xjf gmp-$VER.tar.bz2 || ( echo "Error in tarball file!" >&2 ; exit 1 )
|
2015-05-23 18:48:35 +00:00
|
|
|
else
|
2013-05-12 00:08:52 +00:00
|
|
|
echo "ERROR: gmp tarball not found in current directory" >&2
|
|
|
|
exit 1
|
2015-05-23 18:48:35 +00:00
|
|
|
fi
|
2013-05-12 00:08:52 +00:00
|
|
|
fi
|
2009-03-30 05:31:40 +00:00
|
|
|
|
|
|
|
if [ ! -d bin ]; then
|
2011-12-11 12:50:24 +00:00
|
|
|
mkdir bin
|
2009-03-30 05:31:40 +00:00
|
|
|
fi
|
|
|
|
if [ ! -d lib/net/i2p/util ]; then
|
2011-12-11 12:50:24 +00:00
|
|
|
mkdir -p lib/net/i2p/util
|
2009-03-30 05:31:40 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Don't touch this one.
|
|
|
|
NO_PLATFORM=none
|
|
|
|
|
2015-04-22 22:10:42 +00:00
|
|
|
for x in $PLATFORM_LIST $NO_PLATFORM
|
2009-03-30 05:31:40 +00:00
|
|
|
do
|
2011-12-11 12:50:24 +00:00
|
|
|
(
|
|
|
|
if [ ! -d bin/$x ]; then
|
|
|
|
mkdir bin/$x
|
|
|
|
cd bin/$x
|
|
|
|
else
|
|
|
|
cd bin/$x
|
|
|
|
rm -Rf *
|
|
|
|
fi
|
|
|
|
|
2013-05-12 00:08:52 +00:00
|
|
|
build_file "$VER" "$x" "$NAME" "$TYPE" "-$TARGET-" "$SUFFIX"
|
2011-12-11 12:50:24 +00:00
|
|
|
)
|
2009-03-30 05:31:40 +00:00
|
|
|
done
|
|
|
|
|
2013-05-12 00:08:52 +00:00
|
|
|
echo "Success!"
|
2009-03-30 05:31:40 +00:00
|
|
|
exit 0
|
2013-05-12 00:08:52 +00:00
|
|
|
|
|
|
|
# vim:fenc=utf-8:ai:si:ts=4:sw=4:et:nu
|