|
|||
Dynamic Dependency ScanFeature DescriptionThe capability to determine the implicit dependencies between files, typically between source and header files. Built-in rules are provided for scanning many languages (C, C++, Fortran, ESQL/C, nroff/troff, and others). Users can define new scan strategies for other languages. ImpactProductivity
Build Accuracy
Consequence of Not Having the Feature
Examples
The following files are used in this example.
/*** ./Makefile ****/ .SOURCE.h : include0 include1 include2 include3 include4 include5 abc :: a.c
/*** ./a.c ***/
#include "a.h"
int main() {
printf("abc\n");
return(0);
}
/*** include1/a.h ***/ #include "b.h" /*** include2/b.h ***/ #include "c.h" /*** include3/c.h ***/ #include <stdio.h>
The first example illustrates that nmake scans the source code, locates
the necessary include files and constructs the proper $ nmake + cc -O -Iinclude1 -Iinclude2 -Iinclude3 -I- -c a.c + cc -O -o abc a.o
If one of the include files is updated nmake will recompile the target.
We will use the nmake $ touch include2/b.h $ nmake -e include2/b.h [Aug 21 13:38:18 2003] has changed [Aug 21 13:37:45 2003] . [Aug 21 13:38:13 2003] has changed [Aug 21 13:38:08 2003] + cc -O -Iinclude1 -Iinclude2 -Iinclude3 -I- -c a.c + cc -O -o abc a.o
We can add another header file and it will be picked up automatically
with no makefile change. /*** c.h ***/ #include $ nmake -e include3/c.h [Aug 21 14:07:02 2003] has changed [Aug 21 14:06:32 2003] include3/c.h prerequisite include4/d.h added or re-ordered include4/d.h [Aug 21 14:05:17 2003] has no previous state . [Aug 21 14:06:50 2003] has changed [Aug 21 14:06:45 2003] + cc -O -Iinclude1 -Iinclude2 -Iinclude3 -Iinclude4 -I- -c a.c + cc -O -o abc a.o
Finally, instead of compiling the target we will use a different makefile
to show a list of the implicit include files.
/*** ./Makefile ***/
.SOURCE.h : include0 include1 include2 include3 include4 include5
abc : a.c
: $(!)
$ nmake + : a.c include1/a.h include2/b.h include3/c.h include4/d.h /usr/inclu de/stdio.h /usr/include/sys/va_list.h /usr/include/sys/feature_tests.h Example using standard make toolThe following uses the standard make tool to build the same code. Notice the makefile is much more complicated and verbose.
First we'll build without the additional
##### ./makefile #####
CFLAGS = -O -Iinclude1 -Iinclude2 -Iinclude3 -Iinclude4
abc : a.o
cc $(CFLAGS) -o abc a.o
a.o : a.c include1/a.h include2/b.h include3/c.h \
/usr/include/stdio.h /usr/include/sys/va_list.h \
/usr/include/sys/feature_tests.h
$ make cc -O -Iinclude1 -Iinclude2 -Iinclude3 -Iinclude4 -c a.c cc -O -Iinclude1 -Iinclude2 -Iinclude3 -Iinclude4 -o abc a.o $ touch include2/b.h $ make cc -O -Iinclude1 -Iinclude2 -Iinclude3 -c a.c cc -O -Iinclude1 -Iinclude2 -Iinclude3 -o abc a.o
When $ make cc -O -Iinclude1 -Iinclude2 -Iinclude3 -Iinclude4 -c a.c cc -O -Iinclude1 -Iinclude2 -Iinclude3 -Iinclude4 -o abc a.o $ touch include4/d.h $ make `abc' is up to date. Oops, let's update the makefile.
##### ./makefile #####
CFLAGS = -O -Iinclude1 -Iinclude2 -Iinclude3 -Iinclude4
abc : a.o
cc $(CFLAGS) -o abc a.o
a.o : a.c include1/a.h include2/b.h include3/c.h include4/d.h \
/usr/include/stdio.h /usr/include/sys/va_list.h \
/usr/include/sys/feature_tests.h
$ make cc -O -Iinclude1 -Iinclude2 -Iinclude3 -Iinclude4 -c a.c cc -O -Iinclude1 -Iinclude2 -Iinclude3 -Iinclude4 -o abc a.o $ touch include4/d.h $ make cc -O -Iinclude1 -Iinclude2 -Iinclude3 -Iinclude4 -c a.c cc -O -Iinclude1 -Iinclude2 -Iinclude3 -Iinclude4 -o abc a.o Last Update: Wednesday,20-Dec-06 13:22:02 CST
|
|||