mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
Update android-make-script.sh
build libwebsockets for android ndk standalone toolchain,test in ndk-r17
This commit is contained in:
parent
ba612c3df6
commit
9d9c90bc5b
1 changed files with 73 additions and 71 deletions
|
@ -3,52 +3,40 @@
|
|||
#
|
||||
# Build libwebsockets static library for Android
|
||||
#
|
||||
# requires debian package xutils-dev for makedepend (openssl make depend)
|
||||
#
|
||||
|
||||
# This is based on http://stackoverflow.com/questions/11929773/compiling-the-latest-openssl-for-android/
|
||||
# via https://github.com/warmcat/libwebsockets/pull/502
|
||||
|
||||
# path to NDK
|
||||
export NDK=/opt/Android/SDK/ndk-bundle
|
||||
|
||||
export NDK=/opt/ndk_r17/android-ndk-r17-beta2-linux-x86_64/android-ndk-r17-beta2
|
||||
export ANDROID_NDK=${NDK}
|
||||
export TOOLCHAIN=${NDK}/toolchain
|
||||
export CORSS_SYSROOT=${NDK}/sysroot
|
||||
export SYSROOT=${NDK}/platforms/android-22/arch-arm
|
||||
set -e
|
||||
|
||||
# Download packages libz, openssl and libwebsockets
|
||||
# Download packages libz, libuv, mbedtls and libwebsockets
|
||||
#zlib-1.2.8
|
||||
#libuv-1.x
|
||||
#mbedtls-2.11.0
|
||||
#libwebsockets-3.0.0
|
||||
|
||||
[ ! -f zlib-1.2.8.tar.gz ] && {
|
||||
wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz
|
||||
}
|
||||
|
||||
[ ! -f openssl-1.0.2g.tar.gz ] && {
|
||||
wget https://openssl.org/source/openssl-1.0.2g.tar.gz
|
||||
}
|
||||
|
||||
[ ! -f libwebsockets.tar.gz ] && {
|
||||
git clone https://github.com/warmcat/libwebsockets.git
|
||||
tar caf libwebsockets.tar.gz libwebsockets
|
||||
}
|
||||
|
||||
# Clean then Unzip
|
||||
|
||||
[ -d zlib-1.2.8 ] && rm -fr zlib-1.2.8
|
||||
[ -d openssl-1.0.2g ] && rm -fr openssl-1.0.2g
|
||||
[ -d libwebsockets ] && rm -fr libwebsockets
|
||||
[ -d android-toolchain-arm ] && rm -fr android-toolchain-arm
|
||||
tar xf zlib-1.2.8.tar.gz
|
||||
tar xf openssl-1.0.2g.tar.gz
|
||||
tar xf libwebsockets.tar.gz
|
||||
|
||||
# create a local android toolchain
|
||||
API=${3:-24}
|
||||
|
||||
$NDK/build/tools/make-standalone-toolchain.sh \
|
||||
--platform=android-9 \
|
||||
--toolchain=arm-linux-androideabi-4.9 \
|
||||
--install-dir=`pwd`/android-toolchain-arm
|
||||
--arch=arm \
|
||||
--install-dir=`pwd`/android-toolchain-arm \
|
||||
--platform=android-$API \
|
||||
--stl=libc++ \
|
||||
--force \
|
||||
--verbose
|
||||
|
||||
# setup environment to use the gcc/ld from the android toolchain
|
||||
export TOOLCHAIN_PATH=`pwd`/android-toolchain-arm/bin
|
||||
export INSTALL_PATH=/opt/libwebsockets_android/android-toolchain-arm
|
||||
export TOOLCHAIN_PATH=`pwd`/android-toolchain-arm
|
||||
export TOOL=arm-linux-androideabi
|
||||
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
|
||||
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/bin/${TOOL}
|
||||
export PATH=`pwd`/android-toolchain-arm/bin:$PATH
|
||||
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
|
||||
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
|
||||
export LINK=${CXX}
|
||||
|
@ -56,59 +44,73 @@ export LD=$NDK_TOOLCHAIN_BASENAME-ld
|
|||
export AR=$NDK_TOOLCHAIN_BASENAME-ar
|
||||
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
|
||||
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
|
||||
export PLATFORM=android
|
||||
export CFLAGS="D__ANDROID_API__=$API"
|
||||
|
||||
# setup buildflags
|
||||
export ARCH_FLAGS="-mthumb"
|
||||
export ARCH_LINK=
|
||||
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
|
||||
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
|
||||
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
|
||||
export LDFLAGS=" ${ARCH_LINK} "
|
||||
# configure and build libuv
|
||||
[ ! -f ./android-toolchain-arm/lib/libuv.so ] && {
|
||||
cd libuv
|
||||
echo "=============================================>> build libuv"
|
||||
|
||||
# configure and build zlib
|
||||
[ ! -f ./android-toolchain-arm/lib/libz.a ] && {
|
||||
cd zlib-1.2.8
|
||||
PATH=$TOOLCHAIN_PATH:$PATH ./configure --static --prefix=$TOOLCHAIN_PATH/..
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make clean
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make install
|
||||
echo "<<============================================= build libuv"
|
||||
cd ..
|
||||
}
|
||||
|
||||
# configure and build openssl
|
||||
[ ! -f ./android-toolchain-arm/lib/libssl.a ] && {
|
||||
PREFIX=$TOOLCHAIN_PATH/..
|
||||
cd openssl-1.0.2g
|
||||
./Configure android --prefix=${PREFIX} no-shared no-idea no-mdc2 no-rc5 no-zlib no-zlib-dynamic enable-tlsext no-ssl2 no-ssl3 enable-ec enable-ecdh enable-ecp
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make depend
|
||||
# configure and build zlib
|
||||
[ ! -f ./android-toolchain-arm/lib/libz.so ] && {
|
||||
cd zlib-1.2.8
|
||||
echo "=============================================>> build libz"
|
||||
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make clean
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make install_sw
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make install
|
||||
echo "<<============================================= build libz"
|
||||
cd ..
|
||||
}
|
||||
|
||||
# configure and build mbedtls
|
||||
[ ! -f ./android-toolchain-arm/lib/libmbedtls.so ] && {
|
||||
echo "=============================================>> build mbedtls"
|
||||
PREFIX=$TOOLCHAIN_PATH
|
||||
cd mbedtls-2.11.0
|
||||
[ ! -d build ] && mkdir build
|
||||
cd build
|
||||
export CFLAGS="$CFLAGS -fomit-frame-pointer"
|
||||
|
||||
PATH=$TOOLCHAIN_PATH:$PATH cmake .. -DCMAKE_TOOLCHAIN_FILE=`pwd`/../cross-arm-android-gnueabi.cmake \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} \
|
||||
-DCMAKE_BUILD_TYPE=RELEASE -DUSE_SHARED_MBEDTLS_LIBRARY=On
|
||||
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make clean
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make SHARED=1
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make install
|
||||
echo "<<============================================= build mbedtls"
|
||||
cd ../..
|
||||
}
|
||||
|
||||
# configure and build libwebsockets
|
||||
[ ! -f ./android-toolchain-arm/lib/libwebsockets.a ] && {
|
||||
[ ! -f ./android-toolchain-arm/lib/libwebsockets.so ] && {
|
||||
cd libwebsockets
|
||||
[ ! -d build ] && mkdir build
|
||||
cd build
|
||||
PATH=$TOOLCHAIN_PATH:$PATH cmake \
|
||||
-DCMAKE_C_COMPILER=$CC \
|
||||
-DCMAKE_AR=$AR \
|
||||
-DCMAKE_RANLIB=$RANLIB \
|
||||
-DCMAKE_C_FLAGS="$CFLAGS" \
|
||||
-DCMAKE_INSTALL_PREFIX=$TOOLCHAIN_PATH/.. \
|
||||
-DLWS_WITH_SHARED=OFF \
|
||||
-DLWS_WITH_STATIC=ON \
|
||||
-DLWS_WITHOUT_DAEMONIZE=ON \
|
||||
-DLWS_WITHOUT_TESTAPPS=ON \
|
||||
-DLWS_IPV6=OFF \
|
||||
-DLWS_WITH_BUNDLED_ZLIB=OFF \
|
||||
-DLWS_WITH_SSL=ON \
|
||||
-DLWS_WITH_HTTP2=ON \
|
||||
-DLWS_OPENSSL_LIBRARIES="$TOOLCHAIN_PATH/../lib/libssl.a;$TOOLCHAIN_PATH/../lib/libcrypto.a" \
|
||||
-DLWS_OPENSSL_INCLUDE_DIRS=$TOOLCHAIN_PATH/../include \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
..
|
||||
echo "=============================================>> build libwebsockets"
|
||||
|
||||
PATH=$TOOLCHAIN_PATH:$PATH cmake .. -DCMAKE_TOOLCHAIN_FILE=`pwd`/../cross-arm-android-gnueabi.cmake \
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=${INSTALL_PATH} \
|
||||
-DLWS_WITH_LWSWS=1 \
|
||||
-DLWS_WITH_MBEDTLS=1 \
|
||||
-DLWS_WITHOUT_TESTAPPS=1 \
|
||||
-DLWS_MBEDTLS_LIBRARIES="${INSTALL_PATH}/lib/libmbedcrypto.a;${INSTALL_PATH}/lib/libmbedtls.a;${INSTALL_PATH}/lib/libmbedx509.a" \
|
||||
-DLWS_MBEDTLS_INCLUDE_DIRS=${INSTALL_PATH}/include \
|
||||
-DLWS_LIBUV_LIBRARIES=${INSTALL_PATH}/lib/libuv.so \
|
||||
-DLWS_LIBUV_INCLUDE_DIRS=${INSTALL_PATH}/include \
|
||||
-DLWS_ZLIB_LIBRARIES=${INSTALL_PATH}/lib/libz.so \
|
||||
-DLWS_ZLIB_INCLUDE_DIRS=${INSTALL_PATH}/include
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make
|
||||
PATH=$TOOLCHAIN_PATH:$PATH make install
|
||||
echo "<<============================================= build libwebsockets"
|
||||
cd ../..
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue