This article is also available from my software page at http://tkb.mpl.com/~tkb/software.html or directly as http://tkb.mpl.com/~tkb/software/misc/pm3-NT386GNU.patch The current NT386GNU bootstrap and source for Polytechnique Montreal Modula-3 (PM3) from http://www.elegosoft.com/pm3/ doesn't build on Microsoft Windows using the current version of Cygwin because the standard location of the library files and the syntax for specifiying drives in Cygwin has changed since pm3-1.1.15 was released. However, it is fairly simple to build a bootstrap that will work on Microsoft Windows. A patch for this follows. I've used this to build a NT386GNU bootstrap using the FreeBSD port of pm3-1.1.15, and it should work just as well using any other pm3-1.1.15 installation. There are four minor changes that need to be made: 1. There are some double quotes missing in the m3makefile for the bootstrap. 2. The old versions of cygwin used "//" to refer to Microsoft Windows drives, but the current versions do not. Luckily, the new versions understand the native Microsoft Windows ":" syntax. 3. The libraries used to live in /cygnus/cygwin-b20/H-i586/i586-cygwin32/lib and now live in /lib. 4. Skip building m3gdb: it won't build. This patch would probably work with the original pm3-1.1.15 distribution (which is slightly different from the one available from http://www.elegosoft.com/pm3/) with a little work. (I think I remember that the changes to the language/modula3/m3compiler/m3bootstrap/src/m3makefile were not necessary with the original distribution.) These directions and this patch assume you want to install PM3 at C:\usr\pm3. If you want to install it somewhere else, you'll need to manually change pm3/m3config/src/NT386GNU so that INSTALL_ROOT points before building the complete distribtuion on MS Windows. To build the bootstrap for MS Windows, follow these steps on a machine that has PM3 installed (say, a FreeBSD or Linux machine): 1. Install Cygwin. 2. Get the PM3 source distribtion from elegosoft at ftp://www.elegosoft.com/pub/pm3/pm3-src-1.1.15.tar.bz2 3. Extract pm3-src-1.1.15.tar.bz2 into a directory of your choosing: $ tar --use-compress=bzip2 -xf pm3-src-1.1.15.tar.bz2 This creates a directory called pm3 with lots of subdirectories. 4. cd into the pm3 directory: $ cd pm3 5. Copy this patch into the pm3 directory: $ cp /path/to/this/patch.file pm3-NT386GNU.patch 6. Patch the source: $ patch -p1 &1 | tee Log.m3build-bootstrap (The bootstrap, btw, contains generated assembly and C source files and supporting files to build a minimal version of the PM3 build system and compiler; it gets assembled and compiled and linked on the target system.) 9. Cd into the build directory. It's name is the M3 name for your platform; in this example I'll use FreeBSD4: $ cd FreeBSD4 10. Rename the bootstrap directory, so that when you extract the pm3 source distribtion and the new bootstrap from their tar files they'll end up in the correct place: $ mv pm3-NT386GNU pm3 11. Create the bootstrap tar file: $ tar -czvf pm3-NT386GNU-boot.tar.gz pm3 12. Copy the bootstrap file, the PM3 source distribtion, and the patch over to the MS Windows system. You'll need m3-nt386gnu.patch, pm3-src-1.1.15.tar.bz2, and pm3-src-1.1.15.tar.bz2. From now on everything will be done on the MS Windows machine in a Cygwin terminal window. 13. Ensure that the directories where you are going to be build PM3 are mounted in binary mode. (Look in the Cygwin documentation if you need to know more about this.) 14. Extract pm3-src-1.1.15.tar.bz2 into a directory of your choosing: $ tar --use-compress=bzip2 -xvf pm3-src-1.1.15.tar.bz2 This creates a directory called pm3 with lots of subdirectories. 15. Extract the new bootstrap file in the same directory: $ tar -xzf pm3-NT386GNU-boot.tar.gz 16. cd into the pm3 directory: $ cd pm3 17. Copy this patch into the pm3 directory: $ cp /path/to/this/patch.file pm3-NT386GNU.patch 18. Patch the source: $ patch -p1 &1 | tee Log.make This will take a while. It will build the system and install it in c:\usr\pm3. The binaries will be in c:\usr\pm3\bin. Have fun! diff -Naur pm3-orig/language/modula3/m3compiler/m3bootstrap/src/m3makefile pm3/language/modula3/m3compiler/m3bootstrap/src/m3makefile --- pm3-orig/language/modula3/m3compiler/m3bootstrap/src/m3makefile 2001-04-07 14:46:40.000000000 -0400 +++ pm3/language/modula3/m3compiler/m3bootstrap/src/m3makefile 2002-11-18 16:13:08.000000000 -0500 @@ -272,8 +272,8 @@ end if equal(target,"SOLgnu") or equal(target,"SOLsun") - AS=/usr/ccs/bin/as - AR=/usr/ccs/bin/ld + AS="/usr/ccs/bin/as" + AR="/usr/ccs/bin/ld" header = header & "ASFLAGS=-s -P" & CR end diff -Naur pm3-orig/language/modula3/m3compiler/m3templates/src/BldQuake.m3 pm3/language/modula3/m3compiler/m3templates/src/BldQuake.m3 --- pm3-orig/language/modula3/m3compiler/m3templates/src/BldQuake.m3 2000-05-31 13:50:48.000000000 -0400 +++ pm3/language/modula3/m3compiler/m3templates/src/BldQuake.m3 2002-11-19 14:08:46.000000000 -0500 @@ -2881,15 +2881,7 @@ len := Text.Length(string); car: CHAR; BEGIN - IF len >= 2 AND Text.GetChar(string,1) = ':' THEN - chars := NEW(REF ARRAY OF CHAR, len + 1); - chars[0] := '/'; chars[1] := '/'; - chars[2] := Text.GetChar(string,0); - INC(i,2); - INC(j,3); - ELSE - chars := NEW(REF ARRAY OF CHAR, len); - END; + chars := NEW(REF ARRAY OF CHAR, len); WHILE i < len DO car := Text.GetChar(string,i); IF car = '\\' THEN car := '/'; END; @@ -2919,16 +2911,7 @@ len := Text.Length(string); car: CHAR; BEGIN - IF len >= 3 AND Text.GetChar(string,0) = '/' AND - Text.GetChar(string,1) = '/' THEN - chars := NEW(REF ARRAY OF CHAR, len - 1); - chars[0] := Text.GetChar(string,2); - chars[1] := ':'; - INC(i,3); - INC(j,2); - ELSE - chars := NEW(REF ARRAY OF CHAR, len); - END; + chars := NEW(REF ARRAY OF CHAR, len); WHILE i < len DO car := Text.GetChar(string,i); IF car = '/' THEN car := '\\'; END; diff -Naur pm3-orig/m3config/src/NT386GNU pm3/m3config/src/NT386GNU --- pm3-orig/m3config/src/NT386GNU 2000-05-31 13:55:02.000000000 -0400 +++ pm3/m3config/src/NT386GNU 2002-11-20 14:55:44.000000000 -0500 @@ -15,7 +15,9 @@ %BPIC_FLAG = "" %option("static_lib","") -CYGNUS_LIB_DIR = "/cygnus/cygwin-b20/H-i586-cygwin32/i586-cygwin32/lib" +SKIP_M3GDB="T" + +CYGNUS_LIB_DIR = "/lib" INSTALL_ROOT = "c:\\usr\\pm3" -- T. Kurt Bond, tkb@tkb.mpl.com