Nokia nmake Product Builder
Customer Support Newsletter

http://www.bell-labs.com/project/nmake/newsletters/

Issue No. 27 - December 2007
Contacts
Articles
  1. nmake Eclipse Plugin
  2. alu3.9 Linux Package Update
  3. Essential Automatic Variables

nmake Eclipse Plugin

An experimental release of the Alcatel-Lucent nmake Eclipse Plug-in is now available. This release of the plug-in is compatible with Eclipse 3.3, CDT 4.0, and nmake alu3.9 on Linux using gcc. The plug-in currently adds CDT build configurations and toolchain definitions customized for nmake-based builds. The plug-in provides the ability to build existing projects with nmake from Eclipse and to create new nmake based projects, optionally populating a new project using the included project template. Using a wizard based control the template provides a means to get a simple example project up and running quickly. The template project is useful as a working example showing use of nmake in a CDT environment, and can also be extended to create your own projects.

Our Eclipse update site contains the experimental release of the Plug-in. Enter the following URL for this site in the Eclipse update manager to download the plug-in: http://www.bell-labs.com/project/nmake/download/eclipse

An on-line version of the plug-in help is available at: http://www.bell-labs.com/project/nmake/manual/eclipse/help_cdt_plugin

Also see our Eclipse support page for more information. We continue to update this page with our Eclipse information and documentation. As noted earlier this is an experimental pre-release of the plug-in, please send any feedback you have to nmake@alcatel-lucent.com.

index

alu3.9 Linux Package Update

The original alu3.9 Linux package released July, 2007 shipped with the wrong file permissions on lib/probe/probe and lib/ssd. Both files should have the setuid bits set but were not set in the original package. The package was fixed with the correct permissions and updated on Dec 4, 2007. If you downloaded the alu3.9 Linux package prior to Dec 4 you can download the updated package from the alu3.9 download page or set the permissions as indicated in the installation instructions:

$ cd <nmake_install_root>
$ chmod 4755 lib/probe/probe
$ chmod 6755 lib/ssd

We apologize for any inconvenience.

index

Essential Automatic Variables

nmake has several automatic variables that can be used in custom rules. They are used to simplify and generalize your rules and to take advantage of unique features such as viewpathing. In this article we'll look at some of the automatic variables and show their differences and how to use them.

Targets and Prerequisites - $(<) $(*) and $(>)

The most common automatic variables are $(<) for the current target and $(*) for the file prerequisites. For example, the target might be an executable you are compiling and the prerequisites are the source files.

$ cat Makefile
hello : hello.c world.c
        : target = $(<)
        : prereq = $(*)

$ nmake
+ : target = hello
+ : prereq = hello.c world.c

Using $(<) for the target helps generalize the rule so the shell action can be used for multiple targets. The following makefile shows a single rule used to build 4 different targets. Notice $(<) expands differently when each target is build:

$ cat Makefile 
t1 t2 t3 t4 : file1 file2
        : target = $(<)
        : prereq = $(*)

$ nmake
+ : target = t1
+ : prereq = file1 file2

$ nmake t2
+ : target = t2
+ : prereq = file1 file2

$ nmake t3
+ : target = t3
+ : prereq = file1 file2

$ nmake t4
+ : target = t4
+ : prereq = file1 file2

The $(*) variable references the file prerequisites through the viewpath and the .SOURCE[.pattern] search directories. In the following example file1 is in the local node and file2 is down the viewpath in the official node. Notice how using the automatic variables takes care of the viewpath for you. For this reason file names and user defined variables should not be used to reference source files in your shell actions.

$ pwd
/home/richb/dev/src

$ echo $VPATH
/home/richb/dev/src:/home/richb/official/src

$ cat Makefile
t1 t2 t3 t4 : file1 file2
        : target = $(<)
        : prereq = $(*)

$ nmake
+ : target = t1
+ : prereq = file1 /home/richb/official/src/file2

The $(>) variable also expands the file prerequisites similar to $(*). But $(>) only lists files that have a date later than the target thus listing the "out of date" prerequisites. In the following example you can see in the first build $(*) and $(>) are the same. In the next build $(>) is null because both file1 and file2 are up to date. After touching file1 we see $(>) expands file1 but not file2.

$ cat Makefile
t1 t2 t3 t4 : file1 file2
        : "target < = $(<)"
        : "prereq * = $(*)"
        : "prereq > = $(>)"

