r/programminghorror • • Jul 26 '26

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

251 Upvotes

54 comments sorted by

View all comments

Show parent comment

14

u/SAI_Peregrinus Jul 27 '26

I think it's allowed to consider an missing target file as an invalid target and run the default target.

https://pubs.opengroup.org/onlinepubs/9799919799/

target_name Target names, as defined in the EXTENDED DESCRIPTION section. If no target is specified, while make is processing the makefiles, the first target that make encounters that is not a special target or an inference rule shall be used.

Not certain, but it's POSIX so the most perverse possible interpretation of the rules existing somewhere is practically required.

8

u/UnluckyDouble Jul 27 '26

I believe that at times like this we should consider the wise words of Linus:

"Sun, you can't beat me, you just can't. Stop trying, give up. I'm serious, I am going to kick the living shit out of you, lights out, game over."

1

u/shponglespore Jul 27 '26

Typical Linus, starting a fight with the sun.

2

u/dydhaw Jul 27 '26

What you cited is just the default target rule that happens when you run make with no target, nothing to do with missing target files

4

u/SAI_Peregrinus Jul 27 '26

As far as I can tell POSIX does not specify the behavior when a target file is missing. Leaving behavior unspecified usually means it differed between implementations when POSIX was written, since POSIX is an attempt to standardize the common subset of behaviors shared by UNIX systems.

Sun probably decided to treat a missing target file the same as a missing target specifier, and since SunOS (1982) predates POSIX (1988) that decision got implicitly allowed in the POSIX specifications.

3

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Jul 27 '26

Okay, say the target name is the executable you want to build. It doesn't exist currently. With dmake, do you have to touch it to create an empty file with the name first to get it to actually build or something completely stupid like that?

1

u/SAI_Peregrinus Jul 27 '26

Never used dmake. Just as far as I can tell, that behavior is allowed by POSIX. It'd be dumb, but it's hardly the only dumb thing in the POSIX standard.

2

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Jul 27 '26

It looks like you just linked to the start of the POSIX spec. I have no idea how to find what you quoted. But anyway, what you quoted says it will do that if a target isn't specified. Unless that isn't the right syntax for dmake, then a target is specified.

1

u/SAI_Peregrinus Jul 27 '26

Select volume, shells & utilities, utilities, make. I think https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html should be correct.

1

u/SAI_Peregrinus Jul 27 '26

Select volume, shells & utilities, utilities, make. I think https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html should be correct for the iframe content of just the Make specification.

1

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo "You live" Jul 27 '26

Looks like a manpage.

1

u/SAI_Peregrinus Jul 27 '26

It's the specification of what POSIX v8 compatible make tools must support. They may support extensions, but that page specifies the minimum.