sources := foo.c bar.c baz.s abc.h
foo: $(sources)
gcc $(filter %.c %.s,$(sources)) -o foo
says that foo depends of foo.c、bar.c、baz.s and ugh.h but only foo.c、bar.c and baz.s should be specified in the command to the compiler.
过滤出.c和.s 参加编译。 objects := main1.o foo.o main2.o bar.o
mains := main1.o main2.o
the following generates a list which contains all the object files not in ‘mains’:
$(filter-out $(mains),$(objects))
实现了去除变量“objects”中“mains”定义的字串(文件名)功能。它的返回值为“foo.o bar.o”。