Alcatel-Lucent nmake Product Builder
How do I keep some .o files after they are archived?
In most cases, after nmake creates an archive library it removes the
archived .o files because they are no longer needed. (The
exception to this is when using a compiler that generate the archive instead
of using ar, such as the Solaris
C++ compiler.) If one or more of the .o files needs to be
in multiple archive libraries then you get an error after nmake removes
the .o from making the first library.
In the following example b.c and c.c are used for both libraries.
:ALL:
libone.a :: a.c b.c c.c
libtwo.a :: b.c c.c d.c
$ nmake
+ cc -O -I- -c a.c
+ cc -O -I- -c b.c
+ cc -O -I- -c c.c
+ ar r libone.a a.o b.o c.o
ar: creating libone.a
+ rm -f a.o b.o c.o
+ cc -O -I- -c d.c
+ ar r libtwo.a b.o c.o d.o
ar: cannot open b.o
No such file or directory
ar: cannot open c.o
No such file or directory
ar: creating libtwo.a
ar: b.o not found
ar: c.o not found
make: *** exit code 2 making libtwo.a
Use the arclean base rules variable to
tell nmake which .o files should not be deleted.
arclean is applied as a variable edit operator to filter
the list of .o to remove. For our example, we will keep
b.o and c.o by adding the following to the
makefile:
arclean = :N!=b.o|c.o
$ nmake + cc -O -I- -c a.c + cc -O -I- -c b.c + cc -O -I- -c c.c + ar r libone.a a.o b.o c.o ar: creating libone.a + rm -f a.o + cc -O -I- -c d.c + ar r libtwo.a b.o c.o d.o ar: creating libtwo.a + rm -f d.o
If you want to keep only one .o file it will look like this:
arclean = :N!=file.o
Shell pattern matching can be used too. For example, to keep all the
.o files use the following:
arclean = :N!=*.o







