Since
chenall committed a handful of patches that I submitted to make the compilation of
Grub4DOS on MinGW easier, I'm just going to jolt down some quick notes on how you can produce a working Grub4DOS on Windows.
Note that part of this guide is shamelessly copied from the
RMPrepUSB Grub4DOS compilation guide.
- If you don't already have a git client, download and install msys-git (a.k.a. "Git for Windows") from here.
- Download the latest MinGW32 installer (
mingw-get-setup.exe
) by clicking the "Download Installer" button on the top right corner of the main MinGW site.
- Keep the default options on the first screen (but you can change the destination directory if you want)
- On the package selection screen, select
- mingw-developer-toolkit
- mingw-base
- msys-base
- Select menu Installation → Apply Changes and click Apply
- Now navigate to your msys directory, e.g..
C:\MinGW\msys\1.0\
, and open the file etc\profile
in a text editor.
- Assuming that you installed msys-git in
C:\Program Files (x86)\Git
, change the following:if [ $MSYSTEM == MINGW32 ]; then
export PATH=".:/usr/local/bin:/mingw/bin:/bin:$PATH"
else
export PATH=".:/usr/local/bin:/bin:/mingw/bin:$PATH"
fi
toif [ $MSYSTEM == MINGW32 ]; then
export PATH=".:/usr/local/bin:/mingw/bin:/bin:/c/Program Files (x86)/Git/bin:$PATH"
else
export PATH=".:/usr/local/bin:/bin:/mingw/bin:/c/Program Files (x86)/Git/bin:$PATH"
fi
This is to ensure that your system will be able to invoke git. Of course, if you use a different git client, you can ignore this step.
- Download nasm (current build is: http://www.nasm.us/pub/nasm/releasebuilds/2.11.06/win32/nasm-2.11.06-win32.zip) extract and copy
nasm.exe
to C:\MinGW\msys\1.0\bin
(the other files in the zip archive can be discarded).
- Download upx (current build is: ftp://ftp.heanet.ie/mirrors/sourceforge/u/up/upx/upx/3.91/upx391w.zip) extract and copy
upx.exe
to C:\MinGW\msys\1.0\bin
(the other files in the zip archive can be discarded).
- In
C:\MinGW\msys\1.0\
launch msys.bat
- In the shell that appears, issue the following command (this may be necessary to locate
mingw-get
):/postintall/pi.sh
You should accept all the default options.
- Now issue the following commands:
mingw-get upgrade gcc=4.6.2-1
mingw-get install mpc=0.8.1-1
This will effectively downgrade your compiler to gcc 4.6.2, which is necessary as gcc 4.7 or later doesn't seem to produce a working grldr
for the time being.
- Download the latest Grub4DOS source from github by issuing the following command
git clone https://github.com/chenall/grub4dos.git
Note: By default this will download the source into C:\MinGW\msys\1.0\home\<your_user_name>\grub4dos\
, but you can of course navigate to a different directory before issuing the git clone
command if you want it elsewhere.
- Run the following commands:
cd grub4dos
./autogen.sh
make
At the end of all this, you should end up with a
grldr
and
grldr.mbr
in the
C:\MinGW\msys\1.0\home\<your_user_name>\grub4dos\stage2\
directory, which is what you want
IMPORTANT: Do not try to invoke
./configure
directly on MinGW, as compilation will fail. Instead should ensure that you call autotools to re-generate configure and Makefiles that MinGW will be happy with. Note that you can run
./bootstrap.sh
instead of
./autogen.sh
, if you don't want
configure
to be invoked with the default options.
What's the deal with gcc 4.7 or later on MinGW?
I haven't really investigated the issue, but the end result is that
grldr
is 303 KB, vs 307 KB for gcc 4.6.2, and freezes at boot after displaying:
A20 Debug: C806 Done! ...
I'm getting an error about objcopy during the configure test...
That's because you're not listening to what I say and try to compile a version of Grub4DOS that doesn't contain the necessary updates for MinGW. You must use a version of the source that's more recent than 2014.11.14 and right now, that source is only available if you clone from git.
Dude, could you, like, also provide the steps to compile from Linux?
Sigh... Alright, since I'm a nice guy, and it's a lot simpler, I'll give you the steps for a bare Debian 7.7.0 x64 Linux setup:
aptitude install gcc glibc-devel.i686 gcc-multilib make autotools autoconf git nasm upx
git clone https://github.com/chenall/grub4dos.git
cd grub4dos
./autogen.sh
make
Happy now? Note that the Linux compiled version is usually a lot smaller than the MinGW32 compiled one.