Sample build rule for door.o in subdir.mk – HP Integrity NonStop J-Series User Manual
Page 53
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. By default, NSDEE does
not include system headers in the final result. Including system headers as dependencies adds
significant overhead to builds. If system headers (or RVUs) change, HP recommends a full rebuild.
However, you can turn on system header dependency generation. For details, see
or disable dependency file creation” (page 55)
NSDEE writes build rules so that the compiler generates a dependency list that is piped to grep
to remove system headers.
-v -e '$(NSDEE_SYS_INCLUDE_PATH_ESC)'
The source file -v -e Door.cpp as the dependency is specified for the .o file at the top of the
build rule.
"src/Door.o: ../src/Door.cpp"
Or another example:
-e $(NSDEE_RVU)
The source file -e Door.cpp as the dependency is specified for the .o file at the top of the build
rule.
src/Door.o: ../src/Door.cpp
Following the grep command, the dependency list is then piped to a sed command that converts
full paths generated by the compiler to relative paths, but only if those paths were passed to the
compiler as relative paths. (This is only important if your make program does not support Windows
paths as dependencies.) Relative paths that the compiler has changed to absolute paths contain
"../" or "../.." in the path.
For example, if you added this include path to your project settings for a project named Car:
-I../../CarParts/src
The compiler would emit a rule similar to the following for an object file (CarTest.o) that depends
on Door.h in CarParts/src:
CarTest.o:
C:\Examples\MultiProjectCarApp\Car\Debug\src\../../CarParts/src/Door.h
The sed command would convert the path to:
CarTest.o: ../../CarParts/src/Door.h
Whereas if you specified the full path, as in:
-IC:\Examples\MultiProjectCarApp\CarParts\src
the compiler would emit this rule:
CarTest.o: C:\Examples\MultiProjectCarApp\Car\Debug\src\Door.h
and the sed command would not change it.
NOTE:
The make program provided by Msys already provides a make program that handles
Windows paths. Cygwin does not. However, the NSDEE installation media contains a version of
make
you can use with Cygwin that also works with Windows paths.
Handling dependencies in managed builds
53