Add build/install scripts
This commit is contained in:
16
scripts/all.sh
Executable file
16
scripts/all.sh
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Convenience wrapper:
|
||||||
|
# apply patches -> build -> install
|
||||||
|
#
|
||||||
|
# Env:
|
||||||
|
# SSLTYPE, TARGET, JOBS (see build.sh)
|
||||||
|
# PREFIX (see install.sh)
|
||||||
|
|
||||||
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
cd "$ROOT"
|
||||||
|
|
||||||
|
./scripts/apply-patches.sh
|
||||||
|
./scripts/build.sh
|
||||||
|
./scripts/install.sh
|
||||||
46
scripts/apply-patches.sh
Executable file
46
scripts/apply-patches.sh
Executable file
@@ -0,0 +1,46 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
PATCHDIR="${ROOT}/patches"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<USAGE
|
||||||
|
Usage: $0
|
||||||
|
Applies patches/*.patch to the working tree (idempotent).
|
||||||
|
USAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$ROOT"
|
||||||
|
|
||||||
|
if [[ ! -d "$PATCHDIR" ]]; then
|
||||||
|
echo "ERROR: patches/ directory not found at: $PATCHDIR" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Apply patches only if they are not already applied.
|
||||||
|
# We use --dry-run to test applicability; if it fails, we assume it's already applied.
|
||||||
|
shopt -s nullglob
|
||||||
|
patches=( "$PATCHDIR"/000[1-4]-*.patch )
|
||||||
|
#patches=( "$PATCHDIR"/*.patch )
|
||||||
|
if (( ${#patches[@]} == 0 )); then
|
||||||
|
echo "ERROR: no patches found in $PATCHDIR" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for p in "${patches[@]}"; do
|
||||||
|
echo "==> Checking $p"
|
||||||
|
if patch --dry-run -p1 < "$p" >/dev/null 2>&1; then
|
||||||
|
echo "==> Applying $(basename "$p")"
|
||||||
|
patch -p1 < "$p"
|
||||||
|
else
|
||||||
|
echo "==> Skipping $(basename "$p") (already applied or does not apply cleanly)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Done."
|
||||||
50
scripts/build.sh
Executable file
50
scripts/build.sh
Executable file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
|
||||||
|
SSLTYPE="${SSLTYPE:-unix.nopwd}" # recommended
|
||||||
|
TARGET="${TARGET:-lnp}" # lnp is what you used successfully
|
||||||
|
JOBS="${JOBS:-$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)}"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<USAGE
|
||||||
|
Usage: $0
|
||||||
|
|
||||||
|
Environment:
|
||||||
|
SSLTYPE (default: unix.nopwd)
|
||||||
|
TARGET (default: lnp)
|
||||||
|
JOBS (default: detected CPU count)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
SSLTYPE=unix.nopwd JOBS=8 $0
|
||||||
|
USAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd "$ROOT"
|
||||||
|
|
||||||
|
# Make sure patches are applied before building (but don't force it here).
|
||||||
|
if [[ -d patches ]]; then
|
||||||
|
echo "Hint: run ./scripts/apply-patches.sh before building if needed."
|
||||||
|
fi
|
||||||
|
|
||||||
|
CLEAN="${CLEAN:-0}"
|
||||||
|
|
||||||
|
if [[ "$CLEAN" == "1" ]]; then
|
||||||
|
echo "==> Cleaning previous build artifacts"
|
||||||
|
make clean || true
|
||||||
|
rm -f OSTYPE CFLAGS CCTYPE LDFLAGS OSCFLAGS ARCHIVE SPECIALS
|
||||||
|
rm -rf c-client mtest ipopd imapd mailutil mlock dmail tmail rebuild tools/an
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "==> Building UW-IMAP: make ${TARGET} SSLTYPE=${SSLTYPE}"
|
||||||
|
# UW-IMAP makefiles are not always parallel-safe in all subdirs; use -j carefully.
|
||||||
|
# We'll still allow -j, but you can set JOBS=1 if you see race issues.
|
||||||
|
make -j"${JOBS}" "${TARGET}" "SSLTYPE=${SSLTYPE}"
|
||||||
|
|
||||||
|
echo "Build done."
|
||||||
51
scripts/install.sh
Executable file
51
scripts/install.sh
Executable 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"
|
||||||
Reference in New Issue
Block a user