Live data from Hacker News

Make for hipsters

mattandre.ws

11–20 of 200 posts

Re: Make for hipsters

#12

Here's a more in-depth and easy to read guide for beginners: http://www.computerhope.com/unix/umake.htm If you want to see some interesting/convoluted Makefiles, get a very complex, large piece of software (something from Gnome, possibly) and use autoconf & automake to generate the Makefiles, then pour through them to see how they tick.

Fixing autoconf/automake issues (particularly when autotools is upgraded) is one of the least fun things to do.

Make is fine. Automake is horrific.

Re: Make for hipsters

#13

Here's a more in-depth and easy to read guide for beginners: http://www.computerhope.com/unix/umake.htm If you want to see some interesting/convoluted Makefiles, get a very complex, large piece of software (something from Gnome, possibly) and use autoconf & automake to generate the Makefiles, then pour through them to see how they tick.

For the target audience (total Make beginners) poring through autogenerated makefiles might not be such good advice. It's functionally equivalent to telling people to learn Bash by studying a `configure` script, or learning JavaScript by studying EmScripten output.

If you're decent with Make and want to learn advanced tricks, then by all means go right ahead, but 95% of Make users will never need to delve into such details.

Re: Make for hipsters

#14
post #10

Do 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?

I dunno. Maybe it's a reaction to the myriad build tools developed for Javascript recently. Could they have been done with makefiles instead?

Re: Make for hipsters

#15
Make is a great tool for automating simple things, but if you use a programming language you should probably use native automation tools for common tasks. If you have any non-trivial logic or want to enable code-reuse make doesn't seem like the right choice either.

Re: Make for hipsters

#16
post #10

Do 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?

I dunno. Maybe it's a reaction to the myriad build tools developed for Javascript recently. Could they have been done with makefiles instead?

I suppose so. But there are always many tools for everything. And everyone can select his favorite.

Re: Make for hipsters

#17
> You need to create a makefile to tell make what to do.

Nope. You can say "make hello" and have make automatically use its default rules - which can be configured - to e.g. compile hello.c into a hello executable. I use this frequently.

Re: Make for hipsters

#18

Answer me this, does anyone have a good cross-platform method of writing Make files? I guess with Windows now having bash, I can actually just target bash scripts?

You _can_ use the GNU Autotools on Windows, though you need a shell installed (and a vaguely sane POSIX environment). CMake does a good job targeting a bunch of environments, including Windows.

Re: Make for hipsters

#19
post #16

Earlier quoted context omitted.

I dunno. Maybe it's a reaction to the myriad build tools developed for Javascript recently. Could they have been done with makefiles instead?

I suppose so. But there are always many tools for everything. And everyone can select his favorite.

The problem is if you want support (even commercial help) you'll need to follow some kind of prevailing trend. If I've got a system with grunt or gulp and I need help, I can probably find a local web developer. I'm not so sure if I can find someone who's an expert in Makefiles at the moment.

Re: Make for hipsters

#20
post #8

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…

For anyone who's curious: you can use a ".PHONY" target to force targets to be rebuilt (i.e. that they don't correspond to real files). All dependencies of the .PHONY pseudo-target will be rebuilt unconditionally when encountered. Typically, "all", "clean", "install", etc. will all be phony targets as the goal isn't to literally make a file called "all".

The syntax is simple:

    .PHONY: all clean install
marks "all", "clean" and "install" as phony. Even if the file "all" happens to exist, "make all" will still trigger the build.
Post reply on HN