Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
build sstp-client universal binary
Browse files Browse the repository at this point in the history
  • Loading branch information
axot committed Sep 9, 2021
1 parent 682303a commit cd1d59f
Show file tree
Hide file tree
Showing 12 changed files with 381 additions and 80 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ DerivedData/
### Custom ###
iSstp/helper
iSstp/helper.dSYM
iSstp/sstp-client/x86_64
iSstp/sstp-client/arm64
iSstp/sstp-client/out
sstpc

190 changes: 110 additions & 80 deletions iSstp.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

67 changes: 67 additions & 0 deletions iSstp.xcodeproj/xcshareddata/xcschemes/sstp-client.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "53B6933726EA3E0200E161B2"
BuildableName = "sstp-client"
BlueprintName = "sstp-client"
ReferencedContainer = "container:iSstp.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "53B6933726EA3E0200E161B2"
BuildableName = "sstp-client"
BlueprintName = "sstp-client"
ReferencedContainer = "container:iSstp.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
70 changes: 70 additions & 0 deletions iSstp/sstp-client/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

set -euo pipefail

PATH=/opt/homebrew/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin

cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null

VERSION=1.0.15
URL=https://downloads.sourceforge.net/project/sstp-client/sstp-client/sstp-client-${VERSION}.tar.gz

function brew_cellar_path() {
echo $($BREW_PATH --cellar "$1")/$($BREW_PATH info --json "$1" | jq -r '.[0].installed[0].version')
}

env

for arch in arm64 x86_64; do
mkdir -p $arch
pushd $arch/

if ! [ -d ./homebrew ]; then
mkdir homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
fi

BREW_PATH=$(realpath homebrew/bin/brew)
HOMEBREW_PREFIX=$($BREW_PATH --prefix)
export PKG_CONFIG_PATH="$HOMEBREW_PREFIX/opt/openssl@1.1/lib/pkgconfig:$HOMEBREW_PREFIX/opt/libevent/lib/pkgconfig"

arch -$arch $BREW_PATH install pkg-config libevent openssl@1.1 automake libtool

if ! [ -d ./build ]; then
mkdir -p build
pushd build

wget $URL
tar zxf sstp-client-${VERSION}.tar.gz --strip-components=1 -C .

find . -name 'Makefile.in' -exec rm {} \;

patch -p0 < ../../configure.ac.patch
patch -p0 < ../../src_Makefile.am.patch
patch -p0 < ../../src_libsstp-api_Makefile.am.patch

arch -$arch autoreconf -f -i
arch -$arch ./configure \
--disable-dependency-tracking \
--disable-silent-rules \
--disable-ppp-plugin \
--with-runtime-dir=/var/run/sstpc \
--with-openssl=$(brew_cellar_path openssl@1.1) \
--with-libevent=$(brew_cellar_path libevent) \
LIBEVENT_STATIC_LIBS="$HOMEBREW_PREFIX/opt/libevent/lib/libevent.a" \
OPENSSL_STATIC_LIBS="$HOMEBREW_PREFIX/opt/openssl@1.1/lib/libssl.a $HOMEBREW_PREFIX/opt/openssl@1.1/lib/libcrypto.a" \
popd
fi

pushd build
arch -$arch make -j $(nproc)

# ./arch/build
popd

# ./arch
popd
done

