Compiling the Source Code:
--------------------------

Well, for the moment, zsnes source may be a little hard to compile. Here
is a quick guide (based on my own experience and on a doc written by zsKnight)
explaining how to compile zsnes. With these tools, I can build both dos and
win version, I hope it will also work for you

Note to see the bottom of this document if you are compiling releases for
distribution as opposed to CVS/SVN/WIP for personal use.

First, you need the following software:

DOS port:
- NASM v0.98.39 or higher : http://nasm.sourceforge.net
- DJGPP v2.03 or higher, (GCC also installed) : http://www.delorie.com/djgpp/
                   using the zip picker, the default choices are ok if you
                   check C and C++ in the programming languages.
- zlib v1.2.3 or higher : http://www.zlib.net
- libpng : http://www.libpng.org/
                Build the static versions of both of these libraries using
                DJGPP and do a 'make install' to put them where DJGPP
                can find them.  Afterwards you can go ahead and delete
                the source for them from your hard drive.
- PDCurses : http://pdcurses.sourceforge.net
                Only needed if you compile with the debugger.

Then to build the executable, go to the src directory and type:
make -f makefile.ms PLATFORM=dos

You may also want to compress zsnes.exe with upx (http://upx.sourceforge.net),
it will divide its size by 10.


DOS port cross compiling:
-You need to get the DJGPP cross compiler and everything else mentioned above.
-You might need to edit makefile.ms and change
     i386-pc-msdosdjgpp-gcc and i386-pc-msdosdjgpp-g++ to something else.

Then to build the executable, go to the src directory and type:
make -f makefile.ms PLATFORM=dos-cross

If you have any problems we will probably not help you as cross compiling
     is an advanced feature only for people who know what they are doing.



Windows port with MSVC:
- GNU Make : http://unxutils.sourceforge.net/
- NASM v0.98.39 : http://nasm.sf.net/
- MSVC++ 6.0 or higher : not freely available, you'll have to buy it
                   You need to run VCVARS32.BAT.  If you get an
                   out of environment space error, type 'command /e:32768'
                   (to create a new command.com entity with more
                   environment space)
                   I have been able to successfully build ZSNES using the
                   Intel C++ drop-in replacement for Microsoft's C++ compiler
                   that comes with MSVC++ 5 and above.  Since ZSNES contains
                   relatively small amounts of C, I don't see how Intel's
                   compiler could provide any useful optimizations (maybe
                   for winlink.cpp?).
- DX8.0 SDK or higher : you can get it at microsoft.com. It is quite big.
                   Also, edit makefile.ms to set the correct path to your
                   SDK. I also had some problems with vc++ using its own
                   (old) directx headers instead of the sdk headers. I replaced
                   these old headers (in the include directory of vc++ dir)
                   with the newer ones.
- zlib v1.2.3 or higher : http://www.zlib.net
		   you need the Win9x/WinNT static library (the dll version
		   doesn't seem to work with zsnes). Rename the static version
		   to zlib.lib and put it somewhere where vc++ will find it
		   (for example, the lib directory in vc++ dir).
- libpng : http://www.libpng.org/
            I'm not sure if the dynamically linked version of libpng
            will work with ZSNES.  To be safe I would recommend to just
            go ahead and build the static version.  Rename it to libpng.lib
            and put it somewhere where MSVC++ will find it (usually the
            lib subdirectory of your main MSVC++ directory).
- PDCurses : http://pdcurses.sourceforge.net

Then to build the executable, go to the src directory and type:
make -f makefile.ms PLATFORM=msvc

You may also want to compress zsnesw.exe with upx (http://upx.sourceforge.net),
it will divide its size by 10.



Windows port with MinGW:
- GNU Make (don't use included in mingw): http://unxutils.sourceforge.net/
- NASM v0.98.39 : http://nasm.sf.net/
- MinGW : http://www.mingw.org
- Latest Win32API : http://www.mingw.org
- DirectX 8+ for MinGW : Parts of it are included with Win32API, parts aren't.
                     Check http://www.talula.demon.co.uk/allegro/wip.html
                     and http://www.talula.demon.co.uk/allegro/wip.html
                     for the rest of DirectX for MinGW.
- zlib v1.2.3 or higher : http://www.zlib.net
- libpng : http://www.libpng.org/
- PDCurses : http://pdcurses.sourceforge.net
                Only needed if you compile with the debugger.

Then to build the executable, go to the src directory and type:
make -f makefile.ms PLATFORM=win32

You may also want to compress zsnesw.exe with upx (http://upx.sourceforge.net),
it will divide its size by 10.


Windows port cross compiling:
-You need to get the MinGW cross compiler and everything else mentioned above.
-You might need to edit makefile.ms and change
     i586-mingw32-gcc, i586-mingw32-g++, and i586-mingw32-windres
     to something else.

Then to build the executable, go to the src directory and type:
make -f makefile.ms PLATFORM=win32-cross

If you have any problems we will probably not help you as cross compiling
     is an advanced feature only for people who know what they are doing.



Linux/SDL/POSIX port:
I assume the standard development tools are installed (gcc, make, ...)
You'll also need :
- SDL (Simple DirectMedia Layer) : check www.libsdl.org to grab SDL 1.2.0 or
                                   later. If you are using rpm packages, don't
                                   forget the -devel package.
- NASM v0.98.39 : http://nasm.sf.net/
- zlib v1.2.3 or higher : http://www.zlib.net
                                   it is probably already installed on your
                                   system, maybe you are just missing the
                                   development headers. Check in the
                                   packages available with your distribution
                                   or go to the page above
- libpng : http://www.libpng.org/
                    You might also need libpng, ZSNES will compile without
                    PNG support but I have found doing so to make ZSNES
                    unstable for some weird reason.  If you don't have
                    libpng, either get it and install it or pass the
                    --without-png option to the 'configure' script.
- Curses/NCurses
             Check your distro. One of these is needed if you compile with
             the debugger enabled. You may also have to symlink ncurses.h
             to curses.h in your include directory.

Then to build the executable, go to the src directory and type:
sh ./autogen.sh && gmake && gmake install

Note: This only covers SVN/WIP builds, for releases see instructions below.

Note: autogen.sh requires automake and autoconf installed. Any parse errors
you recieve about configure.in are due to those not being installed.

Note: you require root to install zsnes to the the default (/usr/local/*)
directory

Also Note: libpng (optional) needs to be recent, or zsnes will not use it

You may also want to compress the zsnes executable with upx
(http://upx.sourceforge.net), it will divide its size by 10.


Compiling for official builds:
Windows - MSVC: make -f makefile.ms PLATFORM=msvc RELEASE=yes
Windows - MinGW: make -f makefile.ms PLATFORM=win32 RELEASE=yes
DOS: make -f makefile.ms PLATFORM=dos RELEASE=yes
SDL - Package Maintainers: ./configure --enable-release --disable-cpucheck force_arch=i586
SDL - Personal: ./configure --enable-release

Note this is important to remove certain debug messages, as well
as provide heavy optimization (which could take up to an hour
to compile). It also ensures the builds will work with CPUs
matching i586 or higher.
If compiling for personal use, on DOS and Windows-MinGW, add
CPU=your_cpu, where your_cpu matches a GCC -march option.
You can use the archopt utility in tools/ to tell you what is
best. For SDL, remove --disable-cpucheck force_arch=i586.

If you are providing an SDL package for a particular arch
greater than i586, replace force_arch=i586 with the proper
one.
