Nokia Networks Home

Nokia nmake Product Builder

Quick Links

Related Products

Tutorial: A Little Help With Nokia nmake

[Table of Contents] [Previous Section] [Next Section]

11. Common Actions

There are some chores, like cleaning up and installing files, that should be familiar to make users. For example, building a target named clean usually removes intermediate (e.g., .o) files but not final products (e.g., programs or libraries), while building clobber removes everything, including the final products, built by a makefile. Makefiles written for make often include targets named clean, clobber, and install, but nmake provides these capabilities (and many more) in an extensive collection of targets, called common actions [23], that are defined in

Common actions are important because they're general implementations that don't need to be duplicated in makefiles. As a result you'll rarely find targets like clean, clobber, or install in makefiles written for nmake, although they work when you try to build them. For example, we can type

     nmake -f clobber

and nmake does the job without complaining, even though there's no clobber target defined in

11.1 Install

The install common action is probably the most frequently used common action. It is primarily used to install files after they have been built or updated, but it can also install files that are not built (for example a data file that must be delivered to customers and is controlled with the source code but not generated.)

A file will only be re-installed if it is different than the currently installed file [24] (according to the UNIX cmp command.) Before re-installing a file nmake will backup the currently installed file to filename.old [25] in the installation directory.

The :: assertion operator will setup a default install assertion for you. Executable targets defined on the left side of :: will be installed in the directory defined by variable BINDIR. Archive library (.a) files on the left side of :: will be installed in LIBDIR.

     BINDIR = ../bin
     prog :: main.c a.c b.c

To install files you specify the install common action on the nmake command line. Say we have already built this makefile so nothing needs to be re-compiled, nmake will just do the install. Of course if anything were out-of-date nmake would rebuild whatever is necessary before installing files. So we can type,

     nmake -f install

and we get:

     + cp prog ../bin/prog

You may also define explicit install assertions using the :INSTALL: or :INSTALLDIR: assertion operators [26]. :INSTALLDIR: is most common, it takes a directory on the left side and one or more files on the right to be installed in the specified directory.

     ../mydir :INSTALLDIR: abc xyz

When we run

     nmake -f install

we get:

     + cp abc ../mydir/abc
     + cp xyz ../mydir/xyz

The :INSTALL: operator takes a file on the left side and one file on the right. The file specified on the right will be installed as the file on the left. Use this operator when you need to rename the file being installed.

11.2 Clobber

The clobber common action is what you use when you really want to clean everything up. It removes the generated targets, intermediate files such as the .o files, and the nmake objectfile and statefile.

When we clobber our makefile

     nmake -f clobber

we get:

     + ignore rm -f main.o prog b.o a.o

You can also clobber only the files installed by the install common action. After building with install we can run

     nmake -f clobber.install

and get

     + ignore rm -f -r ../bin/prog

11.3 Clean

The clean common action is a little more conservative than clobber. clean will remove the intermediate files but leave the final targets and nmake objectfile and statefile. Running

     nmake -f clean

Will give us:

     + ignore rm -f main.o b.o a.o


See chapter 2 of the nmake User's Guide for the whole list of common actions support by nmake.
Set variable compare=0 to turn off this comparison check.
Set variable clobber=1 prevent nmake from making the filename.old files during install.
See chapter 3 in the nmake Reference Manual for more information on the :INSTALL: and :INSTALLDIR: assertions.

[Table of Contents] [Previous Section] [Next Section]

Last Update: Friday,12-Aug-2016 12:19:08 EDT