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]

10. Viewpathing

If you're working on a big project you may consider viewpathing [22] nmake's most valuable feature. It's often described using an elaborate directory structure that's designed to look like a real product. We're only interested in a few easy demonstrations, so we'll take a simpler approach.

10.1 A Source Node

Let's clean up in /tmp/n2 before we do anything else. That's where we've been working lately, so typing

     nmake -f prog.mk clobber

will do it. We should be left with main.c, a.c, b.c, prog.mk, and a few other makefiles that we don't care about anymore. A clean source directory isn't a viewpathing requirement, but we want to make sure something happens when we build prog in the empty node that we'll create next.

10.2 An Empty Node

We'll need another directory for our viewpathing demonstrations, so let's type:

     mkdir /tmp/n1      

We picked /tmp/n1 but you can use any directory you want, as long it's empty and you remember to substitute your directory when we use /tmp/n1.

10.3 VPATH

There's a shell variable named VPATH that tells nmake where to look for files. VPATH is a colon-separated list of directories, much like the familiar PATH variable that the shell consults when it needs to find a command. We'll set our VPATH variable using:

     VPATH=/tmp/n1:/tmp/n2
     export VPATH

Remember to substitute your directories and export VPATH, and do it at the shell level, not in the makefile. The first directory, in our case /tmp/n1, is called the top node; the last directory in the list is called the bottom node. We're only using two nodes, but viewpaths with three or four nodes are common.

The top node is where you work, and is often called the developer's node. The bottom node is often just source, and is sometimes called the official node. nmake starts looking for files in the top node, and continues trying nodes down the viewpath until it either finds the file or runs out of nodes.

10.4 A Build In An Empty Node

We're in /tmp/n1, and even though it's empty, when we type

     nmake -f prog.mk prog

we get:

     + cc -O -Qpath /nmake/lib -I-D/nmake/lib/probe/C/pp/835E4F4F5bincc -I- -c /tmp/n2/main.c
     + cc -O -Qpath /nmake/lib -I-D/nmake/lib/probe/C/pp/835E4F4F5bincc -I- -c /tmp/n2/a.c
     + cc -O -Qpath /nmake/lib -I-D/nmake/lib/probe/C/pp/835E4F4F5bincc -I- -c /tmp/n2/b.c
     + cc -O -o prog main.o a.o b.o                                            

Our directory was empty when we started, so nmake found everything, even prog.mk, by looking at the second node in our VPATH.

10.5 A Build With A Local Source File

If we clean up by typing

     nmake -f prog.mk clobber

we should end up with an empty directory again. The top node is where we're supposed to work, so let's grab a copy of a.c that we can change without disturbing the official version,

     cp /tmp/n2/a.c .

and rebuild prog by typing:

     nmake -f prog.mk prog

This time we get,

     + cc -O -Qpath /nmake/lib -I-D/nmake/lib/probe/C/pp/835E4F4F5bincc -I- -c /tmp/n2/main.c
     + cc -O -Qpath /nmake/lib -I-D/nmake/lib/probe/C/pp/835E4F4F5bincc -I- -c a.c
     + cc -O -Qpath /nmake/lib -I-D/nmake/lib/probe/C/pp/835E4F4F5bincc -I- -c /tmp/n2/b.c
     + cc -O -o prog main.o a.o b.o

and if you look carefully you'll notice we built prog using our local copy of a.c. If you need proof, change a.c so it prints a different message, rebuild prog, and you'll get the new message when you run prog. Using viewpathing we can have our production source code safely stored in another directory and deal only with the files we're changing for a new version of the program.

FOOTNOTES:

[22]
You'll find more details in chapter 10 of the nmake User's Guide.

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

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