This rediscovery essentially derailed one of my side projects as I started writing a pure GNU Make build system and function library like this one:
https://www.cmcrossroads.com/article/gnu-make-standard-libra...
I even asked this author on Twitter and Stack Overflow about its implementation.
The end result was reinvention of code generation tools because that's what metaprogramming is. I didn't understand what autotools was doing before I tried doing it myself. My objective was to eliminate makefile regeneration whenever project structure changed, I ended up regenerating code 100% of the time and evaluating the resulting code inside the makefile itself. If we must metaprogram, it's better to do it in a proper programming language. At least it didn't have any dependencies other than GNU Make.
My find function has been the single most useful thing to come out of my side project. The first thing I do in my makefiles is get a list of all source files and it's always been annoying because I like organizing my project in trees which requires recursive file system walks. I managed to write a pure GNU Make function that simplifies that to:
sources := $(call find,src,file?)
The find function recursively walks the src directory and returns a list of all paths satisfying the file? predicate function.I think it would be a nice addition to GMSL. In my project, I doubt it will ever help anyone.
One of these days I'll get it off SourceForge...
Is your find function a bit like my rwildcard? https://news.ycombinator.com/item?id=23270235
I think my function is needlessly complicated compared to rwildcard. Here's my code:
https://github.com/matheusmoreira/liblinux/blob/modular-buil...
https://github.com/matheusmoreira/liblinux/blob/modular-buil...
The file? and directory? functions were inspired by GMSL. I think I learned how to check whether a path is a directory from one of your posts.
I wrote a general recursion function. It takes a function to apply to lists and a function to compute whether an element is a base case.
The recursive file system traversal function applies a directory globbing function to the list of paths and has file? as base case. It returns all files without filtering.
The find function recursively traverses the file system while filtering out all items not matching the given predicate function. It was my intention to provide predicates like c_file? and header_file? but I stopped developing that project before that happened. Users can easily write their own predicates too.
I think rwildcard is probably simpler and more efficient! If my code helps in any way though, feel free to use it.
I guess you can commit the generated makefile into your repo so that those who want to build your project from sources don't need your custom build tool installed, only make...
# $FreeBSD$
PACKAGE=runtime PROG= setfacl SRCS= file.c mask.c merge.c remove.c setfacl.c util.c
.include <bsd.prog.mk>
So, yeah, at least for code in C you can have something maintainable in make(1), it’s just you need to structure your project in a sensible way.
2. It doesn’t, it’s programmers job to make an effort to append a file name to a single line in a single file.
3. It’s portable in the same way autotools are portable, which means you can make it work with relative ease.
You can certainly do everything in one system. In practice this seems to lead to a build process that is much slower than it needs to be, see for instance Scons.
What about these projects?
…but I dont, not because it’s impossible to do but because the effort in maintaining those is high.
Come on, are you serious? Hand crafted makefiles? Have you actually tried to maintain one of those? That redis makefile has a explicitly coded set of object files. Can you imagine trying to maintain that for opencv?
I’m just too damn lazy to waste my time maintaining that kind of stuff; it’s a pointless, thankless task… but hey, I’ll give it to you; there are people out there who prefer to do it that way.
I posit, they spend more time maintaining their build system then they would prefer, but they keep make for ideological reasons, not practical ones.
Linux kernel provides "makefile" as interface for you, but it's mostly compiled from a custom KBuild system.
So what is your solution for building large projects?
…but, it was a fad, and it faded, because make is not fine, in any non-trivial incarnation.
Yep, sure. A little script for your projects that only you care about and runs on your machine… go for. I’m fond of make for trivial purposes, it’s easy to remember, it’s widely installed.
…but, make doesn’t scale; the only way to scale make is to generate your makefiles programmatically; once you do this, your makefiles are no longer makefiles, they’re arcane generated non-portable custom build scripts.
Various tools do this; autotools, cmake, etc.
Sure, those are tools which are can use if you want, but the elegance and joy of using make vanishes once you use them; you are no longer using make, you are now using a different tool.
…so, I have mixed feelings about posts like this. On the one hand, that’s cool; but on the other, you’re really wasting your time learning this stuff because, realistically, you’ll never use it. By the time you need it, you’ll be using a meta tool that generates human-unreadable Makefiles for you.
Related, extensive thread: https://news.ycombinator.com/item?id=5275313