Step 1 - download
You will need the following:
Mozilla Build Environment (http://developer.mozilla.org/en/docs/Windows_Build_Prerequisites#MozillaBuild)
ZLib (http://zlib.net/) (sort of optional)
You will need to clone the first two Git repositories and download and extract the source zip files for the latter two (or three).
Step 2 - ZLib
You can build ZLib if you like. I built it, but got linking errors later on, instead I used the ZLib static library which builds as part of LibPNG (more later). If you want to do it, it's straightforward:
First you need to build the assembly files, run bld_ml32.bat found in %zlib%\contrib\masmx86. You will need to do this from the Visual Studio command prompt, not the usual windows one.
Open %zlib%\contrib\vstudio\vc10\zlibvc.sln in Visual Studio.
Change the configuration to 'Release' and build it. That should be it.
Step 3 - build LibPNG
Open %libpng%\projects\vstudio\zlib.props in a text editor and change the value of '
Open %libpng%\projects\vstudio\vstudio.sln in Visual Studio. Change the configuration to 'Release Library' and build it.
Step 4 - build Pixman
I couldn't figure out how to build Pixman or Cairo in Visual Studio, I got close with Eclipse, but couldn't quite figure it out using the Eclipse build system. In the end, I resorted to automating the following method using a batch file and a shell script (see below) and launching that when building from Eclipse. I expect I can do the same thing for Cairo, but haven't yet.
You might need to create pixman-version.h from pixman-version.h.in and configure.ac, I did this manually, but it might get done automatically.
Open %mozbuildenv%/start-msvc10.bat in a text editor and add the following lines:
set LIB="%LIB%;%zlib%\contrib\vstudio\vc10\x86\ZlibStatRelease;%libpng%\projects\vstudio\Release Library;%pixman%\pixman\release"
Note that '%LIB%' and '%INCLUDE%' are literal strings here.
Save the file and close it.
From the command line (Windows or Visual Studio), run %mozbuildenv%/start-msvc10.bat, cd to %pixman%\pixman. Run "make -f Makefile.win32 CFG=release OUT_PATH=%outpath%", where %out path% is the path where you want to output the compiled Pixman library.
That's all you need to do a manual build. To automate it from Eclipse, you will need to create the following batch and shell scripts and run the batch file as the build command in Eclipse. You will also need to set the MINGW_HOME variable in the Eclipse project properties.
del %pixman%\pixman\release /Q
make -f makefile.win32 CFG=release
Note that the %paths will need to be in Windows format in the first two cases, and *nix format in the latter two. You could do the same for Cairo.
Step 5 - Build Cairo
I needed to apply a couple of patches before I could build Cairo. If you get a more recent version these patches may already have been applied, or be unnecessary. The patches are at http://lists.cairographics.org/archives/cairo/2011-May/021927.html and http://lists.cairographics.org/archives/cairo/2011-June/021985.html. Apply these using Git.
Open %cairo%/build/Makefile.win32.common in a text editor and find the reference to 'zdll.lib' and change it to 'zlib.lib'. If you do not have the zlib, libpng, pixman, and cairo directories nested in the same directory, you will need to change the paths in this file accordingly. Save and close the file.
Copy and rename %libpng%\projects\vstudio\Release Library\libpng15.lib to %libpng%\libpng.lib. Copy %libpng%\projects\vstudio\Release Library\zlib.lib to %zlib%. Alternatively, you could change the paths in Makefile.win32.common, in fact this is a better way of doing it, if you plan to re-build libpng or zlib. Note that I am using the version zlib.lib built by libpng, I could not get Cairo to build using the version built by zlib - I got a bunch of errors linking libpng.
From the command line (Windows or Visual Studio), run %mozbuildenv%/start-msvc10.bat, cd to %cairo%. Run "make -f Makefile.win32 CFG=release OUT_PATH=%outpath%", where %out path% is the path where you want to output the compiled Pixman library. Note that you need to run the makefile in the cairo root, not the src directory.