Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuMake, how to force a phony target to run more than once?

my build system insists on executing make with all the targets in one call, so i get:

make clean test clean build

the second clean will just say "Nothing to be done for `clean'." even though it's added to the .PHONY target.

any way around that?

like image 667
gcb Avatar asked Dec 27 '22 09:12

gcb


1 Answers

Yuk! Do not do this. Do not rely on implicit ordering of targets—it changes completely when you use make -j. Make your ordering explicit. If you really must clean between builds, then something like:

.PHONY: everything
everything:
    ${MAKE} clean
    ${MAKE} test
    ${MAKE} clean
    ${MAKE} build

Again, the recursive make is rather smelly, but is your best option in this case.

like image 176
bobbogo Avatar answered Dec 31 '22 12:12

bobbogo