6 ms·
Any good resources for learning about make files that you can recommend?
by trendoid 7y ago
Any good resources for learning about make files that you can recommend?
- gilmi 7y agoMatt Might's article is really good: http://matt.might.net/articles/intro-to-make/ http://matt.might.net/articles/intro-to-make/
- messe 7y agoWorth noting that that's an introduction to GNU make, which, while the most common implementation, isn't the only one out there.
- antipaul 7y agohttps://github.com/pavopax/gists/blob/master/makefile-quick-start.md https://github.com/pavopax/gists/blob/master/makefile-quick-...
- ashton314 7y agoThis video helped me: https://www.youtube.com/watch?v=fkEz_oVh0B4 https://www.youtube.com/watch?v=fkEz_oVh0B4
- aequitas 7y agoThis is a nice video. The only thing I'm missing that should be covered imho (as you will encounter it even if you don't use it) is implicit/pattern rules: https://www.gnu.org/software/make/manual/html_node/Pattern-Rules.html#Pattern-Rules https://www.gnu.org/software/make/manual/html_node/Pattern-R...
- deng 7y agoThe GNU Make manual is excellent. For learning advanced techniques: "The GNU Make Book" by John Graham-Cumming.
- aequitas 7y agoI don't really know a good all in manual, most thing about Make I learned over years of using it from different sources. And I still sometimes discover new features (and new ones are still added in recent release, but I tend to avoid them to keep Makefiles compatible on older systems). But the Make manual is pretty comprehensive as a guide and reference: https://www.gnu.org/software/make/manual/make.html https://www.gnu.org/software/make/manual/make.html Also (as with most things) knowing what name some concept has makes it easy to search for references. For example the terminology of rules (target, prerequisite, recipe): https://www.gnu.org/software/make/manual/make.html#Rule-Syntax https://www.gnu.org/software/make/manual/make.html#Rule-Synt... Things I tend to google often because I forget and some are used more often than others are: automatic variables, implicit rules, conditionals and functions. One trick that really helps making Make complete is making your own pseudo state files and understanding the dependency system. One of the best features of Make is its dependency resolving. You generally write rules because you want a target (a file or directory) to be created, based on prerequisites (dependencies) according to a recipe (shell scripts). Make figures out that if the prerequisites didn't change, it doesn't need to run the recipe again and it will reuse the target. Greatly saving on build time. Because Make relies on file timestamps to do its dependency resolving magic if you don't have a file there is not much Make can do. So what you can do instead is create a pseudo target output yourself. For example: https://github.com/aequitas/macos-menubar-wireguard/blob/master/Makefile#L34-L38 https://github.com/aequitas/macos-menubar-wireguard/blob/mas... Here a linter check is run which creates no output. So instead a hidden file .check is created as target. Whenever the sources change the target is invalidated and Make will run this recipe again updating the timestamp of .check. Also note the prerequisites behind the pipe (order-only prerequisites). These don't count toward the timestamp checking, but only need to be there. Ideal for environment dependencies, like in this case the presence of the swiftlint executable.
- snaky 7y ago"GNU Make Book" by John Graham-Cumming https://nostarch.com/gnumake https://nostarch.com/gnumake