Skip to content

Commit

Permalink
add DOS Watcom support
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Mar 21, 2024
1 parent f2a1bf7 commit 2b88547
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 1 deletion.
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,20 @@ jobs:
with:
name: binary-archive
path: build/package

dos:
timeout-minutes: 10
runs-on: ubuntu-latest

steps:
- uses: open-watcom/setup-watcom@v0
with:
version: "2.0"

- uses: actions/checkout@v2

- name: Configure
run: cmake -Bbuild --toolchain cmake/dos.cmake

- name: Build
run: cmake --build build
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ elseif(WIN32)
target_sources(pdcurses PRIVATE wincon/pdcclip.c wincon/pdcdisp.c wincon/pdcgetsc.c
wincon/pdckbd.c wincon/pdcscrn.c wincon/pdcsetsc.c wincon/pdcutil.c wincon/pdcwin.h
)
elseif(CMAKE_SYSTEM_NAME STREQUAL "DOS")
target_sources(pdcurses PRIVATE dos/pdcclip.c dos/pdcdisp.c dos/pdcgetsc.c
dos/pdckbd.c dos/pdcscrn.c dos/pdcsetsc.c dos/pdcutil.c)
else()
check_include_file("DECkeySym.h" HAVE_DECKEYSYM_H)
check_include_file("Sunkeysym.h" HAVE_SUNKEYSYM_H)
Expand Down
12 changes: 11 additions & 1 deletion cmake/compilers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@ $<$<BOOL:${HAVE_VSSCANF}>:HAVE_VSSCANF>
)

# --- compiler options
add_compile_options(-Wall)

if(CMAKE_C_COMPILER_ID STREQUAL OpenWatcom)
message(STATUS "OpenWatcom: $ENV{WATCOM}
Host: ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION}
Target: ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}
")
# https://wiki.archlinux.org/title/Open_Watcom
add_compile_options(pdcurses PRIVATE -bt=dos -bcl=dos)
else()
add_compile_options(-Wall)
endif()
28 changes: 28 additions & 0 deletions cmake/dos.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
set(CMAKE_SYSTEM_NAME DOS)
set(CMAKE_GENERATOR "Watcom WMake")

if(NOT DEFINED ENV{WATCOM})
if(WIN32)
set(scr ${CMAKE_CURRENT_LIST_DIR}/dos.ps1)
else()
set(scr ${CMAKE_CURRENT_LIST_DIR}/dos.sh)
endif()
message(FATAL_ERROR "WATCOM environment variable not set. Try running ${scr} first.")
endif()

file(TO_CMAKE_PATH "$ENV{WATCOM}" watcom_root)

set(CMAKE_SYSROOT ${watcom_root})

if(WIN32)
set(bin ${watcom_root}/binnt64 ${watcom_root}/binnt)
else()
set(bin ${watcom_root}/binl64 ${watcom_root}/binl)
endif()

find_program(CMAKE_C_COMPILER
NAMES wcl386
HINTS ${bin}
NO_DEFAULT_PATH
REQUIRED
)
15 changes: 15 additions & 0 deletions cmake/dos.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
$watcom = "$Env:SYSTEMDRIVE:\WATCOM"

if (!(Test-Path -Path $watcom)) {
Throw "OpenWatcom not found at $watcom"
}

$env:WATCOM = $watcom
$env:EDPATH = "$watcom\EDDAT"
$env:WHTMLHELP = "$watcom\BINNT\HELP"
$env:WIPFC = "$watcom\WIPFC"

$env:LIBPATH = "$watcom\lib386\"
$env:INCLUDE = "$watcom\H"

$env:Path += ";$watcom\BINNT64;$watcom\BINNT"
15 changes: 15 additions & 0 deletions cmake/dos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

watcom="/opt/watcom/"

if [ ! -d $watcom ]; then
echo "OpenWatcom not found at $watcom" >&2
exit 1
fi

export WATCOM=$watcom
export EDPATH="$watcom/eddat"
export WIPFC="$watcom/wipfc"

export INCLUDE="$watcom/h"
export PATH="$watcom/binl64:$watcom/binl:$PATH"
30 changes: 30 additions & 0 deletions cmake/x11.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ if(PKG_CONFIG_FOUND)

pkg_check_modules(_xt xt)
pkg_check_modules(_x11 x11)
pkg_check_modules(_xmu xmu)
pkg_check_modules(_xpm xpm)
pkg_check_modules(_xaw xaw7)

endif()

Expand All @@ -27,8 +30,35 @@ PATH_SUFFIXES X11
REQUIRED
)

# macOS may need this
find_path(_xmu_inc
NAMES StdSel.h
HINTS ${_xmu_INCLUDE_DIRS} ${X11_INCLUDE_DIR}
PATH_SUFFIXES X11/Xmu
REQUIRED
)

# macOS may need this
find_path(_xpm_inc
NAMES xpm.h
HINTS ${_xpm_INCLUDE_DIRS} ${X11_INCLUDE_DIR}
PATH_SUFFIXES X11
REQUIRED
)

# macOS may need this
find_path(_xaw_inc
NAMES Box.h
HINTS ${_xaw_INCLUDE_DIRS} ${X11_INCLUDE_DIR}
PATH_SUFFIXES X11/Xaw
REQUIRED
)

list(APPEND X11_INCLUDE_DIR
${_xt_inc} ${_xatom_inc}
${_xmu_inc} ${_xmu_inc}/..
${_xpm_inc}
${_xaw_inc} ${_xaw_inc}/..
)

message(STATUS "X11_INCLUDE_DIR: ${X11_INCLUDE_DIR}
Expand Down

0 comments on commit 2b88547

Please sign in to comment.