Skip to content

Commit 5322dae

Browse files
authored
Merge pull request #24 from hannesa2/PrepareAppleM1
Prepare scripts for Apple Silicon M1
2 parents ffe5099 + 4721179 commit 5322dae

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

script/bootstrap

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ check_deps ()
4343
echo "Homebrew is not installed (http://brew.sh). You will need to manually ensure the following tools are installed:"
4444
echo " $REQUIRED_TOOLS"
4545
echo
46-
echo "Additionally, the following libssh2 files must be symlinked under /usr/local:"
46+
echo "Additionally, the following libssh2 files must be symlinked under /usr/local or /opt/homebrew :"
4747
echo " lib/libssh2.a include/libssh2.h include/libssh2_sftp.h include/libssh2_publickey.h"
4848
exit $result
4949
fi
@@ -70,7 +70,13 @@ check_deps ()
7070
done
7171

7272
brew_prefix=`brew --prefix`
73-
expected_prefix=/usr/local
73+
if [[ `uname -m` == 'arm64' ]]; then
74+
echo "Running on a Apple Silicon M1"
75+
export expected_prefix=/opt/homebrew
76+
else
77+
echo "Running on a Apple x86"
78+
export expected_prefix=/usr/local
79+
fi
7480

7581
if [ "$brew_prefix" != "$expected_prefix" ]
7682
then

script/update_libgit2

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
set -e
44

5-
# augment path to help it find cmake installed in /usr/local/bin,
6-
# e.g. via brew. Xcode's Run Script phase doesn't seem to honor
7-
# ~/.MacOSX/environment.plist
8-
PATH="/usr/local/bin:$PATH"
9-
105
cd "External/libgit2"
116

127
if [ -d "build" ]; then
@@ -17,10 +12,22 @@ mkdir build
1712
cd build
1813

1914
# OpenSSL is keg-only, so add its pkgconfig location manually
20-
export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
15+
if [[ `uname -m` == 'arm64' ]]; then
16+
echo "Running on a Apple Silicon M1"
17+
export ARCH_PREFIX=/opt/homebrew
18+
else
19+
echo "Running on a Apple x86"
20+
export ARCH_PREFIX=/usr/local
21+
fi
22+
export PKG_CONFIG_PATH=$ARCH_PREFIX/opt/openssl/lib/pkgconfig
23+
24+
# augment path to help it find cmake installed in /usr/local/bin,
25+
# e.g. via brew. Xcode's Run Script phase doesn't seem to honor
26+
# ~/.MacOSX/environment.plist
27+
PATH="$ARCH_PREFIX/bin:$PATH"
2128

2229
cmake -DBUILD_SHARED_LIBS:BOOL=OFF \
23-
-DLIBSSH2_INCLUDE_DIRS:PATH=/usr/local/include/ \
30+
-DLIBSSH2_INCLUDE_DIRS:PATH=$ARCH_PREFIX/include/ \
2431
-DBUILD_CLAR:BOOL=OFF \
2532
-DTHREADSAFE:BOOL=ON \
2633
..

0 commit comments

Comments
 (0)