|
|||
Tutorial: A Little Help With Alcatel-Lucent nmake[Table of Contents] [Previous Section] [Next Section] 11. Common ActionsThere 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 Makerules.mk. 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 message.mk clobber
and nmake does the job without complaining, even though there's no clobber target defined in message.mk. 11.1 InstallThe 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 prog.mk 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 abc.mk 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 ClobberThe 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 prog.mk makefile
nmake -f prog.mk clobber
we get:
+ ignore rm -f main.o prog b.o a.o Makefile.mo Makefile.ms
You can also clobber only the files installed by the install common action. After building prog.mk with install we can run
nmake -f prog.mk clobber.install
and get
+ ignore rm -f -r ../bin/prog
11.3 CleanThe 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 prog.mk clean
Will give us:
+ ignore rm -f main.o b.o a.o
FOOTNOTES:
[Table of Contents] [Previous Section] [Next Section] Last Update: Wednesday,20-Dec-06 13:22:13 CST
|
|||