make: Avoiding Compilation
1
1 9.4 Avoiding Recompilation of Some Files
1 ========================================
1
1 Sometimes you may have changed a source file but you do not want to
1 recompile all the files that depend on it. For example, suppose you add
1 a macro or a declaration to a header file that many other files depend
1 on. Being conservative, 'make' assumes that any change in the header
1 file requires recompilation of all dependent files, but you know that
1 they do not need to be recompiled and you would rather not waste the
1 time waiting for them to compile.
1
1 If you anticipate the problem before changing the header file, you
1 can use the '-t' flag. This flag tells 'make' not to run the recipes in
1 the rules, but rather to mark the target up to date by changing its
1 last-modification date. You would follow this procedure:
1
1 1. Use the command 'make' to recompile the source files that really
1 need recompilation, ensuring that the object files are up-to-date
1 before you begin.
1
1 2. Make the changes in the header files.
1
1 3. Use the command 'make -t' to mark all the object files as up to
1 date. The next time you run 'make', the changes in the header
1 files will not cause any recompilation.
1
1 If you have already changed the header file at a time when some files
1 do need recompilation, it is too late to do this. Instead, you can use
11 the '-o FILE' flag, which marks a specified file as "old" (⇒Summary
of Options Options Summary.). This means that the file itself will not
1 be remade, and nothing else will be remade on its account. Follow this
1 procedure:
1
1 1. Recompile the source files that need compilation for reasons
1 independent of the particular header file, with 'make -o
1 HEADERFILE'. If several header files are involved, use a separate
1 '-o' option for each header file.
1
1 2. Touch all the object files with 'make -t'.
1