From 45472a5738dc9a2b696ffc4d2a53ac358694fd82 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Fri, 22 May 2026 11:45:18 +0200 Subject: [PATCH] build: add Open Watcom support for DOS utilities --- CMakeLists.txt | 2 + cmake/modules/FindOpenWatcom.cmake | 86 ++++++++++++++++++++++++++++++ dosutils | 2 +- smart | 2 +- 4 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 cmake/modules/FindOpenWatcom.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f9ff1f4..055c432 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,8 @@ option(ENABLE_DEBUG_DOSUTILS "Should we build with Mars Nwe Dosutils Debugging?" option(ENABLE_INTERNAL_RIP_SAP "Should we build Mars Nwe with Internal Router?" ON) option(ENABLE_SHADOW_PWD "Should we build Mars Nwe with Shadow Password Support?" ON) option(ENABLE_QUOTA_SUPPORT "Should we build Mars Nwe with Quota Support?" OFF) +option(MARS_NWE_INSTALL_DOSUTILS "Install prebuilt DOS client utilities" ON) +option(MARS_NWE_BUILD_DOSUTILS "Build DOS client utilities with Open Watcom" OFF) set(MARS_NWE_SMART_ADMIN_GROUP "root" CACHE STRING "Unix group allowed to log in to the SMArT/nwwebui admin interface") diff --git a/cmake/modules/FindOpenWatcom.cmake b/cmake/modules/FindOpenWatcom.cmake new file mode 100644 index 0000000..9718a1b --- /dev/null +++ b/cmake/modules/FindOpenWatcom.cmake @@ -0,0 +1,86 @@ +# FindOpenWatcom.cmake +# +# Locate an Open Watcom v2 toolchain usable for building the 16-bit DOS +# mars-nwe DOS utilities on a Linux host. +# +# Result variables: +# OpenWatcom_FOUND +# OPENWATCOM_WCL +# OPENWATCOM_WCC +# OPENWATCOM_WASM +# OPENWATCOM_WLINK +# OPENWATCOM_BIN_DIR +# OPENWATCOM_ROOT +# OPENWATCOM_ENV +# +# This module intentionally does not enable a CMake language/toolchain. The +# DOS utilities are built via custom commands. OPENWATCOM_ENV is provided so +# wcl can find its helper programs such as wcc, wlink and include files. + +set(_OPENWATCOM_HINTS) + +if(DEFINED ENV{WATCOM}) + list(APPEND _OPENWATCOM_HINTS "$ENV{WATCOM}") +endif() + +list(APPEND _OPENWATCOM_HINTS + /opt/watcom + /usr/local/watcom + /usr/local/open-watcom-v2 + /opt/open-watcom-v2 +) + +find_program(OPENWATCOM_WCL + NAMES wcl owcc + HINTS ${_OPENWATCOM_HINTS} + PATH_SUFFIXES binl binnt binw bin +) + +find_program(OPENWATCOM_WCC + NAMES wcc + HINTS ${_OPENWATCOM_HINTS} + PATH_SUFFIXES binl binnt binw bin +) + +find_program(OPENWATCOM_WASM + NAMES wasm + HINTS ${_OPENWATCOM_HINTS} + PATH_SUFFIXES binl binnt binw bin +) + +find_program(OPENWATCOM_WLINK + NAMES wlink + HINTS ${_OPENWATCOM_HINTS} + PATH_SUFFIXES binl binnt binw bin +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OpenWatcom + REQUIRED_VARS + OPENWATCOM_WCL + OPENWATCOM_WCC + OPENWATCOM_WASM + OPENWATCOM_WLINK +) + +if(OpenWatcom_FOUND) + get_filename_component(OPENWATCOM_BIN_DIR "${OPENWATCOM_WCL}" DIRECTORY) + get_filename_component(OPENWATCOM_ROOT "${OPENWATCOM_BIN_DIR}" DIRECTORY) + + # wcl starts helper tools such as wcc/wlink by name. Therefore finding the + # absolute wcl path is not enough; the Watcom bin directory must be in PATH + # at build time. WATCOM and INCLUDE are also expected by many installations. + set(OPENWATCOM_ENV + "WATCOM=${OPENWATCOM_ROOT}" + "INCLUDE=${OPENWATCOM_ROOT}/h:${OPENWATCOM_ROOT}/h/nt:${OPENWATCOM_ROOT}/h/os2" + "EDPATH=${OPENWATCOM_ROOT}/eddat" + "PATH=${OPENWATCOM_BIN_DIR}:$ENV{PATH}" + ) +endif() + +mark_as_advanced( + OPENWATCOM_WCL + OPENWATCOM_WCC + OPENWATCOM_WASM + OPENWATCOM_WLINK +) diff --git a/dosutils b/dosutils index 0e42d3a..c64a20a 160000 --- a/dosutils +++ b/dosutils @@ -1 +1 @@ -Subproject commit 0e42d3a85bee5594d4d004e4c1acf9fd2ec24200 +Subproject commit c64a20acacafe0c27344a1a577be526fb36b6931 diff --git a/smart b/smart index 46a3d9f..d967947 160000 --- a/smart +++ b/smart @@ -1 +1 @@ -Subproject commit 46a3d9f65394acda9f8c10719795eebb530e82c5 +Subproject commit d967947eceaa9b3c891e7099f776ded6efd0332e