Alcatel-Lucent nmake Product Builder - Eclipse Plugin 0.4.0 Guide Alcatel-Lucent

Description of example

The nmake C project template provides a simple but realistic project example. The project builds 2 commands and 1 library, with the source for each located within its own sub-directory:

hw/
    Makefile
    src/
        Makefile
        global.mk
        cmd/
            Makefile
            hw/
                Makefile
                hw.c
                a.c
                b.c
                b.h
            hw2/
                Makefile
                hw2.c
                a.c
        lib/
            Makefile
            hw/
                Makefile
                lb.c
                la.c
                hw.h
    bin/
    include/
    lib/

This project is representative in that it demonstrates command and library builds, recursive makes, dependencies on installed headers/libraries, use of project level global Makefiles, installs, and clobbers/cleans. The example has characteristics of larger projects and the structure is scalable. It can support complex requirements such as separation of architecture-dependent generated targets (for example, it could easily generate Solaris and Linux objects from the same source and cleanly separate the generated objects through viewpathing.) As shown below, this project structure leads to simple declarative Makefiles that provide full featured build functionality.

hw is the project root (in nmake terminology, the viewpath node root) containing the src, bin, include, and lib directories. src is the root of the source tree; generated executables and libraries are built locally and installed under bin, include, and lib. global.mk is the project global Makefile and is included in all project Makefiles. Following are contents of selected Makefiles.

hw/src/global.mk:

/* generate GNU style make recurse messages */
recurse_begin_message = gnu

/* install build products in build node root directory */
INSTALLROOT = $(project_loc)

/* example project-wide header directory */
.SOURCE.h : $(INCLUDEDIR)

/* example project-wide library directory */
.SOURCE.a : $(LIBDIR)

hw/src/Makefile:

include ../src/global.mk

:MAKE: lib - cmd

hw/src/cmd/Makefile:

include ../../src/global.mk

:MAKE: *

hw/src/cmd/hw/Makefile:

include ../../../src/global.mk

hw :: hw.c a.c b.c -lhw

Complete source for this project is available in the provided template project.

hw/src/global.mk is a project level global Makefile that is included by all other Makefiles. It contains project settings visible to all project Makefiles. Setting recurse_begin_message = gnu configures nmake to output GNU make style recursion messages. This allows a CDT supplied error parser to track the current directory in recursive builds. The default nmake supplied build definitions also set recurse_begin_message = gnu on the default nmake command line as a convenience for existing projects that might not have recurse_begin_message set appropriately in their own Makefiles. (The recurse_begin_message = gnu feature was introduced in nmake alu3.9.) The :MAKE: assertion tell nmake to recurse to the directories specified on the right hand side of the assertion. hw/src/cmd/hw/Makefile is a leaf Makefile and specifies how to build command hw.