Skip to content

Building OSX ARM64 Third Party Dependencies

Pablo Tesone edited this page May 2, 2023 · 10 revisions

BUILD_DIR=/Users/admin/dev/Pharo/thirdparty/Darwin-arm64

SDL2-2.0.14

https://libsdl.org/release/SDL2-2.0.14.tar.gz
./configure --prefix=${BUILD_DIR}/ && make install


install_name_tool -id @executable_path/Plugins/libSDL2-2.0.0.dylib libSDL2-2.0.0.dylib

SDL2-2.24.1

wget https://libsdl.org/release/SDL2-2.24.1.tar.gz

tar xvfz SDL2-2.24.1.tar.gz
cd SDL2-2.24.1

PATH="${BUILD_DIR}/bin:$PATH" \
LDFLAGS="-Z -L/usr/lib -F/Library/Frameworks -F/System/Library/Frameworks" \
MACOSX_DEPLOYMENT_TARGET=11.0 \
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${BUILD_DIR}/lib/pkgconfig" \
./configure --prefix=${BUILD_DIR}/ 

make install

cd ${BUILD_DIR}/lib

install_name_tool -id @executable_path/Plugins/libSDL2-2.0.0.dylib libSDL2-2.0.0.dylib

zip -y SDL2-2.24.1.zip libSDL2*.dylib

pixman-0.40.0

wget https://www.cairographics.org/releases/pixman-0.40.0.tar.gz
tar xvfz pixman-0.40.0.tar.gz

cd pixman-0.40.0

PATH="${BUILD_DIR}/bin:$PATH" \
LDFLAGS="-Z -L/usr/lib -F/Library/Frameworks -F/System/Library/Frameworks" \
MACOSX_DEPLOYMENT_TARGET=11.0 \
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${BUILD_DIR}/lib/pkgconfig" \
./configure --prefix=${BUILD_DIR}/ 

make install

cd ${BUILD_DIR}/lib
install_name_tool -id @executable_path/Plugins/libpixman-1.0.dylib libpixman-1.0.40.0.dylib

zip -y pixman-0.40.0.zip libpixman*.dylib

libpng-1.6.37

cd ${BUILD_DIR}
wget https://download.sourceforge.net/libpng/libpng-1.6.37.tar.gz
tar xvfz libpng-1.6.37.tar.gz
cd libpng-1.6.37

PATH="${BUILD_DIR}/bin:$PATH" \
LDFLAGS="-Z -L/usr/lib -F/Library/Frameworks -F/System/Library/Frameworks" \
MACOSX_DEPLOYMENT_TARGET=11.0 \
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${BUILD_DIR}/lib/pkgconfig" \
cmake . -DCMAKE_PREFIX_PATH=${BUILD_DIR}/ -DCMAKE_INSTALL_PREFIX:PATH=${BUILD_DIR}/ -DPNG_ARM_NEON=on

make install

cd ${BUILD_DIR}/lib

install_name_tool -id @executable_path/Plugins/libpng16.16.dylib libpng16.16.37.0.dylib

zip -y libpng-1.6.37.zip libpng*.dylib

freetype-2.10.0

wget https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.gz
./configure --prefix=${BUILD_DIR}/ && make install

cd ${BUILD_DIR}/lib

install_name_tool -id @executable_path/Plugins/libfreetype.6.dylib libfreetype.6.dylib

install_name_tool -change /opt/homebrew/opt/libpng/lib/libpng16.16.dylib @executable_path/Plugins/libpng16.16.dylib libfreetype.6.dylib

zip -y freetype-2.10.0.zip libfreetype.*dylib

freetype-2.12.1

wget https://download.savannah.gnu.org/releases/freetype/freetype-2.12.1.tar.gz
tar xvfz freetype-2.12.1.tar.gz
cd freetype-2.12.1

PATH="${BUILD_DIR}/bin:$PATH" \
LDFLAGS="-Z -L/usr/lib -F/Library/Frameworks -F/System/Library/Frameworks" \
MACOSX_DEPLOYMENT_TARGET=11.0 \
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${BUILD_DIR}/lib/pkgconfig" \
./configure --prefix=${BUILD_DIR} --enable-freetype-config --without-harfbuzz --without-brotli

