Nokia nmake Product Builder
Customer Support Newsletter

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

Issue No. 17 - May 2004
Contacts
Highlights
  1. Windows Support
  2. JavaDeps lu2.1.2
  3. Support for MS Services for Unix
  4. BSD Based Package Management
Technical Notes
  1. Building Web Pages
  2. UNIX and Windows Portability
Tidbits
  1. Variable Edit Operators :D:B:S

Highlights

Windows Support

The Software Technology Center of Bell Labs/Lucent Technologies is pleased to announce the general availability of the Lucent® nmake Product Builder for UWIN. Available as of April 19, 2004, this product represents a new addition to our portfolio of development tools for Microsoft® Windows® based software development. In addition, a version of the Sablime® Configuration Management System for Windows® is also available.

The following new features are introduced in nmake for UWIN to support the Windows® 2000 platform.

This release is based on nmake release lu3.6 patch 1. For details see the UWIN Overview and the release notes.

If interested in obtaining a license for nmake for UWIN, please contact the STC Customer Care Team at 908-582-5880 or software@alcatel-lucent.com.

index

JavaDeps 2.1.2

The JavaDeps update release JavaDeps-lu2.1.2 is now available. JavaDeps is an optional package and only required for projects building Java code using the nmake supplied :JAVA: operator. This update adds support for the UWIN platform and is required for those using Lucent® nmake for UWIN. It also includes some performance enhancements which apply to all platforms. For details see the JavaDeps page.

JavaDeps lu2.1.2 includes the following updates:

index

Support for MS Services for Unix

We are currently porting nmake to Microsoft Windows Services for Unix, which uses the Interix subsystem to provide a UNIX environment on Windows machines. The release is targeted for 4Q2004. If you are interested in beta testing please contact us at nmake@alcatel-lucent.com.

index

BSD Based Package Management

We are planning to move to a BSD based package installation and management system. For example, pkg_add will be used to install and pkg_delete to delete nmake. The first release to be distributed this way will be SFU/Interix. We are very interested in any feedback on this change. From the user point of view is this desirable or undesirable for any reason? If you have any thoughts please let us know at nmake@alcatel-lucent.com.

index


Technical Notes

Building Web Pages

Here is a method of using nmake to manage web pages using server-side includes for a web server that does not support server-side includes. A custom perl script is used to process the web page and pull in the include files to generate the final page for the server. A scan rule is defined for nmake to track the prerequisite include files. When an include file is changed nmake will regenerate the necessary files.

The source files use the suffix .shtml to indicate the use of server-side includes. Corresponding .html files are generated by our perl script and installed to the web directory.

Here are the custom scan rules.

01   .HTML.VIRTUAL. : .FUNCTION
02           return $(%:C|^/nmake/||)
03   
04   .SCAN.html : .SCAN
05           I|<!--#include file="%" -->|
06           I|<!--#include virtual="%" -->|M$$(.HTML.VIRTUAL. $$(%))|
07   
08   .ATTRIBUTE.%.html : .SCAN.html
09   .ATTRIBUTE.%.shtml : .SCAN.html
10   
11   .SOURCE.%.SCAN.html : .FORCE $$(*.SOURCE.html) $$(*.SOURCE.inc) $$(*.SOURCE)
12   
13   %.html : %.shtml
14           extern_file $(>:P=A) > $(<)
15   
16   .SOURCE : $(VROOT)
17   
18   clobber = 1
19   WWWDIR = /stage/www.bell-labs.com/docs/project/nmake
20   
21   FILES :FUNCTION:
22           return $(".":L<=*.shtml:B:S=.html)

The .HTML.VIRTUAL. function handles include files specified with the virtual=file directive, which represents the file from the web server root and not the actual working directory. The function strips the web root from the specified file so the file can be referenced from $(VROOT) and found in the build area from the .SOURCE assertion on line 16.

Line 4 defines the scan rule. Lines 8 and 9 associate the scan rule with .html and .shtml files. Line 11 defines what directories to search for include files. Line 13 defines the metarule to generate the .html file from the .shtml source. Our perl script, extern_file, does not take any special arguments, just the file to convert. Setting clobber=1 on line 18 tells nmake not to back-up old install files to file.old. The FILES function on line 21 is used in the local makefiles to get a list of all .shtml files in the current directory and returns the corresponding .html files to build.

