Nokia nmake Product Builder
Customer Support Newsletter

http://nmake.alcatel-lucent.com/newsletters/

Issue No. 46 - April 2014
Contacts
Articles
  1. nmake 16 Release Schedule
  2. :P=I Undocumented Behavior
  3. .REBIND Auxiliary Targets
  4. Feedback and Suggestions

nmake 16 Release Schedule

The team is working towards the nmake 16 release targeted for 3Q2014. In addition to the usual fixes and enhancements the changes targeted for the release include the following:

Beta Testers

The nmake 16 beta period is tentatively scheduled for 11-June-2014 through 16-July-2014. The beta test phase is extremely important as it helps us maintain compatibility with existing makefiles and build environments by running the new release on real world projects. As such, the beta phase contributes directly to the stability of the product. All feedback from the beta is helpful so if you are interested in trying the beta or would like updates on the beta status please let us know at nmake@alcatel-lucent.com.


:P=I Undocumented Behavior

The usage of the :P=I edit operator is documented as $(S:P[!]=I=name). It compares inodes and returns files in variable S with device and inode numbers identical to that of name.

A currently undocumented feature dating back to release 3.0.2 is to return the actual inode numbers when used without =name. The documentation will be updated to reflect this feature.

$ cat Makefile
FILES = file1
targ:
        : $(FILES:P=I)

$ ls -li file1
3645380 -rw-r--r-- 1 richb richb 0 Apr  1 15:23 file1

$ nmake
+ : 3645380

.REBIND Auxiliary Targets

Typically all generated files should be listed as targets to the rule that generates them in their makefile. This tells nmake what files are created so it knows to maintain the files, can properly report such files and can remove the files with the clobber common action. However some tools can inconsistently create auxiliary files in addition to the main target, where some files may not always be generated or their file names may change. In such cases where the files cannot be specified as targets the .REBIND special atom can be used to treat the extra files as generated targets.

In our first example we have a simple rule that generates abc.targ from abc.in. Lets say the tools may also generate any of the auxiliary files named aux1, aux2 and aux3. To simulate this the rule touches aux1 and aux3 so in this case aux2 is not generated.

$ ls -l
total 0
-rw-r--r-- 1 richb richb 49 Apr  2 09:14 Makefile
-rw-r--r-- 1 richb richb 36 Apr  1 17:19 abc.in

$ cat Makefile
abc.targ : abc.in
        cp $(*) $(<)
        touch aux1 aux3

$ nmake
+ cp abc.in abc.targ
+ touch aux1 aux3

$ ls -l     
total 24
-rw-r--r-- 1 richb richb    49 Apr  2 09:14 Makefile
-rw-r--r-- 1 richb richb  3421 Apr  2 09:16 Makefile.mo
-rw-r--r-- 1 richb richb 19061 Apr  2 09:16 Makefile.ms
-rw-r--r-- 1 richb richb    36 Apr  1 17:19 abc.in
-rw-r--r-- 1 richb richb    36 Apr  2 09:16 abc.targ
-rw-r--r-- 1 richb richb     0 Apr  2 09:16 aux1
-rw-r--r-- 1 richb richb     0 Apr  2 09:16 aux3

$ nmake list.generated
  Makefile.mo
Makefile.ms
abc.targ

$ nmake clobber
+ ignore rm -f Makefile.mo Makefile.ms abc.targ

$ ls -l
total 0
-rw-r--r-- 1 richb richb 49 Apr  2 09:14 Makefile
-rw-r--r-- 1 richb richb 36 Apr  1 17:19 abc.in
-rw-r--r-- 1 richb richb  0 Apr  2 09:16 aux1
-rw-r--r-- 1 richb richb  0 Apr  2 09:16 aux3

Notice that the list.generated common action does not list the aux files and clobber does not remove them. nmake does not know these files were generated.

Now we add a rule to rebind the aux files which is triggered after the original rule completes. The rule rebinds all three aux files even though all three may not be generated. Now nmake treats the aux files as generated files.

$ ls -l
total 4
-rw-r--r-- 1 richb richb 137 Apr  2 09:19 Makefile
-rw-r--r-- 1 richb richb  36 Apr  1 17:19 abc.in

$ cat Makefile
abc.targ : abc.in .MY.REBIND
        cp $(*) $(<)
        touch aux1 aux3

.MY.REBIND : .MAKE .AFTER .FORCE .REPEAT .VIRTUAL
        .REBIND : aux1 aux2 aux3

