When you open a build environment window, the directory in the window is set to the default directory for the Windows DDK. For more information about how to set up the build environment, see Setting Up the Build Environment.
Before running the Build utility, you must first create a number of data files. The Build utility requires the files in the following table to build a driver.
| File | Location |
|---|---|
| Source files | Typically reside in a subdirectory of the DDK install directory, but can be anywhere. |
| sources File | Required in each directory that contains source files. The sources file lists the source files to be compiled and linked, and specifies values for certain macros. |
| makefile File | Required in each directory that contains a sources file. The makefile file specifies dependency relationships, compiler and linker options, and various other build-related settings. |
| dirs File | Optional file used to compile source code in multiple subdirectories automatically. This contains macros called DIRS and OPTIONAL_DIRS that specify the directories to open recursively and the order in which they should be opened. |
The Build utility (build.exe) is invoked from the command line of your build environment window.
For a description of the command-line syntax, see Build Utility Command-Line Options. You can also use the command build -? to display the command-line syntax.
The Build utility searches the dirs file for the macros DIRS and OPTIONAL_DIRS. It then recurses to each directory listed in the dirs file, searching for another dirs file or a sources file. Each additional dirs file indicates another directory to recurse into. Each sources file indicates a job to be built.
If sources files are found, the Build utility searches for the macros, SOURCES, INCLUDES, TARGETNAME, and TARGETPATH. The values assigned to these macros are parsed to determine the dependencies, the list of files to build, and the end result. Generally, this information is then stored by the Build utility in a file called build.dat for future reference.
Depending on the options you pass to it, the Build utility performs the appropriate actions and then calls a make program. This program will be NMAKE, unless a different make program has been specified in BUILD_MAKE_PROGRAM.
Caution Specifying any other make program besides NMAKE is not recommended.
NMAKE uses the makefile files to generate dependency and command lists. A standard makefile located in the source code directory of every sample driver directs NMAKE to the master macro definition file, makefile.def (which is included in the Windows DDK). The makefile you supply for your own source code should do the same.
After locating the relevant make files, the Build utility might search for other files (makefile0 and makefile.inc); this occurs only on a clean build, or if NTTARGETFILES is specified in the sources file.
After the NMAKE utility evaluates the macros in all the relevant make files, it spawns the C compiler (cl.exe) with the proper switches. After compilation is complete, the Build utility again spawns NMAKE, this time to link the compiled object files.
When the entire directory tree is built, the Build utility halts.