Here is the local makefile for building the newsletters directory, which contains about 18 .shtml files.

1   include ../htmlrules.mk
2   
3   :ALL: $(FILES)
4   
5   $(WWWDIR)/newsletters :INSTALLDIR: $(FILES)

Let's run nmake. In this case only the current newsletter has changed.

$ nmake install
+ extern_file /home/richb/wwwsource/nmake/newsletters/issue017.shtml
+ 1> issue017.html
+ rm -f /stage/www.bell-labs.com/docs/project/nmake/newsletters/issue017.html
+ cp issue017.html /stage/www.bell-labs.com/docs/project/nmake/newsletters/issue017.html

This is a unique use of nmake and shows the versatility of the programmable scan engine.

index

UNIX and Windows Portability

Now that nmake for UWIN is available, here is an example makefile that builds a simple shared library and application for win32, Solaris, and HP-UX. Notice the makefile is platform neutral and does not take any platform into account.

1   LIBDIR = lib
2   BINDIR = bin
3   CCFLAGS += $$(CC.PIC)
4   sharedlibvers = 0
5   :ALL:
6   abc :LIBRARY: abc.c
7   hello :: hello.c -labc

Here is the simple source code.

/*** abc.c ***/
#include 
int abc(){
    printf("hello worlds\n");
    return(0);
}
/*** hello.c ***/
int main() {
    abc();
    return(0);
}

Build on UWIN

The win32 binaries are built on UWIN. abc.lib is generated and hello is compiled and linked with the library. hello and abc.dll are installed in bin/. abc.lib and libabc.a are installed in lib/.

$ ls -l
total 3
-rw-r--r--  1 nmake    None         115 Mar 17 17:36 Makefile
-rw-r--r--  1 nmake    None          77 Mar 17 17:16 abc.c
-rw-r--r--  1 nmake    None          30 Mar 17 17:18 hello.c

$ nmake install
[2]+ cc -O -D_BLD_DLL -I- -c abc.c
[2]+ ar rI libabc.a abc.o
ar: creating libabc.a
[2]+ rm -f abc.o
[8]+ /usr/bin/ld -G -o abc.dll -Bwhole-archive libabc.a -Bno-whole-archive 
abc.ign
   Creating library abc.lib and object abc.exp
[2]+ cc -O -D_BLD_DLL -I- -c hello.c
[2]+ cc -O -L/C/users/nmake/slides/portable -o hello hello.o -labc
[4]+ mkdir -p lib
[4]+ 2> /dev/null
[7]+ cp libabc.a lib/libabc.a
[4]+ mkdir -p bin
[4]+ 2> /dev/null
[7]+ cp hello bin/hello
[7]+ cp abc.dll bin/abc.dll
[7]+ cp abc.lib lib/abc.lib

$ ls -l bin 
total 72
-rwxr-xr-x  1 nmake    None       20480 May 12 16:58 abc.dll
-rwxr-xr-x  1 nmake    None       16384 May 12 16:58 hello.exe

$ ls -l lib
total 6
-rw-r--r--  1 nmake    None        2000 May 12 16:58 abc.lib
-rw-r--r--  1 nmake    None         772 May 12 16:58 libabc.a

Build on Solaris

On Solaris libabc.so is generated and hello is compiled and linked with the library. hello is installed in bin/. libabc.so and libabc.a is installed in lib/.

$ ls -l
total 8
-rw-r--r--    1 richb    richb         115 Mar 17 17:35 Makefile
-rw-r--r--    1 richb    richb          77 Mar 17 17:15 abc.c
-rw-r--r--    1 richb    richb          41 Mar 17 17:15 hello.c

$ nmake install
+ cc -O -KPIC -I- -c abc.c
+ ar r libabc.a abc.o
ar: creating libabc.a
+ rm -f abc.o
+ nm -p libabc.a
+ sed -e /[     ][TDBC][        ][      ]*[_A-Za-z]/!d -e s?.*[         ][T
DBC][        ][      ]*?? -e /_STUB_/d -e s/^/-u /
+ /tools/sun_workshop/SUNWspro/bin/cc -G -o libabc.so -u abc libabc.a
+ cc -O -KPIC -I- -c hello.c
+ cc -O -KPIC -L/home/richb/slides/portable -o hello hello.o -labc
+ mkdir -p lib
+ 2> /dev/null
+ cp libabc.a lib/libabc.a
+ mkdir -p bin
+ 2> /dev/null
+ cp hello bin/hello
+ cp libabc.so lib/libabc.so