make install

cd ${BUILD_DIR}/lib

install_name_tool -id @executable_path/Plugins/libfreetype.6.dylib libfreetype.6.dylib
install_name_tool -change @rpath/libpng16.16.dylib @executable_path/Plugins/libpng16.16.dylib libfreetype.6.dylib

zip -y freetype-2.12.1.zip libfreetype.*dylib

fontconfig-2.13.1

wget https://freedesktop.org/software/fontconfig/release/fontconfig-2.13.1.tar.gz
tar xvfz fontconfig-2.13.1.tar.gz
cd fontconfig-2.13.1

PATH="${BUILD_DIR}/bin:$PATH" \
LDFLAGS="-Z -L/usr/lib -F/Library/Frameworks -F/System/Library/Frameworks" \
MACOSX_DEPLOYMENT_TARGET=11.0 \
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${BUILD_DIR}/lib/pkgconfig" \
./configure \
--prefix=${BUILD_DIR}/ --disable-docs

make install RUN_FC_CACHE_TEST=false

cd ${BUILD_DIR}/lib

install_name_tool -id @executable_path/Plugins/libfontconfig.1.dylib libfontconfig.1.dylib

zip -y fontconfig-2.13.1.zip libfontconfig*.dylib

cairo-1.16.0

./configure --prefix=${BUILD_DIR}/ && make install

cd ${BUILD_DIR}/lib
install_name_tool -id @executable_path/Plugins/libcairo.2.dylib libcairo.2.dylib

install_name_tool -change /opt/homebrew/opt/pixman/lib/libpixman-1.0.dylib @executable_path/Plugins/libpixman-1.0.dylib libcairo.2.dylib

install_name_tool -change /opt/homebrew/opt/fontconfig/lib/libfontconfig.1.dylib @executable_path/Plugins/libfontconfig.1.dylib libcairo.2.dylib

install_name_tool -change /opt/homebrew/opt/freetype/lib/libfreetype.6.dylib @executable_path/Plugins/libfreetype.6.dylib libcairo.2.dylib

install_name_tool -change /opt/homebrew/opt/libpng/lib/libpng16.16.dylib @executable_path/Plugins/libpng16.16.dylib libcairo.2.dylib

zip -y cairo-1.16.0.zip libcairo.*dylib

cairo-1.17.4

wget https://cairographics.org/snapshots/cairo-1.17.4.tar.xz
tar xvf cairo-1.17.4.tar.xz
cd cairo-1.17.4

PATH="${BUILD_DIR}/bin:$PATH" \
MACOSX_DEPLOYMENT_TARGET=11.0 \
LDFLAGS="-Z -L/usr/lib -F/Library/Frameworks -F/System/Library/Frameworks" \
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${BUILD_DIR}/lib/pkgconfig" \
./configure --prefix=${BUILD_DIR}/ --disable-xlib --disable-xcb

make install

cd ${BUILD_DIR}/lib
install_name_tool -id @executable_path/Plugins/libcairo.2.dylib libcairo.2.dylib
install_name_tool -change @rpath/libpng16.16.dylib @executable_path/Plugins/libpng16.16.dylib libcairo.2.dylib

zip -y cairo-1.17.4.zip libcairo.*dylib

harfbuzz-5.3.1

HARFBUZZ_VERSION=5.3.1
HARFBUZZ_FILENAME=harfbuzz-${HARFBUZZ_VERSION}

wget https://github.com/harfbuzz/harfbuzz/releases/download/${HARFBUZZ_VERSION}/${HARFBUZZ_FILENAME}.tar.xz

tar xvf ${HARFBUZZ_FILENAME}.tar.xz

cd ${HARFBUZZ_FILENAME}

PATH="${BUILD_DIR}/bin:$PATH" \
MACOSX_DEPLOYMENT_TARGET=11.0 \
LDFLAGS="-Z -L/usr/lib -F/Library/Frameworks -F/System/Library/Frameworks" \
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${BUILD_DIR}/lib/pkgconfig" \
./configure --prefix=${BUILD_DIR} --with-glib=no --with-icu-no

