<commit_before>#!/bin/bash

# This script builds the iOS and Mac openSSL libraries
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script

# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
#
# https://gist.github.com/foozmeat/5154962


set -e

usage ()
{
    echo "usage: $0 [minimum iOS SDK version (default 8.1)]"
    exit 127
}

if [ $1 -e "-h" ]; then
    usage
fi

if [ -z $1 ]; then
    SDK_VERSION="8.1"
else
    SDK_VERSION=$1
fi

OPENSSL_VERSION="openssl-1.0.1l"
DEVELOPER=`xcode-select -print-path`

buildMac()
{
    ARCH=$1

    echo "Building ${OPENSSL_VERSION} for ${ARCH}"

    TARGET="darwin-i386-cc"

    if [[ $ARCH == "x86_64" ]]; then
        TARGET="darwin64-x86_64-cc"
    fi

    pushd . > /dev/null
    cd "${OPENSSL_VERSION}"
    ./Configure ${TARGET} --openssldir="/tmp/${OPENSSL_VERSION}-${ARCH}" &> "/tmp/${OPENSSL_VERSION}-${ARCH}.log"
    make >> "/tmp/${OPENSSL_VERSION}-${ARCH}.log" 2>&1
    make install >> "/tmp/${OPENSSL_VERSION}-${ARCH}.log" 2>&1
    make clean >> "/tmp/${OPENSSL_VERSION}-${ARCH}.log" 2>&1
    popd > /dev/null
}

buildIOS()
{
    ARCH=$1

    pushd . > /dev/null
    cd "${OPENSSL_VERSION}"
  
    if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then
        PLATFORM="iPhoneSimulator"
    else
        PLATFORM="iPhoneOS"
        sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
    fi
  
    export $PLATFORM
    export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
    export CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk"
    export BUILD_TOOLS="${DEVELOPER}"
    export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
   
    echo "Building ${OPENSSL_VERSION} for ${PLATFORM} ${SDK_VERSION} ${ARCH}"

    if [[ "${ARCH}" == "x86_64" ]]; then
        ./Configure darwin64-x86_64-cc --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
    else
        ./Configure iphoneos-cross --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
    fi
    # add -isysroot to CC=
    sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=${SDK_VERSION} !" "Makefile"

    make >> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log" 2>&1
    make install >> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log" 2>&1
    make clean >> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log" 2>&1
    popd > /dev/null
}

