foo : $(objects)
cc -o foo $(CFLAGS) $(objects)
The value of objects is the actual string ‘*.o’. Wildcard expansion happens in the rule for ‘foo’, so that each existing ‘.o’ file becomes a dependency of ‘foo’ and will be recompiled if necessary. But what if you delete all the ‘.o’ files? When a wildcard matches no files, it is left as it is, so then ‘foo’ will depend on the oddly-named file ‘*.o’. Since no such file is likely to exist, make will give you an error saying it cannot figure out how to make ‘*.o’. This is not what you want! Actually it is possible to obtain the desired result with wildcard expansion, but you need more sophisticated techniques, including the wildcard function and string substitution. These are described in The function, wildcard.