diff --git a/scripts/build.sh b/scripts/build.sh index bda029a..1ec17ad 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -3,21 +3,25 @@ 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)}" +SSLTYPE="${SSLTYPE:-unix.nopwd}" # recommended for RFC 3501 compliance +TARGET="${TARGET:-lnp}" # what you used successfully +CLEAN="${CLEAN:-0}" # set to 1 for a clean build usage() { cat < 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 + + # Remove common UW-IMAP build byproducts/symlink trees that can break rebuilds + rm -f OSTYPE CFLAGS CCTYPE LDFLAGS OSCFLAGS ARCHIVE SPECIALS an 2>/dev/null || true + rm -rf c-client mtest ipopd imapd mailutil mlock dmail tmail rebuild 2>/dev/null || true 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}" +# Ensure tools/an exists and is executable (should be part of the repo) +if [[ ! -f tools/an ]]; then + echo "ERROR: tools/an not found. Repository checkout seems incomplete." >&2 + exit 1 +fi +chmod +x tools/an 2>/dev/null || true + +echo "==> Step 1/3: Prepare symlinks (make an)" +# This creates the symlink layout expected by the rest of the build (c-client/, mtest/, ...) +make an + +echo "==> Step 2/3: Build core (make ${TARGET} SSLTYPE=${SSLTYPE})" +# IMPORTANT: do NOT use -j here; UW-IMAP's legacy build is not reliably parallel-safe. +make "${TARGET}" "SSLTYPE=${SSLTYPE}" + +echo "==> Step 3/3: Build bundled tools (make bundled)" +# Bundled tools depend on generated headers like c-client/osdep.h. +#make bundled || true +make bundled echo "Build done." +echo "Artifacts:" +echo " c-client/c-client.a: $(test -f c-client/c-client.a && echo OK || echo MISSING)" +echo " c-client/osdep.h: $(test -f c-client/osdep.h && echo OK || echo MISSING)"