News for hackers. Stuff that matters.
Re:Learn Makefiles with the Tastiest Examples by paulddraper on Tuesday May 16, 2023 @01:42AM (#35958090)
FYI if you care to, you can prevent `make clean test` by looking at `$(MAKECMDGOALS)`.
Re:Learn Makefiles with the Tastiest Examples by Groxx on Tuesday May 16, 2023 @01:58PM (#35965406)
I have some copypasta that I stick in every makefile that has too many people abusing it blindly, yeah. It works but it's a real pain that there isn't a standard way to do it.

Which is an immediate consequence of make being built to make things, not run tasks. So it goes.

Re:Learn Makefiles with the Tastiest Examples by radiospiel on Wednesday May 17, 2023 @05:31AM (#35973024)
What's the problem with "make clean test"? A test target would have a test-build prerequisite anyways, so

- clean out build artefacts - rebuild test builds - run tests

sounds very much ok to me.

Re:Learn Makefiles with the Tastiest Examples by Groxx on Thursday May 18, 2023 @02:30PM (#35992150)
One obvious problem is that that isn't what `make clean test` does.

Order isn't guaranteed, and most clean targets won't have any dependency relationship with test targets, so it could test and then clean. Or interleave them (clean between test dependencies). Or run them both simultaneously if someone has set the -j flag, and then who knows what happens.

Other than that, make's behavior when a target updates dependencies of another target which do not share dependencies can get extremely complicated, and often depends on execution order. Clean generally affects many/most, so it's sometimes very problematic to run with any other.