简体   繁体   中英

Makefile match any target / task

I want to write a makefile that can be run with any task and just echo all the task names.
Is there any way to do this?

Like:

%.%: 
    echo "$@"

Assuming that your make is GNU make or alike, use the following Makefile:

.PHONY: all

%:
       @echo "Here I am! $@"

See the result:

> make first
Here I am! first
> make second
Here I am! second
> make first second
Here I am! first
Here I am! second

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM