uname -s under MSYS2 never reports Windows_NT, so build.sh picked bmake.mk and gmake.mk's platform branches silently fell through to the Linux path (.so + -ldl), breaking the link. Detect MINGW/MSYS/ UCRT/CLANG uname prefixes in build.sh and route to gmake.mk; export UNAME_S once so make doesn't call uname again. gmake.mk, test/gmake.mk, and module_template/gmake.mk now derive Windows-vs-Unix from uname instead of $(OS), with the cmd.exe/batch command path reserved for environments without a POSIX shell (MSYS2 keeps mkdir -p/rm -rf).
42 lines
789 B
Bash
Executable File
42 lines
789 B
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
|
|
|
|
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 [ "$HAS_INSTALL" = "1" ]; then
|
|
make -f "$MK_FILE" release
|
|
fi
|
|
|
|
if [ "$(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
|