# shellcheck shell=bash # Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License. # See LICENSE.md for license information. # SPDX-License-Identifier: MIT # # Shared by the components that build a Windows 3.x driver for the win16 # port's Windows (kpjoy: KPJOY.DRV, the joystick driver; kpcomm: # KPCOMM.DRV, the communications driver) from a project of its own beside # this repository, with Open Watcom's 16-bit Windows target (component # openWatcom). The project's own makefile builds it into the installer's # build tree, so the project itself is never written to. The project's # LICENSE.md (MIT) goes beside the driver, so a copy taken from there to # ship with a program has its notice. # scripts/lib/win16Gate.sh puts the drivers in each run's Windows. Source # from a component. # # winDriverBuild DIR MAKEFILE FILE build FILE with DIR's MAKEFILE (its # OBJ and BIN set to the build tree) # into compDir, with DIR's LICENSE.md # winDriverPin DIR the project's sources' checksum: a # change there makes the component out # of date # winDriverSources DIR the files a driver is made from, # and its licence # The source files' names: C sources and headers, link and module # definition files, makefiles, the licence. WIN_DRIVER_LICENSE=LICENSE.md WIN_DRIVER_SOURCES=(-name '*.c' -o -name '*.h' -o -name '*.lnk' -o -name '*.def' -o -name 'Makefile' -o -name '*.mk' -o -name "$WIN_DRIVER_LICENSE") winDriverBuild() { local dir="$1" local makefile="$2" local file="$3" local build [ -f "$dir/$makefile" ] || die "no $makefile in $dir: the driver's project must be beside this repository (or named by its *_DIR variable)" [ -f "$dir/$WIN_DRIVER_LICENSE" ] || die "no $WIN_DRIVER_LICENSE in $dir: the driver ships with its licence" build="$(freshBuildDir "$compId")" make -C "$dir" -f "$makefile" WATCOM="$JOEY_OPT/openWatcom" OBJ="$build/obj" BIN="$build/bin" > "$build/make.log" 2>&1 || die "building $file failed; the log: $build/make.log" [ -s "$build/bin/$file" ] || die "$makefile in $dir made no $file; the log: $build/make.log" rm -rf "$compDir" mkdir -p "$compDir" cp "$build/bin/$file" "$compDir/$file" cp "$dir/$WIN_DRIVER_LICENSE" "$compDir/$WIN_DRIVER_LICENSE" dropBuildDir "$compId" } winDriverPin() { local file while IFS= read -r file; do printf '%s %s\n' "${file#"$1"/}" "$(sha256Of "$file")" done < <(winDriverSources "$1") | sha256sum | cut -d' ' -f1 } winDriverSources() { [ -d "$1" ] || return 0 find "$1" -maxdepth 1 -type f \( "${WIN_DRIVER_SOURCES[@]}" \) | sort }