searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

openconnect构建iOS动态库

2023-03-20 08:31:13
95
0

openconnect简介

OpenConnect是一个SSL VPN客户端,最初创建用于支持思科的AnyConnect SSL VPN。
它已经被移植到支持Juniper SSL VPN(现在被称为Pulse Connect Secure)、Palo Alto Networks GlobalProtect SSL VPN、F5 Big-IP SSL VPN和Fortinet FortiGate SSL VPN。

 

openconnect提供C语言、Java接口,支持windows、mac、linux、andriod,但不支持ios系统,本文介绍openconnect构建ios版本动态库。

openconnect以来openssl,openssl构建在另外一篇中介绍。

执行脚本如下:

#!/bin/sh


OPENCONNECTPATH="openconnect-ios"
git clone https://gitlab.com/openconnect/openconnect.git ${OPENCONNECTPATH}

#xcodebuild -version
#xcodeversion_current=`xcodebuild -version`
#xcodeversion="13.4.1"
#result=$(echo $xcodeversion_current | grep "$xcodeversion")
#echo $result
#if [[ "$result" != "" ]]
#then
#  echo "此时Xcode版本设置错误,请运行命令 'sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer' 来更换Xcode版本 "
#  exit
#fi

# build for iOS 

# this is the folder where the libs will be generated
export OUTPUT_DIR=libs

# Select toolchains folder
export XCODE_TOOLCHAINS=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain


#$(CURRENT_ARCH)

build_target()
{
    PLATFORM=$1
    ARCH=$2
    SDK_VERSION=$3
    CONFIGURE_HOST=$4
    IOS_DEPLOYMENT_TARGET=$5

    SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDK_VERSION.sdk


    PKGCONFIGPATH="$(PWD)/libopenssl/$ARCH/lib/pkgconfig"

    #copy pkgconfig
    cp ${PKGCONFIGPATH}/openssl.pc /usr/local/lib/pkgconfig
    cp ${PKGCONFIGPATH}/libssl.pc /usr/local/lib/pkgconfig
    cp ${PKGCONFIGPATH}/libcrypto.pc /usr/local/lib/pkgconfig

    echo ---------------------------------------------------
    echo ---------------------------------------------------
    echo -------------- BUILD OPENCONNECT
    echo -------------- PLATFORM : $PLATFORM
    echo -------------- ARCH : $ARCH
    echo -------------- SDK_VERSION : $SDK_VERSION
    echo -------------- HOST : $CONFIGURE_HOST
    echo -------------- MIN iOS : $IOS_DEPLOYMENT_TARGET
    echo -------------- SDK PATH : $SDKROOT
    echo ---------------------------------------------------
    echo ---------------------------------------------------

    #sleep 3
    cd ${OPENCONNECTPATH}
    sudo ./autogen.sh

    sudo make clean
    sudo ./configure CC="$XCODE_TOOLCHAINS/usr/bin/clang -arch $ARCH"  --prefix=/usr/local/ --with-vpnc-script=/usr/local/etc/vpnc-script \
    --without-gnutls --disable-nls --without-libpcsclite --without-lz4 --host $CONFIGURE_HOST CFLAGS="-g -fPIC -isysroot $SDKROOT"
    

    #x86_64
    #sudo ./configure CC="$XCODE_TOOLCHAINS/usr/bin/clang -arch $ARCH"  --prefix=/usr/local/ --with-vpnc-script=/usr/local/etc/vpnc-script \
    --without-gnutls --disable-nls --without-libpcsclite --without-lz4 --host $CONFIGURE_HOST CFLAGS="-miphoneos-version-min=$IOS_DEPLOYMENT_TARGET -fPIC -isysroot $SDKROOT" 

    sudo make
    sudo make install

    # Copy the lib
    rm -rf $OUTPUT_DIR/$ARCH/
    mkdir $OUTPUT_DIR/$ARCH/

    cp .libs/libopenconnect.5.dylib $OUTPUT_DIR/$ARCH/

}

# Copy the header file too, just for convenience

#build_target "iPhoneOS" "armv7s" "15.5" "arm-apple-darwin" "7.0"
#build_target "iPhoneOS" "armv7" "15.5" "arm-apple-darwin" "11.0"
#build_target "iPhoneOS" "arm64" "15.5" "arm-apple-darwin" "9.0"
build_target "iPhoneSimulator" "x86_64" "15.5" "x86_64-apple-darwin" "9.0"
#build_target "iPhoneSimulator" "i386" "15.5" "i386-apple-darwin" "9.0"

#build_target "MacOSX" "x86_64" "11.4" "i386-apple-darwin" "7.0"

 

 

0条评论
0 / 1000
袁****勋
3文章数
0粉丝数
袁****勋
3 文章 | 0 粉丝
袁****勋
3文章数
0粉丝数
袁****勋
3 文章 | 0 粉丝
原创

