Fixing bwBASIC on FreeDOS - Dr Owain Kenway

Wednesday, Jul 05

Bywater BASIC is very old fashioned, Open Source BASIC interpreter. If you have Ubuntu to hand, you can install it straight from apt.

BwBASIC running on Ubuntu

FreeDOS also has a package for it on the installer, but unfortunately it complains when you try to run it:

C:\DEVEL\BWBASIC>bwbasic
This program must be run under Win32

C:\DEVEL\BWBASIC>

Well that’s a problem. It looks like at some stage, FreeDOS had an extension which let it run Win32 console programs, but that seems absent in my install/on the installer image.

It’s quite possible that bwBASIC has been rebuilt in the online repository, but my EeePC FreeDOS machine is not connected to any kind of network. Luckily, bwBASIC is Open Source, and FreeDOS include the sources with the package. So let’s rebuild it with the OpenWatcom C compiler which is bundled on the image.

First, we need to get our hands on the source. To install a package with sources, you need to do fdnpkg remove bwbasic to uninstall the package and then fdnpkg install-wsrc instead of fdnpkg install. It then places the sources in C:\FDOS\SOURCES\<pkg>\SOURCES.ZIP.

C:\PACKAGES\DEVEL>fdnpkg install-wsrc bwbasic.zip
 source\bwbasic\sources.zip -> C:\FDOS\source\bwbasic\
 devel\bwbasic\example.bas -> C:\devel\bwbasic\
 devel\bwbasic\copying -> C:\devel\bwbasic\
 devel\bwbasic\bwbasic.exe -> C:\devel\bwbasic\
 devel\bwbasic\bwbasic.doc -> C:\devel\bwbasic\
 appinfo\bwbasic.lsm -> C:\FDOS\appinfo\
Package bwbasic installed: 6 files extracted, 0 errors.

C:\PACKAGES\DEVEL>

Well that’s neat. Copy C:\FDOS\source\bwbasic\sources.zip somewhere and issue fdnpkg remove bwbasic to uninstall the package.

You can then unpack the zip file with unzip as usual and take a peek inside. You’ll see that there’s a bunch of files called makefile.*. The one we want is the one for the OpenWatcom C compiler, makefile.wcl, so copy that to makefile.

Unfortunately, for “reasons” there are some issues with this makefile, namely that at the link stage it passes far to many arguments to the linker, causing it to fail. Luckily, I discovered a shorter way of linking the binary earlier when I was trying bwBASIC’s compile.bat to build the binary (which also works as long as you edit both it and stdcomp.bat appropriately.)

So we need to replace that line, line 55 (here I’ve commented it out with a #) so that instead of $(LINK) $(LFLAGS) FILE $(OFILES: =,) NAME $@ it reads $(CC) *.obj -we=$(PROj).exe. Note that the space at the start of the line is a TAB:

$(PROJ).exe:	$(OFILES)
#	$(LINK) $(LFLAGS) FILE $(OFILES: =,) NAME $@
	$(CC) *.obj -we=$(PROJ).exe

You can then issue wmake to run the OpenWatcom version of make, and it will build bwbasic.exe in your current working directory.

You can run it and bravo, it works!

C:\HOME\SOURCE\BWBASIC>bwbasic
DOS/4GW Protected Mode Run-time  Version 1.97
Copyright (c) Rational Systems, Inc. 1990-1994
Bywater BASIC Interpreter/Shell, version 2.60
Copyright (c) 1993, Ted A. Campbell
Copyright (c) 1995-1997, Jon B. Volkoff

bwBASIC: 

(You can exit with quit).

At this point you can simply put bwbasic.exe somewhere in your %PATH% and all will be well.

If you want to package it up, you need to fix some issues with the dist target, namely that $(ZFILES) contains two patch files which don’t exist (line 51), and that the dist target tries to create a .zip file with a long filename. These should be trivial to resolve, at which point you can run wmake dist to create a zip file with some documentation as well as bwbasic.exe.