Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Makefile: What does 'make $* clean' mean?

Tags:

makefile

I know what make clean does.

But what does make $* clean do?

I'm not able to find a clear explanation anywhere.

like image 947
padfoot Avatar asked Sep 06 '25 07:09

padfoot


1 Answers

As Ross says, we can't help because you haven't provided enough context. You need to provide at least the rule in which the make $* clean appears.

However, I'll guess it looks something like this:

%.xyz:
        make $* clean

Here, $* is an automatic variable which will expand to the stem of the target (the text matching the % in the pattern). So, if you invoke make foobar.xyz, this rule would invoke make foobar clean: it would run a sub-make, build the foobar target, then build the clean target.

I've not seen anything quite like the above, although I can think of reasons for doing it. Far more common would be if you mistyped the command and it really said make -C $* clean, giving a rule like this:

%.xyz:
        make -C $* clean

(note you should never use the static string make when invoking a sub-make; you should always use $(MAKE) or ${MAKE}). In this example running make foobar.xyz would run make -C foobar clean, which means change to the directory foobar and run the clean target there.

like image 128
MadScientist Avatar answered Sep 08 '25 21:09

MadScientist