# Open Watcom bootstraps its own compiler and then builds every target with
# it, so the host toolchain flags sorcery exports are neither consumed nor
# meaningful here; clearing them keeps the build reproducible.
unset CFLAGS CXXFLAGS LDFLAGS &&

# OWROOT must be a real path: no symlinks, and no '=' anywhere in it.
export OWROOT="$(realpath "$SOURCE_DIRECTORY")" &&
cd "$OWROOT" &&

export OWTOOLS=GCC &&
export OWRELROOT="$OWROOT/rel" &&

# The documentation is generated by a DOS-only WGML binary that would need
# DOSBox to run, so it is disabled.
export OWDOCBUILD=0 &&
export OWNOWGML=1 &&

# Installers for the other host platforms are of no use to us.
export OWDISTRBUILD=0 &&

if [[ $OPENWATCOM_GUI == n ]]; then
  export OWGUINOBUILD=1 &&
  export OWNOBUILD="ide browser dlgprs"
fi &&

# Derives OWOBJDIR/OWBINDIR and puts the bootstrapped tools on the PATH.
. ./cmnvars.sh &&

# The builder handles its own scheduling; MAKE_NJOBS does not apply.
# First pass bootstraps wmake and builder, then builds the tree.
./build.sh &&

# Second pass populates $OWRELROOT with the shippable tree.
./build.sh rel
