joeylib2/installer/components/openWatcom.sh
2026-10-13 14:01:46 -05:00

59 lines
2.2 KiB
Bash

# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# Open Watcom v2, the 2026-10-01 build for Linux x86-64: the compiler the
# win16 port (make win16) builds Windows 3.x programs with. Its Win386
# target compiles 32-bit flat-model C and binds it to Watcom's Windows
# supervisor (WIN386.EXT), which makes it a Windows 3.x NE executable that
# calls the 16-bit Windows API through the supervisor's covers. Its 16-bit
# Windows target builds the Windows 3.x drivers the win16 port's Windows
# runs with (components kpjoy and kpcomm). The release is the
# self-extracting installer, which is a zip archive; only the Linux tools,
# the headers, the 32- and 16-bit libraries and the supervisor are unpacked.
compDescription="win16: Open Watcom v2 2026-10-01 (Win386 and 16-bit Windows targets)"
compGroups="toolchain:win16"
compRequires="host"
compHostDeps="unzip"
compUrl="https://github.com/open-watcom/open-watcom-v2/releases/download/2026-10-01-Build/open-watcom-2_0-c-linux-x64"
compSha256="a961f3e02ce27bcd88428345dc57483457a623b6e718b6cee52c48d24ab8065f"
compPin="$compSha256"
compInstall() {
local archive
local file
# Every dated build's file has the same name; the cached copy carries
# the date, and .zip says how to unpack it.
archive="$(fetchFile "$compUrl" "$compSha256" open-watcom-2_0-c-linux-x64-2026-10-01.zip)"
rm -rf "$compDir"
mkdir -p "$compDir"
unzip -oq "$archive" 'binl64/*' 'binw/win386.ext' 'h/*' 'lib386/*' 'lib286/*' -d "$compDir"
# The zip keeps no permissions: the ELF programs among binl64's files
# are made executable.
for file in "$compDir"/binl64/*; do
if [ "$(head -c 4 "$file" | od -An -tx1 | tr -d ' \n')" = "7f454c46" ]; then
chmod 755 "$file"
fi
done
}
compInstalled() {
[ -x "$compDir/binl64/owcc" ] && [ -x "$compDir/binl64/wbind" ] && [ -f "$compDir/binw/win386.ext" ] &&
[ -f "$compDir/lib286/win/windows.lib" ]
}
compVerify() {
# owcc finds its compilers and its specs.owc on the PATH.
export WATCOM="$compDir"
export PATH="$compDir/binl64:$PATH"
verifyCompiles owcc -bwin386 "-I$compDir/h"
}
compEnv() {
envVar WIN16_WATCOM "$compDir"
}