Philippe
Philippe

Reputation: 9762

Control the output of subcalls to `make`

I have a Makefile where one of the goals looks as follows:

task: $(foreach t,$(SUBDIRS),subtask_$t)

subtask_%:
        make -C $* subtask

In words, task runs the subtask goals defined in each Makefile found in the directories in the list $(SUBDIRS). By default, the output to the console is the combination of all outputs from the subtasks. Is there a way to simply output, e.g. $* SUCCESS or $* FAILED depending on the exit code?

I have tried using @make..., but this doesn't mask the output of the commands run from the other Makefiles.

Ideally, I would like to keep the sub-Makefiles unchanges, as I still occasionally want to use them directly and get the full output.

Upvotes: 0

Views: 347

Answers (1)

Timothy Brown
Timothy Brown

Reputation: 2280

One possible way would be to get each subtask make write it's output to it's own log file. As in:

subtask_%:
        make -C $* subtask 2>&1 > subtask/make.log

Upvotes: 1

Related Questions