@echo off
setlocal

rem Optional: call Watcom environment if not already set
if not defined WATCOM (
  if exist "C:\WATCOM\owsetenv.bat" call "C:\WATCOM\owsetenv.bat"
)

if not defined WATCOM (
  echo WATCOM environment not set. Please run owsetenv.bat first.
  exit /b 1
)

set SRC=imd_cpmtools_vfii.c
set OUT=imd_cpmtools_vfii.exe

rem Use "16" as the first arg for a 16-bit small-model build.
if /I "%1"=="16" (
  wcl386 -bt=dos -ms -s -wx -zq -ot -d2 -fp3 %SRC% -fe=%OUT%
) else (
  rem Default: 32-bit DOS/4GW so IMD files >64K work
  wcl386 -bt=dos4g -s -wx -zq -ot -d2 -fp3 %SRC% -fe=%OUT%
)
if errorlevel 1 (
  echo Build failed.
  exit /b 1
)

echo Build OK: %OUT%
endlocal
