| 1 | #!/bin/bash |
| 2 | |
| 3 | |
| 4 | set -euo pipefail |
| 5 | [[ $# == 3 || $# == 4 ]] || { echo 'Usage: rebuild-macos-sshfs.sh /source-bundle /macfuse-sdk/usr/local /output [patched-source-tree]' >&2; exit 2; } |
| 6 | materials=$1 |
| 7 | sdk=$2 |
| 8 | output=$3 |
| 9 | [[ $materials == /* && $sdk == /* && $output == /* && ! -e $output && -f $sdk/include/fuse3/fuse.h ]] |
| 10 | work=$(mktemp -d) |
| 11 | trap 'rm -rf "$work"' EXIT |
| 12 | if [[ $# == 4 ]]; then |
| 13 | cd "$4" |
| 14 | else |
| 15 | tar -xf "$materials/upstream/sshfs.tar.gz" -C "$work" --strip-components 1 |
| 16 | cd "$work" |
| 17 | patch -p1 < "$materials/cage/sshfs-openwith.patch" |
| 18 | fi |
| 19 | cat > config.h <<'HEADER' |
| 20 | |
| 21 | |
| 22 | HEADER |
| 23 | export MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-14.0} |
| 24 | glib=$materials/dependencies/glib |
| 25 | intl=$materials/dependencies/gettext |
| 26 | pcre=$materials/dependencies/pcre2 |
| 27 | clang -arch arm64 -O2 -D_REENTRANT -DHAVE_CONFIG_H -DFUSE_DARWIN_ENABLE_EXTENSIONS=0 -DFUSE_USE_VERSION=31 \ |
| 28 | -I. -Icompat -I"$sdk/include/fuse3" -I"$glib/include/glib-2.0" -I"$glib/lib/glib-2.0/include" -I"$intl/include" \ |
| 29 | sshfs.c cache.c compat/darwin_compat.c "$glib/lib/libgthread-2.0.a" "$glib/lib/libglib-2.0.a" "$intl/lib/libintl.a" "$pcre/lib/libpcre2-8.a" \ |
| 30 | -L"$sdk/lib" -lfuse3 -liconv -framework Foundation -framework CoreFoundation -framework AppKit -framework Carbon -o "$output" |