Read more articles
Compose a new article

Building Mini vMac for Windows 10 using the Windows Subsystem for Linux

Category: Emulators , Linux , Windows
Composed by: spyffe
On: 2020-12-24 02:16:14
Updated by: spyffe
On: 2021-01-24 15:08:19

Mini vMac's site includes extensive documentation on how to build the emulator (https://www.gryphel.com/c/minivmac/build.html).  However, I found that these instructions didn't cover my use case, which was a Windows 10 machine running Ubuntu in the Windows Subsystem for Linux.

My build unfortunately ended up being a bit of a hack, because the Makefile generation did not quite get the command lines for the C compiler and tools right, but I will document my steps here and assume that anyone interested enough will modify them as needed for their configuration.

Prerequisites

  • Windows 10.  This guide may work with Ubuntu Linux too, but I'm generating a Windows binary so at some point you'll need a Windows box to run it on.
  • Ubuntu in the Windows Subsystem for Linux.  Microsoft documents how to install this (https://docs.microsoft.com/en-us/windows/wsl/install-win10).  I will assume access to the Ubuntu command line.  You'll also need root access through sudo to install packages.

Installing necessary packages

Before you begin building, you'll need a few packages.  Here's what I installed under Ubuntu.

  • Host-side C compiler.  I installed clang (sudo apt install clang).  This is necessary to build the configurator tool.
  • MingW cross compiler.  I installed for 64-bit Windows (sudo apt install mingw-w64).
  • Make to drive the final build (sudo apt install make)
  • curl to download the source package (sudo apt install curl)
  • Some text editor.  nano is very beginner-friendly (sudo apt install nano)

Preparing the source

You just need to download and uncompress the sources.  All following commands will be run inside the source folder.

curl -O https://www.gryphel.com/d/minivmac/minivmac-36.04/minivmac-36.04.src.tgz

tar xzf minivmac-36.04.src.tgz

cd minivmac

Configuring

This goes pretty similarly to what is described on Mini vMac's site. You will need to customize the configuration slightly, though.

echo "#define cur_ide gbk_ide_mgw" >> setup/CONFIGUR.i

Next, use your host clang to build the configurator tool:

cc -o setup_t setup/tool.c 

At this point, you can use that tool to generate a configuration script.  Here's what I used, since I wanted a Mac SE FDHD.

./setup_t -t wx64 -m SEFDHD > setup.sh

This went fine and generated a setup.sh which you should now run:

sh setup.sh

Now you should have a Makefile.  Here's where the hacks begin.

Hacks

The generated Makefile had several problems which needed to be fixed with a text editor.

nano Makefile

should get you editing the generated file.  I needed to make several fixes.

First, I changed the following things in the file:

  • replaced every place where gcc.exe appears in the file to $(CC)
  • changed a reference to windres.exe to $(WINDRES)
  • changed a reference to strip.exe to $(STRIP)

Then, I added three lines to the top of the file, right after the # line:

CC=x86_64-w64-mingw32-gcc

STRIP=x86_64-w64-mingw32-strip 

WINDRES=x86_64-w64-mingw32-windres 

One more hack is required, but it's not in Makefile.  Save and exit and then edit cfg/main.rc:

nano cfg/main.rc

Then change the text "ICONAPPW.ico" to "src/ICONAPPW.ico", adding src/ on the front.  That allows the tool that compiles the application's resources find the file containing the app's icon.  At the end, the first line of that file should read

256                     ICON    DISCARDABLE     "src/ICONAPPW.ico"

You can now save and exit.  Make sure to return to the minivmac directory 

Build

At this point, simply typing

make

in the minivmac directory should trigger a successful build.  The end result will be a file minivmac.exe.  At this point you can copy it somewhere useful:

cp minivmac.exe /mnt/c/Users/...

You can use Tab completion to figure out exactly where the file should land.  That executable can now be run just like a normal Mini vMac executable