Handling dependencies in managed builds, How managed makefiles create dependency files, Layout of simple project – HP Integrity NonStop H-Series User Manual
Page 48: Sample build rule for door.o in subdir.mk

Figure 8 Layout of simple project
Handling dependencies in managed builds
To ensure C and C++ objects are rebuilt when header files they depend on are changed, NSDEE
adds commands to build rules to generate dependency files. The following sections describe:
•
“How managed makefiles create dependency files” (page 48)
•
“How NSDEE adds rules to handle deleted headers” (page 49)
•
“How SQL/MX preprocessor file header dependencies are handled” (page 50)
•
“How to change or disable dependency file creation” (page 51)
How managed makefiles create dependency files
For C and C++, NSDEE-generated makefiles generate header file dependencies for objects by
re-running the compiler invocation with the addition of the -WM option (so the compiler will list
dependencies). The second compiler invocation is part of the same build rule that builds the object
file. This ensures that, every time a particular object file is built, the header file dependencies for
that file will be regenerated.
Example 3 “Sample build rule for Door.o in subdir.mk”
shows an example of a build rule for an
object file named Door.o in a subdir.mk file for a project named CarParts.
Example 3 Sample build rule for Door.o in subdir.mk
src/Door.o: ../src/Door.cpp
@echo 'Building file: $<'
@echo 'Invoking: C++ Compiler (TNS/E)'
c89 -Wcplusplus -g -Woptimize=1 -Ww -Wsystype=oss -c -Wversion3 -o
"$@" "$<" && c89 -Wcplusplus -g -Woptimize=1 -Ww -Wsystype=oss -c \
-Wversion3 -WM "$<" | grep -v -e '$(NSDEE_SYS_INCLUDE_PATH_ESC)' -e \
'Door.cpp' | sed -e 's/[ ].*CarParts\\Debug\\\.\.\// ..\//g' >src/Door.d
@echo 'Finished building: $<'
@echo ' '
The second invocation of c89 in
Example 3 “Sample build rule for Door.o in subdir.mk”
generates
a list of all headers Door.o depends on, including all system headers; however, NSDEE does not
include system headers in the final result by default. Including system headers as dependencies
adds significant overhead to builds and there is little reason to do so in NSDEE unless you need
to change system headers. Should you actually change system headers (or RVUs), HP recommends
you do a full rebuild. However, you can turn on system header dependency generation if you want
to. For details, see
“How to change or disable dependency file creation” (page 51)
.
48
Concepts