lnsocket

A minimal C library for connecting to the lightning network
git clone git://jb55.com/lnsocket
Log | Files | Refs | Submodules | README | LICENSE

secp-ios.sh (2302B)


      1 #! /usr/bin/env bash
      2 #
      3 #  Step 1.
      4 #  Configure for base system so simulator is covered
      5 #  
      6 #  Step 2.
      7 #  Make for iOS and iOS simulator
      8 #
      9 #  Step 3.
     10 #  Merge libs into final version for xcode import
     11 
     12 cd deps/secp256k1
     13 
     14 export PREFIX="$(pwd)/libsecp256k1-ios"
     15 export IOS64_PREFIX="$PREFIX/tmp/ios64"
     16 export SIMULATOR64_PREFIX="$PREFIX/tmp/simulator64"
     17 export XCODEDIR=$(xcode-select -p)
     18 export IOS_SIMULATOR_VERSION_MIN=${IOS_SIMULATOR_VERSION_MIN-"6.0.0"}
     19 export IOS_VERSION_MIN=${IOS_VERSION_MIN-"6.0.0"}
     20 
     21 mkdir -p $SIMULATOR64_PREFIX $IOS64_PREFIX || exit 1
     22 
     23 # Build for the simulator
     24 export BASEDIR="${XCODEDIR}/Platforms/iPhoneSimulator.platform/Developer"
     25 export PATH="${BASEDIR}/usr/bin:$BASEDIR/usr/sbin:$PATH"
     26 export SDK="${BASEDIR}/SDKs/iPhoneSimulator.sdk"
     27 
     28 ## x86_64 simulator
     29 export CFLAGS="-O2 -arch x86_64 -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN} -flto"
     30 export LDFLAGS="-arch x86_64 -isysroot ${SDK} -mios-simulator-version-min=${IOS_SIMULATOR_VERSION_MIN} -flto"
     31 
     32 make distclean > /dev/null
     33 
     34 ./configure --host=x86_64-apple-darwin10 --disable-shared --enable-module-ecdh --enable-module-schnorrsig --enable-module-extrakeys --prefix="$SIMULATOR64_PREFIX" 
     35 
     36 make -j3 install || exit 1
     37 
     38 # Build for iOS
     39 export BASEDIR="${XCODEDIR}/Platforms/iPhoneOS.platform/Developer"
     40 export PATH="${BASEDIR}/usr/bin:$BASEDIR/usr/sbin:$PATH"
     41 export SDK="${BASEDIR}/SDKs/iPhoneOS.sdk"
     42 
     43 ## 64-bit iOS
     44 export CFLAGS="-O2 -arch arm64 -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN} -flto -fembed-bitcode"
     45 export LDFLAGS="-arch arm64 -isysroot ${SDK} -mios-version-min=${IOS_VERSION_MIN} -flto -fembed-bitcode"
     46 
     47 make distclean > /dev/null
     48 
     49 ./configure --host=arm-apple-darwin10 --disable-shared --enable-module-ecdh --enable-module-schnorrsig --enable-module-extrakeys --prefix="$IOS64_PREFIX" || exit 1
     50 
     51 make -j3 install || exit 1
     52 
     53 # Create universal binary and include folder
     54 rm -fr -- "$PREFIX/include" "$PREFIX/libsecp256k1.a" 2> /dev/null
     55 mkdir -p -- "$PREFIX/lib"
     56 lipo -create \
     57   "$SIMULATOR64_PREFIX/lib/libsecp256k1.a" \
     58   "$IOS64_PREFIX/lib/libsecp256k1.a" \
     59   -output "$PREFIX/lib/libsecp256k1.a"
     60 
     61 echo
     62 echo "libsecp256k1 has been installed into $PREFIX"
     63 echo
     64 file -- "$PREFIX/lib/libsecp256k1.a"
     65 
     66 # Cleanup
     67 rm -rf -- "$PREFIX/tmp"
     68 make distclean > /dev/null