# List of setup, build and config commands below. All commands are executed in the context of the current user. # Pay attention to the SEMICOLON at the end of EACH command and the correct quoting (' or ") for or to avoid expansion of variables. S3TUP_CONFIG_VERSION="39"; # Tokens that are replaced automatically: # @CTNGSOURCE@ crosstool-NG source folder; support/crosstool/crosstool-ng # @FNGSOURCE@ freetz-NG source folder; support/crosstool/freetz-ng # @ANDKSOURCE@ android-NDK source folder; support/crosstool/android-ndk # @LOGFILE@ current log file # @TOOLCHAIN current toolchain folder # @TEMPLATE@ current template file # @CC@ C compiler binary of the toolchain # @RANLIB@ library archive indexer binary of the toolchain # @PREFIX@ prefix folder for cross builds # @HOST@ hostname of the toolchain # @TYPE@ toolchain type (ct-ng, freetz-ng, android-ndk) # @ARCH@ architecture of the toolchain # @BITNESS@ bitness of the toolchain (32, 64) # @API@ Android API level of the toolchain (see https://source.android.com/setup/start/build-numbers) # @SSL_TARGET@ Android specific build target for OpenSSL (android-arm, android-arm64, android-x86, android-x86) # @CFLAGS@ individuell flags for the C compiler # @LDFLAGS@ individuell flags for the C linker # @CPUS@ CPU number of the build system # @VALIDATE@ Special validation function for some libraries (@VALIDATE@ "PCSC") # You normally do *not* need to be root to build a toolchain using crosstool-NG. In fact, it is *VERY* dangerous to run as root, # as crosstool-NG will, as part of the build process, remove a few directories. If anything goes wrong, running as root can ruin your host distribution. CTNG_BUILD_AS_ROOT="0"; # Enable/Disable build as root (1|0) # crosstool-NG toolchain build settings CTNG_REPO_URL="https://github.com/crosstool-ng/crosstool-ng"; # Repository to load ct-ng from CTNG_CONFIG_tasks=('./ct-ng menuconfig;'); # config command1 CTNG_CONFIG_tasks+=('TPL_SAVE=$($gui --defaultno --output-fd 1 --ok-label "${txt_s3tup_menu_command_label_yes}" --cancel-label "${txt_s3tup_menu_command_label_no}" --colors $bt_ "$title_ - \Z0$pdesc\Zn" --title "-[ ${txt_s3tup_menu_edit_title} ]-" --inputbox "\n${txt_s3tup_menu_edit_text}" 10 55 "@TEMPLATE@") && cp ".config" "$TPL_SAVE";'); # config command2 CTNG_BUILD_tasks=('./ct-ng show-config | tee -a "@LOGFILE@";'); # build command1 CTNG_BUILD_tasks+=('./ct-ng build;'); # build command2 CTNG_SETUP_tasks=('git clone --progress "$CTNG_REPO_URL" "@CTNGSOURCE@";'); # setup command1 #CTNG_SETUP_tasks+=('echo "Patch 1: Add option to build binary toolchain tarball..." && curl --silent https://github.com/crosstool-ng/crosstool-ng/commit/77c44ad9a01293983e95949a1ece4b1f2270ad9c.diff | git apply -v;'); # setup command3 CTNG_SETUP_tasks+=('./bootstrap;'); # setup command7 CTNG_SETUP_tasks+=('./configure --enable-local;'); # setup command8 CTNG_SETUP_tasks+=('make;'); # setup command9 # freetz-NG toolchain build settings FNG_REPO_URL="https://github.com/Freetz-NG/freetz-ng.git"; # Repository to load freetz-ng from FNG_SEPARATE_DYNAMIC_LINKER="/usr/lib/freetz/ld-uClibc.so.0"; FNG_CONFIG_tasks=('make menuconfig;'); # config command1 FNG_CONFIG_tasks+=('TPL_SAVE=$($gui --defaultno --output-fd 1 --ok-label "${txt_s3tup_menu_command_label_yes}" --cancel-label "${txt_s3tup_menu_command_label_no}" --colors $bt_ "$title_ - \Z0$pdesc\Zn" --title "-[ ${txt_s3tup_menu_edit_title} ]-" --inputbox "\n${txt_s3tup_menu_edit_text}" 10 55 "@TEMPLATE@") && cp ".config" "$TPL_SAVE";'); # config command2 FNG_BUILD_tasks=('make olddefconfig | tee -a "@LOGFILE@";'); # build command1 FNG_BUILD_tasks+=('make toolchain-dirclean | tee -a "@LOGFILE@";'); # build command2 FNG_BUILD_tasks+=('make toolchain | tee -a "@LOGFILE@";'); # build command3 FNG_SETUP_tasks=('git clone --progress "$FNG_REPO_URL" "@FNGSOURCE@";'); # setup command1 FNG_SETUP_tasks+=('ln -s "../../downloads" "@FNGSOURCE@/dl";'); # setup command2 # android-NDK toolchain build settings ANDK_PKG_URL="https://dl.google.com/android/repository/$(curl --silent https://developer.android.com/ndk/downloads | grep -A1 -m1 'ndk_lts_linux64_download' | tail -n1 | awk -F'>|<' '{print $2}' | xargs)"; # Location to load Android Native Development Kit (NDK) from freetz-ng from ANDK_PKG_SHA1="$(curl --silent https://developer.android.com/ndk/downloads | grep -A4 -m1 'ndk_lts_linux64_download' | tail -n1 | awk -F'>|/dev/null >>"@LOGFILE@"; 2>&1; done;'); # build command5 ANDK_BUILD_tasks+=('rm -rf "$TOOLCHAIN/include" "$TOOLCHAIN/libexec" | tee -a "@LOGFILE@";'); # build command6 ANDK_BUILD_tasks+=('echo "Creating symlinks "$TOOLCHAIN/bin/${ANDK_HOST}-gcc", "$TOOLCHAIN/bin/${ANDK_HOST}-clang" to wrap "$TOOLCHAIN/bin/${ANDK_CLANG}"..." | tee -a "@LOGFILE@" && ln -rsf "$TOOLCHAIN/bin/${ANDK_CLANG}" "$TOOLCHAIN/bin/${ANDK_HOST}-gcc" && ln -rsf "$TOOLCHAIN/bin/${ANDK_CLANG}" "$TOOLCHAIN/bin/${ANDK_HOST}-clang" && chmod 775 "$TOOLCHAIN/bin/${ANDK_HOST}*" | tee -a "@LOGFILE@";'); # build command7 ANDK_SETUP_tasks=('pushd "$dldir" >/dev/null && [ ! "$(sha1sum "$(basename "$ANDK_PKG_URL")" 2>/dev/null | cut -d " " -f 1)" == "$ANDK_PKG_SHA1" ] && curl "$ANDK_PKG_URL" -o "$(basename "$ANDK_PKG_URL")";'); # setup command1 ANDK_SETUP_tasks+=('unzip -o -d "$ctdir" "$(basename "$ANDK_PKG_URL")" && popd >/dev/null;'); # setup command1 ANDK_SETUP_tasks+=('mv --force "$(basename "$ANDK_PKG_URL" | cut -d "-" -f 1-3)" "@ANDKSOURCE@";'); # setup command2 ANDK_SETUP_tasks+=('chmod -R 755 "@ANDKSOURCE@";'); # setup command3 # Library build settings LIBS=(SSL_300 SSL_111 SSL_110 SSL_102 SSL_102B SSL_100 SSL_098 LIB_USB LIB_USBB LIB_USB0 LIB_PCSC LIB_CCID LIB_ZLIB); # List of ordered libraries. Only libraries in this list are available LIBS_LIST_BETA="0"; # In(Ex)clude libraries defined as beta LIBS_AUTO_INTEGRATE="1"; # Automatically reintegrate libraries when rebuilding toolchains # OpenSSL 3.0.0 SSL_300="1"; SSL_300_beta="0"; SSL_300_name="OpenSSL"; SSL_300_version="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=1&per_page=100" | jq '[.[] | select(.name|test("openssl-3.*"))][0] | .name' | sed -e 's#openssl-##g; s#_#.#g; s#\"##g')"; SSL_300_check="openssl.pc $(printf "$SSL_300_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"; SSL_300_url="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=1&per_page=100" | jq '[.[] | select(.name|test("openssl-3.*"))][0] | .tarball_url' | sed -e 's#\"##g')"; SSL_300_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); SSL_300_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); SSL_300_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); SSL_300_tasks+=('export LDFLAGS="@LDFLAGS@ -latomic";'); SSL_300_tasks+=('[ "@TYPE@" == "android-ndk" ] && export CC="gcc" || export CC=@CC@;'); SSL_300_tasks+=('[ "@TYPE@" == "android-ndk" ] && export RANLIB=ranlib || export RANLIB=@RANLIB@;'); SSL_300_tasks+=('[ "@TYPE@" == "android-ndk" ] && export ANDROID_NDK="@TOOLCHAIN@";'); SSL_300_tasks+=('FLAGS="linux-generic32 shared no-tests";'); SSL_300_tasks+=('[[ "@CC@" =~ "uclibc"|"musl" ]] && FLAGS+=" -DOPENSSL_NO_ASYNC no-threads no-tests";'); SSL_300_tasks+=('[[ "@CC@" =~ "atom" ]] && FLAGS+=" no-threads no-tests";'); SSL_300_tasks+=('[ "@TYPE@" == "android-ndk" ] && FLAGS="@SSL_TARGET@ --api=0.9.8 -D__ANDROID_API__=@API@ no-shared no-afalgeng no-aria no-asan no-asm no-async no-autoalginit no-autoerrinit no-autoload-config no-bf no-blake2 no-camellia no-capieng no-cast no-chacha no-cmac no-cms no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-ct no-devcryptoeng no-dgram no-dh no-dsa no-dso no-dynamic-engine no-ec no-ec2m no-ecdh no-ecdsa no-ec_nistp_64_gcc_128 no-egd no-engine no-err no-external-tests no-filenames no-fuzz-libfuzzer no-fuzz-afl no-gost no-idea no-makedepend no-md2 no-mdc2 no-md4 no-multiblock no-nextprotoneg no-ocb no-ocsp no-pic no-poly1305 no-posix-io no-psk no-rc2 no-rc4 no-rc5 no-rdrand no-rfc3779 no-rmd160 no-scrypt no-sctp no-seed no-siphash no-sm2 no-sm3 no-sm4 no-srp no-srtp no-sse2 no-ssl-trace no-tests no-threads no-ts no-ubsan no-ui-console no-unit-test no-whirlpool no-weak-ssl-ciphers no-zlib no-zlib-dynamic no-heartbeats no-msan no-dtls no-dtls1 no-dtls1-method no-dtls1_2 no-dtls1_2-method";'); SSL_300_tasks+=('./Configure --prefix=@PREFIX@ $FLAGS;'); SSL_300_tasks+=('make -j@CPUS@;'); SSL_300_tasks+=('make install_sw;'); SSL_300_tasks+=('[ "@TYPE@" == "android-ndk" ] && find "@PREFIX@/lib/" -maxdepth 1 \( -name "libcrypto.*" -o -name "libssl.*" \) -execdir ln -frs "@PREFIX@/lib/{}" "@PREFIX@/lib/@HOST@/@API@/{}" \;;'); # OpenSSL 1.1.1 SSL_111="1"; SSL_111_beta="0"; SSL_111_name="OpenSSL"; SSL_111_version="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=1&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_1_1_1[a-z].*"))][0] | .name' | sed -e 's#OpenSSL_##g; s#_#.#g; s#\"##g')"; SSL_111_check="openssl.pc $(printf "$SSL_111_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"; SSL_111_url="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=1&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_1_1_1[a-z].*"))][0] | .tarball_url' | sed -e 's#\"##g')"; SSL_111_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); SSL_111_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); SSL_111_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); SSL_111_tasks+=('[ "@TYPE@" == "android-ndk" ] && export CC="gcc" || export CC=@CC@;'); SSL_111_tasks+=('[ "@TYPE@" == "android-ndk" ] && export RANLIB="ranlib" || export RANLIB=@RANLIB@;'); SSL_111_tasks+=('[ "@TYPE@" == "android-ndk" ] && export ANDROID_NDK="@TOOLCHAIN@";'); SSL_111_tasks+=('FLAGS="linux-generic32 shared";'); SSL_111_tasks+=('[[ "@CC@" =~ "uclibc"|"musl" ]] && FLAGS+=" -DOPENSSL_NO_ASYNC";'); SSL_111_tasks+=('[[ "@CC@" =~ "atom" ]] && FLAGS+=" no-threads";'); SSL_111_tasks+=('[ "@TYPE@" == "android-ndk" ] && FLAGS="@SSL_TARGET@ --api=0.9.8 -D__ANDROID_API__=@API@ no-shared no-afalgeng no-aria no-asan no-asm no-async no-autoalginit no-autoerrinit no-autoload-config no-bf no-blake2 no-camellia no-capieng no-cast no-chacha no-cmac no-cms no-comp no-crypto-mdebug no-crypto-mdebug-backtrace no-ct no-devcryptoeng no-dgram no-dh no-dsa no-dso no-dynamic-engine no-ec no-ec2m no-ecdh no-ecdsa no-ec_nistp_64_gcc_128 no-egd no-engine no-err no-external-tests no-filenames no-fuzz-libfuzzer no-fuzz-afl no-gost no-idea no-makedepend no-md2 no-mdc2 no-md4 no-multiblock no-nextprotoneg no-ocb no-ocsp no-pic no-poly1305 no-posix-io no-psk no-rc2 no-rc4 no-rc5 no-rdrand no-rfc3779 no-rmd160 no-scrypt no-sctp no-seed no-siphash no-sm2 no-sm3 no-sm4 no-srp no-srtp no-sse2 no-ssl-trace no-tests no-threads no-ts no-ubsan no-ui-console no-unit-test no-whirlpool no-weak-ssl-ciphers no-zlib no-zlib-dynamic no-heartbeats no-msan no-dtls no-dtls1 no-dtls1-method no-dtls1_2 no-dtls1_2-method";'); SSL_111_tasks+=('./Configure --prefix=@PREFIX@ $FLAGS;'); SSL_111_tasks+=('make -j@CPUS@;'); SSL_111_tasks+=('make install_sw;'); SSL_111_tasks+=('[ "@TYPE@" == "android-ndk" ] && find "@PREFIX@/lib/" -maxdepth 1 \( -name "libcrypto.*" -o -name "libssl.*" \) -execdir ln -frs "@PREFIX@/lib/{}" "@PREFIX@/lib/@HOST@/@API@/{}" \;;'); # OpenSSL 1.1.0 SSL_110="1"; SSL_110_name="OpenSSL"; SSL_110_version="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=2&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_1_1_0[a-z].*"))][0] | .name' | sed -e 's#OpenSSL_##g; s#_#.#g; s#\"##g')"; SSL_110_check="openssl.pc $(printf "$SSL_110_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"; SSL_110_url="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=2&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_1_1_0[a-z].*"))][0] | .tarball_url' | sed -e 's#\"##g')"; SSL_110_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); SSL_110_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); SSL_110_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); SSL_110_tasks+=('export CC=@CC@;'); SSL_110_tasks+=('export RANLIB=@RANLIB@;'); SSL_110_tasks+=('FLAGS="linux-generic32 shared";'); SSL_110_tasks+=('[[ "@CC@" =~ "uclibc"|"musl" ]] && FLAGS+=" -DOPENSSL_NO_ASYNC";'); SSL_110_tasks+=('[[ "@CC@" =~ "atom" ]] && FLAGS+=" no-threads";'); SSL_110_tasks+=('./Configure --prefix=@PREFIX@ $FLAGS;'); SSL_110_tasks+=('make -j@CPUS@;'); SSL_110_tasks+=('make install_sw;'); # OpenSSL 1.0.2 SSL_102="1"; SSL_102_beta="0"; SSL_102_name="OpenSSL"; SSL_102_version="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=2&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_1_0_2[a-z].*"))][0] | .name' | sed -e 's#OpenSSL_##g; s#_#.#g; s#\"##g')"; SSL_102_check="openssl.pc $(printf "$SSL_102_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"; SSL_102_checklib="libcrypto.so.1.0.2"; SSL_102_url="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=2&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_1_0_2[a-z].*"))][0] | .tarball_url' | sed -e 's#\"##g')"; SSL_102_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); SSL_102_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); SSL_102_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); SSL_102_tasks+=('export CC=@CC@;'); SSL_102_tasks+=('export RANLIB=@RANLIB@;'); SSL_102_tasks+=('FLAGS="linux-generic32 shared";'); SSL_102_tasks+=('./Configure --prefix=@PREFIX@ $FLAGS;'); SSL_102_tasks+=('make -j@CPUS@;'); SSL_102_tasks+=('make install SHLIB_VERSION_NUMBER=1.0.2 SHLIB_MINOR=0.2;'); # OpenSSL 1.0.2 as 1.0.0 SSL_102B_hint="OpenSSL 1.0.2 variant to create binaries\n\t\twith version 1.0.0 in its filename.\n\t\tUse it e.g. for fritzbox toolchains!"; SSL_102B="1"; SSL_102B_beta="0"; SSL_102B_name="OpenSSL"; SSL_102B_version="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=2&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_1_0_2[a-z].*"))][0] | .name' | sed -e 's#OpenSSL_##g; s#_#.#g; s#\"##g')"; SSL_102B_desc="OpenSSL $SSL_102B_version (1.0.0)"; SSL_102B_check="openssl.pc $(printf "$SSL_102_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"; SSL_102B_checklib="libcrypto.so.1.0.0"; SSL_102B_url="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=2&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_1_0_2[a-z].*"))][0] | .tarball_url' | sed -e 's#\"##g')"; SSL_102B_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); SSL_102B_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); SSL_102B_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); SSL_102B_tasks+=('export CC=@CC@;'); SSL_102B_tasks+=('export RANLIB=@RANLIB@;'); SSL_102B_tasks+=('FLAGS="linux-generic32 shared";'); SSL_102B_tasks+=('./Configure --prefix=@PREFIX@ $FLAGS;'); SSL_102B_tasks+=('make -j@CPUS@;'); SSL_102B_tasks+=('make install;'); # OpenSSL 1.0.0 SSL_100="1"; SSL_100_beta="0"; SSL_100_name="OpenSSL"; SSL_100_version="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=2&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_1_0_0[a-z].*"))][0] | .name' | sed -e 's#OpenSSL_##g; s#_#.#g; s#\"##g')"; SSL_100_check="openssl.pc $(printf "$SSL_100_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"; SSL_100_url="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=2&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_1_0_0[a-z].*"))][0] | .tarball_url' | sed -e 's#\"##g')"; SSL_100_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); SSL_100_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); SSL_100_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); SSL_100_tasks+=('export CC=@CC@;'); SSL_100_tasks+=('export RANLIB=@RANLIB@;'); SSL_100_tasks+=('FLAGS="linux-generic32 shared";'); SSL_100_tasks+=('[[ "@CC@" =~ "musl" ]] && echo "Apply the musl libc patch to avoid OpenSSL build errors due to missing termio.h..." && curl --silent "https://raw.githubusercontent.com/beagleboard/buildroot/master/package/openssl/openssl-004-musl-termios.patch" | patch -p1;'); SSL_100_tasks+=('./Configure --prefix=@PREFIX@ $FLAGS;'); SSL_100_tasks+=('make -j@CPUS@;'); SSL_100_tasks+=('make install;'); # OpenSSL 0.9.8 SSL_098="1"; SSL_098_beta="0"; SSL_098_name="OpenSSL"; SSL_098_version="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=3&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_0_9_8[a-z].*"))][0] | .name' | sed -e 's#OpenSSL_##g; s#_#.#g; s#\"##g')"; SSL_098_check="openssl.pc $(printf "$SSL_098_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"; SSL_098_url="$(curl --silent "https://api.github.com/repos/openssl/openssl/tags?page=3&per_page=100" | jq '[.[] | select(.name|test("OpenSSL_0_9_8[a-z].*"))][0] | .tarball_url' | sed -e 's#\"##g')"; SSL_098_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); SSL_098_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); SSL_098_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); SSL_098_tasks+=('export CC=@CC@;'); SSL_098_tasks+=('export RANLIB=@RANLIB@;'); SSL_098_tasks+=('FLAGS="linux-generic32 shared";'); SSL_098_tasks+=('[[ "@CC@" =~ "musl" ]] && echo "Apply the musl libc patch to avoid OpenSSL build errors due to missing termio.h..." && curl --silent "https://raw.githubusercontent.com/beagleboard/buildroot/master/package/openssl/openssl-004-musl-termios.patch" | patch -p1;'); SSL_098_tasks+=('./Configure --prefix=@PREFIX@ $FLAGS;'); SSL_098_tasks+=('make -j@CPUS@;'); SSL_098_tasks+=('make install;'); # libusb LIB_USB="1"; LIB_USB_beta="0"; LIB_USB_name="libusb"; LIB_USB_version="$(curl --silent "https://api.github.com/repos/libusb/libusb/releases/latest" | jq -r '.tag_name' | cut -c 2-)"; LIB_USB_check="libusb-1.0.pc $(printf "$LIB_USB_version")"; LIB_USB_checkcc="c11"; LIB_USB_desc="$LIB_USB_name $LIB_USB_version (gcc $LIB_USB_checkcc)"; LIB_USB_url="$(curl --silent "https://api.github.com/repos/libusb/libusb/releases/latest" | jq -r '.assets[2].browser_download_url')"; LIB_USB_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); LIB_USB_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); LIB_USB_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); LIB_USB_tasks+=('export CC=@CC@;'); LIB_USB_tasks+=('[ "@TYPE@" == "android-ndk" ] && export ANDROID_NDK="@TOOLCHAIN@";'); LIB_USB_tasks+=('[ "@TYPE@" == "android-ndk" ] && cp -f "android/config.h" "./config.h";'); LIB_USB_tasks+=('[ "@TYPE@" == "android-ndk" ] && FLAGS="--enable-static --disable-shared --disable-udev" || FLAGS="--disable-udev";'); LIB_USB_tasks+=('./configure --prefix=@PREFIX@ --host=@HOST@ $FLAGS;'); LIB_USB_tasks+=('make -j@CPUS@;'); LIB_USB_tasks+=('make install;'); LIB_USB_tasks+=('[ "@TYPE@" == "android-ndk" ] && find "@PREFIX@/lib/" -maxdepth 1 -name "libusb-1.0.*" -execdir ln -frs "@PREFIX@/lib/{}" "@PREFIX@/lib/@HOST@/@API@/{}" \;;'); # libusb 1.0.23 LIB_USBB="1"; LIB_USBB_beta="0"; LIB_USBB_name="libusb"; LIB_USBB_version="$(curl --silent "https://api.github.com/repos/libusb/libusb/releases" | jq '[.[] | select(.tag_name|test("v1.0.23"))][0] | .tag_name' | sed -e 's#v##g; s#\"##g')"; LIB_USBB_check="libusb-1.0.pc $(printf "$LIB_USBB_version")"; LIB_USBB_url="$(curl --silent "https://api.github.com/repos/libusb/libusb/releases" | jq '[.[] | select(.tag_name|test("v1.0.23"))][0] | .assets[1].browser_download_url' | sed -e 's#\"##g')"; LIB_USBB_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); LIB_USBB_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); LIB_USBB_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); LIB_USBB_tasks+=('export CC=@CC@;'); LIB_USBB_tasks+=('[ "@TYPE@" == "android-ndk" ] && export ANDROID_NDK="@TOOLCHAIN@";'); LIB_USBB_tasks+=('[ "@TYPE@" == "android-ndk" ] && cp -f "android/config.h" "./config.h";'); LIB_USBB_tasks+=('[ "@TYPE@" == "android-ndk" ] && FLAGS="--enable-static --disable-shared --disable-udev" || FLAGS="--disable-udev";'); LIB_USBB_tasks+=('./configure --prefix=@PREFIX@ --host=@HOST@ $FLAGS;'); LIB_USBB_tasks+=('make -j@CPUS@;'); LIB_USBB_tasks+=('make install;'); LIB_USBB_tasks+=('[ "@TYPE@" == "android-ndk" ] && find "@PREFIX@/lib/" -maxdepth 1 -name "libusb-1.0.*" -execdir ln -frs "@PREFIX@/lib/{}" "@PREFIX@/lib/@HOST@/@API@/{}" \;;'); # libusb 0.1.12 LIB_USB0="1"; LIB_USB0_beta="0"; LIB_USB0_name="libusb"; LIB_USB0_version="0.1.12"; LIB_USB0_check="libusb.pc"; LIB_USB0_url="http://downloads.sourceforge.net/libusb/libusb-0.1.12.tar.gz"; LIB_USB0_tasks=('echo "Patch 1: Handle compile failures with GCC 7+..." && curl --silent https://sources.debian.org/data/main/libu/libusb/2:0.1.12-32/debian/patches/12_ENAMETOOLONG.diff | git apply -v;'); LIB_USB0_tasks+=('export TOOLCHAIN=@TOOLCHAIN@;'); LIB_USB0_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); LIB_USB0_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); LIB_USB0_tasks+=('export CC=@CC@;'); LIB_USB0_tasks+=('./configure --prefix=@PREFIX@ --host=@HOST@ --disable-udev;'); LIB_USB0_tasks+=('make -j@CPUS@;'); LIB_USB0_tasks+=('make install;'); # PCSC-Lite LIB_PCSC="1"; LIB_PCSC_beta="0"; LIB_PCSC_name="PCSC-Lite"; LIB_PCSC_version="$(curl --silent "https://pcsclite.apdu.fr/files/" | grep -m1 'href="pcsc-lite' | awk -F '"' '{printf $4}' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"; LIB_PCSC_check="libpcsclite.pc"; LIB_PCSC_url="$(printf 'https://pcsclite.apdu.fr/files/'$(curl --silent "https://pcsclite.apdu.fr/files/" | grep -m1 'href="pcsc-lite' | awk -F '"' '{printf $4}'))"; LIB_PCSC_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); LIB_PCSC_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); LIB_PCSC_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); LIB_PCSC_tasks+=('export CC=@CC@;'); LIB_PCSC_tasks+=('[ "@TYPE@" == "android-ndk" ] && export ANDROID_NDK="@TOOLCHAIN@";'); LIB_PCSC_tasks+=('[ "@TYPE@" == "android-ndk" ] && LIBUSB_LIBS="@PREFIX@/lib/@HOST@/@API@ -lusb-1.0" || LIBUSB_LIBS="@PREFIX@/lib -lusb-1.0 -lrt";'); LIB_PCSC_tasks+=('[ "@TYPE@" == "android-ndk" ] && FLAGS="--enable-static --disable-shared --disable-libudev LIBS=-llog" || FLAGS="--disable-libudev";'); LIB_PCSC_tasks+=('./configure --prefix=@PREFIX@ --host=@HOST@ $FLAGS --disable-libsystemd --with-systemdsystemunitdir=@PREFIX@/lib/systemd/system LIBUSB_LIBS="-L${LIBUSB_LIBS}" LIBUSB_CFLAGS="-I@PREFIX@/include/libusb-1.0";'); LIB_PCSC_tasks+=('make -j@CPUS@;'); LIB_PCSC_tasks+=('make install;'); LIB_PCSC_tasks+=('[ "@TYPE@" == "android-ndk" ] && find "@PREFIX@/lib/" -maxdepth 1 -name "libpcsc*" -execdir ln -frs "@PREFIX@/lib/{}" "@PREFIX@/lib/@HOST@/@API@/{}" \;;'); LIB_PCSC_tasks+=('@VALIDATE@ "PCSC";'); LIB_PCSC_tasks+=('[ "@TYPE@" == "android-ndk" ] && zip -j "$bdir/@HOST@@API@-pcscd.zip" -xi "@PREFIX@/sbin/pcscd";'); # CCID IFD Handler LIB_CCID="1"; LIB_CCID_beta="0"; LIB_CCID_name="CCID"; LIB_CCID_version="$(curl --silent "https://ccid.apdu.fr/files/" | grep -m1 'href="ccid' | awk -F '"' '{printf $4}' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"; LIB_CCID_check="libccid.pc"; LIB_CCID_url="$(printf 'https://ccid.apdu.fr/files/'$(curl --silent "https://ccid.apdu.fr/files/" | grep -m1 'href="ccid' | awk -F '"' '{printf $4}'))"; LIB_CCID_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); LIB_CCID_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); LIB_CCID_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); LIB_CCID_tasks+=('export CC=@CC@;'); LIB_CCID_tasks+=('[ "@TYPE@" == "android-ndk" ] && export ANDROID_NDK="@TOOLCHAIN@";'); LIB_CCID_tasks+=('[ "@TYPE@" == "android-ndk" ] && LIBUSB_LIBS="@PREFIX@/lib/@HOST@/@API@ -lusb-1.0" || LIBUSB_LIBS="@PREFIX@/lib -lusb-1.0 -lrt";'); LIB_CCID_tasks+=('[ "@TYPE@" == "android-ndk" ] && FLAGS="--enable-static" || FLAGS="";'); LIB_CCID_tasks+=('./bootstrap;'); LIB_CCID_tasks+=('./configure --prefix=@PREFIX@ --host=@HOST@ $FLAGS --enable-twinserial --enable-usbdropdir="@PREFIX@/..$(pkg-config libpcsclite --variable=usbdropdir)" --enable-serialconfdir="@PREFIX@$(pkg-config libpcsclite --variable=serialconfdir)" LIBUSB_LIBS="-L${LIBUSB_LIBS}" LIBUSB_CFLAGS="-I@PREFIX@/include/libusb-1.0";'); LIB_CCID_tasks+=('make -j@CPUS@;'); LIB_CCID_tasks+=('make install;'); LIB_CCID_tasks+=('echo -e "prefix=@PREFIX@\nexec_prefix=\${prefix}\nlibdir=\${exec_prefix}/lib\nincludedir=\${prefix}/include/PCSC\nusbdropdir=@PREFIX@/lib/pcsc/drivers\nserialconfdir=@PREFIX@/etc/reader.conf.d\n\nName: CCID IFD Handler\nDescription: Generic USB CCID (Chip/Smart Card Interface Devices) and ICCD (Integrated Circuit(s) Card Devices) driver\nVersion: $LIB_CCID_version\nRequires: libusb libpcsclite" > "@PREFIX@/lib/pkgconfig/libccid.pc";'); LIB_CCID_tasks+=('[ "@TYPE@" == "android-ndk" ] && zip -j "$bdir/@HOST@@API@-libccid.zip" -xi "@PREFIX@/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Linux/libccid.so";'); LIB_CCID_tasks+=('[ "@TYPE@" == "android-ndk" ] && zip -j "$bdir/@HOST@@API@-libccidtwin.zip" -xi "@PREFIX@/lib/pcsc/drivers/serial/libccidtwin.so";'); LIB_CCID_tasks+=('[ "@TYPE@" == "android-ndk" ] && zip -j "$bdir/@HOST@@API@-libccidplist.zip" -xi "@PREFIX@/lib/pcsc/drivers/ifd-ccid.bundle/Contents/Info.plist";'); # zlib LIB_ZLIB="1"; LIB_ZLIB_beta="0"; LIB_ZLIB_name="zlib"; LIB_ZLIB_version="$(curl --silent https://api.github.com/repos/madler/zlib/tags | jq -r '.[0].name' | cut -c 2-)"; LIB_ZLIB_check="zlib.pc"; LIB_ZLIB_url="$(curl --silent "https://api.github.com/repos/madler/zlib/tags" | jq -r '.[0].tarball_url')"; LIB_ZLIB_tasks=('export TOOLCHAIN=@TOOLCHAIN@;'); LIB_ZLIB_tasks+=('export PATH="$TOOLCHAIN/bin:$PATH";'); LIB_ZLIB_tasks+=('[ -n "@CFLAGS@" ] && export CFLAGS="@CFLAGS@";'); LIB_ZLIB_tasks+=('export CC=@CC@;'); LIB_ZLIB_tasks+=('[ "@TYPE@" == "android-ndk" ] && export ANDROID_NDK="@TOOLCHAIN@";'); LIB_ZLIB_tasks+=('./configure --prefix=@PREFIX@;'); LIB_ZLIB_tasks+=('make -j@CPUS@;'); LIB_ZLIB_tasks+=('make install;'); LIB_ZLIB_tasks+=('[ "@TYPE@" == "android-ndk" ] && find "@PREFIX@/lib/" -maxdepth 1 -name "libz.*" -execdir ln -frs "@PREFIX@/lib/{}" "@PREFIX@/lib/@HOST@/@API@/{}" \;;');