| 
									
										
										
										
											2023-10-12 00:29:17 +00:00
										 |  |  | #!/bin/sh | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-25 17:40:08 +00:00
										 |  |  | OPENSSL_VERSION=3.2.0 | 
					
						
							| 
									
										
										
										
											2023-10-12 00:29:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | API_LEVEL=28 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | BUILD_DIR=out/openssl_ios_build | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-14 01:56:40 +00:00
										 |  |  | BUILD_TARGETS="ios64-xcrun iossimulator-xcrun" | 
					
						
							| 
									
										
										
										
											2023-10-12 00:29:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | rm -rfv openssl-${OPENSSL_VERSION} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ ! -d openssl-${OPENSSL_VERSION} ] | 
					
						
							|  |  |  | then | 
					
						
							|  |  |  |     if [ ! -f openssl-${OPENSSL_VERSION}.tar.gz ] | 
					
						
							|  |  |  |     then | 
					
						
							|  |  |  |         curl https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz -o openssl-${OPENSSL_VERSION}.tar.gz || exit 128 | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |     tar xzf openssl-${OPENSSL_VERSION}.tar.gz || exit 128 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | WORK_DIR=openssl-${OPENSSL_VERSION} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ##### export ndk directory. Required by openssl-build-scripts ##### | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ##### build-function ##### | 
					
						
							|  |  |  | build_the_thing() { | 
					
						
							|  |  |  |     export PATH=$TOOLCHAIN/$TRIBLE/bin:$TOOLCHAIN/bin:$PATH | 
					
						
							|  |  |  |     echo $PATH | 
					
						
							|  |  |  |     echo "./Configure $SSL_TARGET $OPTIONS" && \ | 
					
						
							|  |  |  |     ./Configure $SSL_TARGET $OPTIONS no-tests && \ | 
					
						
							|  |  |  |     make clean && \ | 
					
						
							|  |  |  |     make build_generated && \ | 
					
						
							|  |  |  |     make libcrypto.a libssl.a || exit 128 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ##### set variables according to build-tagret ##### | 
					
						
							|  |  |  | for build_target in $BUILD_TARGETS | 
					
						
							|  |  |  | do | 
					
						
							|  |  |  |     echo "Building $build_target" | 
					
						
							|  |  |  |     cd $WORK_DIR || exit 128 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     case $build_target in | 
					
						
							|  |  |  |     ios64-xcrun) | 
					
						
							|  |  |  |         TRIBLE="arm64-darwin-ios" | 
					
						
							|  |  |  |         OPTIONS="--static -static -ffunction-sections -fdata-sections -fPIC -Wno-macro-redefined" | 
					
						
							|  |  |  |         DESTDIR="/tmp/$BUILD_DIR/arm64-ios" | 
					
						
							|  |  |  |         SSL_TARGET="ios64-xcrun" | 
					
						
							|  |  |  |         CC=clang | 
					
						
							|  |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2023-10-14 01:56:40 +00:00
										 |  |  |     iossimulator-xcrun) | 
					
						
							|  |  |  |         TRIBLE="x86_64-darwin-ios" | 
					
						
							|  |  |  |         OPTIONS="--static -static -ffunction-sections -fdata-sections -fPIC -Wno-macro-redefined" | 
					
						
							|  |  |  |         DESTDIR="/tmp/$BUILD_DIR/x86_64-iossim" | 
					
						
							|  |  |  |         SSL_TARGET="iossimulator-xcrun" | 
					
						
							|  |  |  |         CC=clang | 
					
						
							|  |  |  |     ;; | 
					
						
							| 
									
										
										
										
											2023-10-12 00:29:17 +00:00
										 |  |  |     esac | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     rm -rf $DESTDIR | 
					
						
							|  |  |  |     build_the_thing | 
					
						
							|  |  |  |     cd .. | 
					
						
							|  |  |  | #### copy libraries and includes to output-directory ##### | 
					
						
							|  |  |  |     echo WORK_DIR=$WORK_DIR | 
					
						
							|  |  |  |     rm -rf deps/openssl/ios/$build_target/ | 
					
						
							|  |  |  |     mkdir -p deps/openssl/ios/$build_target/usr/local/include | 
					
						
							|  |  |  |     mkdir -p deps/openssl/ios/$build_target/usr/local/lib/ | 
					
						
							|  |  |  |     cp -R $WORK_DIR/include/* deps/openssl/ios/$build_target/usr/local/include/ | 
					
						
							|  |  |  |     cp $WORK_DIR/*.a deps/openssl/ios/$build_target/usr/local/lib/ | 
					
						
							|  |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | echo Success |