i should probably learn how makefiles work some day
-
-
i should probably learn how makefiles work some day
@eniko make is kind of a mess, but very simple to learn, honestly
GNU make has a full manual online I've referenced frequently
the important bit to understand is that it is very based in traditional C building where each .c file is compiled into a .o file and then linked
so, it effectively does a topological/tree sort of dependencies where when you ask "make binary" it goes:
- is binary newer than its dependencies? (by file modification time?)
- are those dependencies newer than their dependencies?
- etc.
and then builds the stuff as necessary. it also lets you parallelise which is cool
the most complicated bit is "phony" targets where instead of an actual file, you say something like "make build" which always runs commands and/or builds dependencies
also, load-bearing tabs; space-indenting doesn't work
-
Wait. Is cmake make? Or are they different things
@eniko Different and bleh but better than automake.
Build tools are a mess each generation must create their own flavor of dissatisfaction that they get used toโyou know, like fashion.
-
Wait. Is cmake make? Or are they different things
@eniko cmake is really a bad name, it is very different from make. yea, as other comments said, it generates makefiles from a cmake definition, and does extra things like managing subprojects and stuff iirc
what really doesn't help is there is bmake, which is a make implementation from the BSD operating systems, and gnu make is often referred to as gmake, so it is a reasonable assumptions that cmake would also be a make implementation, but, yea, no
-
Wait. Is cmake make? Or are they different things
I looked into cmake a couple of times, but it seemed to bring so much complexity of its own.
I think it can make things easier (or at least quicker) when you want to pull in a ton of dependencies, which it can download & build for you.
My projects only have very few dependencies, so I just put in the time to write a versatile Makefile that works with all my projects.
How are you building your projects at the moment?
-
@eniko make is kind of a mess, but very simple to learn, honestly
GNU make has a full manual online I've referenced frequently
the important bit to understand is that it is very based in traditional C building where each .c file is compiled into a .o file and then linked
so, it effectively does a topological/tree sort of dependencies where when you ask "make binary" it goes:
- is binary newer than its dependencies? (by file modification time?)
- are those dependencies newer than their dependencies?
- etc.
and then builds the stuff as necessary. it also lets you parallelise which is cool
the most complicated bit is "phony" targets where instead of an actual file, you say something like "make build" which always runs commands and/or builds dependencies
also, load-bearing tabs; space-indenting doesn't work
@eniko also like, the reason why external systems like cmake exist is because, specifically for the purpose of making C code, plain make is a pain in the absolute ass
while header files make dependency lookup relatively easy, make does not do that, and so you either have to just force-rebuild parts if you modify a header file or manually list all dependencies and update them when they change
so, cmake will figure that out for you, and so will ninja, etc.
but makefiles are still really good in any build system, because if you have a way of outputting the dependency tree into a file and the right commands you can just have make figure out how to run and parallelise it for you
-
I looked into cmake a couple of times, but it seemed to bring so much complexity of its own.
I think it can make things easier (or at least quicker) when you want to pull in a ton of dependencies, which it can download & build for you.
My projects only have very few dependencies, so I just put in the time to write a versatile Makefile that works with all my projects.
How are you building your projects at the moment?
@duke_of_germany I use visual studio. Or a batch file. Or a shell script
-
Wait. Is cmake make? Or are they different things
- make is a build system: it builds your code
- cmake is a meta-build system: it builds your build systemWhich might seem confusing until you realize that build systems and compiler toolchains are often tied to specific operating systems. If you want to build portable code it helps to have something to abstract over them.
-
- make is a build system: it builds your code
- cmake is a meta-build system: it builds your build systemWhich might seem confusing until you realize that build systems and compiler toolchains are often tied to specific operating systems. If you want to build portable code it helps to have something to abstract over them.
@yosh @eniko That's a helpful taxonomy, yeah. I'm guessing that by thr same logic, autoconf and friends are metaโbuild systems? I'm also curious where task runners like just or do-runner (my own attempt) fit into the picture โ basically tools for keeping collections of tiny shell scripts.
I ask because make is a weird one to me in that it's both a build system and a task runner (thanks to .PHONY).
-
undefined oblomov@sociale.network shared this topic
-
@eniko I LOVE make! AMA.