GnuMake how to make fake target run more than once?

my build system insists on running make with all targets in one call, so I get:

make clean test clean build

the second net will simply say, “Nothing needs to be done for“ pure. ”even if it is added to the target .PHONY.

is there any way around this?

+3


source to share


2 answers


Yuk! Do not do it. Don't rely on implicit target ordering - it changes completely when you use make -j

. Make your order explicit. If you really have to clean between assemblies, then something like:

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

      



Again, recursive make is pretty smelly, but your best bet in this case.

+3


source


I checked it out. Try the following:

test: ...
    ...

build: ...
    ...

clean%: ...
    ...

      

Then you can call:



make clean1 test clean2 build

      

It looks like if the target name is different, even if it hits the same target pattern, it will restart it.

+4


source







All Articles