summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorDmitry Goncharov <dgoncharov@users.sf.net>2021-10-02 15:19:15 -0400
committerPaul Smith <psmith@gnu.org>2021-10-17 19:08:16 -0400
commitf5af979357f10e3c2dd1fc5e483d52928c7cf6ec (patch)
tree66b6fe7394df2468e919de48b04b1eef0813a133 /doc
parent76cb18673216f9a7089584b4f3831befa2a4d559 (diff)
downloadmake-git-f5af979357f10e3c2dd1fc5e483d52928c7cf6ec.tar.gz
* doc/make.texi (Special Targets): [SV 61122] Add .SECONDARY example
Diffstat (limited to 'doc')
-rw-r--r--doc/make.texi24
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/make.texi b/doc/make.texi
index 53648b0a..5eea2a94 100644
--- a/doc/make.texi
+++ b/doc/make.texi
@@ -3031,6 +3031,30 @@ The targets which @code{.SECONDARY} depends on are treated as
intermediate files, except that they are never automatically deleted.
@xref{Chained Rules, ,Chains of Implicit Rules}.
+@code{.SECONDARY} can be used to avoid redundant rebuilds in some unusual
+situations. For example:
+
+@example
+@group
+hello.bin: hello.o bye.o
+ $(CC) -o $@@ $^
+
+%.o: %.c
+ $(CC) -c -o $@@ $<
+
+.SECONDARY: hello.o bye.o
+@end group
+@end example
+
+Suppose @file{hello.bin} is up to date in regards to the source files,
+@emph{but} the object file @file{hello.o} is missing. Without
+@code{.SECONDARY} make would rebuild @file{hello.o} then rebuild
+@file{hello.bin} even though the source files had not changed. By declaring
+@file{hello.o} as @code{.SECONDARY} @code{make} will not need to rebuild it
+and won't need to rebuild @file{hello.bin} either. Of course, of one of the
+source files @emph{were} updated then all object files would be rebuilt so
+that the creation of @file{hello.bin} could succeed.
+
@code{.SECONDARY} with no prerequisites causes all targets to be treated
as secondary (i.e., no target is removed because it is considered
intermediate).