re: How To Make A Makefile VIEW POST

FULL DISCUSSION
 

Thanks for this!! I'll be honest I know enough about makefiles to compile a project that's using them, but haven't ever written more than the most basic one myself. And I know they are WAY more powerful than that!

Bookmarked and will read later tonight hopefully!

 

The problem is that as you get to more and more powerful recipes you get further and further away from anything readable ;)

 

I have the impression that the more 'powerful' my recipes get, the less target: dependency I'm thinking.

The real power of make is that it converts requirements into target files/dirs. "PHONY" targets are to be shunned as much as possible if you want to make use of this power, since they leave nothing to be required, so they're really at the end of the chain.

I don't know if I agree they should be shunned so much as used sparingly. I think they do help organize sets of subtasks, especially ask makefiles grow with many related recipes. I'd much prefer a little extra verbosity to keep my makefile organized and readable.

You're absolutely not alone in that.

But make isn't intended to organize tasks, is it? It's intended to build stuff out of other stuff, honouring the dependencies.

GNU Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files.

These PHONY targets mostly contain bash scripts as recipes. What would be worse if you create actual bash scripts out of them?

I've lost hours and hours trying to get my code changes into a flash image, thinking that make image would do. The makefile authors thought that new developers would be smart enough to understand that not all make targets have explicit dependencies (that would slow the build down). Surprise: I wasn't.

That's what I meant: I prefer the targets to be actual Targets, because then the rules I have to remember (and forward to new devs, and document, ...) becomes way smaller. Less room for human errors. And after all, that's what causes the biggest cost for the company.

code of conduct - report abuse