Explicit dependencies on searched-for sources
Learn how to declare the searched-for source object as an explicit dependency in the makefile.
There are situations in which the configuration lookup algorithm that clearmake and omake use qualify a derived object, even though rebuilding the target would produce a different result. Configuration lookup requires that for each object listed in an existing CR, the current view must select the same version of that object. However, when search paths must be used to find an object, a target rebuild might use a different object than the one listed in the CR. Configuration lookup does not take this possibility into account.
When files are accessed by explicit path names, configuration lookup qualifies derived objects correctly. Configuration lookup might qualify a derived object incorrectly if files are accessed at build time by a search through multiple directories, for example, when the -I option to a C or C++ compiler specifies a header file or when the -L option to a linker specifies a library file. The following build script uses a search to locate a header file, fio.h:
hello.obj:
cl /c /I \projvob\privh /I \projvob\stdh hello.c
The command clearmake hello.obj might qualify an existing derived object built with C:\projvob\privh\fio.h, even though rebuilding the target would now use C:\projvob\stdh\fio.h instead.
omake and clearmake address this problem in the same way as some standard make implementations:
- You must declare the searched-for source object as an explicit dependency in the
makefile:
hello.obj: fio.h ...
- You must use the VPATH macro to specify the set of directories to be searched:
VPATH = \projvob\privh;projvob\stdh
Given this makefile, omake (or clearmake) uses the
VPATH (if any) when it performs configuration lookup on fio.h
. If a
candidate derived object was built with C:\projvob\privh\fio.h
, but
would be built with C:\projvob\stdh\fio.h
in the current view, the
candidate is rejected.
Build Tool Dependencies. You can use this mechanism to implement dependencies on build tools. For example, you can track the version of the C compiler used in a build as follows:
msg.obj: msg.c $(CC)
$(CC) /c msg.c
With this makefile, either your VPATH must include the directories on your search path,
or you must use a full path name as the $(CC)
value.