any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^) please give me an example based on this command
时间: 2023-09-04 19:07:13 浏览: 148
filter 简单小例子,入门例子
Sure, here's an example:
Let's say you have a Makefile with two targets, `main` and `test`, and the following dependencies:
```
main: file1.o file2.o
test: file1.o file3.o
```
You can use the `any-prereq` command to pass all dependencies to the `clean` target as follows:
```
clean:
rm -f $(any-prereq)
```
Now, when you run `make clean`, it will remove all the object files (`file1.o`, `file2.o`, and `file3.o`) because they are dependencies of either `main` or `test`.
Note that if you have any PHONY targets (i.e., targets that don't produce files), they will be filtered out by the `$(filter-out $(PHONY),$?)` part of the command.
阅读全文