Fix build order (make an -> core build -> bundled tools)

This commit is contained in:
2025-12-14 16:35:34 +01:00
parent d6ec34c922
commit c30f6ceaea

View File

@@ -3,21 +3,25 @@ set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SSLTYPE="${SSLTYPE:-unix.nopwd}" # recommended SSLTYPE="${SSLTYPE:-unix.nopwd}" # recommended for RFC 3501 compliance
TARGET="${TARGET:-lnp}" # lnp is what you used successfully TARGET="${TARGET:-lnp}" # what you used successfully
JOBS="${JOBS:-$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)}" CLEAN="${CLEAN:-0}" # set to 1 for a clean build
usage() { usage() {
cat <<USAGE cat <<USAGE
Usage: $0 Usage: $0
Build UW-IMAP in a deterministic, legacy-compatible order.
Environment: Environment:
SSLTYPE (default: unix.nopwd) SSLTYPE (default: unix.nopwd)
TARGET (default: lnp) TARGET (default: lnp)
JOBS (default: detected CPU count) CLEAN (default: 0) set to 1 to remove build artifacts before building
Example: Examples:
SSLTYPE=unix.nopwd JOBS=8 $0 $0
CLEAN=1 $0
SSLTYPE=unix.nopwd TARGET=lnp CLEAN=1 $0
USAGE USAGE
} }
@@ -28,23 +32,40 @@ fi
cd "$ROOT" cd "$ROOT"
# Make sure patches are applied before building (but don't force it here).
if [[ -d patches ]]; then if [[ -d patches ]]; then
echo "Hint: run ./scripts/apply-patches.sh before building if needed." echo "Hint: run ./scripts/apply-patches.sh before building if needed."
fi fi
CLEAN="${CLEAN:-0}"
if [[ "$CLEAN" == "1" ]]; then if [[ "$CLEAN" == "1" ]]; then
echo "==> Cleaning previous build artifacts" echo "==> Cleaning previous build artifacts"
make clean || true 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 fi
echo "==> Building UW-IMAP: make ${TARGET} SSLTYPE=${SSLTYPE}" # Ensure tools/an exists and is executable (should be part of the repo)
# UW-IMAP makefiles are not always parallel-safe in all subdirs; use -j carefully. if [[ ! -f tools/an ]]; then
# We'll still allow -j, but you can set JOBS=1 if you see race issues. echo "ERROR: tools/an not found. Repository checkout seems incomplete." >&2
make -j"${JOBS}" "${TARGET}" "SSLTYPE=${SSLTYPE}" 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 "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)"