Add build/install scripts

This commit is contained in:
2025-12-14 15:32:50 +01:00
parent 4c170cf105
commit d6ec34c922
4 changed files with 163 additions and 0 deletions

51
scripts/install.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PREFIX="${PREFIX:-/usr/local/imap}"
usage() {
cat <<USAGE
Usage: $0
Environment:
PREFIX (default: /usr/local/imap)
Installs:
- headers to: \$PREFIX/include
- static lib to: \$PREFIX/lib/libc-client.a
Note:
Requires a successful build (c-client/c-client.a exists).
USAGE
}
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
usage
exit 0
fi
cd "$ROOT"
SRC_LIB="${ROOT}/c-client/c-client.a"
SRC_HDR_DIR="${ROOT}/c-client"
if [[ ! -f "$SRC_LIB" ]]; then
echo "ERROR: $SRC_LIB not found. Build first (./scripts/build.sh)." >&2
exit 1
fi
echo "==> Installing to PREFIX=$PREFIX"
install -d -m 0755 "$PREFIX/include" "$PREFIX/lib"
echo "==> Installing headers"
# Only install the public headers (all .h in c-client/)
install -m 0644 "$SRC_HDR_DIR"/*.h "$PREFIX/include/"
echo "==> Installing libc-client.a"
install -m 0644 "$SRC_LIB" "$PREFIX/lib/libc-client.a"
echo "==> Done."
echo "Installed:"
echo " Headers: $PREFIX/include/*.h"
echo " Library: $PREFIX/lib/libc-client.a"