This introduction neglects to mention that Makefile rules are primarily rules to derive files (usually from other files). Make will not re-run a rule when the target (file) generated by the rule is already up to date. From this perspective, a well structured Makefile can be thought of as a pipeline/graph of functions, that derive values (files) from previously known values (files). Expressing a build process in this…
This sounds nice, except that the only kinds of dependencies are files (e.g. variables are excluded), and the dependencies should be mentioned explicitly, or things get ugly, especially when using non-standard compilers/tools.
Make for hipsters
101–110 of 200 posts
Re: Make for hipsters
#102Pop make quiz: what is the difference between these two Makefiles? ---------------------------------------------------- foo: bar bar: ---------------------------------------------------- .PHONY: foo foo:
Re: Make for hipsters
#103Earlier quoted context omitted.
This sounds nice, except that the only kinds of dependencies are files (e.g. variables are excluded), and the dependencies should be mentioned explicitly, or things get ugly, especially when using non-standard compilers/tools.
No need to explicitly declare dependencies, you have wildcards and macros at hand to manage redundancy (1). If the compiler/program accepts a file and produces another, it can be used just as easily as the C compiler. My website uses awk, m4 and html-tidy on a pipeline to produce HTML, and with 45 lines of make (with about 10-15% whitespace) I build everything, with html-tidy being optional.
Re: Make for hipsters
#104Earlier quoted context omitted.
if your devs can't handle learning basic make, all is lost.
yeah, makes you wonder what kind of bubbles some of these developers are living in if they see Make as some magical relic from the past.
The "bubble" is "most people that never used C/C++" (because outside of there, make is pretty rare despite its usefulness), and even if you've used C/C++ you are not necessarily familiar enough with it to know how to properly use it or to realize you can use it as a general tool.
Why would you expect people to magically know about (and prefer to others) a tool that's almost never used in the ecosystems they touch, or only behind the scenes?
Re: Make for hipsters
#105Do so many people who go on this site not know how to make makefiles? Also why is it for hipsters? Or is the article for hipsters? Why does the author call his own published notes factually inaccurate? Why is it hacky to use a makefile? Is this all a big ruse?
Unfortunately, many developers have a mortal fear of anything from before the year 2000. They've grown up with this tribal wisdom of unix and it's various tools being a beardy wilderness of byzantine hacks and toxic waste dumps. Meanwhile they'll merrily pile up a thousand node modules into a towering pillar of bad, just to run the equivalent of a shell one-liner, and call it a job well done.
Tools that gain traction today are those that can be learned incrementally by doing a google search and copy pasting a solution, one problem at a time.
Out are all those systems that have an underlying theory to them that has to be mastered first. As pointed out elsewhere, there is a perfectly good manual for make[1] that you can read.
My theory is that it has to do with shortened attention spans, and impatience perhaps bred by constant use of technologies with short stimulus response cycles [2].
[1] https://www.gnu.org/software/make/manual/make.html#Introduct... [2] Cellphones.
Re: Make for hipsters
#106Earlier quoted context omitted.
Unfortunately, many developers have a mortal fear of anything from before the year 2000. They've grown up with this tribal wisdom of unix and it's various tools being a beardy wilderness of byzantine hacks and toxic waste dumps. Meanwhile they'll merrily pile up a thousand node modules into a towering pillar of bad, just to run the equivalent of a shell one-liner, and call it a job well done.
I think Make is also broadly associated with autotools, which surely can't help its public image.
Re: Make for hipsters
#107So there's that. Make being such a good idea and a popular standard, there's no shortage of people implementing not quite compatible make-like-systems.
Another fun tip is make your makefile executable and try the first line like
#!/usr/bin/env gmake
or whatever seems appropriate. Or perhaps GNU make is installed as "make" on your OS or you use an "alternatives" link farm or whatever. Some people will flip out if you put arguments on that command line, others will pat you on the back and high-five. So there's that "fun".
Re: Make for hipsters
#108Earlier quoted context omitted.
No need to explicitly declare dependencies, you have wildcards and macros at hand to manage redundancy (1). If the compiler/program accepts a file and produces another, it can be used just as easily as the C compiler. My website uses awk, m4 and html-tidy on a pipeline to produce HTML, and with 45 lines of make (with about 10-15% whitespace) I build everything, with html-tidy being optional.
But some languages allow an "#include / import" construct. You'll have to somehow walk all those dependencies and convert them into something Make understands.
Of course you need to convert those externally -- with e.g. the C preprocessor for C files...
Re: Make for hipsters
#109Earlier quoted context omitted.
I think these days you're better off using -MMD to generate header dependencies at the same time as compiling, rather than doing it in a separate rule. %.o: %.c $(CC) $(CFLAGS) -MMD -c $
Is this always correct? The %.d files don't depend explicitly on the %.c files so they aren't rebuilt every time at the beginning of the make run, so old dependencies are included after a change in header dependencies. I'm still trying to construct an example where such a makefile breaks though.
Also specify -MP on the GCC command line, which causes GCC to emit an empty rule for all the header files, like this:
foo.o: foo.c foo.h bar.h
foo.h:
bar.h:
Alternatively, you can write a generic empty header creation rule: %.h:
Which has the same effect.Re: Make for hipsters
#110Do so many people who go on this site not know how to make makefiles? Also why is it for hipsters? Or is the article for hipsters? Why does the author call his own published notes factually inaccurate? Why is it hacky to use a makefile? Is this all a big ruse?
You'd be surprised. Especially if they work outside C/C++, and do e.g. mostly web development, they neither care much, not know much about makefiles. At best the know to configure, make and make install something on their Linux, but most haven't even tried that.
>Also why is it for hipsters? Or is the article for hipsters?
The article is (supposedly) for hipsters. You seem a little challenged keeping with the latest "culture" (ain't we all), so let me explain.
What he means is that the article is not for seasoned veterans, or unfashionable people who delve in the old-fashioned word of GNU-tools and Make, but for "hipsters", e.g. the new-ish, young-ish developers, usually working with hip languages (and especially web, scripting, etc.), that are not rooted and well versed in the UNIX traditions.
>Why does the author call his own published notes factually inaccurate? Why is it hacky to use a makefile?
It's just a funny wording for the author to convey:
"I'm not a complete authority on Make and Make best practices, I'll just tell you what I know from experience about it. And I expect some Make-gurus to try yell at me about my suggestions being inaccurate/hacky etc, so I try to pre-empt them with this warning".