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 is very easy to 
compile it on various systems. Call the configure file as usual
and give the proper --prefix command line option.



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 from
	ftp://ftp.cygnus.com/pub/gnu-win32/gnu-win32-b18/cdk-src.tar.gz
and unpack it from /usr/src into /usr/src/cdk. cdk-src.tar.gz is 
27561754 bytes long and `du -c -s' in the CDK directory tree 
reports 163168 kb.

The compile process of CDK is a bit tricky. First you should go into the CDK
directory.

    cd /usr/src/cdk

Then you should correct 2 small errors in the package. 

Change in /usr/src/cdk/winsup/utils/configure line 658 from 

    for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do

to 

    for ac_dir in $srcdir $srcdir/.. $srcdir/../../..; do

Change in /usr/src/cdk/winsup/utils/Makefile.in line 40 from

    INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../include -I$(srcdir)/../../include

to

    INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../include -I$(srcdir)/../../../include 

Without these changes, the compilation process will stop with

    configure: error: can not find install-sh or install.sh in . ./.. ./../..
    configure: error: ./configure failed for utils
    make: *** [configure-target-winsup] Error 1

or

    ./cygwin.cc:29: getopt.h: No such file or directory
    make[2]: *** [cygwin] Error 1
    make[2]: Leaving directory /usr/src/cdk/i386-pc-cygwin32/winsup/utils'
    make[1]: *** [utils-all] Error 2
    make[1]: Leaving directory /usr/src/cdk/i386-pc-cygwin32/winsup'
    make: *** [all-target-winsup] Error 2

Now configure the whole package and define a destination prefix 
directory i.e.

    ./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-gnu host.

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

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

This configuration process takes about 3 minutes.
BTW. The gdb can be compiled in its subdirectory without any problems.

Now you can compile the cross-compiler with

    make

This compilation process takes about 40 minutes.
You should have now in your /usr/src/cdk directory about 216866 kb.

Then you can install all with

    make install

This installation process takes about 7 minutes and installs in
/usr/cygnus about 60165 kb.


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
cygwin.dll in their c:\windows\system directory to run.
Copy cygwin.dll from /usr/cygnus/bin/ to this place.

If I find some free space on my hard drive I'll try the current version (b19).



4. Win32 (Mingw32) binaries

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.



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 cygwin.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 as 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 thoroughly.

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

I test the Win32 (Cygnus) versions in the Windows emulator (Wine) of Linux 
shortly. This works with the old version b17.1 of cygwin.dll only.
I have no idea why.

I can't test the Win32 (Mingw32) versions because they don't run in Wine.



7. Additional compilation hints

You need lex and yacc 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). This is my first language parse project. Therefore I 
have no idea if it may compile with other versions too. I don't provide 
precompiled C-files. They tend to be very long and can recreated easily.

LMPC is written for Automake 1.2 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
