Wildcards are also useful
in the dependencies of a rule. With the following rule in the makefile,
‘make print’
will print all the ‘.c’
files that have changed since the last time you printed them:
This rule uses ‘print’ as an empty target file; see Empty target files to record events. (The automatic variable, ‘$?’, is used to print only those files that have changed; see Automatic variables.) Wildcard expansion does not happen when you define a variable. Thus, if you write objects = *.o, then the value of the variable objects is the actual string ‘*.o’. However, if you use the value of objects in a target, dependency or command, wildcard expansion will take place at that time. To set objects to the expansion, instead use: objects := $(wildcard *.o). See The function, wildcard.