openconnect构建iOS动态库

2023-03-20 08:31:13
95
0

openconnect简介

OpenConnect是一个SSL VPN客户端,最初创建用于支持思科的AnyConnect SSL VPN。
它已经被移植到支持Juniper SSL VPN(现在被称为Pulse Connect Secure)、Palo Alto Networks GlobalProtect SSL VPN、F5 Big-IP SSL VPN和Fortinet FortiGate SSL VPN。

 

openconnect提供C语言、Java接口,支持windows、mac、linux、andriod,但不支持ios系统,本文介绍openconnect构建ios版本动态库。

openconnect以来openssl,openssl构建在另外一篇中介绍。

执行脚本如下:

#!/bin/sh


OPENCONNECTPATH="openconnect-ios"
git clone https://gitlab.com/openconnect/openconnect.git ${OPENCONNECTPATH}

#xcodebuild -version
#xcodeversion_current=`xcodebuild -version`
#xcodeversion="13.4.1"
#result=$(echo $xcodeversion_current | grep "$xcodeversion")
#echo $result
#if [[ "$result" != "" ]]
#then
#  echo "此时Xcode版本设置错误,请运行命令 'sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer' 来更换Xcode版本 "
#  exit
#fi

# build for iOS 

# this is the folder where the libs will be generated
export OUTPUT_DIR=libs

# Select toolchains folder
export XCODE_TOOLCHAINS=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain


#$(CURRENT_ARCH)

build_target()
{
    PLATFORM=$1
    ARCH=$2
    SDK_VERSION=$3
    CONFIGURE_HOST=$4
    IOS_DEPLOYMENT_TARGET=$5

    SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/$PLATFORM.platform/Developer/SDKs/$PLATFORM$SDK_VERSION.sdk


    PKGCONFIGPATH="$(PWD)/libopenssl/$ARCH/lib/pkgconfig"

    #copy pkgconfig
    cp ${PKGCONFIGPATH}/openssl.pc /usr/local/lib/pkgconfig
    cp ${PKGCONFIGPATH}/libssl.pc /usr/local/lib/pkgconfig
    cp ${PKGCONFIGPATH}/libcrypto.pc /usr/local/lib/pkgconfig

    echo ---------------------------------------------------
    echo ---------------------------------------------------
    echo -------------- BUILD OPENCONNECT
    echo -------------- PLATFORM : $PLATFORM
    echo -------------- ARCH : $ARCH
    echo -------------- SDK_VERSION : $SDK_VERSION
    echo -------------- HOST : $CONFIGURE_HOST
    echo -------------- MIN iOS : $IOS_DEPLOYMENT_TARGET
    echo -------------- SDK PATH : $SDKROOT
    echo ---------------------------------------------------
    echo ---------------------------------------------------

    #sleep 3
    cd ${OPENCONNECTPATH}
    sudo ./autogen.sh

    sudo make clean
    sudo ./configure CC="$XCODE_TOOLCHAINS/usr/bin/clang -arch $ARCH"  --prefix=/usr/local/ --with-vpnc-script=/usr/local/etc/vpnc-script \
    --without-gnutls --disable-nls --without-libpcsclite --without-lz4 --host $CONFIGURE_HOST CFLAGS="-g -fPIC -isysroot $SDKROOT"
    

    #x86_64
    #sudo ./configure CC="$XCODE_TOOLCHAINS/usr/bin/clang -arch $ARCH"  --prefix=/usr/local/ --with-vpnc-script=/usr/local/etc/vpnc-script \
    --without-gnutls --disable-nls --without-libpcsclite --without-lz4 --host $CONFIGURE_HOST CFLAGS="-miphoneos-version-min=$IOS_DEPLOYMENT_TARGET -fPIC -isysroot $SDKROOT" 

    sudo make
    sudo make install

    # Copy the lib
    rm -rf $OUTPUT_DIR/$ARCH/
    mkdir $OUTPUT_DIR/$ARCH/

    cp .libs/libopenconnect.5.dylib $OUTPUT_DIR/$ARCH/

}

# Copy the header file too, just for convenience

#build_target "iPhoneOS" "armv7s" "15.5" "arm-apple-darwin" "7.0"
#build_target "iPhoneOS" "armv7" "15.5" "arm-apple-darwin" "11.0"
#build_target "iPhoneOS" "arm64" "15.5" "arm-apple-darwin" "9.0"
build_target "iPhoneSimulator" "x86_64" "15.5" "x86_64-apple-darwin" "9.0"
#build_target "iPhoneSimulator" "i386" "15.5" "i386-apple-darwin" "9.0"

#build_target "MacOSX" "x86_64" "11.4" "i386-apple-darwin" "7.0"

 

 

文章来自个人专栏
SSL VPN
3 文章 | 1 订阅
0条评论
0 / 1000
请输入你的评论
0
0