-
Notifications
You must be signed in to change notification settings - Fork 116
Using OpenWatcom C with ELKS
ELKS is experimentally supporting using the OpenWatcom C toolchain for creating programs in small, medium, compact and large models. Currently, only compact model is tested.
In order to build programs using Watcom C, first either install OpenWatcom C v2 or clone the repo from https://github.com/open-watcom/open-watcom-v2.
The following are instructions to build OpenWatcom C on macOS (Linux not tested). Only two small changes are required, realpath doesn't exist on macOS and dosbox
is required for the build. Here's the diff:
diff --git a/setvars.sh b/setvars.sh
index 81a0614a68..c822246db9 100755
--- a/setvars.sh
+++ b/setvars.sh
@@ -16,7 +16,7 @@
# export "OWROOT=/home/ow/o w"
#
-export OWROOT=$(realpath "`pwd`")
+export OWROOT=$(pwd)
# Set OWTOOLS entry to identify your toolchain used by build process
# supported values are WATCOM GCC CLANG
@@ -71,7 +71,7 @@ export OWDISTRBUILD=0
# if DOSBOX emulator is used then OWDOSBOX variable must be set
# Uncoment and set OWDOSBOX variable bellow to point to DOSBOX emulator executable
-# export OWDOSBOX=dosbox
+export OWDOSBOX=/Users/greg/net/elks-gh/dosbox-x-sdl2
# Windows documentation build process requires Microsoft Help Compilers which can
# work only on Windows host therefore by default this build is disabled on non-Windows
Running ./build.sh rel
built the entire system, which then was copied into open-watcom-v2/rel/bino64.
After building or installing OpenWatcomm, the WATCOM and WATDIR environment variables need to be setup by sourcing a script like the following with the full path to the OpenWatcom binary directory (WATCOM) and top-level directory (WATDIR). This is available in ELKS libc/wcenv.sh and executed via cd libc; . ./wcenv.sh
. The WATDIR= line will need to be modified to the top directory of the OpenWatcom repository:
#!/usr/bin/env bash
# Set up Watcom build environment
export WATDIR=/Users/greg/net/open-watcom-v2
export WATCOM=$WATDIR/rel/bino64 # for macOS
#export WATCOM=$WATDIR/rel/binl # for Linux-32
#export WATCOM=$WATDIR/rel/binl64 # for Linux-64
add_path () {
if [[ ":$PATH:" != *":$1:"* ]]; then
export PATH="$1:$PATH"
fi
}
add_path "$WATCOM"
echo PATH set to $PATH
After that, the ELKS C library needs to be built using OpenWatcom:
cd $TOPDIR # ELKS top-level directory
cd libc
make -f watcom.mk # creates libc.lib
ELKS provides two scripts to more easily compile and link programs with OpenWatcom C for testing under ELKS. These are ewcc
and ewlink
- very simple scripts to compile a single .c file for each file in a project, and then link them into a final ELKS executable. The source for these scripts is in elks/tools/objtools/ewcc and ewlink.
For a tested example, the following will build ELKS basic
from scratch using OpenWatcom:
. ./wcenv.sh
cd $TOPDIR/libc
make -f watcom.mk clean
make -f watcom.mk (produces libc/libc.lib, required for linking)
cd $TOPDIR/elkscmd/basic
ewcc basic.c
ewcc host.c
ewcc host-stubs.c
ewlink basic.obj host.obj host-stubs.obj
cp basic $TOPDIR/elkscmd/rootfs_template/root
... then, in ELKS:
# ./basic