makefile

One target equivalent to many targets


Is it possible to have a target in a Makefile that is equivalent to several other targets, without listing them explicity? Something like:

all: task-*

task-name1:
    do something
task-name2:
    do something else
...
task-name(a big number):
    do yet something else

The tasks may be very different and are specified one by one, but I want to make them all by just typing make. Since there is no systematics in the names, keeping an explicit list of all targets is tedious.


Solution

  • There's nothing like this available from make itself.

    If you were willing to adhere to some naming conventions, you can search your makefile yourself with something like this:

    ALL_TASKS := $(sort $(shell sed -n 's/^ *\(task-[^:]*\):.*/\1/p' Makefile))
    
    all: $(ALL_TASKS)