make install

cd ${BUILD_DIR}/lib

install_name_tool -id @executable_path/Plugins/libharfbuzz.0.dylib libharfbuzz.0.dylib

zip -y harfbuzz-5.3.1.zip libharfbuzz.*dylib

openssl-1.1.1k

Download sources

mkdir ssl
cd ssl
wget https://www.openssl.org/source/openssl-1.1.1k.tar.gz
tar -xvf openssl-1.1.1k.tar.gz
cd openssl-1.1.1k

Compile

CFLAGS="-mmacosx-version-min=10.7" ./config --prefix=${BUILD_DIR}/ && make install

Fix RPaths and package zip

install_name_tool -id @executable_path/Plugins/libcrypto.1.1.dylib libcrypto.1.1.dylib

install_name_tool -id @executable_path/Plugins/libssl.1.1.dylib libssl.1.1.dylib
install_name_tool -change ${BUILD_DIR}/lib/libcrypto.1.1.dylib @executable_path/Plugins/libcrypto.1.1.dylib libssl.1.1.dylib

zip -y openssl-1.1.1k.zip libssl*dylib
zip -y openssl-1.1.1k.zip libcry*dylib

Check with otool -L

otool -L libssl.1.1.dylib
libssl.1.1.dylib:
	@executable_path/Plugins/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	@executable_path/Plugins/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)

libssh2-1.9.0

Download Sources

git clone [email protected]:libssh2/libssh2.git
cd libssh2
git checkout libssh2-1.9.0 
cd ..

Compile

cmake . -DCMAKE_INSTALL_PREFIX:PATH=${BUILD_DIR}/ -DBUILD_SHARED_LIBS=ON
make install

Fix RPaths and package zip

install_name_tool -id @executable_path/Plugins/libssh2.1.0.1.dylib libssh2.1.0.1.dylib

zip -y libssh2-1.9.0.zip libssh*dylib

Check with otool -L

otool -L libssh2.dylib
libssh2.dylib:
	@executable_path/Plugins/libssh2.1.0.1.dylib (compatibility version 1.0.0, current version 1.0.1)
	@executable_path/Plugins/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	@executable_path/Plugins/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)

libssh2-1.10.0

Download Sources

git clone [email protected]:libssh2/libssh2.git
cd libssh2
git checkout libssh2-1.10.0 

Compile

mkdir build
cd build

CFLAGS="-mmacosx-version-min=10.7" PKG_CONFIG_PATH="${BUILD_DIR}/lib/pkgconfig" \
cmake .. \
-B . \
-DCMAKE_PREFIX_PATH=${BUILD_DIR} \
-DCMAKE_INSTALL_PREFIX=${BUILD_DIR} \
-DCRYPTO_BACKEND=OpenSSL \
-DBUILD_SHARED_LIBS=ON \
-DENABLE_ZLIB_COMPRESSION=ON

cmake --build .
cmake --build . --target install

Fix RPaths and package zip

install_name_tool -id @executable_path/Plugins/libssh2.1.0.1.dylib libssh2.1.0.1.dylib

zip -y libssh2-1.10.0.zip libssh*dylib

Check with otool -L

otool -L libssh2.dylib
libssh2.dylib:
	@executable_path/Plugins/libssh2.1.0.1.dylib (compatibility version 1.0.0, current version 1.0.1)
	@executable_path/Plugins/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	@executable_path/Plugins/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)

libgit2-1.4.4

Download Sources

git clone [email protected]:libgit2/libgit2.git
cd libgit2
git checkout v1.4.4 
cd ..

Compile

cmake -S libgit2 -B build -DUSE_SSH=ON -DCMAKE_INSTALL_PREFIX:PATH=`pwd`/libs/ -DCMAKE_PREFIX_PATH="`pwd`/libs/"
cmake --build build --target install

Fix RPaths and package zip