echo "Cleaning up"
rm -rf include/openssl/* libs/ios/libcrypto* libs/mac/libcrypto*

mkdir -p libs/ios
mkdir -p libs/mac
mkdir -p include/openssl/

rm -rf "/tmp/${OPENSSL_VERSION}-*"
rm -rf "/tmp/${OPENSSL_VERSION}-*.log"

rm -rf "${OPENSSL_VERSION}"

if [ ! -e ${OPENSSL_VERSION}.tar.gz ]; then
    echo "Downloading ${OPENSSL_VERSION}.tar.gz"
    curl -O http://www.openssl.org/source/${OPENSSL_VERSION}.tar.gz
else
    echo "Using ${OPENSSL_VERSION}.tar.gz"
fi

echo "Unpacking openssl"
tar xfz "${OPENSSL_VERSION}.tar.gz"<commit_msg>notes in build-openssl.h<commit_after>#!/bin/bash

# This script builds the iOS and Mac openSSL libraries
# Download openssl http://www.openssl.org/source/ and place the tarball next to this script

# Credits:
# https://github.com/st3fan/ios-openssl
# https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh
#
# https://gist.github.com/foozmeat/5154962


set -e

usage ()
{
    echo "usage: $0 [minimum iOS SDK version (default 8.1)]"
    exit 127
}

if [ $1 -e "-h" ]; then
    usage
fi

if [ -z $1 ]; then
    SDK_VERSION="8.1"
else
    SDK_VERSION=$1
fi

OPENSSL_VERSION="openssl-1.0.1l"
DEVELOPER=`xcode-select -print-path`

# TODO
#EXCLUDES=" no-idea no-camellia no-ec "

# TODO make build_crypto, but then make install messes it up

buildMac()
{
    ARCH=$1

    echo "Building ${OPENSSL_VERSION} for ${ARCH}"

    TARGET="darwin-i386-cc"

    if [[ $ARCH == "x86_64" ]]; then
        TARGET="darwin64-x86_64-cc"
    fi

    pushd . > /dev/null
    cd "${OPENSSL_VERSION}"
    ./Configure ${TARGET} ${EXCLUDES} --openssldir="/tmp/${OPENSSL_VERSION}-${ARCH}" &> "/tmp/${OPENSSL_VERSION}-${ARCH}.log"
    make >> "/tmp/${OPENSSL_VERSION}-${ARCH}.log" 2>&1
    make install >> "/tmp/${OPENSSL_VERSION}-${ARCH}.log" 2>&1
    make clean >> "/tmp/${OPENSSL_VERSION}-${ARCH}.log" 2>&1
    popd > /dev/null
}

buildIOS()
{
    ARCH=$1

    pushd . > /dev/null
    cd "${OPENSSL_VERSION}"
  
    if [[ "${ARCH}" == "i386" || "${ARCH}" == "x86_64" ]]; then
        PLATFORM="iPhoneSimulator"
    else
        PLATFORM="iPhoneOS"
        sed -ie "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;!" "crypto/ui/ui_openssl.c"
    fi
  
    export $PLATFORM
    export CROSS_TOP="${DEVELOPER}/Platforms/${PLATFORM}.platform/Developer"
    export CROSS_SDK="${PLATFORM}${SDK_VERSION}.sdk"
    export BUILD_TOOLS="${DEVELOPER}"
    export CC="${BUILD_TOOLS}/usr/bin/gcc -arch ${ARCH}"
   
    echo "Building ${OPENSSL_VERSION} for ${PLATFORM} ${SDK_VERSION} ${ARCH}"

    if [[ "${ARCH}" == "x86_64" ]]; then
        ./Configure darwin64-x86_64-cc ${EXCLUDES} --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
    else
        ./Configure iphoneos-cross ${EXCLUDES} --openssldir="/tmp/${OPENSSL_VERSION}-iOS-${ARCH}" &> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log"
    fi
    # add -isysroot to CC=
    sed -ie "s!^CFLAG=!CFLAG=-isysroot ${CROSS_TOP}/SDKs/${CROSS_SDK} -miphoneos-version-min=${SDK_VERSION} !" "Makefile"

    make >> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log" 2>&1
    make install >> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log" 2>&1
    make clean >> "/tmp/${OPENSSL_VERSION}-iOS-${ARCH}.log" 2>&1
    popd > /dev/null
}

echo "Cleaning up"
rm -rf include/openssl/* libs/ios/libcrypto* libs/mac/libcrypto*

mkdir -p libs/ios
mkdir -p libs/mac
mkdir -p include/openssl/

rm -rf "/tmp/${OPENSSL_VERSION}-*"
rm -rf "/tmp/${OPENSSL_VERSION}-*.log"

rm -rf "${OPENSSL_VERSION}"

if [ ! -e ${OPENSSL_VERSION}.tar.gz ]; then
    echo "Downloading ${OPENSSL_VERSION}.tar.gz"
    curl -O http://www.openssl.org/source/${OPENSSL_VERSION}.tar.gz
else
    echo "Using ${OPENSSL_VERSION}.tar.gz"
fi

echo "Unpacking openssl"
tar xfz "${OPENSSL_VERSION}.tar.gz"
{'fraction_non_alphanumeric': 0.19163100332857821, 'fraction_numerical': 0.021239499128229512, 'mean_word_length': 3.4033496161898116, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 53, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2320872', 'n_tokens_mistral': 2516, 'n_tokens_neox': 2362, 'n_words': 459}