$ nmake        
+ : target < = t1
+ : prereq * = file1 /home/richb/official/src/file2
+ : prereq > = file1 /home/richb/official/src/file2

$ nmake
+ : target < = t1
+ : prereq * = file1 /home/richb/official/src/file2
+ : prereq > = 

$ touch file1

$ nmake      
+ : target < = t1
+ : prereq * = file1 /home/richb/official/src/file2
+ : prereq > = file1

This example does not actually create target t1 so it keeps rebuilding. In normal usage the second build would not rebuild since nothing changed and you wouldn't see the null variable. Here is another example that sorts file1 and file2 and puts the results in t1.

$ cat Makefile
t1 : file1 file2
        sort -o $(<) $(>)

$ nmake
+ sort -o t1 file1 /home/richb/official/src/file2

$ nmake

$ touch file1

$ nmake
+ sort -o t1 file1

Again the first build expands $(>) to both files but after touching file1 only file1 is expanded. It is an important difference between $(*) and $(>). Also keep in mind $(>) can expand to null if an update is triggered but the prerequisites haven't changed. Extending the above example, if we touch target t1 it will be remade since its time stamp is inconsistent with its time stored in the state file. But since file1 and file2 haven't changed $(>) is null.

$ touch t1

$ nmake
+ sort -o t1

If we change the rule to use $(*) then all the explicit file prerequisites are always expanded. When writing your own rules it is recommended to use $(*) for safety unless you know you need $(>) instead.

$ cat Makefile
t1 : file1 file2
        sort -o $(<) $(*)

$ nmake
+ sort -o t1 file1 /home/richb/official/src/file2

$ nmake

$ touch file1

$ nmake
+ sort -o t1 file1 /home/richb/official/src/file2

$ touch t1

$ nmake
+ sort -o t1 file1 /home/richb/official/src/file2

More Prerequisites - $(!), $(&), $(?) and $(~)

As shown above $(*) and $(>) expand the explicit file prerequisites, or the file prerequisites that are listed in the makefile as dependencies. There are more automatic variables for expanding implicit prerequisites (dependencies not specified in the makefile that are determined from scanning the source files) and state variable prerequisites. These variables are defined as follows:

$(!) all implicit and explicit file prerequisites of current target
$(&) all implicit and explicit state variable prerequisites of current target
$(?) all prerequisites of the current target
$(~) explicit prerequisites of the current target

Here is an example showing the values of these variables.

$ cat hello.c
#include "hello.h"
int main(){
    printf("hello worlds\n");
    return(0);
}

$ cat hello.h
#include <stdio.h>
#ifdef XYZ
#define ZEE
#endif

$ cat Makefile 
XYZ == 1

hello.o : hello.c (ABC)
        : "! = $(!)"
        : "& = $(&)"
        : "? = $(?)"
        : "~ = $(~)"

$ nmake
+ : ! = hello.c hello.h /usr/include/stdio.h /usr/include/sys/va_list.h /usr/include/sys/feature_tests.h
+ : & = (XYZ) (ABC)
+ : ? = hello.c hello.h (XYZ) /usr/include/stdio.h /usr/include/sys/va_list.h /usr/include/sys/feature_tests.h (ABC)
+ : ~ = hello.c (ABC)

The Value of $(!)

$(!) expands the implicit and explicit file prerequisites. The explicit file prerequisite is hello.c since it is explicitly listed in he makefile. The remaining files, hello.h, stdio.h, va_list.h and feature_tests.h are implicit prerequisites picked up from the automatic dependency scan. Touching any of these files will cause the target to be remade.

The Value of $(&)

$(&) expands the implicit and explicit state variable prerequisites. The Makefile specifies (ABC) as an explicit state variable prerequisite to hello.o. (XYZ) is picked up as an implicit prerequisite because it is defined as a state variable (XYZ == 1) and hello.h references the symbol XYZ in an #ifdef. In this case nmake would also add -DXYZ to the compile flags when compiling hello.c. Changing the values of either variable will cause the target to be remade.

The Value of $(?)

$(?) expands all the prerequisites. It is equivalent to both both $(!) and $(&) together. The output shows all the explicit and implicit file and state variable prerequisites.

The Value of $(~)

$(~) expands the explicit prerequisites. The output shows hello.c and (ABC) because they are stated on the right-hand-side of the hello.o target in the Makefile.

There are more automatic variables. For a complete list with descriptions and examples see the nmake Reference Manual Chapter 4, Variables.

index

<<home / newsletters