mkdir -p out
lipo -create -output out/sstpc x86_64/build/src/sstpc arm64/build/src/sstpc
107 changes: 107 additions & 0 deletions iSstp/sstp-client/configure.ac.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
--- configure.ac.orig 2021-09-09 21:46:59.000000000 +0900
+++ configure.ac 2021-09-09 21:48:03.000000000 +0900
@@ -1,5 +1,5 @@
AC_PREREQ([2.65])
-AC_INIT([sstp-client],
+AC_INIT([sstp-client],
[1.0.15],
[https://gitlab.com/eivnaes/sstp-client])

@@ -25,7 +25,7 @@
[with_libevent="$withval"], [with_libevent="2"])

AS_CASE([$with_libevent],
- ["1"],[AX_CHECK_LIBRARY([LIBEVENT], [event.h], [event],
+ ["1"],[AX_CHECK_LIBRARY([LIBEVENT], [event.h], [event],
[AC_CHECK_LIB([event], [event_init], [],
[AC_MSG_ERROR([libevent is not usable])])],
[AC_MSG_ERROR([Required library libevent not found])])],
@@ -34,16 +34,24 @@
[AC_MSG_ERROR([Required library libevent not found])])],
["*"],[AC_MSG_ERROR([Unknown version of libevent specified])])

-CFLAGS="$LIBEVENT_CFLAGS $CFLAGS"
-LDFLAGS="$LIBEVENT_LIBS $LDFLAGS"
+PKG_CHECK_MODULES([LIBEVENT], [libevent >= $LIBEVENT2_MINIMUM],
+ [AC_DEFINE([HAVE_LIBEVENT2], [1], [Specify use of libevent >= $LIBEVENT2_MINIMUM])],
+ [AC_MSG_ERROR([Required library libevent not found])])
+
+CFLAGS="$LIBEVENT_CFLAGS $LIBEVENT_INCLUDES $CFLAGS"

# Check for OpenSSL
-AX_CHECK_OPENSSL([],
+AX_CHECK_OPENSSL([],
[AC_MSG_ERROR([OpenSSL not found Hint: apt-get install libssl-dev])])
-LIBS="$LIBS $OPENSSL_LIBS"
+
CFLAGS="$OPENSSL_INCLUDES $CFLAGS"
-LDFLAGS="$OPENSSL_LDFLAGS $LDFLAGS"

+LDFLAGS=""
+LIBEVENT_STATIC_LIBS="$LIBEVENT_STATIC_LIBS"
+OPENSSL_STATIC_LIBS="$OPENSSL_STATIC_LIBS"
+
+AC_SUBST([LIBEVENT_STATIC_LIBS])
+AC_SUBST([OPENSSL_STATIC_LIBS])

# Check for openpty
AC_CHECK_LIB([util], [openpty])
@@ -70,7 +78,7 @@


# Specify runtime directory
-AC_ARG_WITH([runtime-dir],
+AC_ARG_WITH([runtime-dir],
AC_HELP_STRING([--with-runtime-dir=DIR], [Specify the runtime directory for sstpc]))
AS_IF([ test -n "$with_runtime_dir"],
[SSTP_RUNTIME_DIR="$with_runtime_dir"],
@@ -79,7 +87,7 @@


# Check to see if we enabled PPP plug-in support (default:yes)
-AC_ARG_ENABLE(ppp-plugin,
+AC_ARG_ENABLE(ppp-plugin,
AC_HELP_STRING([--disable-ppp-plugin=DIR], [disable PPP Plugin support]),
[enable_ppp_plugin=${enableval}], [enable_ppp_plugin=yes])
AS_IF([test "x$enable_ppp_plugin" != "xno"],
@@ -111,12 +119,12 @@
AS_HELP_STRING([--with-pppd-auth-notify-support], [is the auth-notifier supported in this pppd version]))
AS_IF([test "x$with_pppd_auth_notify_support" == "xyes" ],
[AC_DEFINE(USE_PPPD_AUTH_HOOK,1,[Define if pppd has support for client side authentication complete notification])
- PPPD_AUTH_NOTIFIER="yes"],
+ PPPD_AUTH_NOTIFIER="yes"],
[PPPD_AUTH_NOTIFIER="no"])

# Check to see if the plugin directory was set
AM_CONDITIONAL(WITH_PPP_PLUGIN, test "${enable_ppp_plugin}" = "yes")
-AC_ARG_WITH([pppd-plugin-dir],
+AC_ARG_WITH([pppd-plugin-dir],
AS_HELP_STRING([--with-pppd-plugin-dir=DIR], [path to the pppd plugins directory]))
if test -n "$with_pppd_plugin_dir" ; then
PPPD_PLUGIN_DIR="$with_pppd_plugin_dir"
@@ -128,7 +136,7 @@
# system CA certificates path
AC_ARG_WITH(system-ca-path,
AS_HELP_STRING([--with-system-ca-path=/path/to/ssl/certs], [path to system CA certificates]))
-if test "x${with_system_ca_path}" = x; then
+if test "x${with_system_ca_path}" = x; then
SYSTEM_CA_PATH="${sysconfdir}/ssl/certs"
else
SYSTEM_CA_PATH="$with_system_ca_path"
@@ -206,9 +214,9 @@
System CA Path..: $SYSTEM_CA_PATH
User:...........: $enable_user
Group:..........: $enable_group
- Using OpenSSL...: $OPENSSL_INCLUDES $OPENSSL_LDFLAGS $OPENSSL_LIBS
+ Using OpenSSL...: $OPENSSL_INCLUDES $OPENSSL_LDFLAGS $OPENSSL_LIBS $OPENSSL_STATIC_LIBS
C Compiler......: $CC $CFLAGS
- Using Event.....: $LIBEVENT_CFLAGS $LIBEVENT_LIBS
+ Using Event.....: $LIBEVENT_CFLAGS $LIBEVENT_LIBS $LIBEVENT_STATIC_LIBS
Linker..........: $LD $LDFLAGS $LIBS
"
if [ test "x${enable_ppp_plugin}" = "xyes" ] ; then
@@ -220,4 +228,3 @@
Plugin Cflags...: $PPPD_PLUGIN_CFLAGS
"
fi
-
Binary file removed iSstp/sstp-client/lib/libcrypto.1.1.dylib
Binary file not shown.
Binary file removed iSstp/sstp-client/lib/libevent-2.1.7.dylib
Binary file not shown.
Binary file removed iSstp/sstp-client/lib/libssl.1.1.dylib
Binary file not shown.
Binary file removed iSstp/sstp-client/lib/libsstp_api-0.dylib
Binary file not shown.
Binary file removed iSstp/sstp-client/sbin/sstpc
Binary file not shown.
13 changes: 13 additions & 0 deletions iSstp/sstp-client/src_Makefile.am.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- src/Makefile.am.orig 2021-09-09 21:47:15.000000000 +0900
+++ src/Makefile.am 2021-09-09 21:48:15.000000000 +0900
@@ -3,7 +3,9 @@
sstpc_LDADD = \
libsstp-log/libsstp_log.la \
libsstp-api/libsstp_api.la \
- libsstp-compat/libsstp_compat.la
+ libsstp-compat/libsstp_compat.la \
+ $(OPENSSL_STATIC_LIBS) \
+ $(LIBEVENT_STATIC_LIBS)

utest_task_SOURCES = sstp-task.c
utest_task_CFLAGS = -I$(top_srcdir)/include -D__SSTP_UNIT_TEST_TASK=1
9 changes: 9 additions & 0 deletions iSstp/sstp-client/src_libsstp-api_Makefile.am.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- src/libsstp-api/Makefile.am.orig 2021-09-08 22:47:42.000000000 +0900
+++ src/libsstp-api/Makefile.am 2021-09-08 22:47:53.000000000 +0900
@@ -1,5 +1,5 @@
lib_LTLIBRARIES = libsstp_api.la
-libsstp_api_la_LDFLAGS = -export-dynamic -release 0
+libsstp_api_la_LDFLAGS = -static
libsstp_api_la_CFLAGS = -I$(top_srcdir)/include
libsstp_api_la_SOURCES = \
sstp-api.c

0 comments on commit cd1d59f

Please # to comment.