2023-12-01 12:51:28 +03:00
|
|
|
#!/bin/bash -xe
|
|
|
|
SCRIPT_PATH="$(dirname -- "${BASH_SOURCE[0]}")" # relative
|
|
|
|
SCRIPT_PATH="$(cd -- "$SCRIPT_PATH" && pwd)" # absolutized and normalized
|
|
|
|
|
|
|
|
BASE=$(pwd)
|
|
|
|
SRC="$BASE/src"
|
|
|
|
BUILD="$BASE/build"
|
|
|
|
INSTALL="$BASE/install/MacFreeRDP.app/Contents"
|
|
|
|
|
|
|
|
BINDIR=MacOS
|
|
|
|
LIBDIR=Frameworks
|
|
|
|
DATADIR=Resources
|
|
|
|
|
2023-12-13 21:27:26 +03:00
|
|
|
DEPLOYMENT_ARCH='arm64 x86_64'
|
2023-12-13 20:34:18 +03:00
|
|
|
DEPLOYMENT_TARGET=12
|
|
|
|
|
2023-12-13 21:27:26 +03:00
|
|
|
usage () {
|
|
|
|
echo "${BASH_SOURCE[0]} [-a|--arch 'arch1 arch2 ...'] [-t|--target target][-h|--help]"
|
|
|
|
echo ""
|
|
|
|
echo "default options:"
|
|
|
|
echo "arch [$DEPLOYMENT_ARCH]"
|
|
|
|
echo "target [$DEPLOYMENT_TARGET]"
|
|
|
|
}
|
|
|
|
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
case $1 in
|
|
|
|
-a|--arch)
|
|
|
|
DEPLOYMENT_ARCH="$2"
|
|
|
|
shift # past argument
|
|
|
|
shift # past value
|
|
|
|
;;
|
|
|
|
-t|--target)
|
|
|
|
DEPLOYMENT_TARGET="$2"
|
|
|
|
shift # past argument
|
|
|
|
shift # past value
|
|
|
|
;;
|
|
|
|
-t|--target)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
-*|--*)
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2023-12-14 04:49:40 +03:00
|
|
|
fix_rpath() {
|
2023-12-14 13:00:19 +03:00
|
|
|
SEARCH_PATH=$1
|
2023-12-14 04:49:40 +03:00
|
|
|
FIX_PATH=$1
|
2023-12-14 13:43:48 +03:00
|
|
|
EXT=".dylib"
|
|
|
|
if [ "$#" -gt 1 ];
|
2023-12-14 13:00:19 +03:00
|
|
|
then
|
|
|
|
FIX_PATH=$2
|
|
|
|
fi
|
2023-12-14 13:43:48 +03:00
|
|
|
if [ "$#" -gt 2 ];
|
|
|
|
then
|
|
|
|
EXT=$3
|
|
|
|
fi
|
2023-12-14 13:00:19 +03:00
|
|
|
|
|
|
|
# some build systems do not handle @rpath on mac os correctly.
|
|
|
|
# do check that and fix it.
|
2023-12-14 13:43:48 +03:00
|
|
|
DYLIB_ABS_NAMES=$(find $SEARCH_PATH -type f -name "*$EXT")
|
2023-12-14 13:00:19 +03:00
|
|
|
for DYLIB_ABS in $DYLIB_ABS_NAMES;
|
|
|
|
do
|
|
|
|
DYLIB_NAME=$(basename $DYLIB_ABS)
|
|
|
|
install_name_tool -id @rpath/$DYLIB_NAME $DYLIB_ABS
|
|
|
|
|
|
|
|
for DYLIB_DEP in $(otool -L $DYLIB_ABS | grep "$FIX_PATH" | cut -d' ' -f1);
|
|
|
|
do
|
|
|
|
if [[ $DYLIB_DEP == $DYLIB_ABS ]];
|
|
|
|
then
|
|
|
|
continue
|
|
|
|
elif [[ $DYLIB_DEP == $FIX_PATH/* ]];
|
|
|
|
then
|
|
|
|
DEP_BASE=$(basename $DYLIB_DEP)
|
|
|
|
install_name_tool -change $DYLIB_DEP @rpath/$DEP_BASE $DYLIB_ABS
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
2023-12-14 04:49:40 +03:00
|
|
|
}
|
|
|
|
|
2023-12-14 14:35:21 +03:00
|
|
|
replace_rpath() {
|
|
|
|
FILE=$1
|
|
|
|
for PTH in $(otool -l $FILE | grep -A2 LC_RPATH | grep path | xargs -J ' ' | cut -d ' ' -f2);
|
|
|
|
do
|
|
|
|
install_name_tool -delete_rpath $PTH $FILE
|
|
|
|
done
|
|
|
|
install_name_tool -add_rpath @loader_path/../$LIBDIR $FILE
|
|
|
|
}
|
|
|
|
|
2023-12-13 20:34:18 +03:00
|
|
|
CMAKE_ARCHS=
|
|
|
|
OSSL_FLAGS="-mmacosx-version-min=$DEPLOYMENT_TARGET"
|
2023-12-13 21:27:26 +03:00
|
|
|
for ARCH in $DEPLOYMENT_ARCH;
|
2023-12-13 20:34:18 +03:00
|
|
|
do
|
|
|
|
OSSL_FLAGS="$OSSL_FLAGS -arch $ARCH"
|
2023-12-13 21:27:26 +03:00
|
|
|
CMAKE_ARCHS="$ARCH;$CMAKE_ARCHS"
|
2023-12-13 20:34:18 +03:00
|
|
|
done
|
2023-12-01 12:51:28 +03:00
|
|
|
|
2023-12-13 21:27:26 +03:00
|
|
|
echo "build arch [$DEPLOYMENT_ARCH]"
|
|
|
|
echo "build target [$DEPLOYMENT_TARGET]"
|
|
|
|
|
2023-12-01 12:51:28 +03:00
|
|
|
CMAKE_ARGS="-DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON \
|
|
|
|
-DCMAKE_VERBOSE_MAKEFILE=ON \
|
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
2023-12-21 21:24:22 +03:00
|
|
|
-DWITH_MANPAGES=OFF \
|
2023-12-01 12:51:28 +03:00
|
|
|
-DBUILD_SHARED_LIBS=ON \
|
2023-12-13 20:34:18 +03:00
|
|
|
-DCMAKE_OSX_ARCHITECTURES=$CMAKE_ARCHS \
|
|
|
|
-DCMAKE_OSX_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET \
|
2023-12-01 12:51:28 +03:00
|
|
|
-DCMAKE_INSTALL_PREFIX='$INSTALL' \
|
2023-12-14 13:43:48 +03:00
|
|
|
-DCMAKE_INSTALL_LIBDIR='lib' \
|
|
|
|
-DCMAKE_INSTALL_BINDIR='bin' \
|
2023-12-01 12:51:28 +03:00
|
|
|
-DCMAKE_INSTALL_DATADIR='$DATADIR' \
|
2023-12-14 13:43:48 +03:00
|
|
|
-DINSTALL_LIB_DIR='$INSTALL/lib' \
|
|
|
|
-DINSTALL_BIN_DIR='$INSTALL/bin' \
|
|
|
|
-DCMAKE_PREFIX_PATH='$INSTALL;$INSTALL/lib;$INSTALL/lib/cmake' \
|
2023-12-13 21:18:17 +03:00
|
|
|
-DCMAKE_IGNORE_PATH='/opt/local;/usr/local;/opt/homebrew;/Library;~/Library'
|
2023-12-01 12:51:28 +03:00
|
|
|
"
|
|
|
|
|
|
|
|
if [ ! -d $SRC ];
|
|
|
|
then
|
|
|
|
mkdir -p $SRC
|
|
|
|
cd $SRC
|
|
|
|
git clone -b openssl-3.2.0 https://github.com/openssl/openssl.git
|
|
|
|
git clone --depth 1 -b v1.3 https://github.com/madler/zlib.git
|
|
|
|
git clone --depth 1 -b uriparser-0.9.7 https://github.com/uriparser/uriparser.git
|
|
|
|
git clone --depth 1 -b v1.7.16 https://github.com/DaveGamble/cJSON.git
|
|
|
|
git clone --depth 1 -b release-2.28.1 https://github.com/libsdl-org/SDL.git
|
|
|
|
git clone --depth 1 --shallow-submodules --recurse-submodules -b release-2.20.2 https://github.com/libsdl-org/SDL_ttf.git
|
2023-12-21 19:29:44 +03:00
|
|
|
git clone --depth 1 --shallow-submodules --recurse-submodules -b release-2.8.1 https://github.com/libsdl-org/SDL_image.git
|
2023-12-01 12:51:28 +03:00
|
|
|
git clone --depth 1 --shallow-submodules --recurse-submodules -b v1.0.26 https://github.com/libusb/libusb-cmake.git
|
|
|
|
git clone --depth 1 -b n6.0 https://github.com/FFmpeg/FFmpeg.git
|
|
|
|
git clone --depth 1 -b v2.4.0 https://github.com/cisco/openh264.git
|
2023-12-13 22:26:54 +03:00
|
|
|
git clone --depth 1 -b v1.4 https://gitlab.xiph.org/xiph/opus.git
|
2023-12-13 22:34:30 +03:00
|
|
|
git clone --depth 1 -b 2.11.1 https://github.com/knik0/faad2.git
|
2023-12-13 23:28:43 +03:00
|
|
|
git clone --depth 1 -b 1.18.0 https://gitlab.freedesktop.org/cairo/cairo.git
|
|
|
|
git clone --depth 1 -b 1_30 https://github.com/knik0/faac.git
|
|
|
|
cd faac
|
|
|
|
./bootstrap
|
2023-12-01 12:51:28 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d $INSTALL ];
|
|
|
|
then
|
|
|
|
rm -rf $INSTALL
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d $BUILD ];
|
|
|
|
then
|
|
|
|
rm -rf $BUILD
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p $BUILD
|
|
|
|
cd $BUILD
|
|
|
|
|
|
|
|
cmake -GNinja -Bzlib -S$SRC/zlib $CMAKE_ARGS
|
|
|
|
cmake --build zlib
|
|
|
|
cmake --install zlib
|
|
|
|
|
2023-12-14 13:43:48 +03:00
|
|
|
cmake -GNinja -Buriparser -S$SRC/uriparser $CMAKE_ARGS -DURIPARSER_BUILD_DOCS=OFF -DURIPARSER_BUILD_TESTS=OFF \
|
|
|
|
-DURIPARSER_BUILD_TOOLS=OFF
|
2023-12-01 12:51:28 +03:00
|
|
|
cmake --build uriparser
|
|
|
|
cmake --install uriparser
|
|
|
|
|
2023-12-13 23:28:43 +03:00
|
|
|
cmake -GNinja -BcJSON -S$SRC/cJSON $CMAKE_ARGS -DENABLE_CJSON_TEST=OFF -DBUILD_SHARED_AND_STATIC_LIBS=OFF
|
2023-12-01 12:51:28 +03:00
|
|
|
cmake --build cJSON
|
|
|
|
cmake --install cJSON
|
|
|
|
|
2023-12-13 22:26:54 +03:00
|
|
|
cmake -GNinja -Bopus -S$SRC/opus $CMAKE_ARGS -DOPUS_BUILD_SHARED_LIBRARY=ON
|
|
|
|
cmake --build opus
|
|
|
|
cmake --install opus
|
|
|
|
|
2023-12-13 22:34:30 +03:00
|
|
|
cmake -GNinja -Bfaad2 -S$SRC/faad2 $CMAKE_ARGS
|
|
|
|
cmake --build faad2
|
|
|
|
cmake --install faad2
|
|
|
|
|
2023-12-13 23:28:43 +03:00
|
|
|
cmake -GNinja -BSDL -S$SRC/SDL $CMAKE_ARGS -DSDL_TEST=OFF -DSDL_TESTS=OFF -DSDL_STATIC_PIC=ON
|
2023-12-01 12:51:28 +03:00
|
|
|
cmake --build SDL
|
|
|
|
cmake --install SDL
|
|
|
|
|
|
|
|
cmake -GNinja -BSDL_ttf -S$SRC/SDL_ttf $CMAKE_ARGS -DSDL2TTF_HARFBUZZ=ON -DSDL2TTF_FREETYPE=ON -DSDL2TTF_VENDORED=ON \
|
|
|
|
-DFT_DISABLE_ZLIB=OFF -DSDL2TTF_SAMPLES=OFF
|
|
|
|
cmake --build SDL_ttf
|
|
|
|
cmake --install SDL_ttf
|
|
|
|
|
2023-12-18 14:10:14 +03:00
|
|
|
cmake -GNinja -BSDL_image -S$SRC/SDL_image $CMAKE_ARGS -DSDL2IMAGE_SAMPLES=OFF -DSDL2IMAGE_DEPS_SHARED=OFF
|
|
|
|
cmake --build SDL_image
|
|
|
|
cmake --install SDL_image
|
|
|
|
|
2023-12-01 12:51:28 +03:00
|
|
|
cmake -GNinja -Blibusb-cmake -S$SRC/libusb-cmake $CMAKE_ARGS -DLIBUSB_BUILD_EXAMPLES=OFF -DLIBUSB_BUILD_TESTING=OFF \
|
|
|
|
-DLIBUSB_ENABLE_DEBUG_LOGGING=OFF -DLIBUSB_BUILD_SHARED_LIBS=ON
|
|
|
|
cmake --build libusb-cmake
|
|
|
|
cmake --install libusb-cmake
|
|
|
|
|
|
|
|
mkdir -p openssl
|
|
|
|
cd openssl
|
|
|
|
|
2023-12-14 13:43:48 +03:00
|
|
|
CFLAGS=$OSSL_FLAGS LDFLAGS=$OSSL_FLAGS $SRC/openssl/config --prefix=$INSTALL --libdir=lib no-asm no-tests no-docs no-apps zlib
|
2023-12-01 12:51:28 +03:00
|
|
|
CFLAGS=$OSSL_FLAGS LDFLAGS=$OSSL_FLAGS make -j build_sw
|
|
|
|
CFLAGS=$OSSL_FLAGS LDFLAGS=$OSSL_FLAGS make -j install_sw
|
|
|
|
|
2023-12-13 23:28:43 +03:00
|
|
|
cd $BUILD
|
|
|
|
mkdir -p faac
|
|
|
|
cd faac
|
|
|
|
# undefine __SSE2__, symbol clashes with universal build
|
2023-12-14 13:43:48 +03:00
|
|
|
CFLAGS="$OSSL_FLAGS -U__SSE2__" LDFLAGS=$OSSL_FLAGS $SRC/faac/configure --prefix=$INSTALL --libdir="$INSTALL/lib" \
|
2023-12-13 23:28:43 +03:00
|
|
|
--enable-shared --disable-static
|
|
|
|
CFLAGS="$OSSL_FLAGS -U__SSE2__" LDFLAGS=$OSSL_FLAGS make -j
|
|
|
|
CFLAGS="$OSSL_FLAGS -U__SSE2__" LDFLAGS=$OSSL_FLAGS make -j install
|
|
|
|
|
2023-12-01 12:51:28 +03:00
|
|
|
cd $BUILD
|
|
|
|
|
|
|
|
meson setup --prefix="$INSTALL" -Doptimization=3 -Db_lto=true -Db_pie=true -Dc_args="$OSSL_FLAGS" -Dc_link_args="$OSSL_FLAGS" \
|
2023-12-14 13:43:48 +03:00
|
|
|
-Dcpp_args="$OSSL_FLAGS" -Dcpp_link_args="$OSSL_FLAGS" -Dpkgconfig.relocatable=true -Dtests=disabled \
|
|
|
|
-Dlibdir=lib openh264 $SRC/openh264
|
2023-12-01 12:51:28 +03:00
|
|
|
ninja -C openh264 install
|
|
|
|
|
2023-12-14 04:49:40 +03:00
|
|
|
for ARCH in $DEPLOYMENT_ARCH;
|
|
|
|
do
|
|
|
|
mkdir -p $BUILD/FFmpeg/$ARCH
|
|
|
|
cd $BUILD/FFmpeg/$ARCH
|
|
|
|
FFCFLAGS="-arch $ARCH -mmacosx-version-min=$DEPLOYMENT_TARGET"
|
|
|
|
FINSTPATH=$BUILD/FFmpeg/install/$ARCH
|
2023-12-14 13:43:48 +03:00
|
|
|
CFLAGS=$FFCFLAGS LDFLAGS=$FFCFLAGS $SRC/FFmpeg/configure --prefix=$FINSTPATH --disable-all \
|
2023-12-14 04:49:40 +03:00
|
|
|
--enable-shared --disable-static --enable-swscale --disable-asm --disable-libxcb \
|
2024-01-07 12:12:27 +03:00
|
|
|
--disable-securetransport --disable-xlib --enable-cross-compile
|
2023-12-14 04:49:40 +03:00
|
|
|
CFLAGS=$FFCFLAGS LDFLAGS=$FFCFLAGS make -j
|
|
|
|
CFLAGS=$FFCFLAGS LDFLAGS=$FFCFLAGS make -j install
|
2023-12-14 13:43:48 +03:00
|
|
|
fix_rpath "$FINSTPATH/lib"
|
2023-12-14 04:49:40 +03:00
|
|
|
done
|
|
|
|
|
|
|
|
BASE_ARCH="${DEPLOYMENT_ARCH%% *}"
|
|
|
|
|
|
|
|
cd $BUILD/FFmpeg/install/$ARCH
|
|
|
|
cp -r include/* $INSTALL/include/
|
2023-12-14 13:43:48 +03:00
|
|
|
find lib -type l -exec cp -P {} $INSTALL/lib/ \;
|
|
|
|
BASE_LIBS=$(find lib -type f -name "*.dylib" -exec basename {} \;)
|
2023-12-14 04:49:40 +03:00
|
|
|
|
|
|
|
cd $BUILD/FFmpeg/install
|
|
|
|
for LIB in $BASE_LIBS;
|
|
|
|
do
|
|
|
|
LIBS=$(find . -name $LIB)
|
2023-12-14 13:43:48 +03:00
|
|
|
lipo $LIBS -output $INSTALL/lib/$LIB -create
|
2023-12-14 04:49:40 +03:00
|
|
|
done
|
|
|
|
|
|
|
|
cd $BUILD
|
2024-01-07 11:32:15 +03:00
|
|
|
cmake -GNinja -Bfreerdp -S"$SCRIPT_PATH/.." \
|
|
|
|
$CMAKE_ARGS \
|
|
|
|
-DWITH_PLATFORM_SERVER=OFF \
|
|
|
|
-DWITH_NEON=OFF \
|
|
|
|
-DWITH_SSE=OFF \
|
|
|
|
-DWITH_FFMPEG=OFF \
|
|
|
|
-DWITH_SWSCALE=ON \
|
|
|
|
-DWITH_OPUS=ON \
|
|
|
|
-DWITH_WEBVIEW=OFF \
|
|
|
|
-DWITH_FAAD2=ON \
|
|
|
|
-DWITH_FAAC=ON \
|
|
|
|
-DWITH_INTERNAL_RC4=ON \
|
|
|
|
-DWITH_INTERNAL_MD4=ON \
|
|
|
|
-DWITH_INTERNAL_MD5=ON
|
2023-12-01 12:51:28 +03:00
|
|
|
cmake --build freerdp
|
|
|
|
cmake --install freerdp
|
|
|
|
|
2023-12-14 13:43:48 +03:00
|
|
|
# remove unused stuff from bin
|
|
|
|
find "$INSTALL" -name "*.a" -exec rm -f {} \;
|
|
|
|
find "$INSTALL" -name "*.la" -exec rm -f {} \;
|
|
|
|
find "$INSTALL" -name sdl2-config -exec rm -f {} \;
|
|
|
|
|
|
|
|
fix_rpath "$INSTALL/lib"
|
|
|
|
fix_rpath "$INSTALL/bin" "$INSTALL/lib" ""
|
2023-12-01 12:51:28 +03:00
|
|
|
|
2023-12-14 13:43:48 +03:00
|
|
|
# move files in place
|
|
|
|
cd $INSTALL
|
|
|
|
mv lib $LIBDIR
|
|
|
|
mv bin $BINDIR
|
2023-12-14 13:00:19 +03:00
|
|
|
|
2023-12-14 14:35:21 +03:00
|
|
|
# update RPATH
|
|
|
|
for LIB in $(find $LIBDIR -type f -name "*.dylib");
|
|
|
|
do
|
|
|
|
replace_rpath $LIB
|
|
|
|
done
|
|
|
|
|
|
|
|
for BIN in $(find $BINDIR -type f);
|
|
|
|
do
|
|
|
|
replace_rpath $BIN
|
|
|
|
done
|
|
|
|
|
2023-12-01 12:51:28 +03:00
|
|
|
# clean up unused data
|
|
|
|
rm -rf "$INSTALL/include"
|
|
|
|
rm -rf "$INSTALL/share"
|
|
|
|
rm -rf "$INSTALL/bin"
|
|
|
|
rm -rf "$INSTALL/$LIBDIR/cmake"
|
|
|
|
rm -rf "$INSTALL/$LIBDIR/pkgconfig"
|
|
|
|
|
|
|
|
# TODO: Create remaining files required
|