Forked from 43z3com/build-android-libjpeg-turbo.sh
Last active
October 31, 2019 19:48
-
-
Save tastyone/da6ec6d4a2579abd0339 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| : << '#__REM__' | |
| 指定さたライブラリをAndroid用にフルオートで作成します。ダウンロード、toolchainsの作成、複数のアーキテクチャのビルドも自動的に行います。デフォルトではarmv5te、armv7-a、mips1、i386のアーキテクチャを作成します。 | |
| Create a full-auto for Android the library specified. Creating download, toolchains, build the architecture of multiple automatically. Create architecture, mips1, i386 armv5te, armv7-a by default. | |
| #__REM__ | |
| TARGET_VERSION="1.3.1" | |
| ARCHIVE_BASENAME="libjpeg-turbo" | |
| DOWNLOAD_URL="http://sourceforge.net/projects/${ARCHIVE_BASENAME}/files/${TARGET_VERSION}/${ARCHIVE_BASENAME}-${TARGET_VERSION}.tar.gz" | |
| #check the version | |
| #http://sourceforge.net/projects/libjpeg-turbo/files/?source=navbar | |
| #android | |
| #NDK_ROOT="/Workshop/Android-SDK/android-ndk-r8e" | |
| DEPLOYMENT_TARGET="android" | |
| # see ${NDK-ROOT}/platforms | |
| ANDROID_PLATFORM=9 | |
| # see ${NDK-ROOT}/toolchains | |
| ARCHS="[email protected] [email protected] [email protected] [email protected]" | |
| NEON=1 #arm architecture valid only | |
| DEBUG=0 | |
| VERBOSE=0 | |
| ######################################## | |
| if [ ! -n "${NDK_ROOT}" ]; then | |
| echo "NDK_ROOT is not defined" | |
| exit ; | |
| fi | |
| NDK="${NDK_ROOT}" | |
| cd "`dirname \"$0\"`" | |
| REPOROOT="$(pwd)" | |
| OUTPUT_DIR="${REPOROOT}/dependencies-lib" | |
| mkdir -p "${OUTPUT_DIR}" | |
| BUILD_DIR="${REPOROOT}/build" | |
| SRC_DIR="${BUILD_DIR}/src" | |
| mkdir -p "${SRC_DIR}" | |
| INTER_DIR="${BUILD_DIR}/built" | |
| mkdir -p "${INTER_DIR}" | |
| export TOOLCHAIN_BASE_DIR="${BUILD_DIR}/toolchain" | |
| ######################################## | |
| #set -x | |
| cd $SRC_DIR | |
| set -e | |
| if [ ! -e "${SRC_DIR}/${ARCHIVE_BASENAME}-${TARGET_VERSION}.tar.gz" ]; then | |
| cat <<_EOT_ | |
| ############################################################################## | |
| #### | |
| #### Downloading ${ARCHIVE_BASENAME}-${TARGET_VERSION}.tar.gz | |
| #### | |
| ############################################################################## | |
| _EOT_ | |
| #curl -O ${DOWNLOAD_URL} | |
| wget ${DOWNLOAD_URL} | |
| echo "Done." ; echo "" | |
| fi | |
| cat <<_EOT_ | |
| ############################################################################## | |
| #### | |
| #### Using ${ARCHIVE_BASENAME}-${TARGET_VERSION}.tar.gz | |
| #### | |
| ############################################################################## | |
| _EOT_ | |
| tar zxf ${ARCHIVE_BASENAME}-${TARGET_VERSION}.tar.gz -C $SRC_DIR | |
| cd "${SRC_DIR}/${ARCHIVE_BASENAME}-${TARGET_VERSION}" | |
| export ORIGINALPATH="$PATH" | |
| MACHINE=`uname -m | tr '[A-Z]' '[a-z]'` | |
| SYSNAME=`uname -s | tr '[A-Z]' '[a-z]'` | |
| BUILD="${MACHINE}-${SYSNAME}" | |
| for ELEM in ${ARCHS} | |
| do | |
| OIFS="$IFS"; IFS='@' | |
| set -- ${ELEM}; IFS="$OIFS" | |
| ARCH="$1" | |
| TOOLCHAIN="$2" | |
| if [ ! -e "${TOOLCHAIN_BASE_DIR}/${ARCH}@${TOOLCHAIN}" ]; then | |
| cat <<_EOT_ | |
| ############################################################################## | |
| #### | |
| #### Generate toolchain ${TOOLCHAIN} | |
| #### | |
| ############################################################################## | |
| _EOT_ | |
| "${NDK}/build/tools/make-standalone-toolchain.sh" --platform="android-${ANDROID_PLATFORM}" --toolchain="${TOOLCHAIN}" --install-dir="${TOOLCHAIN_BASE_DIR}/${ARCH}@${TOOLCHAIN}" --system="${SYSNAME}-${MACHINE}" | |
| echo "" | |
| fi | |
| TOOLCHAIN_DIR="${TOOLCHAIN_BASE_DIR}/${ARCH}@${TOOLCHAIN}" | |
| PREFIX="${INTER_DIR}/${ARCHIVE_BASENAME}-${TARGET_VERSION}-android-${ANDROID_PLATFORM}-${ARCH}" | |
| mkdir -p "${PREFIX}" | |
| export PATH="$ORIGINALPATH" | |
| autoreconf -fiv | |
| cat <<_EOT_ | |
| ############################################################################## | |
| #### | |
| #### Configure ${ARCH} | |
| #### | |
| ############################################################################## | |
| _EOT_ | |
| case "${ARCH}" in | |
| "armv5te" ) | |
| export PATH="${TOOLCHAIN_DIR}/bin:${TOOLCHAIN_DIR}/arm-linux-androideabi/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/opt/local/sbin" | |
| HOST_CC="${TOOLCHAIN_DIR}/bin/arm-linux-androideabi-gcc" | |
| HOST_CFLAGS="\ | |
| -march=armv5te -mtune=xscale -msoft-float \ | |
| \ | |
| -D_GNU_SOURCE=1 -DANDROID -DAL_LIBTYPE_STATIC -DAL_ALEXT_PROTOTYPES \ | |
| -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \ | |
| -DUSE_FILE32API \ | |
| \ | |
| -ffunction-sections -funwind-tables -fomit-frame-pointer -fstrict-aliasing \ | |
| -funswitch-loops -finline-limit=300 \ | |
| \ | |
| -Winline -Wall -Wextra -fvisibility=internal -Wmissing-field-initializers" | |
| HOST_LDFLAGS="" | |
| HOST_SYSROOT="${TOOLCHAIN_DIR}/sysroot" | |
| if [ "${DEBUG}" == 0 ]; then | |
| HOST_CFLAGS="${HOST_CFLAGS} -O3 -DNDEBUG" | |
| else | |
| HOST_CFLAGS="${HOST_CFLAGS} -O0 -g -DDEBUG -DCOCOS2D_DEBUG=2" | |
| fi | |
| ./configure \ | |
| --prefix="${PREFIX}" \ | |
| --build ${BUILD} \ | |
| --host arm-linux-androideabi \ | |
| --enable-static \ | |
| --disable-shared \ | |
| --disable-silent-rules \ | |
| --with-pic \ | |
| --with-sysroot ${HOST_SYSROOT} \ | |
| CC="$HOST_CC" \ | |
| CFLAGS="-isysroot ${HOST_SYSROOT} ${HOST_CFLAGS}" \ | |
| LDFLAGS="-isysroot ${HOST_SYSROOT} ${HOST_LDFLAGS}" | |
| ;; | |
| "armv7" | "armv7-a" ) | |
| export PATH="${TOOLCHAIN_DIR}/bin:${TOOLCHAIN_DIR}/arm-linux-androideabi/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/opt/local/sbin" | |
| HOST_CC="${TOOLCHAIN_DIR}/bin/arm-linux-androideabi-gcc" | |
| HOST_CFLAGS="\ | |
| -march=${ARCH} -mfloat-abi=softfp -mfpu=vfpv3-d16 \ | |
| \ | |
| -D_GNU_SOURCE=1 -DANDROID -DAL_LIBTYPE_STATIC -DAL_ALEXT_PROTOTYPES \ | |
| -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__ \ | |
| -DUSE_FILE32API \ | |
| \ | |
| -ffunction-sections -funwind-tables -fomit-frame-pointer -fstrict-aliasing \ | |
| -funswitch-loops -finline-limit=300 \ | |
| \ | |
| -Winline -Wall -Wextra -fvisibility=internal -Wmissing-field-initializers" | |
| HOST_LDFLAGS="-Wl,--fix-cortex-a8" | |
| HOST_SYSROOT="${TOOLCHAIN_DIR}/sysroot" | |
| if [ ! ${NEON} -eq 0 ]; then | |
| HOST_CFLAGS="${HOST_CFLAGS} -mfpu=neon" | |
| fi | |
| if [ ${DEBUG} -eq 0 ]; then | |
| HOST_CFLAGS="${HOST_CFLAGS} -O3 -DNDEBUG" | |
| else | |
| HOST_CFLAGS="${HOST_CFLAGS} -O0 -g -DDEBUG -DCOCOS2D_DEBUG=2" | |
| fi | |
| ./configure \ | |
| --prefix="${PREFIX}" \ | |
| --build ${BUILD} \ | |
| --host arm-linux-androideabi \ | |
| --enable-static \ | |
| --disable-shared \ | |
| --disable-silent-rules \ | |
| --with-pic \ | |
| --with-sysroot ${HOST_SYSROOT} \ | |
| CC="$HOST_CC" \ | |
| CFLAGS="-isysroot ${HOST_SYSROOT} ${HOST_CFLAGS}" \ | |
| LDFLAGS="-isysroot ${HOST_SYSROOT} ${HOST_LDFLAGS}" | |
| ;; | |
| "mips1" | "mips2" | "mips3" | "mips4" | "mips32" | "mips32r2" ) | |
| export PATH="${TOOLCHAIN_DIR}/bin:${TOOLCHAIN_DIR}/mipsel-linux-android/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/opt/local/sbin" | |
| HOST_CC="${TOOLCHAIN_DIR}/bin/mipsel-linux-android-gcc" | |
| HOST_CFLAGS="\ | |
| -march=${ARCH} \ | |
| \ | |
| -D_GNU_SOURCE=1 -DANDROID -DAL_LIBTYPE_STATIC -DAL_ALEXT_PROTOTYPES \ | |
| -DUSE_FILE32API \ | |
| \ | |
| -ffunction-sections -funwind-tables -fomit-frame-pointer -fstrict-aliasing \ | |
| -funswitch-loops -finline-limit=300 \ | |
| \ | |
| -Winline -Wall -Wextra -fvisibility=internal -Wmissing-field-initializers" | |
| HOST_LDFLAGS="" | |
| HOST_SYSROOT="${TOOLCHAIN_DIR}/sysroot" | |
| if [ ${DEBUG} -eq 0 ]; then | |
| HOST_CFLAGS="${HOST_CFLAGS} -O3 -DNDEBUG" | |
| else | |
| HOST_CFLAGS="${HOST_CFLAGS} -O0 -g -DDEBUG -DCOCOS2D_DEBUG=2" | |
| fi | |
| ./configure \ | |
| --prefix="${PREFIX}" \ | |
| --build ${BUILD} \ | |
| --host mipsel-linux-android \ | |
| --enable-static \ | |
| --disable-shared \ | |
| --disable-silent-rules \ | |
| --with-pic \ | |
| --with-sysroot ${HOST_SYSROOT} \ | |
| CC="$HOST_CC" \ | |
| CFLAGS="-isysroot ${HOST_SYSROOT} ${HOST_CFLAGS}" \ | |
| LDFLAGS="-isysroot ${HOST_SYSROOT} ${HOST_LDFLAGS}" | |
| ;; | |
| "i386" ) | |
| export PATH="${TOOLCHAIN_DIR}/bin:${TOOLCHAIN_DIR}/i686-linux-android/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/opt/local/sbin" | |
| HOST_CC="${TOOLCHAIN_DIR}/bin/i686-linux-android-gcc" | |
| HOST_CFLAGS="\ | |
| -march=${ARCH} \ | |
| \ | |
| -D_GNU_SOURCE=1 -DANDROID -DAL_LIBTYPE_STATIC -DAL_ALEXT_PROTOTYPES \ | |
| -DUSE_FILE32API \ | |
| \ | |
| -ffunction-sections -funwind-tables -fomit-frame-pointer -fstrict-aliasing \ | |
| -funswitch-loops -finline-limit=300 \ | |
| \ | |
| -Winline -Wall -Wextra -fvisibility=internal -Wmissing-field-initializers" | |
| HOST_LDFLAGS="" | |
| HOST_SYSROOT="${TOOLCHAIN_DIR}/sysroot" | |
| if [ ${DEBUG} -eq 0 ]; then | |
| HOST_CFLAGS="${HOST_CFLAGS} -O3 -DNDEBUG" | |
| else | |
| HOST_CFLAGS="${HOST_CFLAGS} -O0 -g -DDEBUG -DCOCOS2D_DEBUG=2" | |
| fi | |
| ./configure \ | |
| --prefix="${PREFIX}" \ | |
| --build ${BUILD} \ | |
| --host x86 \ | |
| --enable-static \ | |
| --disable-shared \ | |
| --disable-silent-rules \ | |
| --with-pic \ | |
| --with-sysroot ${HOST_SYSROOT} \ | |
| CC="$HOST_CC" \ | |
| CFLAGS="-isysroot ${HOST_SYSROOT} ${HOST_CFLAGS}" \ | |
| LDFLAGS="-isysroot ${HOST_SYSROOT} ${HOST_LDFLAGS}" | |
| ;; | |
| esac | |
| echo "Done." ; echo "" | |
| cat <<_EOT_ | |
| ############################################################################## | |
| #### | |
| #### Make ${ARCH} | |
| #### | |
| ############################################################################## | |
| _EOT_ | |
| make V=${VERBOSE} clean | |
| make -j4 V=${VERBOSE} | |
| make -j4 V=${VERBOSE} install | |
| echo "Done." ; echo "" | |
| cat <<_EOT_ | |
| ############################################################################## | |
| #### | |
| #### Build library ${ARCH} | |
| #### | |
| ############################################################################## | |
| _EOT_ | |
| PREFIX="${INTER_DIR}/${ARCHIVE_BASENAME}-${TARGET_VERSION}-android-${ANDROID_PLATFORM}-${ARCH}" | |
| PLATFORM_OUT_DIR="${OUTPUT_DIR}/${ARCHIVE_BASENAME}-${TARGET_VERSION}-android-${ANDROID_PLATFORM}-${ARCH}" | |
| mkdir -p "${PLATFORM_OUT_DIR}" | |
| cp -R "${PREFIX}/include" "${PLATFORM_OUT_DIR}" | |
| cp -R "${PREFIX}/lib" "${PLATFORM_OUT_DIR}" | |
| echo "Done." ; echo "" | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment