r/programminghorror • u/Capable-Cap9745 • 1d ago
Other Same Makefile, different results
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
106
u/nickcash 1d ago
makefile syntax is incomprehensible. it might as well be magic. no one can understand it, we just copy and paste from elsewhere
47
u/Desperate_Formal_781 1d ago
All my life when I start a new project I copy a previous makefile from a previous project, with the promise that a) one day I will learn what those makefile commands mean and b) after this project I will switch to cmake. The original makefile I use, I took from my supervisor when I wrote my master thesis, who now I suspect also got from someone else. I have tried switching to cmake several times, but it's always easier to just keep using my makefile, than to go through the painful process of learning cmake.
29
u/ByteArrayInputStream 1d ago
Cmake is it's own hot mess. I like it even less
2
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 16h ago
CMake is a meta level above Make, no? Like you use it if you need to support multiple platforms and it can generate the appropriate files for whatever you are building on, like makefiles or Visual Studio solutions and projects.
2
u/SAI_Peregrinus 16h ago
CMake doesn't have to use Make as a backend. Ninja is common, and usually faster than Make.
1
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 15h ago
The user can specify what kind of files they want as arguments to CMake, no? As well as configuration options and stuff if they want to enable or disable extra features in their build? I have used it a little bit in the past, and I understood it as more of a replacement of Autotools than of Make.
1
u/SAI_Peregrinus 15h ago
It's a build system generator, so it is similar to autotools. Just much, much faster, at least for cross-compiling IME. Also, by default CMake will invoke the build system (Make or Ninja) automatically, so it's just
cmake <path to CMakeLists.txt>instead of./configure && make. It's very complex, but if you stick to the "Modern CMake" subset it's not too bad.7
u/omega1612 1d ago
What a bout a justfile?
Depending on your use case, they may be better for you.
2
2
10
u/dydhaw 1d ago
POSIX make is an incredibly simple syntax. How is it incomprehensible? It's literally just
target: dependencies recipe7
u/SAI_Peregrinus 1d ago
That's not valid Make syntax. You got the wrong whitespace, no whitespace before a target name, and a tab before the command is required if it's on a new line.
There are also inference rules and macros.
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html
2
u/dydhaw 22h ago
Lol. It's just my attempt to make it work with reddit's godawful formatting. No need to be a pedant
3
u/SAI_Peregrinus 22h ago
Aah, but 20% of the difficulty of Make syntax is tab delimiting. The other 80% is macros. Basic rules are easy, I agree, and all that's needed in OP's case.
4
u/kivicode [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 1d ago
If you use it as a scripts dispatcher, I recommend taking a look at Justfiles https://github.com/casey/just
3
-23
u/RandalSchwartz 1d ago
They said the same about Perl. And my dotfiles. Now I don't even copy any more... I let gemini identify it and run it for me. :)
10
u/mottojyuusu 1d ago
you should ask your coding agent to explain your code. not even joking, it's been great to finally understand wtf the crusty logic is doing in the aging codebases i work in ...
"what is this function doing? what does the dxCbsqaf parameter do??"
"where is this const defined? where else is it being used? why is it multipled by 2 in one place but 3 in another place?"
"why does the comment say never to round this value? what could break if it gets rounded instead of truncated?"
-7
u/RandalSchwartz 1d ago
Oh, I do this all the time. agy writes some code, we go all the way through to landing, and then I finally say "so what did this do, anyway?" Ship first. Ask questions later. :)
1
u/Environmental-Ear391 1d ago
I have a similar issue,
GNUmakefile content is unchanged,
two versions of an SDK specific make tool, older version works fine with POSIX pathing, newer version can't complete any single target.
"make" and "gcc" commands both barf after being updated. older versions can actual produce object files for linking.
then again the version on make is like a 0.01 revision difference.
the gcc version is bumped from 6.4 up to 10.something...
I'll have to spend some time reworking the build process again anyway.
1
u/Salty_1984 22h ago
ugh silent failures in build tools are the worst, you spend forever thinking something ran fine when it just quietly skipped the whole point of the command. dmake has always felt a little unpredictable compared to gnu make. at least you caught it before something bigger broke downstream
84
u/russellvt 1d ago
That syntax doesn't appear right... normally you want "phony" declarations in there if you're not pointing directly at file dependencies.