$ ls -l bin
total 8
-rwxr-xr-x    1 richb    richb        6576 May 12 16:46 hello

$ ls -l lib
total 12
-rw-r--r--    1 richb    richb        1544 May 12 16:46 libabc.a
-rwxr-xr-x    1 richb    richb        5112 May 12 16:46 libabc.so

Build on HP-UX

On HP-UX libabc.sl is generated and hello is compiled and linked with the library. hello is installed in bin/. libabc.sl and libabc.a are installed in lib/.

$ ls -l
total 4
-rw-r--r--   1 nmake      sablime        115 May 12 16:54 Makefile
-rw-r--r--   1 nmake      sablime         77 May 12 16:54 abc.c
-rw-r--r--   1 nmake      sablime         41 May 12 16:54 hello.c

$ nmake install
+ cc -O +z -t p,/tools/nmake/hppa10/lu3.6-p01/lib/cpp -I-D/tools/nmake/hppa
10/lu3.6-p01/lib/probe/C/pp/0735ED0C.bincc -I/usr/include -I- -c abc.c
+ ar r libabc.a abc.o
ar: creating libabc.a
+ rm -f abc.o
+ /bin/nm -p libabc.a
+ sed -e /[     ][TDBC][        ][      ]*[_A-Za-z]/!d -e s?.*[         ][T
DBC][        ][      ]*?? -e /_STUB_/d -e s/^/-u /
+ /bin/ld -b -o libabc.sl -u abc libabc.a
/bin/ld: (Warning) At least one PA 2.0 object file (libabc.a(abc.o)) was de
tected. The linked output may not run on a PA 1.x system.
+ cc -O +z -t p,/tools/nmake/hppa10/lu3.6-p01/lib/cpp -I-D/tools/nmake/hppa
10/lu3.6-p01/lib/probe/C/pp/0735ED0C.bincc -I- -c hello.c
+ cc -O +z -L/home/nmakehome/xyz -o hello hello.o -labc
+ mkdir -p lib
+ 2> /dev/null
+ cp libabc.a lib/libabc.a
+ mkdir -p bin
+ 2> /dev/null
+ cp hello bin/hello
+ cp libabc.sl lib/libabc.sl

$ ls -l bin
total 6
-rwxr-xr-x   1 nmake      sablime      20480 May 12 16:55 hello

$ ls -l lib
total 6
-rw-r--r--   1 nmake      sablime       5420 May 12 16:55 libabc.a
-rwxr-xr-x   1 nmake      sablime      12288 May 12 16:55 libabc.sl

index


Tidbits

Variable Edit Operators :D:B:S

Here is a quick introduction to the variable edit operators :D:B:S, which are used to return or modify the directory, base name, and suffix respectively of one or more filenames stored in a variable.

$ cat Makefile
LIBABC = /opt/abc/lib/libabc.a
targ:
        : get the directory -- $(LIBABC:D)
        : get the basename -- $(LIBABC:B)
        : get the basename and suffix -- $(LIBABC:B:S)
        : change the suffix -- $(LIBABC:B:S=.so)

$ nmake
+ : get the directory -- /opt/abc/lib
+ : get the basename -- libabc
+ : get the basename and suffix -- libabc.a
+ : change the suffix -- libabc.so

A common application is to change the file suffix for a number of filenames.

$ cat Makefile 
SRC = a.c b.c c.cxx d.C
OBJ = $(SRC:B:S=.o)
targ:
        : SRC = $(SRC)
        : OBJ = $(OBJ)

$ nmake
+ : SRC = a.c b.c c.cxx d.C
+ : OBJ = a.o b.o c.o d.o

The :D:B:S edit operators are used in conjunction with each other. If only one of them is applied to a variable then the other elements will be stripped. For example, see what happens when :S is used to change the suffix without applying :B.

$ cat Makefile
SRC = a.c b.c c.cxx d.C
targ:
        : without :B -- $(SRC:S=.o)
        : with :B -- $(SRC:B:S=.o)

$ nmake
+ : without :B -- .o .o .o .o
+ : with :B -- a.o b.o c.o d.o

The :D:B:S edit operators provide a simple yet powerful means to apply common transformations to a list of files.

index

<<home / newsletters