Exporting a Makefile
Home Page (Projects) | Overviews | How Do I... Topics | NMAKE Reference
If you want to use NMAKE to build a Visual C++ project, instead of building it from within the environment or by using the Visual C++ command line tools, you can it export it as a makefile (ProjectName.mak). However, you no longer need to use NMAKE to build a Visual C++ project from the command line. For more information, see Building a project from the command line.
Exporting a .mak file consists of two parts: creating the .mak file and creating or updating a corresponding .dep file. The first time you export a .mak file, Visual C++ creates an NMAKE-style include file (Projectname.dep), which contains information about any included files required to build the project source files. Within the .mak file, Visual C++ adds an !include directive that references the projectname.dep file. Once this .dep file exists, you can specify whether or not you want Visual C++ to export the dependency information when it exports the .mak file.
You can greatly increase the speed of exporting .mak files by exporting dependency information only when you explicitly want to update the .dep file. You may not wish to update dependency information, for example, if only compiler switches have changed since the last time you built the project.
By default, the information written to the .dep file is applied to all build configurations. If there are significant differences in the dependencies between build configurations, for example, extra header files for a "Win32 Debug" configuration, you can specify that the dependency information be written on a per-configuration basis.
You may also wish to create and maintain the .dep files yourself. If so, you must follow the NMAKE naming convention (ProjectName.dep) or your project will not build.
Here is an example .dep file for MyProject.mak:
FileName.cpp: MyDep1.h, MyDep2.h
FileName2.cpp: YourDep2.h
What do you want to do?
Export a makefile
Automatically export a makefile whenever a project is updated
Automatically write dependency information when exporting a makefile
Specify different dependency information for different configurations
To export a makefile
From the Project menu, select Export Makefile.
In the Export Makefile(s) dialog box, select the project(s) for which you want to create a .mak file.
A separate .mak file is created for each project you select.
If you want Visual C++ to update dependency information, check the Write dependencies when writing makefiles checkbox.
If you know that you want to automatically export the .mak file each time you update this project, use the following procedure.
To automatically export a makefile when the project is updated
From the Tools menu, choose Options.
On the Build tab, check the Export makefile when saving project file checkbox.
Selecting this option increases the time it takes to save the project.
To automatically write dependency information every time you export a makefile
From the Tools menu, choose Options.
On the Build tab, check the Always write dependencies when writing makefiles checkbox.
Selecting this option considerably increases the time it takes to write the .mak file.
To specify per-configuration dependency information
From the Project menu, choose Settings.
On the General tab, check the Allow per-configuration dependencies checkbox.
Selecting this option increases the time it takes to write the dependency information, according to the number of build configurations in the project.