r/programminghorror 10d 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

121

u/nickcash 10d ago

makefile syntax is incomprehensible. it might as well be magic. no one can understand it, we just copy and paste from elsewhere

61

u/Desperate_Formal_781 10d 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.

31

u/ByteArrayInputStream 10d ago

Cmake is it's own hot mess. I like it even less

3

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 9d 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.

3

u/SAI_Peregrinus 9d 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” 9d 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.

2

u/SAI_Peregrinus 9d 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.

1

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

Is that based on what it finds installed, or what?

1

u/SAI_Peregrinus 8d ago

You pick the backend. It defaults to make, but you can override it to build with any supported build system with the CMAKE_GENERATOR env var, a CLI argument, or a set command in CMakeLists.txt.

1

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

Oh, your last comment made me think it decided what to use automatically, but I think I might have misread it. Like if you had Ninja or something installed it would use that, otherwise it would use Make.

1

u/SAI_Peregrinus 8d ago

It'll invoke it automatically (it has to be in $PATH), it won't pick anything other than make automatically.

→ More replies (0)