GNU Make Standard Library
6 comments
·February 5, 2025t43562
bandrami
GNU Make also embeds GNU Guile, a criminally underused feature:
https://www.gnu.org/software/make/manual/html_node/Guile-Int...
throwfgtpwd234
OP FYI: US copyright law doesn't recognize or require a range of years, only the date of first publication. Many organizations have decided to omit (the) year(s) altogether. https://blog.ntpsec.org/2020/02/15/copyright-year.html
jgrahamc
I guess this is here because it's been 20 years and I blogged about it on Monday: https://blog.jgc.org/2025/02/twenty-years-of-gnu-make-standa...
p4bl0
Okay who will be doing this year's Advent of Code in GNU Make?
shakna
I wonder how thread-safe the memoisation and/or ALists are? Make's version of parralel processing is a very fun little thing, but has a few quirks around recursion limits that can bite you when going off the beaten path.
[0] https://www.gnu.org/software/make/manual/html_node/Options_0...
GNU make now has a load directive which lets you load up functions written in C
Your makefile can contain instructions to build my_module.o and they will be automatically triggered.For example you can create an equality test that works in an expression (ifeq can't be used as part of an expression obviously). For example
The C for this function (without includes and export directives): This can be done with a macro but it's ugly and verbose. Macros also slow makefile parsing a lot and for a large build like e.g. an operating system this makes a big difference - it's a penalty you pay every time you run "make" even if you only changed 1 file.There are plenty of things you cannot do with macros too. $(shell) is a getout card but it drastically slows down large makefiles.
Your module has a setup function which gets called when it's loaded and this adds the function into gmake:
Things that are hard/slow to do with macros like arithmetic - comparing, adding and so on are even better candidates. A hash function is great for generating intermediate target names that aren't too long for the filesystem.My favorite one that I've done is embedding a python interpreter into make - this is very convenient as it's MUCH faster than running a process from $(shell) and it keeps state between uses which can be useful.