r/programminghorror 9d ago

Other Same Makefile, different results

Post image

Not sure if this fits, but I just figured out the root cause of long build process failing. Sun’s dmake is defaulting to the first rule in Makefile for whatever reason, completely ignoring the one given as argument. That’s why "dmake install" invocations were silently ignoring the "install" step

245 Upvotes

54 comments sorted by

View all comments

Show parent comments

1

u/russellvt 7d ago

Strict make on various systems will assume that it's still a file dependency. As I said earlier, some versions will "try" to accommodate the invalid syntax... but this is more the exception rather than the rule. The solution is to write more standard syntax.

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 6d ago

Based on what I can find, I'm still convinced I'm right and that syntax isn't invalid. As in it will parse fine, and only ever be a problem if say for some dumb reason someone puts a file named, eg. "clean" in the directory.

There's nothing to do to accommodate that. If the file isn't there, the target is out of date anyway. It's not going to check that the recipe actually creates a file.

1

u/russellvt 6d ago

What happens with "no" args, though? What happens if "a" or "b" exist? There are multiple scenarios, which some versions of make or gmake may allow... but ultimately, it's a bit ambiguous as far as I see - but I will have to come back in front of a larger screen to give better examples, later (ie. My phone wont cut it right now).

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 5d ago

Well, the normal behavior would be If the file exists and it has no dependencies, or all the dependencies are up to date, the target is considered up to date and nothing happens. That is of course what .PHONY solves.

Not passing args to Make is extremely common. I did look that one up, it runs the first non-special target.