This COMPILE file describes how to compile the various LMPC binaries for
Unix, MS-DOS, Win32 (Cygnus and Mingw32) on any Unix system.

This is a high-level file. If you are Joe Windows User, don't even try to
read it. It would be a complete waste of time.



1. Unix binaries

LMPC comes with a Autoconf configure script. This makes it very easy to
compile it on various systems. Read the INSTALL text file for more information
on Autoconf configure scripts.



2. MS-DOS binaries

The MS-DOS binaries can be cross-compiled with a GO32 compatible gcc.

Get the Linux version from
	ftp://sunsite.unc.edu/devel/msdos/binutils-2.7.go32.tar.gz
	ftp://sunsite.unc.edu/devel/msdos/djdev200.go32.tar.gz
	ftp://sunsite.unc.edu/devel/msdos/gcc-2.7.2.go32.tar.gz
and install it. 

The MS-DOS binaries may be cross-compiled as usual:
	CC=/path/to/cross-gcc RANLIB=/path/to/cross-ranlib \
	./configure --host=i386-go32 && make
but the main Makefile provides the target go32 to simplify this task.
I use it for the MS-DOS Binary Package. You may have to adapt some paths
in Makefile.in (or better Makefile.am if you have Automake) and reconfigure.

The executables created with the cross-compiler need the special runtime
program bin/cwsdpmi.exe.



3. Win32 (Cygnus) binaries

The Win32 (Cygnus) binaries can be cross-compiled on any Unix system
using the Cygnus Developers' Kit (CDK) (known as GNU-WIN32/CYGWIN32 too).

Get the version b19 from
	ftp://ftp.cygnus.com/pub/gnu-win32/gnu-win32-b19/cdk-src.tar.gz
and unpack it from /usr/src/cdk. All files are now in the /usr/src/cdk/src
subdirectory. 

Get the update to version b19.1 from
	ftp://ftp.cygnus.com/pub/gnu-win32/gnu-win32-b19/b19.1-update/winsup-b19.1.tar.gz
and unpack it from /usr/src/cdk/src. All files from this update come into the
/usr/src/cdk/src/winsup subdirectory.

The full unpacked package CDK directory tree /usr/src/cdk should now
contain 114214 kb.

The run-time DLL alone can be downloaded from
	ftp://ftp.cygnus.com/pub/gnu-win32/gnu-win32-b19/b19.1-update/new-cygwinb19.dll.gz
Unpack it (with gunzip) and copy it as cygwinb19.dll in your Windows system
directory.

The compile process of CDK is a bit tricky. It may be better to compile the 
whole stuff in a different directory then the base source directory. This way 
the base source directory may be exported via NFS and everywhere someone
hacks on its own compilation in its own build directory.

make your CDK directory
        mkdir -p /usr/src/cdk

change in it
	cd /usr/src/cdk

unpack the source code
	gzip -dc /tmp/cdk-src.tar.gz | tar xf -

change in the source directory
	cd src

unpack the updated source code 
	gzip -dc /tmp/winsup-b19.1.tar.gz | tar xf -

let every-one read all files
	chmod -R a+r *

let exery-one execute all script files
	find . -type f -perm +a+x -exec chmod a+x {} \;

change back into the CDK directory
	cd ..

create a build directory
	mkdir build

change to it
	cd build

configure the whole package from there
	../src/configure --target=i386-pc-cygwin32 --prefix=/usr/cygnus

This should give you

a. a progress message (you may have an other machine type)
    Configuring for a i586-pc-linux-gnulibc1 host.

b. a warning (ignore it)
    *** This configuration is not supported in the following subdirectories:
         target-libgloss gdb tcl tk expect itcl tix
        (Any other directories should still work fine.)

c. a second progress message
    Created "Makefile" in /usr/src/cdk/build
    Links are now set up to build a cross-compiler for i386-pc-cygwin32
      from i586-pc-linux-gnulibc1.

This configuration process takes about 3 minutes.

Make the whole thing
	make
This process takes about 40 minutes. Now you have 95164kb in the build 
directory.

Now install everything as root.
	su -
	make install
This process takes about 7 minutes, Now you have 48431kb in the /usr/cygnus
directory.

Sidenote: gdb can be compiled in its subdirectory without any problems:

	cd build
	mkdir gdb
	cd gdb
	../../src/gdb/configure --target=i386-pc-cygwin32 --prefix=/usr/cygnus
	make
	su -
	make install


The Win32 (Cygnus) binaries may be cross-compiled as usual:
	CC=/path/to/cross-gcc RANLIB=/path/to/cross-ranlib \
	./configure --host=i386-pc-cygwin && make
