This text describes the steps needed to build GnuPG for Win32 using MinGW in a native Win32 environment, without cross-compiling from a Linux system. These instructions refer to GnuPG 1.4.9 [I know, some images show 1.4.0, or even 1.2.6, but I am too lazy to recreate them every time... ;-)], but maybe they can also be applied, with some modification, to all the other 1.x versions since 1.2.0. Of course, I can't say anything about the future versions since (and including) 1.5.0...
Of course, this is just the description of the procedure I followed to build GnuPG for Win32. Probably it can be improved in some places. It is not sure that this procedure will work on your machines like it worked on mine and that it will not create you any problem. All that I can say is in the title of this page: following this procedure, "on my PC it worked, on yours I don't know". If you find errors of any kind in this text, please feel free to point them out to me.
Now, if you are not completely sure of what you are doing and/or you have doubts of any kind about the correctness of the obtained result, my suggestion is to avoid the "home-made" builds and to use the official binaries found on GnuPG web site.
If, on the contrary, you arrived up to this point in the text and you still want to try, then take a long breath, count up to 10, repeat loudly the English alphabet from "z" to "a" a couple of times, think to it again and, if you are still sure, then... well... in the following there are all the instructions you need!
Before starting, the author of this page wants to thank TJL73 who tested on his machine the correctness and completeness of the following procedure. The subtitle then can be read as "on our PCs it worked, on yours I don't know"... ;-)
The author wants to thank as well Joe Vender and Maxine Brandt, for their help in solving the compatibility problems between GnuPG and the external libraries for Win32, mainly gettext in the "complete" compilation and Bzip2, Tom Pegios, for his suggestions about a simpler way to remove debugging symbols, and Michel Nallino aka WinTerMiNator who, beside taking care of the French version of the page, gave also many suggestions to make its contents much more clear and complete even in the other languages... ;-)
These are the instructions. Good luck!
1.1) Create the folder C:\MinGW
1.2) Go to the website http://sourceforge.net/project/showfiles.php?group_id=2435
and download the following packages:
a) gcc-core-3.4.5-20060117-1.tar.gz
b) binutils-2.18.50-20080109.tar.gz
c) mingw-runtime-3.14.tar.gz
d) w32api-3.11.tar.gz
e) mingw-utils-0.3.tar.gz
The numbers in the file names are the package versions, and then they may be
different when you will read these notes. In principle, it is better to
download the most recent version of each package. Of course, you can
download also other packages, but these are enough to build GnuPG.
1.3) Unpack the packages inside the MinGW folder created at step 1, starting from the earliest to the newest (the date is on the website along the file names). Pay attention to unpack the files with all the directory structure. If you succeed, at the end you will have many folders inside MinGW: "bin", "include", "lib", etc. If during this step you are asked to overwrite an already existing file, answer "yes". If you unpack the files from the earliest to the newest, in this way you are sure to have always the latest version of each file.
2.1) Now, you can install MSYS. Go again at the website http://sourceforge.net/project/showfiles.php?group_id=2435 and download MSYS-1.0.10.exe (or the version that will be available when you will be reading). It is a standard self-installing file. You will have to answer "next" a couple of times and the installation will be completed in a few moments:

2.2) At the end of the installation, MSYS will start a procedure to auto-configure itself on the ground of the MinGW packets installed in step 1:

You will have to ask "y" to start this procedure, to say (with another "y") to have already installed MinGW

and to insert the folder where it is.

If you have followed exactly the step 1, you have to insert "c:/mingw", without the quotes. Using lower letters and "/" instead of "\" is absolutely mandatory.

