@@ -35,6 +35,9 @@ function buildOpenSSL {
3535 local ARCH=$2
3636 local SUBPLATFORM=$3
3737
38+ # Boolean flag: if non-zero then configure CC/LD/CFLAGS/LDFLAGS etc.
39+ local CONFIGURE_CC_FOR_TARGET=1
40+
3841 # Each target type in OpenSSL is given a name
3942 case " ${PLATFORM} " in
4043 mac)
@@ -58,24 +61,29 @@ function buildOpenSSL {
5861 fi
5962 ;;
6063 android)
64+ configureAndroidToolchain " ${ARCH} "
65+ export ANDROID_NDK_HOME=" ${ANDROID_TOOLCHAIN_BASE} "
66+ export PATH=" ${ANDROID_NDK_HOME} /bin:${PATH} "
67+ CONFIGURE_CC_FOR_TARGET=0
68+
6169 if [ " ${ARCH} " == " x86_64" ] ; then
62- SPEC=" android64 "
70+ SPEC=" android-x86_64 "
6371 elif [[ " ${ARCH} " =~ (x| i[3-6])86 ]] ; then
6472 # Work around a linker crash using the i686 gold linker in Android NDK r14
65- EXTRA_CFLAGS =" -fuse-ld=bfd"
73+ export CFLAGS =" -fuse-ld=bfd"
6674 SPEC=" android-x86"
6775 elif [ " ${ARCH} " == " arm64" ] ; then
6876 # Clang's integrated assembler is a bit broken so we need to force the use of GAS instead
69- EXTRA_CFLAGS =" -fno-integrated-as"
70- SPEC=" android64-aarch64 "
77+ export CFLAGS =" -fno-integrated-as"
78+ SPEC=" android-arm64 "
7179 elif [[ " ${ARCH} " =~ armv(6| 7) ]] ; then
7280 # Clang's integrated assembler is a bit broken so we need to force the use of GAS instead
73- EXTRA_CFLAGS =" -fno-integrated-as -U__clang__ "
81+ export CFLAGS =" -fno-integrated-as"
7482
7583 # When compiling with -mthumb, we need to link to libatomic
7684 EXTRA_OPTIONS=" -latomic"
7785
78- SPEC=" android-armeabi "
86+ SPEC=" android-arm "
7987 elif [[ " ${ARCH} " =~ .* 64 ]] ; then
8088 SPEC=" android64"
8189 else
@@ -100,20 +108,19 @@ function buildOpenSSL {
100108 local PLATFORM_NAME=${PLATFORM}
101109 fi
102110
103- CUSTOM_SPEC=" ${SPEC} -livecode"
111+ # The android-* targets derive the arch from the last portion of the target name
112+ # so this needs to be a prefix instead of suffix.
113+ CUSTOM_SPEC=" livecode_${SPEC} "
104114
105115 OPENSSL_ARCH_SRC=" ${OPENSSL_SRC} -${PLATFORM_NAME} -${ARCH} "
106- OPENSSL_ARCH_CONFIG=" no-rc5 no-hw shared -DOPENSSL_NO_ASYNC=1 --prefix=${INSTALL_DIR} /${NAME} ${CUSTOM_SPEC} ${EXTRA_OPTIONS} "
116+ OPENSSL_ARCH_CONFIG=" no-rc5 no-hw no-threads shared -DOPENSSL_NO_ASYNC=1 --prefix=${INSTALL_DIR} /${NAME} ${CUSTOM_SPEC} ${EXTRA_OPTIONS} "
107117
108118 # Copy the source to a target-specific directory
109119 if [ ! -d " ${OPENSSL_ARCH_SRC} " ] ; then
110120 echo " Duplicating OpenSSL source directory for ${NAME} "
111121 cp -r " ${OPENSSL_SRC} " " ${OPENSSL_ARCH_SRC} "
112122 fi
113123
114- # Patch the main OpenSSL configuration script to remove a '-mandroid' flag that is incompatible with clang.
115- sed -i.bak -e " s/-mandroid//g" " ${OPENSSL_ARCH_SRC} /Configurations/10-main.conf"
116-
117124 # Get the command used to build a previous copy, if any
118125 if [ -e " ${OPENSSL_ARCH_SRC} /config.cmd" ] ; then
119126 OPENSSL_ARCH_CURRENT_CONFIG=` cat ${OPENSSL_ARCH_SRC} /config.cmd`
@@ -127,17 +134,19 @@ function buildOpenSSL {
127134
128135 # Customise the OpenSSL configuration to ensure variables are exported as functions
129136 cat > Configurations/99-livecode.conf << EOF
130- %targets = (
137+ my %targets = (
131138"${CUSTOM_SPEC} " => {
132139 inherit_from => [ "${SPEC} " ],
133- bn_ops => sub { join(" ",(@_," EXPORT_VAR_AS_FN")) } ,
140+ bn_ops => add(" EXPORT_VAR_AS_FN"),
134141},
135142);
136143EOF
137144
145+ if [ $CONFIGURE_CC_FOR_TARGET != 0 ] ; then
146+ setCCForTarget " ${PLATFORM} " " ${ARCH} " " ${SUBPLATFORM} "
147+ fi
148+
138149 echo " Configuring OpenSSL for ${NAME} "
139-
140- setCCForTarget " ${PLATFORM} " " ${ARCH} " " ${SUBPLATFORM} "
141150 ./Configure ${OPENSSL_ARCH_CONFIG}
142151
143152 # iOS requires some tweaks to the source when building for devices
0 commit comments