mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2025-02-13 09:34:56 +00:00
Add untracked files that git was not able to track when asked to perform a 'git mv'
This commit is contained in:
parent
7c7cb15f36
commit
8e4942bbfc
402
TestScripts/setenv-android.sh
Executable file
402
TestScripts/setenv-android.sh
Executable file
@ -0,0 +1,402 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ====================================================================
|
||||
# Sets the cross compile environment for Android
|
||||
# Based upon OpenSSL's setenv-android.sh (by TH, JW, and SM).
|
||||
#
|
||||
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
|
||||
# licensed under the Boost Software License 1.0, while the individual files
|
||||
# in the compilation are all public domain.
|
||||
#
|
||||
# See http://www.cryptopp.com/wiki/Android_(Command_Line) for more details
|
||||
# ====================================================================
|
||||
|
||||
set -eu
|
||||
|
||||
unset IS_CROSS_COMPILE
|
||||
|
||||
unset IS_IOS
|
||||
unset IS_ANDROID
|
||||
unset IS_ARM_EMBEDDED
|
||||
|
||||
# Variables used in GNUmakefile-cross
|
||||
unset AOSP_FLAGS
|
||||
unset AOSP_SYSROOT
|
||||
unset AOSP_STL_INC
|
||||
unset AOSP_STL_LIB
|
||||
unset AOSP_BITS_INC
|
||||
|
||||
# Former variables
|
||||
unset ANDROID_FLAGS ANDROID_SYSROOT
|
||||
unset ANDROID_STL_INC ANDROID_STL_LIB
|
||||
|
||||
# Tools set by this script
|
||||
unset CPP CC CXX LD AS AR RANLIB STRIP
|
||||
|
||||
# Similar to a "make clean"
|
||||
if [ x"${1-}" = "xunset" ]; then
|
||||
echo "Unsetting script variables. PATH may remain tainted"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 0 || return 0
|
||||
fi
|
||||
|
||||
# Set AOSP_TOOLCHAIN_SUFFIX to your preference of tools and STL library.
|
||||
# Note: 4.9 is required for the latest architectures, like ARM64/AARCH64.
|
||||
# AOSP_TOOLCHAIN_SUFFIX=4.8
|
||||
# AOSP_TOOLCHAIN_SUFFIX=4.9
|
||||
if [ -z "${AOSP_TOOLCHAIN_SUFFIX-}" ]; then
|
||||
AOSP_TOOLCHAIN_SUFFIX=4.9
|
||||
fi
|
||||
|
||||
# Set AOSP_API to the API you want to use. 'armeabi' and 'armeabi-v7a' need
|
||||
# API 3 (or above), 'mips' and 'x86' need API 9 (or above), etc.
|
||||
# AOSP_API="android-3" # Android 1.5 and above
|
||||
# AOSP_API="android-4" # Android 1.6 and above
|
||||
# AOSP_API="android-5" # Android 2.0 and above
|
||||
# AOSP_API="android-8" # Android 2.2 and above
|
||||
# AOSP_API="android-9" # Android 2.3 and above
|
||||
# AOSP_API="android-14" # Android 4.0 and above
|
||||
# AOSP_API="android-18" # Android 4.3 and above
|
||||
# AOSP_API="android-19" # Android 4.4 and above
|
||||
# AOSP_API="android-21" # Android 5.0 and above
|
||||
# AOSP_API="android-23" # Android 6.0 and above
|
||||
if [ -z "${AOSP_API-}" ]; then
|
||||
AOSP_API="android-21"
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
|
||||
# ANDROID_NDK_ROOT should always be set by the user (even when not running this script)
|
||||
# http://groups.google.com/group/android-ndk/browse_thread/thread/a998e139aca71d77.
|
||||
# If the user did not specify the NDK location, try and pick it up. We expect something
|
||||
# like ANDROID_NDK_ROOT=/opt/android-ndk-r10e or ANDROID_NDK_ROOT=/usr/local/android-ndk-r10e.
|
||||
|
||||
if [ -z "${ANDROID_NDK_ROOT-}" ]; then
|
||||
ANDROID_NDK_ROOT=$(find /opt -maxdepth 1 -type d -name android-ndk-r10* 2>/dev/null | tail -1)
|
||||
|
||||
if [ -z "$ANDROID_NDK_ROOT" ]; then
|
||||
ANDROID_NDK_ROOT=$(find /usr/local -maxdepth 1 -type d -name android-ndk-r10* 2>/dev/null | tail -1)
|
||||
fi
|
||||
if [ -z "$ANDROID_NDK_ROOT" ]; then
|
||||
ANDROID_NDK_ROOT=$(find $HOME -maxdepth 1 -type d -name android-ndk-r10* 2>/dev/null | tail -1)
|
||||
fi
|
||||
if [ -d "$HOME/Library/Android/sdk/ndk-bundle" ]; then
|
||||
ANDROID_NDK_ROOT="$HOME/Library/Android/sdk/ndk-bundle"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -d "$ANDROID_NDK_ROOT/toolchains" ]; then
|
||||
echo "ERROR: ANDROID_NDK_ROOT is not a valid path. Please set it."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
|
||||
if [ "$#" -lt 1 ]; then
|
||||
THE_ARCH=armv7
|
||||
else
|
||||
THE_ARCH=$(tr [A-Z] [a-z] <<< "$1")
|
||||
fi
|
||||
|
||||
# https://developer.android.com/ndk/guides/abis.html
|
||||
case "$THE_ARCH" in
|
||||
arm|armv5|armv6|armv7|armeabi)
|
||||
TOOLCHAIN_ARCH="arm-linux-androideabi"
|
||||
TOOLCHAIN_NAME="arm-linux-androideabi"
|
||||
AOSP_ABI="armeabi"
|
||||
AOSP_ARCH="arch-arm"
|
||||
AOSP_FLAGS="-march=armv5te -mtune=xscale -mthumb -msoft-float -funwind-tables -fexceptions -frtti"
|
||||
;;
|
||||
armv7a|armeabi-v7a)
|
||||
TOOLCHAIN_ARCH="arm-linux-androideabi"
|
||||
TOOLCHAIN_NAME="arm-linux-androideabi"
|
||||
AOSP_ABI="armeabi-v7a"
|
||||
AOSP_ARCH="arch-arm"
|
||||
AOSP_FLAGS="-march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti"
|
||||
;;
|
||||
hard|armv7a-hard|armeabi-v7a-hard)
|
||||
TOOLCHAIN_ARCH="arm-linux-androideabi"
|
||||
TOOLCHAIN_NAME="arm-linux-androideabi"
|
||||
AOSP_ABI="armeabi-v7a"
|
||||
AOSP_ARCH="arch-arm"
|
||||
AOSP_FLAGS="-mhard-float -D_NDK_MATH_NO_SOFTFP=1 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti -Wl,--no-warn-mismatch -Wl,-lm_hard"
|
||||
;;
|
||||
neon|armv7a-neon)
|
||||
TOOLCHAIN_ARCH="arm-linux-androideabi"
|
||||
TOOLCHAIN_NAME="arm-linux-androideabi"
|
||||
AOSP_ABI="armeabi-v7a"
|
||||
AOSP_ARCH="arch-arm"
|
||||
AOSP_FLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=softfp -Wl,--fix-cortex-a8 -funwind-tables -fexceptions -frtti"
|
||||
;;
|
||||
armv8|armv8a|aarch64|arm64|arm64-v8a)
|
||||
TOOLCHAIN_ARCH="aarch64-linux-android"
|
||||
TOOLCHAIN_NAME="aarch64-linux-android"
|
||||
AOSP_ABI="arm64-v8a"
|
||||
AOSP_ARCH="arch-arm64"
|
||||
AOSP_FLAGS="-funwind-tables -fexceptions -frtti"
|
||||
;;
|
||||
mips|mipsel)
|
||||
TOOLCHAIN_ARCH="mipsel-linux-android"
|
||||
TOOLCHAIN_NAME="mipsel-linux-android"
|
||||
AOSP_ABI="mips"
|
||||
AOSP_ARCH="arch-mips"
|
||||
AOSP_FLAGS="-funwind-tables -fexceptions -frtti"
|
||||
;;
|
||||
mips64|mipsel64|mips64el)
|
||||
TOOLCHAIN_ARCH="mips64el-linux-android"
|
||||
TOOLCHAIN_NAME="mips64el-linux-android"
|
||||
AOSP_ABI="mips64"
|
||||
AOSP_ARCH="arch-mips64"
|
||||
AOSP_FLAGS="-funwind-tables -fexceptions -frtti"
|
||||
;;
|
||||
x86)
|
||||
TOOLCHAIN_ARCH="x86"
|
||||
TOOLCHAIN_NAME="i686-linux-android"
|
||||
AOSP_ABI="x86"
|
||||
AOSP_ARCH="arch-x86"
|
||||
AOSP_FLAGS="-march=i686 -mtune=intel -mssse3 -mfpmath=sse -funwind-tables -fexceptions -frtti"
|
||||
;;
|
||||
x86_64|x64)
|
||||
TOOLCHAIN_ARCH="x86_64"
|
||||
TOOLCHAIN_NAME="x86_64-linux-android"
|
||||
AOSP_ABI="x86_64"
|
||||
AOSP_ARCH="arch-x86_64"
|
||||
AOSP_FLAGS="-march=x86-64 -msse4.2 -mpopcnt -mtune=intel -funwind-tables -fexceptions -frtti"
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Unknown architecture $1"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
#####################################################################
|
||||
|
||||
# GNUmakefile-cross expects these to be set. They are also used in the tests below.
|
||||
export IS_ANDROID=1
|
||||
export AOSP_FLAGS
|
||||
|
||||
# TODO: for the previous GNUmakefile-cross. These can go away eventually.
|
||||
export ANDROID_FLAGS=$AOSP_FLAGS
|
||||
|
||||
export CPP="$TOOLCHAIN_NAME-cpp"
|
||||
export CC="$TOOLCHAIN_NAME-gcc"
|
||||
export CXX="$TOOLCHAIN_NAME-g++"
|
||||
export LD="$TOOLCHAIN_NAME-ld"
|
||||
export AS="$TOOLCHAIN_NAME-as"
|
||||
export AR="$TOOLCHAIN_NAME-ar"
|
||||
export RANLIB="$TOOLCHAIN_NAME-ranlib"
|
||||
export STRIP="$TOOLCHAIN_NAME-strip"
|
||||
|
||||
#####################################################################
|
||||
|
||||
# Based on ANDROID_NDK_ROOT, try and pick up the path for the tools. We expect something
|
||||
# like /opt/android-ndk-r10e/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin
|
||||
# Once we locate the tools, we add it to the PATH.
|
||||
AOSP_TOOLCHAIN_PATH=""
|
||||
for host in "linux-x86_64" "darwin-x86_64" "linux-x86" "darwin-x86"
|
||||
do
|
||||
if [ -d "$ANDROID_NDK_ROOT/toolchains/$TOOLCHAIN_ARCH-$AOSP_TOOLCHAIN_SUFFIX/prebuilt/$host/bin" ]; then
|
||||
AOSP_TOOLCHAIN_PATH="$ANDROID_NDK_ROOT/toolchains/$TOOLCHAIN_ARCH-$AOSP_TOOLCHAIN_SUFFIX/prebuilt/$host/bin"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Error checking
|
||||
if [ -z "$AOSP_TOOLCHAIN_PATH" ] || [ ! -d "$AOSP_TOOLCHAIN_PATH" ]; then
|
||||
echo "ERROR: AOSP_TOOLCHAIN_PATH is not valid. Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$CPP" ]; then
|
||||
echo "ERROR: Failed to find Android cpp. Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$CC" ]; then
|
||||
echo "ERROR: Failed to find Android gcc. Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$CXX" ]; then
|
||||
echo "ERROR: Failed to find Android g++. Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$RANLIB" ]; then
|
||||
echo "ERROR: Failed to find Android ranlib. Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$AR" ]; then
|
||||
echo "ERROR: Failed to find Android ar. Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$AS" ]; then
|
||||
echo "ERROR: Failed to find Android as. Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -e "$AOSP_TOOLCHAIN_PATH/$LD" ]; then
|
||||
echo "ERROR: Failed to find Android ld. Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Only modify/export PATH if AOSP_TOOLCHAIN_PATH good
|
||||
if [ -d "$AOSP_TOOLCHAIN_PATH" ]; then
|
||||
|
||||
# And only modify PATH if AOSP_TOOLCHAIN_PATH is not present
|
||||
LEN=${#AOSP_TOOLCHAIN_PATH}
|
||||
SUBSTR=${PATH:0:$LEN}
|
||||
if [ "$SUBSTR" != "$AOSP_TOOLCHAIN_PATH" ]; then
|
||||
export PATH="$AOSP_TOOLCHAIN_PATH":"$PATH"
|
||||
fi
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
|
||||
# Error checking
|
||||
if [ ! -d "$ANDROID_NDK_ROOT/platforms/$AOSP_API" ]; then
|
||||
echo "ERROR: AOSP_API is not valid. Does the NDK support the API? Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
elif [ ! -d "$ANDROID_NDK_ROOT/platforms/$AOSP_API/$AOSP_ARCH" ]; then
|
||||
echo "ERROR: AOSP_ARCH is not valid. Does the NDK support the architecture? Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Android SYSROOT. It will be used on the command line with --sysroot
|
||||
# http://android.googlesource.com/platform/ndk/+/ics-mr0/docs/STANDALONE-TOOLCHAIN.html
|
||||
export AOSP_SYSROOT="$ANDROID_NDK_ROOT/platforms/$AOSP_API/$AOSP_ARCH"
|
||||
|
||||
# TODO: export for the previous GNUmakefile-cross. These can go away eventually.
|
||||
export ANDROID_SYSROOT=$AOSP_SYSROOT
|
||||
|
||||
#####################################################################
|
||||
|
||||
# Android STL. We support GNU, LLVM and STLport out of the box.
|
||||
|
||||
if [ "$#" -lt 2 ]; then
|
||||
THE_STL=gnu-shared
|
||||
else
|
||||
THE_STL=$(tr [A-Z] [a-z] <<< "$2")
|
||||
fi
|
||||
|
||||
case "$THE_STL" in
|
||||
stlport-static)
|
||||
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport/"
|
||||
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/$AOSP_ABI/libstlport_static.a"
|
||||
;;
|
||||
stlport|stlport-shared)
|
||||
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/stlport/"
|
||||
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/stlport/libs/$AOSP_ABI/libstlport_shared.so"
|
||||
;;
|
||||
gabi++-static|gnu-static)
|
||||
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/include"
|
||||
AOSP_BITS_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/include"
|
||||
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/libgnustl_static.a"
|
||||
;;
|
||||
gnu|gabi++|gnu-shared|gabi++-shared)
|
||||
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/include"
|
||||
AOSP_BITS_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/include"
|
||||
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/gnu-libstdc++/$AOSP_TOOLCHAIN_SUFFIX/libs/$AOSP_ABI/libgnustl_shared.so"
|
||||
;;
|
||||
llvm-static)
|
||||
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/libcxx/include"
|
||||
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/libs/$AOSP_ABI/libc++_static.a"
|
||||
;;
|
||||
llvm|llvm-shared)
|
||||
AOSP_STL_INC="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/libcxx/include"
|
||||
AOSP_STL_LIB="$ANDROID_NDK_ROOT/sources/cxx-stl/llvm-libc++/libs/$AOSP_ABI/libc++_shared.so"
|
||||
;;
|
||||
*)
|
||||
echo "ERROR: Unknown STL library $2"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
esac
|
||||
|
||||
# Error checking
|
||||
if [ ! -d "$AOSP_STL_INC" ] || [ ! -e "$AOSP_STL_INC/memory" ]; then
|
||||
echo "ERROR: AOSP_STL_INC is not valid. Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Error checking
|
||||
if [ ! -e "$AOSP_STL_LIB" ]; then
|
||||
echo "ERROR: AOSP_STL_LIB is not valid. Please edit this script."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
export AOSP_STL_INC
|
||||
export AOSP_STL_LIB
|
||||
|
||||
# TODO: for the previous GNUmakefile-cross. These can go away eventually.
|
||||
export ANDROID_STL_INC=$AOSP_STL_INC
|
||||
export ANDROID_STL_LIB=$AOSP_STL_LIB
|
||||
|
||||
if [ ! -z "$AOSP_BITS_INC" ]; then
|
||||
export AOSP_BITS_INC
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
|
||||
VERBOSE=1
|
||||
if [ ! -z "$VERBOSE" ] && [ "$VERBOSE" != "0" ]; then
|
||||
echo "ANDROID_NDK_ROOT: $ANDROID_NDK_ROOT"
|
||||
echo "AOSP_TOOLCHAIN_PATH: $AOSP_TOOLCHAIN_PATH"
|
||||
echo "AOSP_ABI: $AOSP_ABI"
|
||||
echo "AOSP_API: $AOSP_API"
|
||||
echo "AOSP_SYSROOT: $AOSP_SYSROOT"
|
||||
echo "AOSP_FLAGS: $AOSP_FLAGS"
|
||||
echo "AOSP_STL_INC: $AOSP_STL_INC"
|
||||
echo "AOSP_STL_LIB: $AOSP_STL_LIB"
|
||||
if [ ! -z "$AOSP_BITS_INC" ]; then
|
||||
echo "AOSP_BITS_INC: $AOSP_BITS_INC"
|
||||
fi
|
||||
fi
|
||||
|
||||
#####################################################################
|
||||
|
||||
COUNT=$(echo -n "$AOSP_STL_LIB" | grep -i -c 'libstdc++')
|
||||
if [[ ("$COUNT" -ne "0") ]]; then
|
||||
echo
|
||||
echo "*******************************************************************************"
|
||||
echo "You are using GNU's runtime and STL library. Please ensure the resulting"
|
||||
echo "binary meets licensing requirements. If you can't use GNU's runtime"
|
||||
echo "and STL library, then reconfigure with stlport or llvm. Also see"
|
||||
echo "http://code.google.com/p/android/issues/detail?id=216331"
|
||||
echo "*******************************************************************************"
|
||||
fi
|
||||
|
||||
COUNT=$(echo -n "$AOSP_STL_LIB" | grep -i -c 'libstlport')
|
||||
if [[ ("$COUNT" -ne "0") ]]; then
|
||||
echo
|
||||
echo "*******************************************************************************"
|
||||
echo "You are using STLport's runtime and STL library. STLport could cause problems"
|
||||
echo "if the resulting binary is used in other environments, like a QT project."
|
||||
echo "Also see http://code.google.com/p/android/issues/detail?id=216331"
|
||||
echo "*******************************************************************************"
|
||||
fi
|
||||
|
||||
COUNT=$(echo -n "$AOSP_STL_LIB" | egrep -i -c 'libc++)')
|
||||
if [[ ("$COUNT" -ne "0") ]]; then
|
||||
echo
|
||||
echo "*******************************************************************************"
|
||||
echo "You are using LLVM's runtime and STL library. LLVM could cause problems"
|
||||
echo "if the resulting binary is used in other environments, like a QT project."
|
||||
echo "Also see http://code.google.com/p/android/issues/detail?id=216331"
|
||||
echo "*******************************************************************************"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "*******************************************************************************"
|
||||
echo "It looks the the environment is set correctly. Your next step is"
|
||||
echo "build the library with 'make -f GNUmakefile-cross'"
|
||||
echo "*******************************************************************************"
|
||||
echo
|
||||
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 0 || return 0
|
142
TestScripts/setenv-embedded.sh
Executable file
142
TestScripts/setenv-embedded.sh
Executable file
@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ====================================================================
|
||||
# Sets the cross compile environment for ARM Embedded
|
||||
#
|
||||
# Written by Jeffrey Walton, noloader gmail account
|
||||
#
|
||||
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
|
||||
# licensed under the Boost Software License 1.0, while the individual files
|
||||
# in the compilation are all public domain.
|
||||
#
|
||||
# This script only supports Ubuntu at the moment. It does not support Fedora.
|
||||
# See http://www.cryptopp.com/wiki/ARM_Embedded_(Command_Line) for details.
|
||||
# ====================================================================
|
||||
|
||||
set -eu
|
||||
|
||||
# Unset old options
|
||||
|
||||
unset IS_CROSS_COMPILE
|
||||
|
||||
unset IS_IOS
|
||||
unset IS_ANDROID
|
||||
unset IS_ARM_EMBEDDED
|
||||
|
||||
if [ -z "${ARM_EMBEDDED_TOOLCHAIN-}" ]; then
|
||||
ARM_EMBEDDED_TOOLCHAIN="/usr/bin"
|
||||
fi
|
||||
|
||||
if [ ! -d "$ARM_EMBEDDED_TOOLCHAIN" ]; then
|
||||
echo "ARM_EMBEDDED_TOOLCHAIN is not valid"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Fedora
|
||||
# TOOL_PREFIX="arm-linux-gnu"
|
||||
|
||||
# Ubuntu
|
||||
TOOL_PREFIX="arm-linux-gnueabi"
|
||||
|
||||
export CPP="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-cpp"
|
||||
export CC="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-gcc"
|
||||
export CXX="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-g++"
|
||||
export LD="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-ld"
|
||||
export AR="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-ar"
|
||||
export AS="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-as"
|
||||
export RANLIB="$ARM_EMBEDDED_TOOLCHAIN/$TOOL_PREFIX-gcc-ranlib-4.7"
|
||||
|
||||
# Test a few of the tools
|
||||
if [ ! -e "$CPP" ]; then
|
||||
echo "ERROR: CPP is not valid"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
if [ ! -e "$CC" ]; then
|
||||
echo "ERROR: CC is not valid"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
if [ ! -e "$CXX" ]; then
|
||||
echo "ERROR: CXX is not valid"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
if [ ! -e "$AR" ]; then
|
||||
echo "ERROR: AR is not valid"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
if [ ! -e "$AS" ]; then
|
||||
echo "ERROR: AS is not valid"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
if [ ! -e "$RANLIB" ]; then
|
||||
echo "ERROR: RANLIB is not valid"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
if [ ! -e "$LD" ]; then
|
||||
echo "ERROR: LD is not valid"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# The Crypto++ Makefile uses these to disable host settings like
|
||||
# IS_LINUX or IS_DARWIN, and incorporate settings for ARM_EMBEDDED
|
||||
export IS_ARM_EMBEDDED=1
|
||||
|
||||
# GNUmakefile-cross uses these to to set CXXFLAGS for ARM_EMBEDDED
|
||||
if [ -z "$ARM_EMBEDDED_SYSROOT" ]; then
|
||||
export ARM_EMBEDDED_SYSROOT="/usr/arm-linux-gnueabi"
|
||||
fi
|
||||
|
||||
if [ ! -d "$ARM_EMBEDDED_SYSROOT" ]; then
|
||||
echo "ERROR: ARM_EMBEDDED_SYSROOT is not valid"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Fix C++ header paths for Ubuntu
|
||||
ARM_EMBEDDED_TOOLCHAIN_VERSION="4.7.3"
|
||||
ARM_EMBEDDED_CXX_HEADERS="$ARM_EMBEDDED_SYSROOT/include/c++/$ARM_EMBEDDED_TOOLCHAIN_VERSION"
|
||||
|
||||
if [ ! -d "$ARM_EMBEDDED_CXX_HEADERS" ]; then
|
||||
echo "ERROR: ARM_EMBEDDED_CXX_HEADERS is not valid"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$ARM_EMBEDDED_CXX_HEADERS/arm-linux-gnueabi" ]; then
|
||||
echo "ERROR: ARM_EMBEDDED_CXX_HEADERS is not valid"
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Finally, the flags...
|
||||
# export ARM_EMBEDDED_FLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -Wl,--fix-cortex-a8 -I$ARM_EMBEDDED_CXX_HEADERS -I$ARM_EMBEDDED_CXX_HEADERS/arm-linux-gnueabi"
|
||||
|
||||
# Add additional flags below, like -mcpu=cortex-m3.
|
||||
if [ -z "$ARM_EMBEDDED_FLAGS" ]; then
|
||||
export ARM_EMBEDDED_FLAGS="-I$ARM_EMBEDDED_CXX_HEADERS -I$ARM_EMBEDDED_CXX_HEADERS/arm-linux-gnueabi"
|
||||
fi
|
||||
|
||||
# And print stuff to wow the user...
|
||||
VERBOSE=1
|
||||
if [ ! -z "$VERBOSE" ] && [ "$VERBOSE" -ne 0 ]; then
|
||||
echo "CPP: $CPP"
|
||||
echo "CXX: $CXX"
|
||||
echo "AR: $AR"
|
||||
echo "LD: $LD"
|
||||
echo "RANLIB: $RANLIB"
|
||||
echo "ARM_EMBEDDED_TOOLCHAIN: $ARM_EMBEDDED_TOOLCHAIN"
|
||||
echo "ARM_EMBEDDED_CXX_HEADERS: $ARM_EMBEDDED_CXX_HEADERS"
|
||||
echo "ARM_EMBEDDED_FLAGS: $ARM_EMBEDDED_FLAGS"
|
||||
echo "ARM_EMBEDDED_SYSROOT: $ARM_EMBEDDED_SYSROOT"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "*******************************************************************************"
|
||||
echo "It looks the the environment is set correctly. Your next step is"
|
||||
echo "build the library with 'make -f GNUmakefile-cross'"
|
||||
echo "*******************************************************************************"
|
||||
echo
|
||||
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 0 || return 0
|
293
TestScripts/setenv-ios.sh
Executable file
293
TestScripts/setenv-ios.sh
Executable file
@ -0,0 +1,293 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ====================================================================
|
||||
# Sets the cross compile environment for Xcode/iOS
|
||||
# Based upon OpenSSL's setenv-ios.sh (by TH, JW, and SM).
|
||||
#
|
||||
# Crypto++ Library is copyrighted as a compilation and (as of version 5.6.2)
|
||||
# licensed under the Boost Software License 1.0, while the individual files
|
||||
# in the compilation are all public domain.
|
||||
#
|
||||
# See http://www.cryptopp.com/wiki/iOS_(Command_Line) for more details
|
||||
# ====================================================================
|
||||
|
||||
set -eu
|
||||
|
||||
#########################################
|
||||
##### Clear old options #####
|
||||
#########################################
|
||||
|
||||
unset IS_CROSS_COMPILE
|
||||
|
||||
unset IS_IOS
|
||||
unset IS_ANDROID
|
||||
unset IS_ARM_EMBEDDED
|
||||
|
||||
unset IOS_ARCH
|
||||
unset IOS_FLAGS
|
||||
unset IOS_SYSROOT
|
||||
|
||||
#########################################
|
||||
##### User configurable options #####
|
||||
#########################################
|
||||
|
||||
# Define SETENV_VERBOSE=1 to print the configuration, including exported variables.
|
||||
SETENV_VERBOSE=1
|
||||
|
||||
# For various SDKs, see https://groups.google.com/d/msg/cryptopp-users/8Z0qfwAjSbA/nKYbhTNBBgAJ
|
||||
|
||||
########################################
|
||||
##### Command line #####
|
||||
########################################
|
||||
|
||||
APPLE_SDK=
|
||||
IOS_ARCH=
|
||||
|
||||
for ARG in "$@"
|
||||
do
|
||||
CL=$(echo $ARG | tr '[A-Z]' '[a-z]')
|
||||
|
||||
# i386 (simulator)
|
||||
if [ "$CL" == "i386" ]; then
|
||||
IOS_ARCH=i386
|
||||
fi
|
||||
|
||||
# x86_64 (simulator)
|
||||
if [ "$CL" == "x86_64" ]; then
|
||||
IOS_ARCH=x86_64
|
||||
fi
|
||||
|
||||
# ARMv5
|
||||
if [ "$CL" == "armv5" ]; then
|
||||
IOS_ARCH=armv5
|
||||
fi
|
||||
|
||||
# ARMv6
|
||||
if [ "$CL" == "armv6" ]; then
|
||||
IOS_ARCH=armv6
|
||||
fi
|
||||
|
||||
# ARMv7
|
||||
if [ "$CL" == "armv7" ]; then
|
||||
IOS_ARCH=armv7
|
||||
fi
|
||||
|
||||
# ARMv7s
|
||||
if [ "$CL" == "armv7s" ]; then
|
||||
IOS_ARCH=armv7s
|
||||
fi
|
||||
|
||||
# ARM64
|
||||
if [ "$CL" == "arm64" ]; then
|
||||
IOS_ARCH=arm64
|
||||
fi
|
||||
|
||||
# iPhone
|
||||
if [ "$CL" == "iphone" ] || [ "$CL" == "iphoneos" ]; then
|
||||
APPLE_SDK=iPhoneOS
|
||||
fi
|
||||
|
||||
# iPhone Simulator
|
||||
if [ "$CL" == "simulator" ] || [ "$CL" == "iphonesimulator" ]; then
|
||||
APPLE_SDK=iPhoneSimulator
|
||||
fi
|
||||
|
||||
# Watch
|
||||
if [ "$CL" == "watch" ] || [ "$CL" == "watchos" ] || [ "$CL" == "applewatch" ]; then
|
||||
APPLE_SDK=WatchOS
|
||||
fi
|
||||
|
||||
# Watch Simulator
|
||||
if [ "$CL" == "watchsimulator" ]; then
|
||||
APPLE_SDK=WatchSimulator
|
||||
fi
|
||||
|
||||
# Apple TV
|
||||
if [ "$CL" == "tv" ] || [ "$CL" == "appletv" ] || [ "$CL" == "appletvos" ]; then
|
||||
APPLE_SDK=AppleTVOS
|
||||
fi
|
||||
|
||||
# Apple TV Simulator
|
||||
if [ "$CL" == "tvsimulator" ] || [ "$CL" == "appletvsimulator" ]; then
|
||||
APPLE_SDK=AppleTVSimulator
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
# Defaults if not set
|
||||
if [ -z "$APPLE_SDK" ]; then
|
||||
APPLE_SDK=iPhoneOS
|
||||
fi
|
||||
|
||||
if [ -z "$IOS_ARCH" ]; then
|
||||
if [ "$APPLE_SDK" == "iPhoneOS" ]; then
|
||||
IOS_ARCH=armv7
|
||||
elif [ "$APPLE_SDK" == "iPhoneSimulator" ]; then
|
||||
IOS_ARCH=i386
|
||||
elif [ "$APPLE_SDK" == "AppleTVOS" ]; then
|
||||
IOS_ARCH=arm64
|
||||
elif [ "$APPLE_SDK" == "WatchOS" ]; then
|
||||
IOS_ARCH=armv7
|
||||
fi
|
||||
|
||||
# TODO: fill in missing simulator architectures
|
||||
fi
|
||||
|
||||
# Allow a user override? I think we should be doing this. The use case is:
|
||||
# move /Applications/Xcode somewhere else for a side-by-side installation.
|
||||
# These sorts of tricks are a required procedure on Apple's gear:
|
||||
# http://stackoverflow.com/questions/11651773/install-simulator-sdk-4-3-to-xcode-4-4-on-mountain-lion
|
||||
if [ -z "${XCODE_DEVELOPER-}" ]; then
|
||||
XCODE_DEVELOPER=$(xcode-select -print-path 2>/dev/null)
|
||||
fi
|
||||
|
||||
if [ ! -d "$XCODE_DEVELOPER" ]; then
|
||||
echo "ERROR: unable to find XCODE_DEVELOPER directory."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Default toolchain location
|
||||
XCODE_TOOLCHAIN="$XCODE_DEVELOPER/usr/bin"
|
||||
|
||||
if [ ! -d "$XCODE_TOOLCHAIN" ]; then
|
||||
echo "ERROR: unable to find XCODE_TOOLCHAIN directory."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# XCODE_DEVELOPER_TOP is the top of the development tools tree
|
||||
XCODE_DEVELOPER_TOP="$XCODE_DEVELOPER/Platforms/$APPLE_SDK.platform/Developer"
|
||||
|
||||
if [ ! -d "$XCODE_DEVELOPER_TOP" ]; then
|
||||
echo "ERROR: unable to find XCODE_DEVELOPER_TOP directory."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# IOS_TOOLCHAIN is the location of the actual compiler tools.
|
||||
if [ -d "$XCODE_DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/" ]; then
|
||||
IOS_TOOLCHAIN="$XCODE_DEVELOPER/Toolchains/XcodeDefault.xctoolchain/usr/bin/"
|
||||
elif [ -d "$XCODE_DEVELOPER_TOP/usr/bin/" ]; then
|
||||
IOS_TOOLCHAIN="$XCODE_DEVELOPER_TOP/usr/bin/"
|
||||
fi
|
||||
|
||||
if [ -z "$IOS_TOOLCHAIN" ] || [ ! -d "$IOS_TOOLCHAIN" ]; then
|
||||
echo "ERROR: unable to find Xcode cross-compiler tools."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
#
|
||||
# XCODE_SDK is the SDK name/version being used - adjust the list as appropriate.
|
||||
# For example, remove 4.3, 6.2, and 6.1 if they are not installed. We go back to
|
||||
# the 1.0 SDKs because Apple WatchOS uses low numbers, like 2.0 and 2.1.
|
||||
unset XCODE_SDK
|
||||
for i in $(seq -f "%.1f" 20.0 -0.1 1.0)
|
||||
do
|
||||
if [ -d "$XCODE_DEVELOPER/Platforms/$APPLE_SDK.platform/Developer/SDKs/$APPLE_SDK$i.sdk" ]; then
|
||||
XCODE_SDK="$APPLE_SDK$i.sdk"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Error checking
|
||||
if [ -z "$XCODE_SDK" ]; then
|
||||
echo "ERROR: unable to find a SDK."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
# Simulator fixup. LD fails to link dylib.
|
||||
if [ "$APPLE_SDK" == "iPhoneSimulator" ] && [ "$IOS_ARCH" == "i386" ]; then
|
||||
IOS_FLAGS=-miphoneos-version-min=5
|
||||
fi
|
||||
|
||||
# ARMv7s fixup. Xcode 4/iOS 6
|
||||
if [ "$IOS_ARCH" == "armv7s" ]; then
|
||||
IOS_FLAGS=-miphoneos-version-min=6
|
||||
fi
|
||||
|
||||
# ARM64 fixup. Xcode 5/iOS 7
|
||||
if [ "$IOS_ARCH" == "arm64" ]; then
|
||||
IOS_FLAGS=-miphoneos-version-min=7
|
||||
fi
|
||||
|
||||
# ARM64 Simulator fixup. Under Xcode 6/iOS 8, it uses x86_64 and not i386
|
||||
if [ "$IOS_ARCH" == "x86_64" ]; then
|
||||
IOS_FLAGS=-miphoneos-version-min=8
|
||||
fi
|
||||
|
||||
# Simulator uses i386 or x86_64, Device uses ARMv5, ARMv6, ARMv7, or ARMv7s
|
||||
#
|
||||
# Apple deprecated ARMv5 at iOS 4.0, and ARMv6 at iOS 5.0
|
||||
# http://stackoverflow.com/questions/7488657/how-to-build-for-armv6-and-armv7-architectures-with-ios-5
|
||||
|
||||
echo "Configuring for $APPLE_SDK ($IOS_ARCH)"
|
||||
|
||||
# Used by the GNUmakefile-cross
|
||||
export IS_IOS=1
|
||||
export IOS_ARCH
|
||||
export IOS_FLAGS
|
||||
export IOS_SYSROOT="$XCODE_DEVELOPER_TOP/SDKs/$XCODE_SDK"
|
||||
|
||||
#######################################
|
||||
##### Verbose #####
|
||||
#######################################
|
||||
|
||||
if [ "$SETENV_VERBOSE" == "1" ]; then
|
||||
|
||||
echo "XCODE_SDK:" $XCODE_SDK
|
||||
echo "XCODE_DEVELOPER: $XCODE_DEVELOPER"
|
||||
echo "XCODE_TOOLCHAIN: $XCODE_TOOLCHAIN"
|
||||
echo "XCODE_DEVELOPER_TOP: $XCODE_DEVELOPER_TOP"
|
||||
echo "IOS_ARCH: $IOS_ARCH"
|
||||
echo "IOS_TOOLCHAIN: $IOS_TOOLCHAIN"
|
||||
echo "IOS_FLAGS: ${IOS_FLAGS-}"
|
||||
echo "IOS_SYSROOT: ${IOS_SYSROOT-}"
|
||||
fi
|
||||
|
||||
########################################
|
||||
##### Path with Toolchains #####
|
||||
########################################
|
||||
|
||||
# Only modify/export PATH if IOS_TOOLCHAIN good
|
||||
if [ ! -z "$IOS_TOOLCHAIN" ] && [ ! -z "$XCODE_TOOLCHAIN" ]; then
|
||||
|
||||
# And only modify PATH if IOS_TOOLCHAIN is not present
|
||||
TOOL_PATH="$IOS_TOOLCHAIN:$XCODE_TOOLCHAIN"
|
||||
LEN=${#TOOL_PATH}
|
||||
SUBSTR=${PATH:0:$LEN}
|
||||
if [ "$SUBSTR" != "$TOOL_PATH" ]; then
|
||||
export PATH="$TOOL_PATH":"$PATH"
|
||||
fi
|
||||
else
|
||||
echo "ERROR: unable to set new PATH."
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
########################################
|
||||
##### Tool Test Time #####
|
||||
########################################
|
||||
|
||||
# Test for various tools needed during cross compilation.
|
||||
# FOUND_ALL starts high, and pushes low on failure
|
||||
FOUND_ALL=1
|
||||
|
||||
# Apple's embedded g++ cannot compile integer.cpp
|
||||
TOOLS=(clang clang++ ar ranlib libtool ld)
|
||||
for tool in ${TOOLS[@]}
|
||||
do
|
||||
if [ ! -e "$IOS_TOOLCHAIN/$tool" ] && [ ! -e "$XCODE_TOOLCHAIN/$tool" ]; then
|
||||
echo "ERROR: unable to find $tool at IOS_TOOLCHAIN or XCODE_TOOLCHAIN"
|
||||
FOUND_ALL=0
|
||||
fi
|
||||
done
|
||||
|
||||
if [ "$FOUND_ALL" -eq "0" ]; then
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 1 || return 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "*******************************************************************************"
|
||||
echo "It looks the the environment is set correctly. Your next step is"
|
||||
echo "build the library with 'make -f GNUmakefile-cross'"
|
||||
echo "*******************************************************************************"
|
||||
echo
|
||||
|
||||
[ "$0" = "$BASH_SOURCE" ] && exit 0 || return 0
|
Loading…
x
Reference in New Issue
Block a user