Bump to 1.0.4. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
61 lines
1.3 KiB
Bash
Executable File
61 lines
1.3 KiB
Bash
Executable File
#!/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
|
|
# build as the invoking user; only install/uninstall step runs privileged,
|
|
# so obj/ and bin/ never end up root-owned
|
|
BUILD_ARGS=""
|
|
PRIV_ARGS=""
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
install|uninstall) PRIV_ARGS="$PRIV_ARGS $arg" ;;
|
|
*) BUILD_ARGS="$BUILD_ARGS $arg" ;;
|
|
esac
|
|
done
|
|
|
|
if [ -n "$BUILD_ARGS" ]; then
|
|
make -f "$MK_FILE" $BUILD_ARGS || exit 1
|
|
fi
|
|
if [ "$HAS_INSTALL" = "1" ]; then
|
|
make -f "$MK_FILE" release || exit 1
|
|
fi
|
|
|
|
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" $PRIV_ARGS
|
|
else
|
|
make -f "$MK_FILE" "$@"
|
|
fi
|