#!/bin/sh UNAME_S=$(uname -s) export UNAME_S OS=$(echo "$UNAME_S" | tr '[:upper:]' '[:lower:]') case "$OS" in linux|mingw*|msys*|ucrt*|clang*) MK_FILE="gmake.mk" ;; *) MK_FILE="bmake.mk" ;; esac case "$OS" in mingw*|msys*|ucrt*|clang*) IS_WIN=1 ;; *) IS_WIN=0 ;; esac HAS_INSTALL=0 HAS_UNINSTALL=0 for arg in "$@"; do case "$arg" in install) HAS_INSTALL=1 ;; uninstall) HAS_UNINSTALL=1 ;; esac done if [ "$HAS_INSTALL" = "1" ] || [ "$HAS_UNINSTALL" = "1" ]; then if [ "$IS_WIN" = "1" ] || [ "$(id -u)" = "0" ]; then PRIV="" elif command -v doas > /dev/null 2>&1; then PRIV="doas" elif command -v sudo > /dev/null 2>&1; then PRIV="sudo" else echo "error: install requires root. neither doas nor sudo found." >&2 exit 1 fi $PRIV make -f "$MK_FILE" "$@" else make -f "$MK_FILE" "$@" fi