Live data from Hacker News

Make for hipsters

mattandre.ws

61–70 of 200 posts

Re: Make for hipsters

#61

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?

Take a look at makefiles from various suckless projects. For example: http://git.suckless.org/dwm/tree/Makefile

Their makefiles work with GNU Make and BSD Make, don't know about nmake (AFAIR Windows).

Re: Make for hipsters

#62
post #33

Earlier quoted context omitted.

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.

if your devs can't handle learning basic make, all is lost.

I'd wager there are a fair few Windows devs who don't know make. Granted there are few who truly understand MSBuild to make the comparison fair.

Re: Make for hipsters

#63
post #34

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?

That was Java all over again. - you've got dependencies on some basic Unix commands (cp, rm etc.) in your tasks, so better rewrite that all to use your cross-platform language's facilities. - XML, erm, no, JSON, shall be your only file format.

> dependencies on coreutils

Or just install that Ubuntu on Windows thingy and be done with it.

Re: Make for hipsters

#64
I feel like the author just structured their build dependencies wrong. I used to work on a project that had a 16,000 line Makefile, where almost the entire file was actively in use. So you can abuse any build system.

Re: Make for hipsters

#65
post #60
post #56

Earlier quoted context omitted.

Not be sound harsh, but your problem lies here My personal preference for everything is spaces You want a tool that has been around longer than you do stuff your way. I think it is better if learn to work with the tools and accept that there is a reason some things work in certain ways.

Make 4.2 was released this year. Many people prefer spaces over tabs and many editors insert spaces by default. Most compilers can deal with both spaces and tabs in their parsers, so I assume that it's not an insurmountable problem to make both work for Makefiles, or at least improve the error message. So calling it a "usability hole" is completely accurate.

Most sane editors automatically switch to tabs when editing makefiles.

Anyway, my point was, not everything needs to be customizable to your liking. Sometimes things have a set of simple rules you just have to follow. I for one like that we are limited to tabs, otherwise we would have problems with different number of spaces in the same file and by the way exactly how many spaces are a tab? I like 4 but maybe you like 8 or, god forbidden, 2?

Re: Make for hipsters

#66

The single biggest piece of advice I can give for Make is to make sure your text editor uses real tabs in Makefiles. My personal preference for everything is spaces (mostly a habit learned from Python's PEP 8), but Make doesn't honour spaces for indentation - only tabs. Despite being an obvious usability hole, this has never been fixed. Exacerbating the issue is the poor error message given upon encountering a space-…

That's an error message from GNU Make. I'm not sure what version of GNU Make you're using, because GNU Make has emitted the following since 1998:

  Makefile:2: *** missing separator (did you mean TAB instead of 8 spaces?).  Stop.
See 2c64fb221a265f9e7fc93374906b1e7540377561:

  1998-09-04  Paul D. Smith  
  
  * read.c (read_makefile): If we hit the "missing separator" error,
  check for the common case of 8 spaces instead of a TAB and give an
  extra comment to help people out.
I guess you may have indented it in the modern way with 4 spaces of "tab". Either way, there's also help to be had from your other tools, e.g., vim highlights space-indented make recipes in glaring red error bars.

Re: Make for hipsters

#67
post #6

I don't see what this has to do with hipsters. The fonts are not very cool.

Abuse of a top-level domain which occurs at the end of the author's name - that gets about a 7/10 on my hipsterometer.

Not knowing something any CS graduate should already know and then feel so great about discovering it you just have to write a blog post about it?

that gets a 8/10 on my hipsterometer

Re: Make for hipsters

#68

Another way is using npm-install-changed for the "npm install" problem and fix everything else with other npm scripts like npm-run-all. Use make if you like it but if everything else is npm you can solve most problems using "npm run" and npm scripts. https://github.com/oNaiPs/npm-install-changed http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool... [edit: formatting]

Supplying even a trivial Makefile is advantageous if your target audience knows it. They'll see a Makefile and just do `make && make check && make install` without needing to browse your README.

For example, Debian's packaging process is heavily optimized towards Makefiles that supply the standard targets, and you can reduce a lot of friction for packagers if you supply a wellbehaving Makefile with your program. (Even if developers would usually `go build` or whatever instead of `make`.)

Re: Make for hipsters

#69
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?

Most people are probably writing web based apps in higher level languages that don't require make files. ("Hipsters" sounds like a dig at Ruby / Node devs to me).

Re: Make for hipsters

#70
post #47
post #35

One really neat thing about make: If you include other makefiles then before including them make checks if there are prerequisites of these files and rebuilds them as needed. One can use this to automatically generate header dependencies of translation units for C/C++ projects. Some of the relevant lines in one of my Makefiles: include ${DEPENDS} ${DEPDIR}/%.d: ${SRCDIR}/%.${SRCEXT} @mkdir -p ${shell dirname $@} ; \…

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.
Post reply on HN