The MSYS post-installation procedure will end with a window similar to the following one:
Do not be afraid for the message about the missing "make". It is not at all an error. The original MinGW "make" has some problems, and then MSYS contains an updated version. During the post-installation phase, MSYS checks for an existing MinGW "make" and renames it. In our case, "make" is not in the MinGW packages downloaded and installed in step 1, and then it has not been installed. Then, MSYS doesn't find it during the post-installation phase and says that everything is already OK and that you should keep it this way. Then, you can push a key to close the window.
2.3) Now you can run MSYS with the start menu icon or with the desktop one.
2.4) At MSYS prompt, write "gcc -v" and press enter. If you see something similar to this figure:

then congratulations: GCC is working!
3.1) Now, to build GnuPG, you may need some additional
libraries. Go the the website
http://sourceforge.net/project/showfiles.php?group_id=23617,
download the following packages:
a) bzip2-1.0.5-bin.zip
b) bzip2-1.0.5-lib.zip
c) libiconv-1.9.2-1-bin.zip
d) libiconv-1.9.2-1-dep.zip
e) zlib-1.2.3-bin.zip
f) zlib-1.2.3-lib.zip
and unpack them in the MinGW folder, with all the directory structure, with
the same procedure followed in step 1 (from the oldest to the newest).
Like before, the version numbers may be different.
None of these libraries is really necessary for basic GnuPG functions.
Packages "a" and "b" are required to add the support for compression algorithm
Bzip2. Packages "c" and "d" are required for multi-language support.
Packages "e" and "f" would be required to support the compression algorithm
zlib but, if they are not present in the system, GnuPG compilation script
will use a custom zlib version included in the GnuPG sources. Such a custom
version will be always linked statically to the GnuPG executable file,
regardless of what specified in LDFLAGS (see step 5.1b below).
3.2) If you have decided to use libiconv, you must now start MSYS and run the following command:
cp /mingw/bin/libiconv2.dll /mingw/bin/iconv.dll
3.3) Download also the file coreutils-5.2.1-1-bin.zip (or the version that will be available when you will be reading, but keep in mind that, on my machine, version 5.3.0 crashes very often) and unpack it in a temporary folder (NOT in MinGW). Many subfolders will be unpacked, and one of them is named "bin". Copy the file dd.exe from this "bin" subfolder to "C:\MinGW\bin" and then delete the temporary folder in which you have unpacked the zip file. DO NOT copy other files but only dd.exe, all other commands are already present in MSYS and having another copy in MinGW can only be a source of troubles.
3.4) Now, optionally, if you want to enable the
libcurl support enabled, you can connect to the website http://curl.haxx.se/download.html
and download, under "Win32 - Generic", the last version for your OS
(choosing between 2000/XP-specific or plain)
labelled "libcurl" (not "binary")
with no SSL support (version 7.17.1, now when I am writing). You will have
now to follow this procedure:
a) Unpack this file in a temporary folder
(NOT in MinGW). Many subfolders will be created.
b) Copy the content of the "bin" subfolder into
C:\MinGW\bin.
c) Copy the content of the "include" subfolder into
C:\MinGW\include.
d) Copy the content of the "lib" subfolder
into C:\MinGW\lib, all but the .dll files which you must copy into
C:\MinGW\bin if they are present.
e) Open, with your favorite text editor, the file
"curl-config" in C:\Mingw\bin, change in line 28 "/usr/local" into
"/mingw" and remove "-L/home/dast/src/win32" from lines 198, 200 and 205.
f) Open, with your favorite text editor, the file
"libcurl.la" in C:\Mingw\lib, remove "-L/home/dast/src/win32" from line 17
and change in line 35 "/usr/local/lib" into "/mingw/lib".
g) Delete the temporary folder.
Before starting the compilation, a small fix to GnuPG sources is required.
4.1) If you have not yet done so, download the GnuPG 1.4.9 source (of course from http://www.gnupg.org). In the MSYS folder, there is a subfolder named "home" with another subfolder named after your user name. You have to unpack GnuPG sources inside this last folder, with all the directory structure of the compressed file. If everything is OK, you will have another subfolder named "gnupg-1.4.9" with all the sources inside.
4.2) Now, open the file "seat.test" in the "checks" subfolder and go to line 9.