$ nmake
+ cp abc.in abc.targ
+ touch aux1 aux3

$ ls -l
total 28
-rw-r--r-- 1 richb richb   137 Apr  2 09:19 Makefile
-rw-r--r-- 1 richb richb  3472 Apr  2 09:23 Makefile.mo
-rw-r--r-- 1 richb richb 19228 Apr  2 09:23 Makefile.ms
-rw-r--r-- 1 richb richb    36 Apr  1 17:19 abc.in
-rw-r--r-- 1 richb richb    36 Apr  2 09:23 abc.targ
-rw-r--r-- 1 richb richb     0 Apr  2 09:23 aux1
-rw-r--r-- 1 richb richb     0 Apr  2 09:23 aux3

$ nmake list.generated
  aux1
aux3
Makefile.mo
Makefile.ms
abc.targ

$ nmake clobber
+ ignore rm -f aux1 aux3 Makefile.mo Makefile.ms abc.targ

$ ls -l
total 4
-rw-r--r-- 1 richb richb 137 Apr  2 09:19 Makefile
-rw-r--r-- 1 richb richb  36 Apr  1 17:19 abc.in

The next example is a little more complex. We have a metarule that generates a .targ file from a .in file using the tool myproc. The tool generates some auxiliary .db files but their names depend on the contents of the input file. Since we are using a general metarule we cannot hard-code the auxiliary file names in the makefile. Again we trigger a rule after the metarule to rebind the extra files.

$ ls -l
total 4
-rw-r--r-- 1 richb richb 152 Apr  2 09:26 Makefile
-rw-r--r-- 1 richb richb  51 Apr  2 09:27 abc.in

$ cat Makefile 
:ALL: abc.targ

%.targ : %.in .MY.REBIND
        myproc -o $(<) $(>)

.MY.REBIND : .MAKE .AFTER .FORCE .REPEAT .VIRTUAL
        . : -SCANNED
        .REBIND : $(".":L=*.db)

$ nmake
+ myproc -o abc.targ abc.in

$ ls -l
total 28
-rw-r--r-- 1 richb richb   152 Apr  2 09:26 Makefile
-rw-r--r-- 1 richb richb  3749 Apr  2 09:36 Makefile.mo
-rw-r--r-- 1 richb richb 19306 Apr  2 09:36 Makefile.ms
-rw-r--r-- 1 richb richb    51 Apr  2 09:27 abc.in
-rw-r--r-- 1 richb richb    51 Apr  2 09:36 abc.targ
-rw-r--r-- 1 richb richb    17 Apr  2 09:36 aux2.db
-rw-r--r-- 1 richb richb    17 Apr  2 09:36 aux4.db
-rw-r--r-- 1 richb richb    17 Apr  2 09:36 aux5.db

$ nmake list.generated
  aux5.db
aux2.db
Makefile.mo
Makefile.ms
aux4.db
abc.targ

$ nmake clobber
+ ignore rm -f aux5.db aux2.db Makefile.mo Makefile.ms aux4.db abc.targ

$ ls -l
total 4
-rw-r--r-- 1 richb richb 152 Apr  2 09:26 Makefile
-rw-r--r-- 1 richb richb  51 Apr  2 09:27 abc.in

The .MY.REBIND rule first removes the .SCANNED attribute from the current directory. This will cause nmake to rescan the current directory so see the extra .db files. Next .REBIND is applied to the variable $(".":L=*.db) which expands all the .db files in the current directory.

The .DONTCARE special atom may be used under similar circumstances for the auxiliary files. In contrast to .REBIND, .DONTCARE should be used on all auxiliary files that are also specified as prerequisites to another rule. Typically if a prerequisite does not exist and cannot be generated nmake will issue an error. With .DONTCARE nmake will continue with the files that are available. In this case .DONTCARE would be used in addition to .REBIND.

With this .REBIND technique nmake will treat the auxiliary files as generated files. However, nmake still won't be able to regenerate an auxiliary file if it is removed or out-of-date. It is best to specify generated files as actual targets when possible and use this technique only when necessary.


Feedback and Suggestions

We are interested in any feedback you might have about nmake. Please send comments / suggestions to nmake@alcatel-lucent.com.

We're also open to suggestions for future articles. If there is anything you would like to see in the newsletter please send us a note to nmake@alcatel-lucent.com. Thanks for your support!

<<home / newsletters