diff --git a/bin/ape-install b/bin/ape-install index 829e27c58..bb71c98e2 100755 --- a/bin/ape-install +++ b/bin/ape-install @@ -2,6 +2,7 @@ PROG=${0##*/} MODE=${MODE:-$m} +TMPDIR=${TMPDIR:-/tmp} COSMO=${COSMO:-/opt/cosmo} COSMOS=${COSMOS:-/opt/cosmos} @@ -18,6 +19,19 @@ fi echo "Actually Portable Executable (APE) Installer" >&2 echo "Author: Justine Tunney " >&2 +# special installation process for apple silicon +if [ "$(uname -s)" = "Darwin" ] && [ "$(uname -m)" = "arm64" ]; then + echo "cc -O -o $TMPDIR/ape.$$ ape/ape-m1.c" >&2 + cc -O -o "$TMPDIR/ape.$$" ape/ape-m1.c || exit + if [ ! -d /usr/local/bin ]; then + echo "$SUDO mkdir -p /usr/local/bin" >&2 + $SUDO mkdir -p /usr/local/bin || exit + fi + echo "$SUDO mv -f $TMPDIR/ape.$$ /usr/local/bin/ape" >&2 + $SUDO mv -f "$TMPDIR/ape.$$" /usr/local/bin/ape || exit + exit +fi + ################################################################################ # INSTALL APE LOADER SYSTEMWIDE @@ -50,8 +64,8 @@ fi if [ "$(uname -s)" = "Darwin" ]; then if ! [ /usr/bin/ape -nt o//ape/ape.macho ]; then echo >&2 - echo "installing o//ape/ape.elf to /usr/bin/ape" >&2 - echo "$SUDO mv -f o//ape/ape.elf /usr/bin/ape" >&2 + echo "installing o//ape/ape.macho to /usr/bin/ape" >&2 + echo "$SUDO cp -f o//ape/ape.macho /usr/bin/ape" >&2 $SUDO cp -f o//ape/ape.macho /usr/bin/ape || exit echo "done" >&2 fi diff --git a/bin/ape-uninstall b/bin/ape-uninstall index 00df17ae3..cde7a7064 100755 --- a/bin/ape-uninstall +++ b/bin/ape-uninstall @@ -37,6 +37,9 @@ done if [ -f /usr/bin/ape ]; then $SUDO rm -f /usr/bin/ape fi +if [ -f /usr/local/bin/ape ]; then + $SUDO rm -f /usr/local/bin/ape +fi # legacy installations rm -f o/tmp/ape /tmp/ape "${TMPDIR:-/tmp}/ape" diff --git a/build/bootstrap/cocmd.com b/build/bootstrap/cocmd.com index 0697915b8..72109dc78 100755 Binary files a/build/bootstrap/cocmd.com and b/build/bootstrap/cocmd.com differ diff --git a/build/bootstrap/compile.com b/build/bootstrap/compile.com index d2466a674..bc4e8733a 100755 Binary files a/build/bootstrap/compile.com and b/build/bootstrap/compile.com differ diff --git a/build/bootstrap/make.com b/build/bootstrap/make.com index 8562372d7..cc107f4b8 100755 Binary files a/build/bootstrap/make.com and b/build/bootstrap/make.com differ diff --git a/libc/proc/execve-sysv.c b/libc/proc/execve-sysv.c index 2a6a64c85..d4d7fa254 100644 --- a/libc/proc/execve-sysv.c +++ b/libc/proc/execve-sysv.c @@ -127,7 +127,11 @@ int sys_execve(const char *prog, char *const argv[], char *const envp[]) { shargs[1] = (char *)"-"; shargs[2] = (char *)prog; memcpy(shargs + 3, argv, (argc + 1) * sizeof(char *)); - RetryExecve("/usr/bin/ape", shargs, envp); + if (IsXnuSilicon()) { + RetryExecve("/usr/local/bin/ape", shargs, envp); + } else { + RetryExecve("/usr/bin/ape", shargs, envp); + } char *buf = alloca(PATH_MAX); const char *name = "/.ape-" APE_VERSION_STR; InitExecve();