Phobos is D's standard run-time library. The DMD package comes with a prebuilt Phobos library, so most users will not have to build their own. But, since it's still in development, it might occasionally be necessary to build your own version. For example, when you've added a new module; or you might want to build with all debugging options turned on; or perhaps to include a bug fix from some user (and you don't want to wait for the next official release).
Building Phobos is pretty simple. There are makefiles for win32 and linux in /dmd/src/phobos, but they are pretty old so have to be changed a bit.
- Open the makefile in an editor and remove all references to recls.obj, realtest.obj and gamma.obj.
Note: you'll need MASM to build the file minit.obj. Since the DMD distribution already includes minit.obj in its built form, there's usually no need for MASM, but you must make sure it doesn't get removed during a clean operation. Use attrib +r minit.obj to prevent the file from getting deleted. Depending on the modification time of the minit.asm file, make might still ask for masm386:
- Either remove the (2) lines referring to minit.asm or touch the minit.obj file. (If you touch the file, do this BEFORE marking the file read-only.)
- Change the CFLAGS and DFLAGS at the top of the makefile as you see fit.
Make sure /dm/bin and /dmd/bin are in your PATH and that when you type make it's actually using the DigitalMars tool from /dmd/bin.
Open a console and chdir to /dmd/src/phobos and type make -fwin32.mak phobos.lib or make -flinux.mak phobos.lib. If everything went well there should be a fresh 'phobos.lib in /dmd/src/phobos. Move it to /dmd/lib and you're set to go!
Here's a Windows batch file which performs all the steps except for removing the .objs at the beginning:
The GarbageCollector has its own makefile in /dmd/src/phobos/internal/gc and you can change the CFLAGS and DFLAGS in that makefile too. To build it, simply change to the gc directory and run make -fwin32.mak dmgc.lib or make -flinux.mak dmgc.lib. Move the built library to /dmd/lib.