2023-12-16 16:47:38 +00:00
|
|
|
# Cosmopolitan zsh make helper.
|
|
|
|
# Setup (in ~/.zshrc, for instance):
|
2023-12-19 02:25:50 +00:00
|
|
|
# fpath+=($COSMO/tool/zsh)
|
|
|
|
# autoload -Uz mmake
|
2023-12-16 16:47:38 +00:00
|
|
|
# e.g.:
|
2023-12-19 02:25:50 +00:00
|
|
|
# mmake tiny ape/ape.elf
|
2023-12-16 16:47:38 +00:00
|
|
|
local mode
|
|
|
|
case $1 in
|
2023-12-19 02:25:50 +00:00
|
|
|
aarch64|x86_64|aarch64-(zero|tiny)|x86_64-tiny) ;&
|
|
|
|
zero|fastbuild|opt|optlinux|rel|asan|dbg|sysv) ;&
|
|
|
|
tiny(|linux(|bsd)|sysv|nowin)|nox87|llvm|ansi) ##
|
|
|
|
mode=$1; shift ;;
|
2023-12-23 16:09:50 +00:00
|
|
|
(m|MODE)=*) mode=${1#*=}; shift ;;
|
2023-12-19 02:25:50 +00:00
|
|
|
*) mode=${MODE:-${m}} ;;
|
2023-12-16 16:47:38 +00:00
|
|
|
esac
|
|
|
|
[[ -z $mode ]] && {
|
|
|
|
local arch=$(uname -m)
|
|
|
|
case $arch in
|
2023-12-19 02:25:50 +00:00
|
|
|
arm64|aarch64) mode=aarch64 ;;
|
2023-12-16 16:47:38 +00:00
|
|
|
esac
|
|
|
|
}
|
2023-12-17 00:22:17 +00:00
|
|
|
local -a targs
|
2023-12-16 16:47:38 +00:00
|
|
|
local -a flags
|
2023-12-17 20:09:41 +00:00
|
|
|
local j
|
2023-12-16 16:47:38 +00:00
|
|
|
while (( $# > 0 )); do
|
|
|
|
case $1 in
|
2023-12-19 02:25:50 +00:00
|
|
|
all|o|bins|check|test|depend|tags|aarch64) ;&
|
|
|
|
clean|toolchain|clean_toolchain|o/$mode/*) ##
|
|
|
|
targs+=($1); shift ;;
|
|
|
|
-j*) j=$1; shift ;;
|
|
|
|
-*|*=*) flags+=($1); shift ;;
|
|
|
|
o/(|aarch64)/*) targs+=(o/$mode/${1#*/*/}); shift ;;
|
|
|
|
o/*) targs+=(o/$mode/${1#*/}); shift ;;
|
|
|
|
*) targs+=(o/$mode/$1); shift ;;
|
2023-12-16 16:47:38 +00:00
|
|
|
esac
|
|
|
|
done
|
2023-12-17 20:09:41 +00:00
|
|
|
[[ -z $j ]] && {
|
2023-12-19 02:25:50 +00:00
|
|
|
whence nproc >/dev/null || autoload -Uz nproc
|
2023-12-17 20:09:41 +00:00
|
|
|
j=-j$(nproc)
|
|
|
|
}
|
2024-01-07 00:14:13 +00:00
|
|
|
local make=${MAKE:-${COSMOCC:-/opt/cosmocc/current}/bin/make}
|
2024-03-03 00:57:56 +00:00
|
|
|
[[ -x $make ]] || make=${COSMO:-$PWD}/build/bootstrap/make
|
2023-12-17 00:22:17 +00:00
|
|
|
( set -x
|
2023-12-17 20:31:06 +00:00
|
|
|
exec $make $j $flags MODE=$mode $targs )
|
2024-01-08 05:18:18 +00:00
|
|
|
# vim:ft=zsh
|