PW32: Bootstrapping
In this document, procedure for bootstrapping the PW32 is described.
Generally it's only of interest to those who want to walk all path from
the beginning (for example, me).
To bootstrap PW32, you'll need GNU C compiler, capable of producing
Win32 PE code (including DLLs). I gradually used Mumit Khan's mingw32
egcs/gcc builds for that, with gcc 2.95.2/binutils 2.9.4
release in
the meantime. Indeed, build procedure currently relies on some mingw32
features (such as argument globbing). What is also required is of course
GNU make. Mingw32 prebuilt is available at Mumit's site. I however
sometimes forced to use Cygwin's make, when mingw32 behaves badly.
Step-by-step bootstrapping procedure
- Build PW32 library itself
- Build bootstrap versions of some GNU (and non-GNU) utilities. This accomplished
by applying bootstrap patches (available in binary distributions of
bootstrap utilities and all together in separate archive) to GNU
distributions. Versions used as bootstrap are outdated, they were taken
from Linux Slackware 3.2 distribution (just because I already had them
on my hdd, and in case I would distribute PW32 off my site, I just could
link to sources, instead of making GNU dump from my ftp).
- Build fileutils (cd lib;make;cd ../src;make). Copy ginstall.exe to
install.exe .
- Build grep (make). Copy grep.exe to egrep.exe .
- Build sed (make).
- Build textutils (cd lib;make;cd ../src;make).
- Build ash (make).
- At this step, all required to run common configure scripts is up,
except for make (but we have mingw32's) and cmp
(lives in diffutils),
but it's only used to facilate some caching between configure runs, and
its absence can be ignored for now.
- So, time to setup PW32 environment.
- Choose $(prefix). For production
system, that would be /usr. Use something else for now.
As $(core) further
referred top dir of PW32 core library (something like /projects/pw32).
- Copy all the
binaries (i.e. exe files) of stuff built earlier to $(prefix)/bin.
- Copy pw32.dll to $(prefix)/bin.
- Copy $(core)/include/ from to $(prefix).
- Then need to setup mingw32-hosted gcc as compiler for pw32:
- Copy ar.exe, ranlib.exe, gcc.exe from Mingw32 to $(prefix)/bin.
Rename
gcc.exe as gcc.w32.
Copy $(core)/utils/exec-w32.exe as $(prefix)/bin/gcc.exe .
Make sure that running that gcc.exe gives "No input files" message. Now
run it from within sh and make sure you don't get 'Hangup' trailer.
- Create $(prefix)/i386-mingw32msvc/lib/ . Put there
libkernel32.a,
libadvapi32.a, libuser32.a, libwinmm.a of mingw32.
- Create $(prefix)/lib/gcc-lib/i386-mingw32msvc/2.95.2/ , and copy
cc1.exe, cpp.exe, libgcc.a, all from the corresponding mingw32 dir
there. Put mingw32's as.exe and ld.exe there.
specs file, hacked for PW32
(available in bootstrap package) also goes there.
- Put $(core)/lib/{crt0.a, libcrt0.a, libc.a} to
$(prefix)/lib/.
- Now test it (from native shell): gcc hello.c -o hello
(I'm sure you know
what hello.c contains). Make sure that hello.exe
references only pw32.dll
and system dlls.
- Now do the same from sh.
- Congratulations!
Paul Sokolovsky
| use this form to submit bug