PREFIX="/usr/local"
SHELL_NAME=""
for arg in "$@"; do
case $arg in
--prefix=*)
PREFIX=$(echo "$arg" | sed 's/--prefix=//')
;;
*)
echo "Unknown option: $arg"
echo "Usage: ./configure [--prefix=/path/to/install]"
exit 1
;;
esac
done
OS_NAME=$(uname -s)
ARCH_NAME=$(uname -m)
case $OS_NAME in
Linux) OS_NAME="linux" ;;
Darwin) OS_NAME="macos" ;;
*NT*)
OS_NAME="windows"
SHELL_NAME="powershell"
;;
*)
echo "Warning: Unsupported OS '$OS_NAME' detected. The build may fail."
;;
esac
if [ -z "$SHELL_NAME" ]; then
SHELL_NAME=$(basename "$SHELL")
fi
case $ARCH_NAME in
x86_64 | amd64) ARCH_NAME="amd64" ;;
aarch64 | arm64) ARCH_NAME="arm64" ;;
*)
echo "Warning: Unsupported architecture '$ARCH_NAME' detected. The build may fail."
;;
esac
cat << EOF > config.mk
# This file is generated by ./configure. Do not edit.
# Installation prefix
PREFIX = $PREFIX
# Directory for executables (derived from PREFIX)
BINDIR = \$(PREFIX)/bin
# Detected OS, Architecture, and Shell
OS_NAME = $OS_NAME
ARCH_NAME = $ARCH_NAME
SHELL_NAME = $SHELL_NAME
EOF
echo "Zoi configured successfully:"
echo " Installation prefix: $PREFIX"
echo " Binary directory: \$PREFIX/bin"
echo " Operating System: $OS_NAME"
echo " Architecture: $ARCH_NAME"
echo " Detected Shell: $SHELL_NAME"
echo ""
echo "Now run 'make' to build, 'make setup' to configure your shell,"
echo "and 'make install' to install."