install_name_tool -id @executable_path/Plugins/libgit2.1.4.4.dylib libgit2.1.4.4.dylib
install_name_tool -change libssh2.1.dylib @executable_path/Plugins/libssh2.1.dylib libgit2.1.4.4.dylib

zip -y libgit2-1.4.4.zip libgit2*dylib

Check with otool -L

Libz and libiconv are linked against the system libraries, that should be ok

otool -L libgit2.1.4.4.dylib
libgit2.1.4.4.dylib:
	@executable_path/Plugins/libgit2.1.4.4.dylib (compatibility version 1.4.0, current version 1.4.4)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1858.112.0)
	/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 60158.100.133)
	@executable_path/Plugins/libssh2.1.0.1.dylib (compatibility version 1.0.0, current version 1.0.1)
	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)

libgit2-1.5.2

Download Sources

git clone [email protected]:libgit2/libgit2.git
cd libgit2
git checkout v1.5.2 

Compile

mkdir build
cd build 

CFLAGS="-mmacosx-version-min=10.7" PKG_CONFIG_PATH="${BUILD_DIR}/lib/pkgconfig" \
cmake .. -B . \
-DCMAKE_PREFIX_PATH=${BUILD_DIR} \
-DCMAKE_INSTALL_PREFIX:PATH=${BUILD_DIR} \
-DCMAKE_FIND_ROOT_PATH=${BUILD_DIR} \
-DCMAKE_LIBRARY_PATH=${BUILD_DIR}/lib \
-DCMAKE_INCLUDE_PATH=${BUILD_DIR}/include \
-DUSE_SSH=ON \
-DBUILD_EXAMPLES=ON 

cmake --build . --target install

Fix RPaths and package zip

install_name_tool -id @executable_path/Plugins/libgit2.1.5.2.dylib libgit2.1.5.2.dylib

zip -y libgit2-1.5.2.zip libgit2.1.5.2.dylib
zip -y libgit2-1.5.2.zip libgit2.1.5.dylib
zip -y libgit2-default-2023-04-14.zip libgit2.dylib

libgit2-1.6.4

Download Sources

git clone [email protected]:libgit2/libgit2.git
cd libgit2
git checkout v1.6.4 

Compile

mkdir build1.6.4
cd build1.6.4 

CFLAGS="-mmacosx-version-min=10.7" PKG_CONFIG_PATH="${BUILD_DIR}/lib/pkgconfig" \
cmake .. -B . \
-DCMAKE_PREFIX_PATH=${BUILD_DIR} \
-DCMAKE_INSTALL_PREFIX:PATH=${BUILD_DIR} \
-DCMAKE_FIND_ROOT_PATH=${BUILD_DIR} \
-DCMAKE_LIBRARY_PATH=${BUILD_DIR}/lib \
-DCMAKE_INCLUDE_PATH=${BUILD_DIR}/include \
-DUSE_SSH=ON \
-DBUILD_EXAMPLES=ON 

cmake --build . --target install

Fix RPaths and package zip

install_name_tool -id @executable_path/Plugins/libgit2.1.6.4.dylib libgit2.1.6.4.dylib

zip -y libgit2-1.6.4.zip libgit2.1.6.4.dylib
zip -y libgit2-1.6.4.zip libgit2.1.6.dylib

libgit2-1.0.1

TAG: v1.0.1

PKG_CONFIG_PATH="$PKG_CONFIG_PATH:${BUILD_DIR}/lib/pkgconfig" cmake . -DBUILD_CLAR=OFF  -DCMAKE_PREFIX_PATH=${BUILD_DIR}/ -DCMAKE_INSTALL_PREFIX:PATH=${BUILD_DIR}/ -DCMAKE_FIND_ROOT_PATH=${BUILD_DIR}/lib/ -DOPENSSL_SSL_LIBRARY=${BUILD_DIR}/lib/

make install

install_name_tool -id @executable_path/Plugins/libgit2.1.0.1.dylib libgit2.1.0.1.dylib
install_name_tool -change libssh2.1.dylib @executable_path/Plugins/libssh2.1.dylib libgit2.1.0.1.dylib

zip -y libgit2-1.0.1.zip libgit2*dylib
Clone this wiki locally