Change "$i y" into "z y" and add just before line 9 a new line with the following command: "unix2dos -c 7bit -n $i z". Save and close the file.

5.1) Now insert the following commands at a newly
started MSYS prompt:
a) cd gnupg-1.4.9
b) CFLAGS='-O3 -mtune=i386 -march=i386
-mfpmath=387 -mno-mmx -mno-sse -mno-3dnow -mno-sse2'
LDFLAGS='-s' ./configure

Other options can be added at the end of the "./configure" command line. E.g., it is possible to add "--enable-camellia" to enable the experimental support for the "Camellia" encryption algorithm. A list of all the possible options can be viewed with the command "./configure --help". With this procedure you will then obtain an executable which will be able to run on every i386 machine. If you want enable special optimization for your machine, you can change the parameters in the CFLAGS variable with the ones of your choice. E.g., for a Pentium III machine, you can specify:
CFLAGS='-O3 -mtune=pentium3 -march=pentium3 -mfpmath=sse -mmmx -msse'
or, for an Athlon-XP:
CFLAGS='-O3 -mtune=athlon-xp -march=athlon-xp -mfpmath=sse -mmmx -msse -m3dnow'.
The executable file created in this way will require the .dll files of the external libraries which you have added in step 3 above (bzip2, zlib, etc.). Such .dll files must be copied in the same folder of gpg.exe or in a folder contained in the system %path% (see step 5.2 below). Instead, if you want to build a stand-alone executable file, able to work without additional .dll files, you will have to specify:
LDFLAGS='-s -static'
instead of:
LDFLAGS='-s'.
It must be noted, however, that such a procedure does not work necessarily
with all the external libraries. In particular, libiconv cannot be statically
linked to the executable file and, therefore, the iconv.dll file will be
always needed to use multi-language support.
For a complete list of all the parameters you can specify to trigger
special optimizations, you can look the GCC
user manual. Now, you will see many messages while all the
building parameters are set. At the end, you should see the message in the
figure below. If you do not see it, then there was some problem and you
should fix it before continuing.
c) make

You will see again many messages during the build process. If everything
goes right you will see something similar to the figure below, else the
build process will stop with an error.
d) make check

This is not a mandatory step, but it is useful to check the everything went right and that the just built GnuPG works perfectly.

e) iconv -f LATIN1 -t cp850 po/it.po > po/it2.po
&& mv po/it2.po po/it.po && msgfmt -o po/it.gmo po/it.po
where "it" can be changed with the localization file of your choice (e.g.,
"fr" for French, "es" for Spanish, ecc.) and "cp850" must of course be
changed with the actual codepage (some sort of "character table") used by
your Windows version in the command prompt windows. The codepage 850 is the
one, so called, of Western Europe, and it is used by Italian versions. To
know the codepage used by your Windows version, open a command prompt window
and use the command "chcp". If you are interested in more than a GnuPG
localization, repeat this point "g" for all the localization files of your
choice. If you have skipped point 3.2, then you must skip also this point
"g".
5.2) If everything went well without any errors, then you will find gpg.exe and gpgv.exe in the g10 subfolder, gpgkeys_hkp.exe, gpgkeys_ldap.exe, gpgkeys_finger.exe and gpgkeys_http.exe in the keyserver subfolder and gpgsplit.exe in the tools subfolder. Now you can copy them in another folder (e.g. C:\GnuPG), together with the dynamic libraries which you have used during the compilation (e.g. bzip2, iconv, libcurl, zlib, etc.) and which can be found in C:\MinGW\bin. You can also copy the file "it.gmo" (or the one you created at point 5.1g above), which is in the "po" subfolder, in the folder of the GnuPG localization files (e.g. C:\GnuPG\gnupg.nls) renaming it as "it.mo". You can now follow the standard GnuPG installation procedure, described in the README-W32.txt file, creating the required registry keys.