but the main Makefile provides the target cygnus to simplify this task.
I use it for the Win32 (Cygnus) Binary Package. You may have to adapt 
some paths in Makefile.in (or better Makefile.am if you have Automake) and 
reconfigure.

The executables created with the cross-compiler need the special DLL
cygwinb19.dll in their c:\windows\system directory to run.
Copy cygwinb19.dll from /usr/cygnus/bin/ to this place.



4. Win32 (Mingw32) binaries

	cd build/i386-pc-cygwin32/winsup/mingw
	make


The Win32 (Mingw32) binaries can be cross-compiled on any Unix system
using the Minimalist GNU Win32 (Mingw32) package.

Get the Minimalist GNU-Win32 / Cross Platform Development Version 0.1
by Werner Koch <werner.koch@guug.de> from 
	http://www.d.shuttle.de/isil/mingw32-cpd-0.1.tar.gz

You need 
	ftp://prep.ai.mit.edu/pub/gnu/gcc-2.7.2.1.tar.gz
	ftp://prep.ai.mit.edu/pub/gnu/binutils-2.8.1.tar.gz
	ftp://prep.ai.mit.edu/pub/gnu/windows32api-0.1.2.tar.gz
as well. I know that these are old versions and they may even disappeared
from the FTP site but the the cross compile suite applies some patches 
especially for these versions. I didn't get it to work with current
versions at all.

Install Mingw32 as described in the README of mingw32-cpd-0.1.tar.gz.

The installed include files may contain the DOS carriage return. Go into the 
include directories $(prefix)/include and $(prefix)/i386--mingw32/include
and correct the problem with the usual

    find . -type f -name "*.h" -exec perl -pi -e "s/\015//g" {} \;


The Win32 (Mingw32) binaries may be cross-compiled as usual:
	CC=/path/to/cross-gcc RANLIB=/path/to/cross-ranlib \
	./configure --host=i386--mingw32 && make
but the main Makefile provides the target mingw32 to simplify this task.
I use it for the Win32 (Mingw32) Binary Package. You may have to adapt 
some paths in Makefile.in (or better in Makefile.am if you have Automake) and 
reconfigure.

Mingw32 is an integral part of the b19 Cygnus distribution but I couldn't
get it to work. Some hint anyone?



5. Why 2 different Win32 packages?

My programs are (from a programmers point of view) so simple, they don't
need the full power of the cygwinb19.dll. With Mingw32 I can compile a native
Win32 program, which doesn't need any extra files. 

There are some drawbacks coming with Mingw32, because standard C library
functions like strsep or memmem are missing in crtdll.dll but in general 
the GNU C library source code and a good configure file helps a lot in 
such cases. 

Users report a bit slower execution of lmpcm.exe in comparison to
lmpc32.exe.

Beta testers report a totally broken demcutm.exe. I have no idea and no
possibility to check it. Until nobody with a working Windows debugger finds 
the problem, it will remain. I even got a hate-mail because of this. 
The world is bad.



6. Program tests

My computers are both "Linux only". This makes it a bit difficult to check the
cross-compiled programs.

I test the Linux versions with a simple script, which does all possible
conversions and compares the first and last binary file. They must be
identical. I have a bunch of short demo files for this but I do need
always new ones.

I test the MS-DOS versions in the DOS emulator (DOSemu) of Linux shortly.

I test the Win32 (Cygnus and Mingw32) versions on a NT computer at work after
packaging and uploading. I know it's a bit late but the b19.1 binaries don't
work in the Windows emulator (Wine) of Linux.



7. Additional compilation hints

You need lex(1) and yacc(1) to compile the package. I compile it with flex
version 2.5.4 and GNU Bison version 1.25 because they were included in my 
S.u.S.E. Linux 5.1 (December '97). They should compile just fine with other
versions too. I don't provide precompiled C-files created by bison(1) and 
flex(1). 

LMPC is written for Automake 1.3 compliance. The cross-compile rules
were added very rude but anyway, it works as it is.

The configure script tries its best but it may detect that the compilers for 
both Windows systems aren't cross-compilers because I use in Linux a special 
module which provides a loading routine for Win32 binaries: it calls the 
Windows emulator.



8. Compiling speed

The whole process of configuring and compiling Linux, MS-DOS and Win32 
(Cygnus and Mingw32) binaries of LMPC, DEMcut and DBS, the creation of the 
documentation for the distribution packages (txt, doc, ps) and the
packaging itself takes on my P166 almost 7 minutes (make pack).



Uwe Girlich
