TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Notes for new Make users

332 点作者 henry_flower大约 7 年前

20 条评论

dahart大约 7 年前
&gt; or you use special pattern rules<p>I used make for years before I understood pattern rules, even though they&#x27;re pretty simple. I kept trying to use foreach loops all over the place. If you&#x27;re using foreach loops, check whether a pattern rule can do the job.<p>&gt; The popular clamour is that the autovars are too short &amp; confusing.<p>I finally realized, after years of using make and then learning pattern rules, that the three autovars listed here are visual mnemonics. $@ looks like a target, a ring with a bullseye. $&lt; is pointing left, so it&#x27;s the first prereq. $^ is like a horizontal bracket that groups all prereqs.
评论 #16525769 未加载
评论 #16527481 未加载
评论 #16539799 未加载
gengen大约 7 年前
What I&#x27;ve always loved about Make and related tools is how directly they expose their fundamental concept in building artefacts: the DAG. I don&#x27;t do that much JS, but I&#x27;ve not found this kind of clarity in any of the JS frontend build tools I&#x27;ve used.<p>Honest question for the webpack power-users here.<p>What are some important webpack features that you lose by using a Makefile like this? Because it seems like pretty much every part of a regular webpack buildchain has a command-line equivalent that you could potentially use in a Makefile.
评论 #16524903 未加载
评论 #16524837 未加载
评论 #16526724 未加载
评论 #16527272 未加载
评论 #16528205 未加载
评论 #16524761 未加载
vortico大约 7 年前
Pretty spot on. I use a pretty similar dependency system for all of my C and C++ projects.<p><pre><code> FLAGS += -MMD CFLAGS += $(FLAGS) CXXFLAGS += $(FLAGS) OBJECTS += $(patsubst %, build&#x2F;%.o, $(SOURCES)) DEPS = $(patsubst %, build&#x2F;%.d, $(SOURCES)) $(TARGET): $(OBJECTS) $(CXX) -o $@ $^ $(LDFLAGS) -include $(DEPS) build&#x2F;%.c.o: %.c @mkdir -p $(@D) $(CC) $(CFLAGS) -c -o $@ $&lt; build&#x2F;%.cpp.o: %.cpp @mkdir -p $(@D) $(CXX) $(CXXFLAGS) -c -o $@ $&lt;</code></pre>
评论 #16527316 未加载
评论 #16525442 未加载
评论 #16527798 未加载
评论 #16527701 未加载
buserror大约 7 年前
The thing people miss a lot about makefile, apart from what has already been mentioned is the fact you can have &quot;local&quot; version of the &quot;global&quot; variables, per rules.<p>It&#x27;s very very powerfull, clear to read, and simplify all these if&#x2F;else&#x2F;end no end...<p>For example:<p><pre><code> CFLAGS = -std=gnu99 -Werror release&#x2F;%.elf: CFLAGS += -DRELEASE debug&#x2F;%.elf: CFLAGS += -DDEBUG </code></pre> Basically you can add your own context flags and variables for each individual targets, and they are &#x27;inherited&#x27; by any of their &#x2F;sub&#x2F; targets...<p>Oh, people also need to learn about VPATH or course [0]!<p>[0]: <a href="https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;make&#x2F;manual&#x2F;html_node&#x2F;General-Search.html" rel="nofollow">https:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;make&#x2F;manual&#x2F;html_node&#x2F;General-S...</a>
评论 #16528351 未加载
elsherbini大约 7 年前
I use snakemake[0] as a replacement for make. The debugging tools in snakemake are really good - it can output the DAG of your workflow as a dotfile, and you can add breakpoints and use pdb to debug your workflow. It also integrates really nicely with conda, so you can have different environments for different rules.<p>The killer feature of snakemake for me is that it can run a workflow on a single core or as many as you give it, or in the case of a cluster it can actually submit jobs to a queue and wait for them to finish before submitting more.<p>The tradeoff is that you need to install it (conda install -c bioconda snakemake), and that it can be very slow if you have thousands of target files. But for most workflows it&#x27;s the right tool for me.<p>[0] <a href="http:&#x2F;&#x2F;snakemake.readthedocs.io&#x2F;en&#x2F;stable&#x2F;" rel="nofollow">http:&#x2F;&#x2F;snakemake.readthedocs.io&#x2F;en&#x2F;stable&#x2F;</a>
评论 #16524773 未加载
ISL大约 7 年前
The point about the manual is a good one. It is well done.<p>When I made extensive use of Make for my graduate thesis, I bought the book and read the majority of the text.<p>The cover illustration brings me joy every time I see or think about it.
评论 #16524233 未加载
评论 #16524845 未加载
dblotsky大约 7 年前
This is so excellent. I was smiling as I read it. Thank you.<p>My personal favourite &quot;watcher&quot; implementation is this:<p><pre><code> while true; do make; sleep 0.5; done</code></pre>
评论 #16523739 未加载
评论 #16526496 未加载
评论 #16524714 未加载
评论 #16528266 未加载
LinXitoW大约 7 年前
In all these discussions about make, everyone argues about using it for everything. Personally, I don&#x27;t know another tool that makes it straight forward to glue together all kinds of different build tools (for example webpack for frontend and maven&#x2F;sbt for the backend).<p>Even if you don&#x27;t directly use make, it makes for great, verifiable documentation.
ejholmes大约 7 年前
&gt; Most important concept #1: DAG<p>Yes! Thank you! This needs to be banged into peoples heads when talking about build systems. Every time you add an edge, you&#x27;re automating an otherwise manual task. Very important realization.
jstimpfle大约 7 年前
I&#x27;ve been working on a small custom build system (of the &quot;re-editable&quot; kind) for my own software project, and have been working on a little writeup. It&#x27;s not finished, and I think there was something in the implementation that I was still unhappy about. But I&#x27;ll take this opportunity to jump on the bandwagon. I think for larger project it is worth it to just make your own system, so here are my notes: <a href="http:&#x2F;&#x2F;jstimpfle.de&#x2F;blah&#x2F;buildsystem.html" rel="nofollow">http:&#x2F;&#x2F;jstimpfle.de&#x2F;blah&#x2F;buildsystem.html</a>
lolikoisuru大约 7 年前
If you’re feeling mischievous, Make has divers ‘secret’ vars &amp; targets for you. For instance, you don’t have to ‘struggle’ w&#x2F; the ancient bash, for it’s possible to program recipes in any language that supports evaluations straight from the command line.<p>In addition you can have different shell for each rule with the rule specific macros if you do desire:<p>.ONESHELL:<p>.SILENT:<p>.PHONY: rule1<p>rule1: SHELL := &#x2F;usr&#x2F;bin&#x2F;python3<p>rule1:<p><pre><code> foo=bar print(&quot;python: {}&quot;.format(foo))</code></pre>
mahoro大约 7 年前
Great article.<p>Also, author prepared a surprice for all coming to his blog from russian IP addresses. That was the first time I came across such thing.
评论 #16525479 未加载
评论 #16528270 未加载
setheron大约 7 年前
Great guide. The variable portion was the first time it was explained succinctly and simply to me.
评论 #16528273 未加载
abhishekjha大约 7 年前
Wait. Did I read it wrong or didn&#x27;t an article a few days back say that we <i>can</i> use make with file names consisting of spaces, its just that we shouldn&#x27;t? Although that article talked about using a non-breaking space as a hack.
评论 #16527084 未加载
评论 #16528140 未加载
lolikoisuru大约 7 年前
One thing I sometimes wish was possible in make is using the automatic variables in the dependency part of the rules. The one that I most often have desired to use is $(@D) so I could depend on a file with specific name in the same directory when the directory name isn&#x27;t known beforehand. I got around this with some touch trickery but it would be just easier to read if those automatic variables were available at that point.
lolikoisuru大约 7 年前
&gt;When in doubt, don’t google until you read the official manual. It’s a document of an astonishing quality. Go print the pdf.<p>This applies to most GNU software.
ghettoimp大约 7 年前
The writing is so awful. “Some ppl will get overexcited &amp; start...”? “2fold”? Are we teenagers texting each other?
评论 #16528259 未加载
评论 #16527818 未加载
pspeter3大约 7 年前
Is it possible to have make use file hashes instead of timestamps?
评论 #16525821 未加载
评论 #16528276 未加载
vorotato大约 7 年前
The only reason I don&#x27;t use it is because I use windows. While you can theoretically use it on windows, nobody does.
评论 #16525373 未加载
评论 #16526329 未加载
andrewmcwatters大约 7 年前
The first point is &quot;Don’t try to be clever,&quot; and using Make in the JavaScript ecosystem defies exactly that to begin with.
评论 #16524124 未加载
评论 #16524795 未加载