This is what order-only prerequisites/dependencies are for:
Occasionally, however, you have a situation where you want to impose a specific ordering on the rules to be invoked without forcing the target to be updated if one of those rules is executed. In that case, you want to define order-only prerequisites. Order-only prerequisites can be specified by placing a pipe symbol (
|
) in the prerequisites list: any prerequisites to the left of the pipe symbol are normal; any prerequisites to the right are order-only.
In your case:
examples/%.h : | %.h
cp $| $@
See also: Order-only prerequisites do not show up in $^
or $+
.